documentation.d.ts 3.9 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732807338073480735807368073780738807398074080741807428074380744807458074680747807488074980750807518075280753807548075580756807578075880759807608076180762807638076480765807668076780768807698077080771807728077380774807758077680777807788077980780807818078280783807848078580786807878078880789807908079180792807938079480795807968079780798807998080080801808028080380804808058080680807808088080980810808118081280813808148081580816808178081880819808208082180822808238082480825808268082780828808298083080831808328083380834808358083680837808388083980840808418084280843808448084580846808478084880849808508085180852808538085480855808568085780858808598086080861808628086380864808658086680867808688086980870808718087280873808748087580876808778087880879808808088180882808838088480885808868088780888808898089080891808928089380894808958089680897808988089980900809018090280903809048090580906809078090880909809108091180912809138091480915809168091780918809198092080921809228092380924809258092680927809288092980930809318093280933809348093580936809378093880939809408094180942809438094480945809468094780948809498095080951809528095380954809558095680957809588095980960809618096280963809648096580966809678096880969809708097180972809738097480975809768097780978809798098080981809828098380984809858098680987809888098980990809918099280993809948099580996809978099880999810008100181002810038100481005810068100781008810098101081011810128101381014810158101681017810188101981020810218102281023810248102581026810278102881029810308103181032810338103481035810368103781038810398104081041810428104381044810458104681047810488104981050810518105281053810548105581056810578105881059810608106181062810638106481065810668106781068810698107081071810728107381074810758107681077810788107981080810818108281083810848108581086810878108881089810908109181092810938109481095810968109781098810998110081101811028110381104811058110681107811088110981110811118111281113811148111581116811178111881119811208112181122811238112481125811268112781128811298113081131811328113381134811358113681137811388113981140811418114281143811448114581146811478114881149811508115181152811538115481155811568115781158811598116081161811628116381164811658116681167811688116981170811718117281173811748117581176811778117881179811808118181182811838118481185811868118781188811898119081191811928119381194811958119681197811988119981200812018120281203812048120581206812078120881209812108121181212812138121481215812168121781218812198122081221812228122381224812258122681227812288122981230812318123281233812348123581236812378123881239812408124181242812438124481245812468124781248812498125081251812528125381254812558125681257812588125981260812618126281263812648126581266812678126881269812708127181272812738127481275812768127781278812798128081281812828128381284812858128681287812888128981290812918129281293812948129581296812978129881299813008130181302813038130481305813068130781308813098131081311813128131381314813158131681317813188131981320813218132281323813248132581326813278132881329813308133181332813338133481335813368133781338813398134081341813428134381344813458134681347813488134981350813518135281353813548135581356813578135881359813608136181362813638136481365813668136781368813698137081371813728137381374813758137681377813788137981380813818138281383813848138581386813878138881389813908139181392813938139481395813968139781398813998140081401814028140381404814058140681407814088140981410814118141281413814148141581416814178141881419814208142181422814238142481425814268142781428814298143081431814328143381434814358143681437814388143981440814418144281443814448144581446814478144881449814508145181452814538145481455814568145781458814598146081461814628146381464814658146681467814688146981470814718147281473814748147581476814778147881479814808148181482814838148481485814868148781488814898149081491814928149381494814958149681497814988149981500815018150281503815048150581506815078150881509815108151181512815138151481515815168151781518815198152081521815228152381524815258152681527815288152981530815318153281533815348153581536815378153881539815408154181542815438154481545815468154781548815498155081551815528155381554815558155681557815588155981560815618156281563815648156581566815678156881569815708157181572815738157481575815768157781578815798158081581815828158381584815858158681587815888158981590815918159281593815948159581596815978159881599816008160181602816038160481605816068160781608816098161081611816128161381614816158161681617816188161981620816218162281623816248162581626816278162881629816308163181632816338163481635816368163781638816398164081641816428164381644816458164681647816488164981650816518165281653816548165581656816578165881659816608166181662816638166481665816668166781668816698167081671816728167381674816758167681677816788167981680816818168281683816848168581686816878168881689816908169181692816938169481695816968169781698816998170081701817028170381704817058170681707817088170981710817118171281713817148171581716817178171881719817208172181722817238172481725817268172781728817298173081731817328173381734817358173681737817388173981740817418174281743817448174581746817478174881749817508175181752817538175481755817568175781758817598176081761817628176381764817658176681767817688176981770817718177281773817748177581776817778177881779817808178181782817838178481785817868178781788817898179081791817928179381794817958179681797817988179981800818018180281803818048180581806818078180881809818108181181812818138181481815818168181781818818198182081821818228182381824818258182681827818288182981830818318183281833818348183581836818378183881839818408184181842818438184481845818468184781848818498185081851818528185381854818558185681857818588185981860818618186281863818648186581866818678186881869818708187181872818738187481875818768187781878818798188081881818828188381884818858188681887818888188981890818918189281893818948189581896818978189881899819008190181902819038190481905819068190781908819098191081911819128191381914819158191681917819188191981920819218192281923819248192581926819278192881929819308193181932819338193481935819368193781938819398194081941819428194381944819458194681947819488194981950819518195281953819548195581956819578195881959819608196181962819638196481965819668196781968819698197081971819728197381974819758197681977819788197981980819818198281983819848198581986819878198881989819908199181992819938199481995819968199781998819998200082001820028200382004820058200682007820088200982010820118201282013820148201582016820178201882019820208202182022820238202482025820268202782028820298203082031820328203382034820358203682037820388203982040820418204282043820448204582046820478204882049820508205182052820538205482055820568205782058820598206082061820628206382064820658206682067820688206982070820718207282073820748207582076820778207882079820808208182082820838208482085820868208782088820898209082091820928209382094820958209682097820988209982100821018210282103821048210582106821078210882109821108211182112821138211482115821168211782118821198212082121821228212382124821258212682127821288212982130821318213282133821348213582136821378213882139821408214182142821438214482145821468214782148821498215082151821528215382154821558215682157821588215982160821618216282163821648216582166821678216882169821708217182172821738217482175821768217782178821798218082181821828218382184821858218682187821888218982190821918219282193821948219582196821978219882199822008220182202822038220482205822068220782208822098221082211822128221382214822158221682217822188221982220822218222282223822248222582226822278222882229822308223182232822338223482235822368223782238822398224082241822428224382244822458224682247822488224982250822518225282253822548225582256822578225882259822608226182262822638226482265822668226782268822698227082271822728227382274822758227682277822788227982280822818228282283822848228582286822878228882289822908229182292822938229482295822968229782298822998230082301823028230382304823058230682307823088230982310823118231282313823148231582316823178231882319823208232182322823238232482325823268232782328823298233082331823328233382334823358233682337823388233982340823418234282343823448234582346823478234882349823508235182352823538235482355823568235782358823598236082361823628236382364823658236682367823688236982370823718237282373823748237582376823778237882379823808238182382823838238482385823868238782388823898239082391823928239382394823958239682397823988239982400824018240282403824048240582406824078240882409824108241182412824138241482415824168241782418824198242082421824228242382424824258242682427824288242982430824318243282433824348243582436824378243882439824408244182442824438244482445824468244782448824498245082451824528245382454824558245682457824588245982460824618246282463824648246582466824678246882469824708247182472824738247482475824768247782478824798248082481824828248382484824858248682487824888248982490824918249282493824948249582496824978249882499825008250182502825038250482505825068250782508825098251082511825128251382514825158251682517825188251982520825218252282523825248252582526825278252882529825308253182532825338253482535825368253782538825398254082541825428254382544825458254682547825488254982550825518255282553825548255582556825578255882559825608256182562825638256482565825668256782568825698257082571825728257382574825758257682577825788257982580825818258282583825848258582586825878258882589825908259182592825938259482595825968259782598825998260082601826028260382604826058260682607826088260982610826118261282613826148261582616826178261882619826208262182622826238262482625826268262782628826298263082631826328263382634826358263682637826388263982640826418264282643826448264582646826478264882649826508265182652826538265482655826568265782658826598266082661826628266382664826658266682667826688266982670826718267282673826748267582676826778267882679826808268182682826838268482685826868268782688826898269082691826928269382694826958269682697826988269982700827018270282703827048270582706827078270882709827108271182712827138271482715827168271782718827198272082721827228272382724827258272682727827288272982730827318273282733827348273582736827378273882739827408274182742827438274482745827468274782748827498275082751827528275382754827558275682757827588275982760827618276282763827648276582766827678276882769827708277182772827738277482775827768277782778827798278082781827828278382784827858278682787827888278982790827918279282793827948279582796827978279882799828008280182802828038280482805828068280782808828098281082811828128281382814828158281682817828188281982820828218282282823828248282582826828278282882829828308283182832828338283482835828368283782838828398284082841828428284382844828458284682847828488284982850828518285282853828548285582856828578285882859828608286182862828638286482865828668286782868828698287082871828728287382874828758287682877828788287982880828818288282883828848288582886828878288882889828908289182892828938289482895828968289782898828998290082901829028290382904829058290682907829088290982910829118291282913829148291582916829178291882919829208292182922829238292482925829268292782928829298293082931829328293382934829358293682937829388293982940829418294282943829448294582946829478294882949829508295182952829538295482955829568295782958829598296082961829628296382964829658296682967829688296982970829718297282973829748297582976829778297882979829808298182982829838298482985829868298782988829898299082991829928299382994829958299682997829988299983000830018300283003830048300583006830078300883009830108301183012830138301483015830168301783018830198302083021830228302383024830258302683027830288302983030830318303283033830348303583036830378303883039830408304183042830438304483045830468304783048830498305083051830528305383054830558305683057830588305983060830618306283063830648306583066830678306883069830708307183072830738307483075830768307783078830798308083081830828308383084830858308683087830888308983090830918309283093830948309583096830978309883099831008310183102831038310483105831068310783108831098311083111831128311383114831158311683117831188311983120831218312283123831248312583126831278312883129831308313183132831338313483135831368313783138831398314083141831428314383144831458314683147831488314983150831518315283153831548315583156831578315883159831608316183162831638316483165831668316783168831698317083171831728317383174831758317683177831788317983180831818318283183831848318583186831878318883189831908319183192831938319483195831968319783198831998320083201832028320383204832058320683207832088320983210832118321283213832148321583216832178321883219832208322183222832238322483225832268322783228832298323083231832328323383234832358323683237832388323983240832418324283243832448324583246832478324883249832508325183252832538325483255832568325783258832598326083261832628326383264832658326683267832688326983270832718327283273832748327583276832778327883279832808328183282832838328483285832868328783288832898329083291832928329383294832958329683297832988329983300833018330283303833048330583306833078330883309833108331183312833138331483315833168331783318833198332083321833228332383324833258332683327833288332983330833318333283333833348333583336833378333883339833408334183342833438334483345833468334783348833498335083351833528335383354833558335683357833588335983360833618336283363833648336583366833678336883369833708337183372833738337483375833768337783378833798338083381833828338383384833858338683387833888338983390833918339283393833948339583396833978339883399834008340183402834038340483405834068340783408834098341083411834128341383414834158341683417834188341983420834218342283423834248342583426834278342883429834308343183432834338343483435834368343783438834398344083441834428344383444834458344683447834488344983450834518345283453834548345583456834578345883459834608346183462834638346483465834668346783468834698347083471834728347383474834758347683477834788347983480834818348283483834848348583486834878348883489834908349183492834938349483495834968349783498834998350083501835028350383504835058350683507835088350983510835118351283513835148351583516835178351883519835208352183522835238352483525835268352783528835298353083531835328353383534835358353683537835388353983540835418354283543835448354583546835478354883549835508355183552835538355483555835568355783558835598356083561835628356383564835658356683567835688356983570835718357283573835748357583576835778357883579835808358183582835838358483585835868358783588835898359083591835928359383594835958359683597835988359983600836018360283603836048360583606836078360883609836108361183612836138361483615836168361783618836198362083621836228362383624836258362683627836288362983630836318363283633836348363583636836378363883639836408364183642836438364483645836468364783648836498365083651836528365383654836558365683657836588365983660836618366283663836648366583666836678366883669836708367183672836738367483675836768367783678836798368083681836828368383684836858368683687836888368983690836918369283693836948369583696836978369883699837008370183702837038370483705837068370783708837098371083711837128371383714837158371683717837188371983720837218372283723837248372583726837278372883729837308373183732837338373483735837368373783738837398374083741837428374383744837458374683747837488374983750837518375283753837548375583756837578375883759837608376183762837638376483765837668376783768837698377083771837728377383774837758377683777837788377983780837818378283783837848378583786837878378883789837908379183792837938379483795837968379783798837998380083801838028380383804838058380683807838088380983810838118381283813838148381583816838178381883819838208382183822838238382483825838268382783828838298383083831838328383383834838358383683837838388383983840838418384283843838448384583846838478384883849838508385183852838538385483855838568385783858838598386083861838628386383864838658386683867838688386983870838718387283873838748387583876838778387883879838808388183882838838388483885838868388783888838898389083891838928389383894838958389683897838988389983900839018390283903839048390583906839078390883909839108391183912839138391483915839168391783918839198392083921839228392383924839258392683927839288392983930839318393283933839348393583936839378393883939839408394183942839438394483945839468394783948839498395083951839528395383954839558395683957839588395983960839618396283963839648396583966839678396883969839708397183972839738397483975839768397783978839798398083981839828398383984839858398683987839888398983990839918399283993839948399583996839978399883999840008400184002840038400484005840068400784008840098401084011840128401384014840158401684017840188401984020840218402284023840248402584026840278402884029840308403184032840338403484035840368403784038840398404084041840428404384044840458404684047840488404984050840518405284053840548405584056840578405884059840608406184062840638406484065840668406784068840698407084071840728407384074840758407684077840788407984080840818408284083840848408584086840878408884089840908409184092840938409484095840968409784098840998410084101841028410384104841058410684107841088410984110841118411284113841148411584116841178411884119841208412184122841238412484125841268412784128841298413084131841328413384134841358413684137841388413984140841418414284143841448414584146841478414884149841508415184152841538415484155841568415784158841598416084161841628416384164841658416684167841688416984170841718417284173841748417584176841778417884179841808418184182841838418484185841868418784188841898419084191841928419384194841958419684197841988419984200842018420284203842048420584206842078420884209842108421184212842138421484215842168421784218842198422084221842228422384224842258422684227842288422984230842318423284233842348423584236842378423884239842408424184242842438424484245842468424784248842498425084251842528425384254842558425684257842588425984260842618426284263842648426584266842678426884269842708427184272842738427484275842768427784278842798428084281842828428384284842858428684287842888428984290842918429284293842948429584296842978429884299843008430184302843038430484305843068430784308843098431084311843128431384314843158431684317843188431984320843218432284323843248432584326843278432884329843308433184332843338433484335843368433784338843398434084341843428434384344843458434684347843488434984350843518435284353843548435584356843578435884359843608436184362843638436484365843668436784368843698437084371843728437384374843758437684377843788437984380843818438284383843848438584386843878438884389843908439184392843938439484395843968439784398843998440084401844028440384404844058440684407844088440984410844118441284413844148441584416844178441884419844208442184422844238442484425844268442784428844298443084431844328443384434844358443684437844388443984440844418444284443844448444584446844478444884449844508445184452844538445484455844568445784458844598446084461844628446384464844658446684467844688446984470844718447284473844748447584476844778447884479844808448184482844838448484485844868448784488844898449084491844928449384494844958449684497844988449984500845018450284503845048450584506845078450884509845108451184512845138451484515845168451784518845198452084521845228452384524845258452684527845288452984530845318453284533845348453584536845378453884539845408454184542845438454484545845468454784548845498455084551845528455384554845558455684557845588455984560845618456284563845648456584566845678456884569845708457184572845738457484575845768457784578845798458084581845828458384584845858458684587845888458984590845918459284593845948459584596845978459884599846008460184602846038460484605846068460784608846098461084611846128461384614846158461684617846188461984620846218462284623846248462584626846278462884629846308463184632846338463484635846368463784638846398464084641846428464384644846458464684647846488464984650846518465284653846548465584656846578465884659846608466184662846638466484665846668466784668846698467084671846728467384674846758467684677846788467984680846818468284683846848468584686846878468884689846908469184692846938469484695846968469784698846998470084701847028470384704847058470684707847088470984710847118471284713847148471584716847178471884719847208472184722847238472484725847268472784728847298473084731847328473384734847358473684737847388473984740847418474284743847448474584746847478474884749847508475184752847538475484755847568475784758847598476084761847628476384764847658476684767847688476984770847718477284773847748477584776847778477884779847808478184782847838478484785847868478784788847898479084791847928479384794847958479684797847988479984800848018480284803848048480584806848078480884809848108481184812848138481484815848168481784818848198482084821848228482384824848258482684827848288482984830848318483284833848348483584836848378483884839848408484184842848438484484845848468484784848848498485084851848528485384854848558485684857848588485984860848618486284863848648486584866848678486884869848708487184872848738487484875848768487784878848798488084881848828488384884848858488684887848888488984890848918489284893848948489584896848978489884899849008490184902849038490484905849068490784908849098491084911849128491384914849158491684917849188491984920849218492284923849248492584926849278492884929849308493184932849338493484935849368493784938849398494084941849428494384944849458494684947849488494984950849518495284953849548495584956849578495884959849608496184962849638496484965849668496784968849698497084971849728497384974849758497684977849788497984980849818498284983849848498584986849878498884989849908499184992849938499484995849968499784998849998500085001850028500385004850058500685007850088500985010850118501285013850148501585016850178501885019850208502185022850238502485025850268502785028850298503085031850328503385034850358503685037850388503985040850418504285043850448504585046850478504885049850508505185052850538505485055850568505785058850598506085061850628506385064850658506685067850688506985070850718507285073850748507585076850778507885079850808508185082850838508485085850868508785088850898509085091850928509385094850958509685097850988509985100851018510285103851048510585106851078510885109851108511185112851138511485115851168511785118851198512085121851228512385124851258512685127851288512985130851318513285133851348513585136851378513885139851408514185142851438514485145851468514785148851498515085151851528515385154851558515685157851588515985160851618516285163851648516585166851678516885169851708517185172851738517485175851768517785178851798518085181851828518385184851858518685187851888518985190851918519285193851948519585196851978519885199852008520185202852038520485205852068520785208852098521085211852128521385214852158521685217852188521985220852218522285223852248522585226852278522885229852308523185232852338523485235852368523785238852398524085241852428524385244852458524685247852488524985250852518525285253852548525585256852578525885259852608526185262852638526485265852668526785268852698527085271852728527385274852758527685277852788527985280852818528285283852848528585286852878528885289852908529185292852938529485295852968529785298852998530085301853028530385304853058530685307853088530985310853118531285313853148531585316853178531885319853208532185322853238532485325853268532785328853298533085331853328533385334853358533685337853388533985340853418534285343853448534585346853478534885349853508535185352853538535485355853568535785358853598536085361853628536385364853658536685367853688536985370853718537285373853748537585376853778537885379853808538185382853838538485385853868538785388853898539085391853928539385394853958539685397853988539985400854018540285403854048540585406854078540885409854108541185412854138541485415854168541785418854198542085421854228542385424854258542685427854288542985430854318543285433854348543585436854378543885439854408544185442854438544485445854468544785448854498545085451854528545385454854558545685457854588545985460854618546285463854648546585466854678546885469854708547185472854738547485475854768547785478854798548085481854828548385484854858548685487854888548985490854918549285493854948549585496854978549885499855008550185502855038550485505855068550785508855098551085511855128551385514855158551685517855188551985520855218552285523855248552585526855278552885529855308553185532855338553485535855368553785538855398554085541855428554385544855458554685547855488554985550855518555285553855548555585556855578555885559855608556185562855638556485565855668556785568855698557085571855728557385574855758557685577855788557985580855818558285583855848558585586855878558885589855908559185592855938559485595855968559785598855998560085601856028560385604856058560685607856088560985610856118561285613856148561585616856178561885619856208562185622856238562485625856268562785628856298563085631856328563385634856358563685637856388563985640856418564285643856448564585646856478564885649856508565185652856538565485655856568565785658856598566085661856628566385664856658566685667856688566985670856718567285673856748567585676856778567885679856808568185682856838568485685856868568785688856898569085691856928569385694856958569685697856988569985700857018570285703857048570585706857078570885709857108571185712857138571485715857168571785718857198572085721857228572385724857258572685727857288572985730857318573285733857348573585736857378573885739857408574185742857438574485745857468574785748857498575085751857528575385754857558575685757857588575985760857618576285763857648576585766857678576885769857708577185772857738577485775857768577785778857798578085781857828578385784857858578685787857888578985790857918579285793857948579585796857978579885799858008580185802858038580485805858068580785808858098581085811858128581385814858158581685817858188581985820858218582285823858248582585826858278582885829858308583185832858338583485835858368583785838858398584085841858428584385844858458584685847858488584985850858518585285853858548585585856858578585885859858608586185862858638586485865858668586785868858698587085871858728587385874858758587685877858788587985880858818588285883858848588585886858878588885889858908589185892858938589485895858968589785898858998590085901859028590385904859058590685907859088590985910859118591285913859148591585916859178591885919859208592185922859238592485925859268592785928859298593085931859328593385934859358593685937859388593985940859418594285943859448594585946859478594885949859508595185952859538595485955859568595785958859598596085961859628596385964859658596685967859688596985970859718597285973859748597585976859778597885979859808598185982859838598485985859868598785988859898599085991859928599385994859958599685997859988599986000860018600286003860048600586006860078600886009860108601186012860138601486015860168601786018860198602086021860228602386024860258602686027860288602986030860318603286033860348603586036860378603886039860408604186042860438604486045860468604786048860498605086051860528605386054860558605686057860588605986060860618606286063860648606586066860678606886069860708607186072860738607486075860768607786078860798608086081860828608386084860858608686087860888608986090860918609286093860948609586096860978609886099861008610186102861038610486105861068610786108861098611086111861128611386114861158611686117861188611986120861218612286123861248612586126861278612886129861308613186132861338613486135861368613786138861398614086141861428614386144861458614686147861488614986150861518615286153861548615586156861578615886159861608616186162861638616486165861668616786168861698617086171861728617386174861758617686177861788617986180861818618286183861848618586186861878618886189861908619186192861938619486195861968619786198861998620086201862028620386204862058620686207862088620986210862118621286213862148621586216862178621886219862208622186222862238622486225862268622786228862298623086231862328623386234862358623686237862388623986240862418624286243862448624586246862478624886249862508625186252862538625486255862568625786258862598626086261862628626386264862658626686267862688626986270862718627286273862748627586276862778627886279862808628186282862838628486285862868628786288862898629086291862928629386294862958629686297862988629986300863018630286303863048630586306863078630886309863108631186312863138631486315863168631786318863198632086321863228632386324863258632686327863288632986330863318633286333863348633586336863378633886339863408634186342863438634486345863468634786348863498635086351863528635386354863558635686357863588635986360863618636286363863648636586366863678636886369863708637186372863738637486375863768637786378863798638086381863828638386384863858638686387863888638986390863918639286393863948639586396863978639886399864008640186402864038640486405864068640786408864098641086411864128641386414864158641686417864188641986420864218642286423864248642586426864278642886429864308643186432864338643486435864368643786438864398644086441864428644386444864458644686447864488644986450864518645286453864548645586456864578645886459864608646186462864638646486465864668646786468864698647086471864728647386474864758647686477864788647986480864818648286483864848648586486864878648886489864908649186492864938649486495864968649786498864998650086501865028650386504865058650686507865088650986510865118651286513865148651586516865178651886519865208652186522865238652486525865268652786528865298653086531865328653386534865358653686537865388653986540865418654286543865448654586546865478654886549865508655186552865538655486555865568655786558865598656086561865628656386564865658656686567865688656986570865718657286573865748657586576865778657886579865808658186582865838658486585865868658786588865898659086591865928659386594865958659686597865988659986600866018660286603866048660586606866078660886609866108661186612866138661486615866168661786618866198662086621866228662386624866258662686627866288662986630866318663286633866348663586636866378663886639866408664186642866438664486645866468664786648866498665086651866528665386654866558665686657866588665986660866618666286663866648666586666866678666886669866708667186672866738667486675866768667786678866798668086681866828668386684866858668686687866888668986690866918669286693866948669586696866978669886699867008670186702867038670486705867068670786708867098671086711867128671386714867158671686717867188671986720867218672286723867248672586726867278672886729867308673186732867338673486735867368673786738867398674086741867428674386744867458674686747867488674986750867518675286753867548675586756867578675886759867608676186762867638676486765867668676786768867698677086771867728677386774867758677686777867788677986780867818678286783867848678586786867878678886789867908679186792867938679486795867968679786798867998680086801868028680386804868058680686807868088680986810868118681286813868148681586816868178681886819868208682186822868238682486825868268682786828868298683086831868328683386834868358683686837868388683986840868418684286843868448684586846868478684886849868508685186852868538685486855868568685786858868598686086861868628686386864868658686686867868688686986870868718687286873868748687586876868778687886879868808688186882868838688486885868868688786888868898689086891868928689386894868958689686897868988689986900869018690286903869048690586906869078690886909869108691186912869138691486915869168691786918869198692086921869228692386924869258692686927869288692986930869318693286933869348693586936869378693886939869408694186942869438694486945869468694786948869498695086951869528695386954869558695686957869588695986960869618696286963869648696586966869678696886969869708697186972869738697486975869768697786978869798698086981869828698386984869858698686987869888698986990869918699286993869948699586996869978699886999870008700187002870038700487005870068700787008870098701087011870128701387014870158701687017870188701987020870218702287023870248702587026870278702887029870308703187032870338703487035870368703787038870398704087041870428704387044870458704687047870488704987050870518705287053870548705587056870578705887059870608706187062870638706487065870668706787068870698707087071870728707387074870758707687077870788707987080870818708287083870848708587086870878708887089870908709187092870938709487095870968709787098870998710087101871028710387104871058710687107871088710987110871118711287113871148711587116871178711887119871208712187122871238712487125871268712787128871298713087131871328713387134871358713687137871388713987140871418714287143871448714587146871478714887149871508715187152871538715487155871568715787158871598716087161871628716387164871658716687167871688716987170871718717287173871748717587176871778717887179871808718187182871838718487185871868718787188871898719087191871928719387194871958719687197871988719987200872018720287203872048720587206872078720887209872108721187212872138721487215872168721787218872198722087221872228722387224872258722687227872288722987230872318723287233872348723587236872378723887239872408724187242872438724487245872468724787248872498725087251872528725387254872558725687257872588725987260872618726287263872648726587266872678726887269872708727187272872738727487275872768727787278872798728087281872828728387284872858728687287872888728987290872918729287293872948729587296872978729887299873008730187302873038730487305873068730787308873098731087311873128731387314873158731687317873188731987320873218732287323873248732587326873278732887329873308733187332873338733487335873368733787338873398734087341873428734387344873458734687347873488734987350873518735287353873548735587356873578735887359873608736187362873638736487365873668736787368873698737087371873728737387374873758737687377873788737987380873818738287383873848738587386873878738887389873908739187392873938739487395873968739787398873998740087401874028740387404874058740687407874088740987410874118741287413874148741587416874178741887419874208742187422874238742487425874268742787428874298743087431874328743387434874358743687437874388743987440874418744287443874448744587446874478744887449874508745187452874538745487455874568745787458874598746087461874628746387464874658746687467874688746987470874718747287473874748747587476874778747887479874808748187482874838748487485874868748787488874898749087491874928749387494874958749687497874988749987500875018750287503875048750587506875078750887509875108751187512875138751487515875168751787518875198752087521875228752387524875258752687527875288752987530875318753287533875348753587536875378753887539875408754187542875438754487545875468754787548875498755087551875528755387554875558755687557875588755987560875618756287563875648756587566875678756887569875708757187572875738757487575875768757787578875798758087581875828758387584875858758687587875888758987590875918759287593875948759587596875978759887599876008760187602876038760487605876068760787608876098761087611876128761387614876158761687617876188761987620876218762287623876248762587626876278762887629876308763187632876338763487635876368763787638876398764087641876428764387644876458764687647876488764987650876518765287653876548765587656876578765887659876608766187662876638766487665876668766787668876698767087671876728767387674876758767687677876788767987680876818768287683876848768587686876878768887689876908769187692876938769487695876968769787698876998770087701877028770387704877058770687707877088770987710877118771287713877148771587716877178771887719877208772187722877238772487725877268772787728877298773087731877328773387734877358773687737877388773987740877418774287743877448774587746877478774887749877508775187752877538775487755877568775787758877598776087761877628776387764877658776687767877688776987770877718777287773877748777587776877778777887779877808778187782877838778487785877868778787788877898779087791877928779387794877958779687797877988779987800878018780287803878048780587806878078780887809878108781187812878138781487815878168781787818878198782087821878228782387824878258782687827878288782987830878318783287833878348783587836878378783887839878408784187842878438784487845878468784787848878498785087851878528785387854878558785687857878588785987860878618786287863878648786587866878678786887869878708787187872878738787487875878768787787878878798788087881878828788387884878858788687887878888788987890878918789287893878948789587896878978789887899879008790187902879038790487905879068790787908879098791087911879128791387914879158791687917879188791987920879218792287923879248792587926879278792887929879308793187932879338793487935879368793787938879398794087941879428794387944879458794687947879488794987950879518795287953879548795587956879578795887959879608796187962879638796487965879668796787968879698797087971879728797387974879758797687977879788797987980879818798287983879848798587986879878798887989879908799187992879938799487995879968799787998879998800088001880028800388004880058800688007880088800988010880118801288013880148801588016880178801888019880208802188022880238802488025880268802788028880298803088031880328803388034880358803688037880388803988040880418804288043880448804588046880478804888049880508805188052880538805488055880568805788058880598806088061880628806388064880658806688067880688806988070880718807288073880748807588076880778807888079880808808188082880838808488085880868808788088880898809088091880928809388094880958809688097880988809988100881018810288103881048810588106881078810888109881108811188112881138811488115881168811788118881198812088121881228812388124881258812688127881288812988130881318813288133881348813588136881378813888139881408814188142881438814488145881468814788148881498815088151881528815388154881558815688157881588815988160881618816288163881648816588166881678816888169881708817188172881738817488175881768817788178881798818088181881828818388184881858818688187881888818988190881918819288193881948819588196881978819888199882008820188202882038820488205882068820788208882098821088211882128821388214882158821688217882188821988220882218822288223882248822588226882278822888229882308823188232882338823488235882368823788238882398824088241882428824388244882458824688247882488824988250882518825288253882548825588256882578825888259882608826188262882638826488265882668826788268882698827088271882728827388274882758827688277882788827988280882818828288283882848828588286882878828888289882908829188292882938829488295882968829788298882998830088301883028830388304883058830688307883088830988310883118831288313883148831588316883178831888319883208832188322883238832488325883268832788328883298833088331883328833388334883358833688337883388833988340883418834288343883448834588346883478834888349883508835188352883538835488355883568835788358883598836088361883628836388364883658836688367883688836988370883718837288373883748837588376883778837888379883808838188382883838838488385883868838788388883898839088391883928839388394883958839688397883988839988400884018840288403884048840588406884078840888409884108841188412884138841488415884168841788418884198842088421884228842388424884258842688427884288842988430884318843288433884348843588436884378843888439884408844188442884438844488445884468844788448884498845088451884528845388454884558845688457884588845988460884618846288463884648846588466884678846888469884708847188472884738847488475884768847788478884798848088481884828848388484884858848688487884888848988490884918849288493884948849588496884978849888499885008850188502885038850488505885068850788508885098851088511885128851388514885158851688517885188851988520885218852288523885248852588526885278852888529885308853188532885338853488535885368853788538885398854088541885428854388544885458854688547885488854988550885518855288553885548855588556885578855888559885608856188562885638856488565885668856788568885698857088571885728857388574885758857688577885788857988580885818858288583885848858588586885878858888589885908859188592885938859488595885968859788598885998860088601886028860388604886058860688607886088860988610886118861288613886148861588616886178861888619886208862188622886238862488625886268862788628886298863088631886328863388634886358863688637886388863988640886418864288643886448864588646886478864888649886508865188652886538865488655886568865788658886598866088661886628866388664886658866688667886688866988670886718867288673886748867588676886778867888679886808868188682886838868488685886868868788688886898869088691886928869388694886958869688697886988869988700887018870288703887048870588706887078870888709887108871188712887138871488715887168871788718887198872088721887228872388724887258872688727887288872988730887318873288733887348873588736887378873888739887408874188742887438874488745887468874788748887498875088751887528875388754887558875688757887588875988760887618876288763887648876588766887678876888769887708877188772887738877488775887768877788778887798878088781887828878388784887858878688787887888878988790887918879288793887948879588796887978879888799888008880188802888038880488805888068880788808888098881088811888128881388814888158881688817888188881988820888218882288823888248882588826888278882888829888308883188832888338883488835888368883788838888398884088841888428884388844888458884688847888488884988850888518885288853888548885588856888578885888859888608886188862888638886488865888668886788868888698887088871888728887388874888758887688877888788887988880888818888288883888848888588886888878888888889888908889188892888938889488895888968889788898888998890088901889028890388904889058890688907889088890988910889118891288913889148891588916889178891888919889208892188922889238892488925889268892788928889298893088931889328893388934889358893688937889388893988940889418894288943889448894588946889478894888949889508895188952889538895488955889568895788958889598896088961889628896388964889658896688967889688896988970889718897288973889748897588976889778897888979889808898188982889838898488985889868898788988889898899088991889928899388994889958899688997889988899989000890018900289003890048900589006890078900889009890108901189012890138901489015890168901789018890198902089021890228902389024890258902689027890288902989030890318903289033890348903589036890378903889039890408904189042890438904489045890468904789048890498905089051890528905389054890558905689057890588905989060890618906289063890648906589066890678906889069890708907189072890738907489075890768907789078890798908089081890828908389084890858908689087890888908989090890918909289093890948909589096890978909889099891008910189102891038910489105891068910789108891098911089111891128911389114891158911689117891188911989120891218912289123891248912589126891278912889129891308913189132891338913489135891368913789138891398914089141891428914389144891458914689147891488914989150891518915289153891548915589156891578915889159891608916189162891638916489165891668916789168891698917089171891728917389174891758917689177891788917989180891818918289183891848918589186891878918889189891908919189192891938919489195891968919789198891998920089201892028920389204892058920689207892088920989210892118921289213892148921589216892178921889219892208922189222892238922489225892268922789228892298923089231892328923389234892358923689237892388923989240892418924289243892448924589246892478924889249892508925189252892538925489255892568925789258892598926089261892628926389264892658926689267892688926989270892718927289273892748927589276892778927889279892808928189282892838928489285892868928789288892898929089291892928929389294892958929689297892988929989300893018930289303893048930589306893078930889309893108931189312893138931489315893168931789318893198932089321893228932389324893258932689327893288932989330893318933289333893348933589336893378933889339893408934189342893438934489345893468934789348893498935089351893528935389354893558935689357893588935989360893618936289363893648936589366893678936889369893708937189372893738937489375893768937789378893798938089381893828938389384893858938689387893888938989390893918939289393893948939589396893978939889399894008940189402894038940489405894068940789408894098941089411894128941389414894158941689417894188941989420894218942289423894248942589426894278942889429894308943189432894338943489435894368943789438894398944089441894428944389444894458944689447894488944989450894518945289453894548945589456894578945889459894608946189462894638946489465894668946789468894698947089471894728947389474894758947689477894788947989480894818948289483894848948589486894878948889489894908949189492894938949489495894968949789498894998950089501895028950389504895058950689507895088950989510895118951289513895148951589516895178951889519895208952189522895238952489525895268952789528895298953089531895328953389534895358953689537895388953989540895418954289543895448954589546895478954889549895508955189552895538955489555895568955789558895598956089561895628956389564895658956689567895688956989570895718957289573895748957589576895778957889579895808958189582895838958489585895868958789588895898959089591895928959389594895958959689597895988959989600896018960289603896048960589606896078960889609896108961189612896138961489615896168961789618896198962089621896228962389624896258962689627896288962989630896318963289633896348963589636896378963889639896408964189642896438964489645896468964789648896498965089651896528965389654896558965689657896588965989660896618966289663896648966589666896678966889669896708967189672896738967489675896768967789678896798968089681896828968389684896858968689687896888968989690896918969289693896948969589696896978969889699897008970189702897038970489705897068970789708897098971089711897128971389714897158971689717897188971989720897218972289723897248972589726897278972889729897308973189732897338973489735897368973789738897398974089741897428974389744897458974689747897488974989750897518975289753897548975589756897578975889759897608976189762897638976489765897668976789768897698977089771897728977389774897758977689777897788977989780897818978289783897848978589786897878978889789897908979189792897938979489795897968979789798897998980089801898028980389804898058980689807898088980989810898118981289813898148981589816898178981889819898208982189822898238982489825898268982789828898298983089831898328983389834898358983689837898388983989840898418984289843898448984589846898478984889849898508985189852898538985489855898568985789858898598986089861898628986389864898658986689867898688986989870898718987289873898748987589876898778987889879898808988189882898838988489885898868988789888898898989089891898928989389894898958989689897898988989989900899018990289903899048990589906899078990889909899108991189912899138991489915899168991789918899198992089921899228992389924899258992689927899288992989930899318993289933899348993589936899378993889939899408994189942899438994489945899468994789948899498995089951899528995389954899558995689957899588995989960899618996289963899648996589966899678996889969899708997189972899738997489975899768997789978899798998089981899828998389984899858998689987899888998989990899918999289993899948999589996899978999889999900009000190002900039000490005900069000790008900099001090011900129001390014900159001690017900189001990020900219002290023900249002590026900279002890029900309003190032900339003490035900369003790038900399004090041900429004390044900459004690047900489004990050900519005290053900549005590056900579005890059900609006190062900639006490065900669006790068900699007090071900729007390074900759007690077900789007990080900819008290083900849008590086900879008890089900909009190092900939009490095900969009790098900999010090101901029010390104901059010690107901089010990110901119011290113901149011590116901179011890119901209012190122901239012490125901269012790128901299013090131901329013390134901359013690137901389013990140901419014290143901449014590146901479014890149901509015190152901539015490155901569015790158901599016090161901629016390164901659016690167901689016990170901719017290173901749017590176901779017890179901809018190182901839018490185901869018790188901899019090191901929019390194901959019690197901989019990200902019020290203902049020590206902079020890209902109021190212902139021490215902169021790218902199022090221902229022390224902259022690227902289022990230902319023290233902349023590236902379023890239902409024190242902439024490245902469024790248902499025090251902529025390254902559025690257902589025990260902619026290263902649026590266902679026890269902709027190272902739027490275902769027790278902799028090281902829028390284902859028690287902889028990290902919029290293902949029590296902979029890299903009030190302903039030490305903069030790308903099031090311903129031390314903159031690317903189031990320903219032290323903249032590326903279032890329903309033190332903339033490335903369033790338903399034090341903429034390344903459034690347903489034990350903519035290353903549035590356903579035890359903609036190362903639036490365903669036790368903699037090371903729037390374903759037690377903789037990380903819038290383903849038590386903879038890389903909039190392903939039490395903969039790398903999040090401904029040390404904059040690407904089040990410904119041290413904149041590416904179041890419904209042190422904239042490425904269042790428904299043090431904329043390434904359043690437904389043990440904419044290443904449044590446904479044890449904509045190452904539045490455904569045790458904599046090461904629046390464904659046690467904689046990470904719047290473904749047590476904779047890479904809048190482904839048490485904869048790488904899049090491904929049390494904959049690497904989049990500905019050290503905049050590506905079050890509905109051190512905139051490515905169051790518905199052090521905229052390524905259052690527905289052990530905319053290533905349053590536905379053890539905409054190542905439054490545905469054790548905499055090551905529055390554905559055690557905589055990560905619056290563905649056590566905679056890569905709057190572905739057490575905769057790578905799058090581905829058390584905859058690587905889058990590905919059290593905949059590596905979059890599906009060190602906039060490605906069060790608906099061090611906129061390614906159061690617906189061990620906219062290623906249062590626906279062890629906309063190632906339063490635906369063790638906399064090641906429064390644906459064690647906489064990650906519065290653906549065590656906579065890659906609066190662906639066490665906669066790668906699067090671906729067390674906759067690677906789067990680906819068290683906849068590686906879068890689906909069190692906939069490695906969069790698906999070090701907029070390704907059070690707907089070990710907119071290713907149071590716907179071890719907209072190722907239072490725907269072790728907299073090731907329073390734907359073690737907389073990740907419074290743907449074590746907479074890749907509075190752907539075490755907569075790758907599076090761907629076390764907659076690767907689076990770907719077290773907749077590776907779077890779907809078190782907839078490785907869078790788907899079090791907929079390794907959079690797907989079990800908019080290803908049080590806908079080890809908109081190812908139081490815908169081790818908199082090821908229082390824908259082690827908289082990830908319083290833908349083590836908379083890839908409084190842908439084490845908469084790848908499085090851908529085390854908559085690857908589085990860908619086290863908649086590866908679086890869908709087190872908739087490875908769087790878908799088090881908829088390884908859088690887908889088990890908919089290893908949089590896908979089890899909009090190902909039090490905909069090790908909099091090911909129091390914909159091690917909189091990920909219092290923909249092590926909279092890929909309093190932909339093490935909369093790938909399094090941909429094390944909459094690947909489094990950909519095290953909549095590956909579095890959909609096190962909639096490965909669096790968909699097090971909729097390974909759097690977909789097990980909819098290983909849098590986909879098890989909909099190992909939099490995909969099790998909999100091001910029100391004910059100691007910089100991010910119101291013910149101591016910179101891019910209102191022910239102491025910269102791028910299103091031910329103391034910359103691037910389103991040910419104291043910449104591046910479104891049910509105191052910539105491055910569105791058910599106091061910629106391064910659106691067910689106991070910719107291073910749107591076910779107891079910809108191082910839108491085910869108791088910899109091091910929109391094910959109691097910989109991100911019110291103911049110591106911079110891109911109111191112911139111491115911169111791118911199112091121911229112391124911259112691127911289112991130911319113291133911349113591136911379113891139911409114191142911439114491145911469114791148911499115091151911529115391154911559115691157911589115991160911619116291163911649116591166911679116891169911709117191172911739117491175911769117791178911799118091181911829118391184911859118691187911889118991190911919119291193911949119591196911979119891199912009120191202912039120491205912069120791208912099121091211912129121391214912159121691217912189121991220912219122291223912249122591226912279122891229912309123191232912339123491235912369123791238912399124091241912429124391244912459124691247912489124991250912519125291253912549125591256912579125891259912609126191262912639126491265912669126791268912699127091271912729127391274912759127691277912789127991280912819128291283912849128591286912879128891289912909129191292912939129491295912969129791298912999130091301913029130391304913059130691307913089130991310913119131291313913149131591316913179131891319913209132191322913239132491325913269132791328913299133091331913329133391334913359133691337913389133991340913419134291343913449134591346913479134891349913509135191352913539135491355913569135791358913599136091361913629136391364913659136691367913689136991370913719137291373913749137591376913779137891379913809138191382913839138491385913869138791388913899139091391913929139391394913959139691397913989139991400914019140291403914049140591406914079140891409914109141191412914139141491415914169141791418914199142091421914229142391424914259142691427914289142991430914319143291433914349143591436914379143891439914409144191442914439144491445914469144791448914499145091451914529145391454914559145691457914589145991460914619146291463914649146591466914679146891469914709147191472914739147491475914769147791478914799148091481914829148391484914859148691487914889148991490914919149291493914949149591496914979149891499915009150191502915039150491505915069150791508915099151091511915129151391514915159151691517915189151991520915219152291523915249152591526915279152891529915309153191532915339153491535915369153791538915399154091541915429154391544915459154691547915489154991550915519155291553915549155591556915579155891559915609156191562915639156491565915669156791568915699157091571915729157391574915759157691577915789157991580915819158291583915849158591586915879158891589915909159191592915939159491595915969159791598915999160091601916029160391604916059160691607916089160991610916119161291613916149161591616916179161891619916209162191622916239162491625916269162791628916299163091631916329163391634916359163691637916389163991640916419164291643916449164591646916479164891649916509165191652916539165491655916569165791658916599166091661916629166391664916659166691667916689166991670916719167291673916749167591676916779167891679916809168191682916839168491685916869168791688916899169091691916929169391694916959169691697916989169991700917019170291703917049170591706917079170891709917109171191712917139171491715917169171791718917199172091721917229172391724917259172691727917289172991730917319173291733917349173591736917379173891739917409174191742917439174491745917469174791748917499175091751917529175391754917559175691757917589175991760917619176291763917649176591766917679176891769917709177191772917739177491775917769177791778917799178091781917829178391784917859178691787917889178991790917919179291793917949179591796917979179891799918009180191802918039180491805918069180791808918099181091811918129181391814918159181691817918189181991820918219182291823918249182591826918279182891829918309183191832918339183491835918369183791838918399184091841918429184391844918459184691847918489184991850918519185291853918549185591856918579185891859918609186191862918639186491865918669186791868918699187091871918729187391874918759187691877918789187991880918819188291883918849188591886918879188891889918909189191892918939189491895918969189791898918999190091901919029190391904919059190691907919089190991910919119191291913919149191591916919179191891919919209192191922919239192491925919269192791928919299193091931919329193391934919359193691937919389193991940919419194291943919449194591946919479194891949919509195191952919539195491955919569195791958919599196091961919629196391964919659196691967919689196991970919719197291973919749197591976919779197891979919809198191982919839198491985919869198791988919899199091991919929199391994919959199691997919989199992000920019200292003920049200592006920079200892009920109201192012920139201492015920169201792018920199202092021920229202392024920259202692027920289202992030920319203292033920349203592036920379203892039920409204192042920439204492045920469204792048920499205092051920529205392054920559205692057920589205992060920619206292063920649206592066920679206892069920709207192072920739207492075920769207792078920799208092081920829208392084920859208692087920889208992090920919209292093920949209592096920979209892099921009210192102921039210492105921069210792108921099211092111921129211392114921159211692117921189211992120921219212292123921249212592126921279212892129921309213192132921339213492135921369213792138921399214092141921429214392144921459214692147921489214992150921519215292153921549215592156921579215892159921609216192162921639216492165921669216792168921699217092171921729217392174921759217692177921789217992180921819218292183921849218592186921879218892189921909219192192921939219492195921969219792198921999220092201922029220392204922059220692207922089220992210922119221292213922149221592216922179221892219922209222192222922239222492225922269222792228922299223092231922329223392234922359223692237922389223992240922419224292243922449224592246922479224892249922509225192252922539225492255922569225792258922599226092261922629226392264922659226692267922689226992270922719227292273922749227592276922779227892279922809228192282922839228492285922869228792288922899229092291922929229392294922959229692297922989229992300923019230292303923049230592306923079230892309923109231192312923139231492315923169231792318923199232092321923229232392324923259232692327923289232992330923319233292333923349233592336923379233892339923409234192342923439234492345923469234792348923499235092351923529235392354923559235692357923589235992360923619236292363923649236592366923679236892369923709237192372923739237492375923769237792378923799238092381923829238392384923859238692387923889238992390923919239292393923949239592396923979239892399924009240192402924039240492405924069240792408924099241092411924129241392414924159241692417924189241992420924219242292423924249242592426924279242892429924309243192432924339243492435924369243792438924399244092441924429244392444924459244692447924489244992450924519245292453924549245592456924579245892459924609246192462924639246492465924669246792468924699247092471924729247392474924759247692477924789247992480924819248292483924849248592486924879248892489924909249192492924939249492495924969249792498924999250092501925029250392504925059250692507925089250992510925119251292513925149251592516925179251892519925209252192522925239252492525925269252792528925299253092531925329253392534925359253692537925389253992540925419254292543925449254592546925479254892549925509255192552925539255492555925569255792558925599256092561925629256392564925659256692567925689256992570925719257292573925749257592576925779257892579925809258192582925839258492585925869258792588925899259092591925929259392594925959259692597925989259992600926019260292603926049260592606926079260892609926109261192612926139261492615926169261792618926199262092621926229262392624926259262692627926289262992630926319263292633926349263592636926379263892639926409264192642926439264492645926469264792648926499265092651926529265392654926559265692657926589265992660926619266292663926649266592666926679266892669926709267192672926739267492675926769267792678926799268092681926829268392684926859268692687926889268992690926919269292693926949269592696926979269892699927009270192702927039270492705927069270792708927099271092711927129271392714927159271692717927189271992720927219272292723927249272592726927279272892729927309273192732927339273492735927369273792738927399274092741927429274392744927459274692747927489274992750927519275292753927549275592756927579275892759927609276192762927639276492765927669276792768927699277092771927729277392774927759277692777927789277992780927819278292783927849278592786927879278892789927909279192792927939279492795927969279792798927999280092801928029280392804928059280692807928089280992810928119281292813928149281592816928179281892819928209282192822928239282492825928269282792828928299283092831928329283392834928359283692837928389283992840928419284292843928449284592846928479284892849928509285192852928539285492855928569285792858928599286092861928629286392864928659286692867928689286992870928719287292873928749287592876928779287892879928809288192882928839288492885928869288792888928899289092891928929289392894928959289692897928989289992900929019290292903929049290592906929079290892909929109291192912929139291492915929169291792918929199292092921929229292392924929259292692927929289292992930929319293292933929349293592936929379293892939929409294192942929439294492945929469294792948929499295092951929529295392954929559295692957929589295992960929619296292963929649296592966929679296892969929709297192972929739297492975929769297792978929799298092981929829298392984929859298692987929889298992990929919299292993929949299592996929979299892999930009300193002930039300493005930069300793008930099301093011930129301393014930159301693017930189301993020930219302293023930249302593026930279302893029930309303193032930339303493035930369303793038930399304093041930429304393044930459304693047930489304993050930519305293053930549305593056930579305893059930609306193062930639306493065930669306793068930699307093071930729307393074930759307693077930789307993080930819308293083930849308593086930879308893089930909309193092930939309493095930969309793098930999310093101931029310393104931059310693107931089310993110931119311293113931149311593116931179311893119931209312193122931239312493125931269312793128931299313093131931329313393134931359313693137931389313993140931419314293143931449314593146931479314893149931509315193152931539315493155931569315793158931599316093161931629316393164931659316693167931689316993170931719317293173931749317593176931779317893179931809318193182931839318493185931869318793188931899319093191931929319393194931959319693197931989319993200932019320293203932049320593206932079320893209932109321193212932139321493215932169321793218932199322093221932229322393224932259322693227932289322993230932319323293233932349323593236932379323893239932409324193242932439324493245932469324793248932499325093251932529325393254932559325693257932589325993260932619326293263932649326593266932679326893269932709327193272932739327493275932769327793278932799328093281932829328393284932859328693287932889328993290932919329293293932949329593296932979329893299933009330193302933039330493305933069330793308933099331093311933129331393314933159331693317933189331993320933219332293323933249332593326933279332893329933309333193332933339333493335933369333793338933399334093341933429334393344933459334693347933489334993350933519335293353933549335593356933579335893359933609336193362933639336493365933669336793368933699337093371933729337393374933759337693377933789337993380933819338293383933849338593386933879338893389933909339193392933939339493395933969339793398933999340093401934029340393404934059340693407934089340993410934119341293413934149341593416934179341893419934209342193422934239342493425934269342793428934299343093431934329343393434934359343693437934389343993440934419344293443934449344593446934479344893449934509345193452934539345493455934569345793458934599346093461934629346393464934659346693467934689346993470934719347293473934749347593476934779347893479934809348193482934839348493485934869348793488934899349093491934929349393494934959349693497934989349993500935019350293503935049350593506935079350893509935109351193512935139351493515935169351793518935199352093521935229352393524935259352693527935289352993530935319353293533935349353593536935379353893539935409354193542935439354493545935469354793548935499355093551935529355393554935559355693557935589355993560935619356293563935649356593566935679356893569935709357193572935739357493575935769357793578935799358093581935829358393584935859358693587935889358993590935919359293593935949359593596935979359893599936009360193602936039360493605936069360793608936099361093611936129361393614936159361693617936189361993620936219362293623936249362593626936279362893629936309363193632936339363493635936369363793638936399364093641936429364393644936459364693647936489364993650936519365293653936549365593656936579365893659936609366193662936639366493665936669366793668936699367093671936729367393674936759367693677936789367993680936819368293683936849368593686936879368893689936909369193692936939369493695936969369793698936999370093701937029370393704937059370693707937089370993710937119371293713937149371593716937179371893719937209372193722937239372493725937269372793728937299373093731937329373393734937359373693737937389373993740937419374293743937449374593746937479374893749937509375193752937539375493755937569375793758937599376093761937629376393764937659376693767937689376993770937719377293773937749377593776937779377893779937809378193782937839378493785937869378793788937899379093791937929379393794937959379693797937989379993800938019380293803938049380593806938079380893809938109381193812938139381493815938169381793818938199382093821938229382393824938259382693827938289382993830938319383293833938349383593836938379383893839938409384193842938439384493845938469384793848938499385093851938529385393854938559385693857938589385993860938619386293863938649386593866938679386893869938709387193872938739387493875938769387793878938799388093881938829388393884938859388693887938889388993890938919389293893938949389593896938979389893899939009390193902939039390493905939069390793908939099391093911939129391393914939159391693917939189391993920939219392293923939249392593926939279392893929939309393193932939339393493935939369393793938939399394093941939429394393944939459394693947939489394993950939519395293953939549395593956939579395893959939609396193962939639396493965939669396793968939699397093971939729397393974939759397693977939789397993980939819398293983939849398593986939879398893989939909399193992939939399493995939969399793998939999400094001940029400394004940059400694007940089400994010940119401294013940149401594016940179401894019940209402194022940239402494025940269402794028940299403094031940329403394034940359403694037940389403994040940419404294043940449404594046940479404894049940509405194052940539405494055940569405794058940599406094061940629406394064940659406694067940689406994070940719407294073940749407594076940779407894079940809408194082940839408494085940869408794088940899409094091940929409394094940959409694097940989409994100941019410294103941049410594106941079410894109941109411194112941139411494115941169411794118941199412094121941229412394124941259412694127941289412994130941319413294133941349413594136941379413894139941409414194142941439414494145941469414794148941499415094151941529415394154941559415694157941589415994160941619416294163941649416594166941679416894169941709417194172941739417494175941769417794178941799418094181941829418394184941859418694187941889418994190941919419294193941949419594196941979419894199942009420194202942039420494205942069420794208942099421094211942129421394214942159421694217942189421994220942219422294223942249422594226942279422894229942309423194232942339423494235942369423794238942399424094241942429424394244942459424694247942489424994250942519425294253942549425594256942579425894259942609426194262942639426494265942669426794268942699427094271942729427394274942759427694277942789427994280942819428294283942849428594286942879428894289942909429194292942939429494295942969429794298942999430094301943029430394304943059430694307943089430994310943119431294313943149431594316943179431894319943209432194322943239432494325943269432794328943299433094331943329433394334943359433694337943389433994340943419434294343943449434594346943479434894349943509435194352943539435494355943569435794358943599436094361943629436394364943659436694367943689436994370943719437294373943749437594376943779437894379943809438194382943839438494385943869438794388943899439094391943929439394394943959439694397943989439994400944019440294403944049440594406944079440894409944109441194412944139441494415944169441794418944199442094421944229442394424944259442694427944289442994430944319443294433944349443594436944379443894439944409444194442944439444494445944469444794448944499445094451944529445394454944559445694457944589445994460944619446294463944649446594466944679446894469944709447194472944739447494475944769447794478944799448094481944829448394484944859448694487944889448994490944919449294493944949449594496944979449894499945009450194502945039450494505945069450794508945099451094511945129451394514945159451694517945189451994520945219452294523945249452594526945279452894529945309453194532945339453494535945369453794538945399454094541945429454394544945459454694547945489454994550945519455294553945549455594556945579455894559945609456194562945639456494565945669456794568945699457094571945729457394574945759457694577945789457994580945819458294583945849458594586945879458894589945909459194592945939459494595945969459794598945999460094601946029460394604946059460694607946089460994610946119461294613946149461594616
  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. /**
  11843. * Gets the forced extension (if any)
  11844. */
  11845. get forcedExtension(): Nullable<string>;
  11846. private _extensions;
  11847. private _textureMatrix;
  11848. private _format;
  11849. private _createPolynomials;
  11850. private _loaderOptions;
  11851. /**
  11852. * Creates a cube texture from an array of image urls
  11853. * @param files defines an array of image urls
  11854. * @param scene defines the hosting scene
  11855. * @param noMipmap specifies if mip maps are not used
  11856. * @returns a cube texture
  11857. */
  11858. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  11859. /**
  11860. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  11861. * @param url defines the url of the prefiltered texture
  11862. * @param scene defines the scene the texture is attached to
  11863. * @param forcedExtension defines the extension of the file if different from the url
  11864. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11865. * @return the prefiltered texture
  11866. */
  11867. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  11868. /**
  11869. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  11870. * as prefiltered data.
  11871. * @param rootUrl defines the url of the texture or the root name of the six images
  11872. * @param null defines the scene or engine the texture is attached to
  11873. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  11874. * @param noMipmap defines if mipmaps should be created or not
  11875. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  11876. * @param onLoad defines a callback triggered at the end of the file load if no errors occurred
  11877. * @param onError defines a callback triggered in case of error during load
  11878. * @param format defines the internal format to use for the texture once loaded
  11879. * @param prefiltered defines whether or not the texture is created from prefiltered data
  11880. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  11881. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11882. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11883. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11884. * @param loaderOptions options to be passed to the loader
  11885. * @return the cube texture
  11886. */
  11887. 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);
  11888. /**
  11889. * Get the current class name of the texture useful for serialization or dynamic coding.
  11890. * @returns "CubeTexture"
  11891. */
  11892. getClassName(): string;
  11893. /**
  11894. * Update the url (and optional buffer) of this texture if url was null during construction.
  11895. * @param url the url of the texture
  11896. * @param forcedExtension defines the extension to use
  11897. * @param onLoad callback called when the texture is loaded (defaults to null)
  11898. * @param prefiltered Defines whether the updated texture is prefiltered or not
  11899. */
  11900. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  11901. /**
  11902. * Delays loading of the cube texture
  11903. * @param forcedExtension defines the extension to use
  11904. */
  11905. delayLoad(forcedExtension?: string): void;
  11906. /**
  11907. * Returns the reflection texture matrix
  11908. * @returns the reflection texture matrix
  11909. */
  11910. getReflectionTextureMatrix(): Matrix;
  11911. /**
  11912. * Sets the reflection texture matrix
  11913. * @param value Reflection texture matrix
  11914. */
  11915. setReflectionTextureMatrix(value: Matrix): void;
  11916. /**
  11917. * Parses text to create a cube texture
  11918. * @param parsedTexture define the serialized text to read from
  11919. * @param scene defines the hosting scene
  11920. * @param rootUrl defines the root url of the cube texture
  11921. * @returns a cube texture
  11922. */
  11923. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  11924. /**
  11925. * Makes a clone, or deep copy, of the cube texture
  11926. * @returns a new cube texture
  11927. */
  11928. clone(): CubeTexture;
  11929. }
  11930. }
  11931. declare module BABYLON {
  11932. /**
  11933. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  11934. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11935. * 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;
  11936. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11937. */
  11938. export class ColorCurves {
  11939. private _dirty;
  11940. private _tempColor;
  11941. private _globalCurve;
  11942. private _highlightsCurve;
  11943. private _midtonesCurve;
  11944. private _shadowsCurve;
  11945. private _positiveCurve;
  11946. private _negativeCurve;
  11947. private _globalHue;
  11948. private _globalDensity;
  11949. private _globalSaturation;
  11950. private _globalExposure;
  11951. /**
  11952. * Gets the global Hue value.
  11953. * 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).
  11954. */
  11955. get globalHue(): number;
  11956. /**
  11957. * Sets the global Hue value.
  11958. * 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).
  11959. */
  11960. set globalHue(value: number);
  11961. /**
  11962. * Gets the global Density value.
  11963. * 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.
  11964. * Values less than zero provide a filter of opposite hue.
  11965. */
  11966. get globalDensity(): number;
  11967. /**
  11968. * Sets the global Density value.
  11969. * 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.
  11970. * Values less than zero provide a filter of opposite hue.
  11971. */
  11972. set globalDensity(value: number);
  11973. /**
  11974. * Gets the global Saturation value.
  11975. * 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.
  11976. */
  11977. get globalSaturation(): number;
  11978. /**
  11979. * Sets the global Saturation value.
  11980. * 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.
  11981. */
  11982. set globalSaturation(value: number);
  11983. /**
  11984. * Gets the global Exposure value.
  11985. * 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.
  11986. */
  11987. get globalExposure(): number;
  11988. /**
  11989. * Sets the global Exposure value.
  11990. * 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.
  11991. */
  11992. set globalExposure(value: number);
  11993. private _highlightsHue;
  11994. private _highlightsDensity;
  11995. private _highlightsSaturation;
  11996. private _highlightsExposure;
  11997. /**
  11998. * Gets the highlights Hue value.
  11999. * 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).
  12000. */
  12001. get highlightsHue(): number;
  12002. /**
  12003. * Sets the highlights Hue value.
  12004. * 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).
  12005. */
  12006. set highlightsHue(value: number);
  12007. /**
  12008. * Gets the highlights Density value.
  12009. * 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.
  12010. * Values less than zero provide a filter of opposite hue.
  12011. */
  12012. get highlightsDensity(): number;
  12013. /**
  12014. * Sets the highlights Density value.
  12015. * 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.
  12016. * Values less than zero provide a filter of opposite hue.
  12017. */
  12018. set highlightsDensity(value: number);
  12019. /**
  12020. * Gets the highlights Saturation value.
  12021. * 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.
  12022. */
  12023. get highlightsSaturation(): number;
  12024. /**
  12025. * Sets the highlights Saturation value.
  12026. * 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.
  12027. */
  12028. set highlightsSaturation(value: number);
  12029. /**
  12030. * Gets the highlights Exposure value.
  12031. * 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.
  12032. */
  12033. get highlightsExposure(): number;
  12034. /**
  12035. * Sets the highlights Exposure value.
  12036. * 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.
  12037. */
  12038. set highlightsExposure(value: number);
  12039. private _midtonesHue;
  12040. private _midtonesDensity;
  12041. private _midtonesSaturation;
  12042. private _midtonesExposure;
  12043. /**
  12044. * Gets the midtones Hue value.
  12045. * 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).
  12046. */
  12047. get midtonesHue(): number;
  12048. /**
  12049. * Sets the midtones Hue value.
  12050. * 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).
  12051. */
  12052. set midtonesHue(value: number);
  12053. /**
  12054. * Gets the midtones Density value.
  12055. * 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.
  12056. * Values less than zero provide a filter of opposite hue.
  12057. */
  12058. get midtonesDensity(): number;
  12059. /**
  12060. * Sets the midtones Density value.
  12061. * 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.
  12062. * Values less than zero provide a filter of opposite hue.
  12063. */
  12064. set midtonesDensity(value: number);
  12065. /**
  12066. * Gets the midtones Saturation value.
  12067. * 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.
  12068. */
  12069. get midtonesSaturation(): number;
  12070. /**
  12071. * Sets the midtones Saturation value.
  12072. * 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.
  12073. */
  12074. set midtonesSaturation(value: number);
  12075. /**
  12076. * Gets the midtones Exposure value.
  12077. * 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.
  12078. */
  12079. get midtonesExposure(): number;
  12080. /**
  12081. * Sets the midtones Exposure value.
  12082. * 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.
  12083. */
  12084. set midtonesExposure(value: number);
  12085. private _shadowsHue;
  12086. private _shadowsDensity;
  12087. private _shadowsSaturation;
  12088. private _shadowsExposure;
  12089. /**
  12090. * Gets the shadows Hue value.
  12091. * 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).
  12092. */
  12093. get shadowsHue(): number;
  12094. /**
  12095. * Sets the shadows Hue value.
  12096. * 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).
  12097. */
  12098. set shadowsHue(value: number);
  12099. /**
  12100. * Gets the shadows Density value.
  12101. * 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.
  12102. * Values less than zero provide a filter of opposite hue.
  12103. */
  12104. get shadowsDensity(): number;
  12105. /**
  12106. * Sets the shadows Density value.
  12107. * 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.
  12108. * Values less than zero provide a filter of opposite hue.
  12109. */
  12110. set shadowsDensity(value: number);
  12111. /**
  12112. * Gets the shadows Saturation value.
  12113. * 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.
  12114. */
  12115. get shadowsSaturation(): number;
  12116. /**
  12117. * Sets the shadows Saturation value.
  12118. * 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.
  12119. */
  12120. set shadowsSaturation(value: number);
  12121. /**
  12122. * Gets the shadows Exposure value.
  12123. * 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.
  12124. */
  12125. get shadowsExposure(): number;
  12126. /**
  12127. * Sets the shadows Exposure value.
  12128. * 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.
  12129. */
  12130. set shadowsExposure(value: number);
  12131. /**
  12132. * Returns the class name
  12133. * @returns The class name
  12134. */
  12135. getClassName(): string;
  12136. /**
  12137. * Binds the color curves to the shader.
  12138. * @param colorCurves The color curve to bind
  12139. * @param effect The effect to bind to
  12140. * @param positiveUniform The positive uniform shader parameter
  12141. * @param neutralUniform The neutral uniform shader parameter
  12142. * @param negativeUniform The negative uniform shader parameter
  12143. */
  12144. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  12145. /**
  12146. * Prepare the list of uniforms associated with the ColorCurves effects.
  12147. * @param uniformsList The list of uniforms used in the effect
  12148. */
  12149. static PrepareUniforms(uniformsList: string[]): void;
  12150. /**
  12151. * Returns color grading data based on a hue, density, saturation and exposure value.
  12152. * @param filterHue The hue of the color filter.
  12153. * @param filterDensity The density of the color filter.
  12154. * @param saturation The saturation.
  12155. * @param exposure The exposure.
  12156. * @param result The result data container.
  12157. */
  12158. private getColorGradingDataToRef;
  12159. /**
  12160. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  12161. * @param value The input slider value in range [-100,100].
  12162. * @returns Adjusted value.
  12163. */
  12164. private static applyColorGradingSliderNonlinear;
  12165. /**
  12166. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  12167. * @param hue The hue (H) input.
  12168. * @param saturation The saturation (S) input.
  12169. * @param brightness The brightness (B) input.
  12170. * @result An RGBA color represented as Vector4.
  12171. */
  12172. private static fromHSBToRef;
  12173. /**
  12174. * Returns a value clamped between min and max
  12175. * @param value The value to clamp
  12176. * @param min The minimum of value
  12177. * @param max The maximum of value
  12178. * @returns The clamped value.
  12179. */
  12180. private static clamp;
  12181. /**
  12182. * Clones the current color curve instance.
  12183. * @return The cloned curves
  12184. */
  12185. clone(): ColorCurves;
  12186. /**
  12187. * Serializes the current color curve instance to a json representation.
  12188. * @return a JSON representation
  12189. */
  12190. serialize(): any;
  12191. /**
  12192. * Parses the color curve from a json representation.
  12193. * @param source the JSON source to parse
  12194. * @return The parsed curves
  12195. */
  12196. static Parse(source: any): ColorCurves;
  12197. }
  12198. }
  12199. declare module BABYLON {
  12200. /**
  12201. * Interface to follow in your material defines to integrate easily the
  12202. * Image processing functions.
  12203. * @hidden
  12204. */
  12205. export interface IImageProcessingConfigurationDefines {
  12206. IMAGEPROCESSING: boolean;
  12207. VIGNETTE: boolean;
  12208. VIGNETTEBLENDMODEMULTIPLY: boolean;
  12209. VIGNETTEBLENDMODEOPAQUE: boolean;
  12210. TONEMAPPING: boolean;
  12211. TONEMAPPING_ACES: boolean;
  12212. CONTRAST: boolean;
  12213. EXPOSURE: boolean;
  12214. COLORCURVES: boolean;
  12215. COLORGRADING: boolean;
  12216. COLORGRADING3D: boolean;
  12217. SAMPLER3DGREENDEPTH: boolean;
  12218. SAMPLER3DBGRMAP: boolean;
  12219. IMAGEPROCESSINGPOSTPROCESS: boolean;
  12220. }
  12221. /**
  12222. * @hidden
  12223. */
  12224. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  12225. IMAGEPROCESSING: boolean;
  12226. VIGNETTE: boolean;
  12227. VIGNETTEBLENDMODEMULTIPLY: boolean;
  12228. VIGNETTEBLENDMODEOPAQUE: boolean;
  12229. TONEMAPPING: boolean;
  12230. TONEMAPPING_ACES: boolean;
  12231. CONTRAST: boolean;
  12232. COLORCURVES: boolean;
  12233. COLORGRADING: boolean;
  12234. COLORGRADING3D: boolean;
  12235. SAMPLER3DGREENDEPTH: boolean;
  12236. SAMPLER3DBGRMAP: boolean;
  12237. IMAGEPROCESSINGPOSTPROCESS: boolean;
  12238. EXPOSURE: boolean;
  12239. constructor();
  12240. }
  12241. /**
  12242. * This groups together the common properties used for image processing either in direct forward pass
  12243. * or through post processing effect depending on the use of the image processing pipeline in your scene
  12244. * or not.
  12245. */
  12246. export class ImageProcessingConfiguration {
  12247. /**
  12248. * Default tone mapping applied in BabylonJS.
  12249. */
  12250. static readonly TONEMAPPING_STANDARD: number;
  12251. /**
  12252. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  12253. * to other engines rendering to increase portability.
  12254. */
  12255. static readonly TONEMAPPING_ACES: number;
  12256. /**
  12257. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  12258. */
  12259. colorCurves: Nullable<ColorCurves>;
  12260. private _colorCurvesEnabled;
  12261. /**
  12262. * Gets whether the color curves effect is enabled.
  12263. */
  12264. get colorCurvesEnabled(): boolean;
  12265. /**
  12266. * Sets whether the color curves effect is enabled.
  12267. */
  12268. set colorCurvesEnabled(value: boolean);
  12269. private _colorGradingTexture;
  12270. /**
  12271. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  12272. */
  12273. get colorGradingTexture(): Nullable<BaseTexture>;
  12274. /**
  12275. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  12276. */
  12277. set colorGradingTexture(value: Nullable<BaseTexture>);
  12278. private _colorGradingEnabled;
  12279. /**
  12280. * Gets whether the color grading effect is enabled.
  12281. */
  12282. get colorGradingEnabled(): boolean;
  12283. /**
  12284. * Sets whether the color grading effect is enabled.
  12285. */
  12286. set colorGradingEnabled(value: boolean);
  12287. private _colorGradingWithGreenDepth;
  12288. /**
  12289. * Gets whether the color grading effect is using a green depth for the 3d Texture.
  12290. */
  12291. get colorGradingWithGreenDepth(): boolean;
  12292. /**
  12293. * Sets whether the color grading effect is using a green depth for the 3d Texture.
  12294. */
  12295. set colorGradingWithGreenDepth(value: boolean);
  12296. private _colorGradingBGR;
  12297. /**
  12298. * Gets whether the color grading texture contains BGR values.
  12299. */
  12300. get colorGradingBGR(): boolean;
  12301. /**
  12302. * Sets whether the color grading texture contains BGR values.
  12303. */
  12304. set colorGradingBGR(value: boolean);
  12305. /** @hidden */
  12306. _exposure: number;
  12307. /**
  12308. * Gets the Exposure used in the effect.
  12309. */
  12310. get exposure(): number;
  12311. /**
  12312. * Sets the Exposure used in the effect.
  12313. */
  12314. set exposure(value: number);
  12315. private _toneMappingEnabled;
  12316. /**
  12317. * Gets whether the tone mapping effect is enabled.
  12318. */
  12319. get toneMappingEnabled(): boolean;
  12320. /**
  12321. * Sets whether the tone mapping effect is enabled.
  12322. */
  12323. set toneMappingEnabled(value: boolean);
  12324. private _toneMappingType;
  12325. /**
  12326. * Gets the type of tone mapping effect.
  12327. */
  12328. get toneMappingType(): number;
  12329. /**
  12330. * Sets the type of tone mapping effect used in BabylonJS.
  12331. */
  12332. set toneMappingType(value: number);
  12333. protected _contrast: number;
  12334. /**
  12335. * Gets the contrast used in the effect.
  12336. */
  12337. get contrast(): number;
  12338. /**
  12339. * Sets the contrast used in the effect.
  12340. */
  12341. set contrast(value: number);
  12342. /**
  12343. * Vignette stretch size.
  12344. */
  12345. vignetteStretch: number;
  12346. /**
  12347. * Vignette centre X Offset.
  12348. */
  12349. vignetteCentreX: number;
  12350. /**
  12351. * Vignette centre Y Offset.
  12352. */
  12353. vignetteCentreY: number;
  12354. /**
  12355. * Vignette weight or intensity of the vignette effect.
  12356. */
  12357. vignetteWeight: number;
  12358. /**
  12359. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  12360. * if vignetteEnabled is set to true.
  12361. */
  12362. vignetteColor: Color4;
  12363. /**
  12364. * Camera field of view used by the Vignette effect.
  12365. */
  12366. vignetteCameraFov: number;
  12367. private _vignetteBlendMode;
  12368. /**
  12369. * Gets the vignette blend mode allowing different kind of effect.
  12370. */
  12371. get vignetteBlendMode(): number;
  12372. /**
  12373. * Sets the vignette blend mode allowing different kind of effect.
  12374. */
  12375. set vignetteBlendMode(value: number);
  12376. private _vignetteEnabled;
  12377. /**
  12378. * Gets whether the vignette effect is enabled.
  12379. */
  12380. get vignetteEnabled(): boolean;
  12381. /**
  12382. * Sets whether the vignette effect is enabled.
  12383. */
  12384. set vignetteEnabled(value: boolean);
  12385. private _applyByPostProcess;
  12386. /**
  12387. * Gets whether the image processing is applied through a post process or not.
  12388. */
  12389. get applyByPostProcess(): boolean;
  12390. /**
  12391. * Sets whether the image processing is applied through a post process or not.
  12392. */
  12393. set applyByPostProcess(value: boolean);
  12394. private _isEnabled;
  12395. /**
  12396. * Gets whether the image processing is enabled or not.
  12397. */
  12398. get isEnabled(): boolean;
  12399. /**
  12400. * Sets whether the image processing is enabled or not.
  12401. */
  12402. set isEnabled(value: boolean);
  12403. /**
  12404. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  12405. */
  12406. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  12407. /**
  12408. * Method called each time the image processing information changes requires to recompile the effect.
  12409. */
  12410. protected _updateParameters(): void;
  12411. /**
  12412. * Gets the current class name.
  12413. * @return "ImageProcessingConfiguration"
  12414. */
  12415. getClassName(): string;
  12416. /**
  12417. * Prepare the list of uniforms associated with the Image Processing effects.
  12418. * @param uniforms The list of uniforms used in the effect
  12419. * @param defines the list of defines currently in use
  12420. */
  12421. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  12422. /**
  12423. * Prepare the list of samplers associated with the Image Processing effects.
  12424. * @param samplersList The list of uniforms used in the effect
  12425. * @param defines the list of defines currently in use
  12426. */
  12427. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  12428. /**
  12429. * Prepare the list of defines associated to the shader.
  12430. * @param defines the list of defines to complete
  12431. * @param forPostProcess Define if we are currently in post process mode or not
  12432. */
  12433. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  12434. /**
  12435. * Returns true if all the image processing information are ready.
  12436. * @returns True if ready, otherwise, false
  12437. */
  12438. isReady(): boolean;
  12439. /**
  12440. * Binds the image processing to the shader.
  12441. * @param effect The effect to bind to
  12442. * @param overrideAspectRatio Override the aspect ratio of the effect
  12443. */
  12444. bind(effect: Effect, overrideAspectRatio?: number): void;
  12445. /**
  12446. * Clones the current image processing instance.
  12447. * @return The cloned image processing
  12448. */
  12449. clone(): ImageProcessingConfiguration;
  12450. /**
  12451. * Serializes the current image processing instance to a json representation.
  12452. * @return a JSON representation
  12453. */
  12454. serialize(): any;
  12455. /**
  12456. * Parses the image processing from a json representation.
  12457. * @param source the JSON source to parse
  12458. * @return The parsed image processing
  12459. */
  12460. static Parse(source: any): ImageProcessingConfiguration;
  12461. private static _VIGNETTEMODE_MULTIPLY;
  12462. private static _VIGNETTEMODE_OPAQUE;
  12463. /**
  12464. * Used to apply the vignette as a mix with the pixel color.
  12465. */
  12466. static get VIGNETTEMODE_MULTIPLY(): number;
  12467. /**
  12468. * Used to apply the vignette as a replacement of the pixel color.
  12469. */
  12470. static get VIGNETTEMODE_OPAQUE(): number;
  12471. }
  12472. }
  12473. declare module BABYLON {
  12474. /** @hidden */
  12475. export var postprocessVertexShader: {
  12476. name: string;
  12477. shader: string;
  12478. };
  12479. }
  12480. declare module BABYLON {
  12481. /**
  12482. * Type used to define a render target texture size (either with a number or with a rect width and height)
  12483. */
  12484. export type RenderTargetTextureSize = number | {
  12485. width: number;
  12486. height: number;
  12487. layers?: number;
  12488. };
  12489. interface ThinEngine {
  12490. /**
  12491. * Creates a new render target texture
  12492. * @param size defines the size of the texture
  12493. * @param options defines the options used to create the texture
  12494. * @returns a new render target texture stored in an InternalTexture
  12495. */
  12496. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12497. /**
  12498. * Creates a depth stencil texture.
  12499. * This is only available in WebGL 2 or with the depth texture extension available.
  12500. * @param size The size of face edge in the texture.
  12501. * @param options The options defining the texture.
  12502. * @returns The texture
  12503. */
  12504. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12505. /** @hidden */
  12506. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12507. }
  12508. }
  12509. declare module BABYLON {
  12510. /**
  12511. * Defines the kind of connection point for node based material
  12512. */
  12513. export enum NodeMaterialBlockConnectionPointTypes {
  12514. /** Float */
  12515. Float = 1,
  12516. /** Int */
  12517. Int = 2,
  12518. /** Vector2 */
  12519. Vector2 = 4,
  12520. /** Vector3 */
  12521. Vector3 = 8,
  12522. /** Vector4 */
  12523. Vector4 = 16,
  12524. /** Color3 */
  12525. Color3 = 32,
  12526. /** Color4 */
  12527. Color4 = 64,
  12528. /** Matrix */
  12529. Matrix = 128,
  12530. /** Custom object */
  12531. Object = 256,
  12532. /** Detect type based on connection */
  12533. AutoDetect = 1024,
  12534. /** Output type that will be defined by input type */
  12535. BasedOnInput = 2048
  12536. }
  12537. }
  12538. declare module BABYLON {
  12539. /**
  12540. * Enum used to define the target of a block
  12541. */
  12542. export enum NodeMaterialBlockTargets {
  12543. /** Vertex shader */
  12544. Vertex = 1,
  12545. /** Fragment shader */
  12546. Fragment = 2,
  12547. /** Neutral */
  12548. Neutral = 4,
  12549. /** Vertex and Fragment */
  12550. VertexAndFragment = 3
  12551. }
  12552. }
  12553. declare module BABYLON {
  12554. /**
  12555. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  12556. */
  12557. export enum NodeMaterialBlockConnectionPointMode {
  12558. /** Value is an uniform */
  12559. Uniform = 0,
  12560. /** Value is a mesh attribute */
  12561. Attribute = 1,
  12562. /** Value is a varying between vertex and fragment shaders */
  12563. Varying = 2,
  12564. /** Mode is undefined */
  12565. Undefined = 3
  12566. }
  12567. }
  12568. declare module BABYLON {
  12569. /**
  12570. * Enum used to define system values e.g. values automatically provided by the system
  12571. */
  12572. export enum NodeMaterialSystemValues {
  12573. /** World */
  12574. World = 1,
  12575. /** View */
  12576. View = 2,
  12577. /** Projection */
  12578. Projection = 3,
  12579. /** ViewProjection */
  12580. ViewProjection = 4,
  12581. /** WorldView */
  12582. WorldView = 5,
  12583. /** WorldViewProjection */
  12584. WorldViewProjection = 6,
  12585. /** CameraPosition */
  12586. CameraPosition = 7,
  12587. /** Fog Color */
  12588. FogColor = 8,
  12589. /** Delta time */
  12590. DeltaTime = 9
  12591. }
  12592. }
  12593. declare module BABYLON {
  12594. /**
  12595. * Represents a camera frustum
  12596. */
  12597. export class Frustum {
  12598. /**
  12599. * Gets the planes representing the frustum
  12600. * @param transform matrix to be applied to the returned planes
  12601. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  12602. */
  12603. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  12604. /**
  12605. * Gets the near frustum plane transformed by the transform matrix
  12606. * @param transform transformation matrix to be applied to the resulting frustum plane
  12607. * @param frustumPlane the resuling frustum plane
  12608. */
  12609. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12610. /**
  12611. * Gets the far frustum plane transformed by the transform matrix
  12612. * @param transform transformation matrix to be applied to the resulting frustum plane
  12613. * @param frustumPlane the resuling frustum plane
  12614. */
  12615. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12616. /**
  12617. * Gets the left frustum plane transformed by the transform matrix
  12618. * @param transform transformation matrix to be applied to the resulting frustum plane
  12619. * @param frustumPlane the resuling frustum plane
  12620. */
  12621. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12622. /**
  12623. * Gets the right frustum plane transformed by the transform matrix
  12624. * @param transform transformation matrix to be applied to the resulting frustum plane
  12625. * @param frustumPlane the resuling frustum plane
  12626. */
  12627. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12628. /**
  12629. * Gets the top frustum plane transformed by the transform matrix
  12630. * @param transform transformation matrix to be applied to the resulting frustum plane
  12631. * @param frustumPlane the resuling frustum plane
  12632. */
  12633. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12634. /**
  12635. * Gets the bottom frustum plane transformed by the transform matrix
  12636. * @param transform transformation matrix to be applied to the resulting frustum plane
  12637. * @param frustumPlane the resuling frustum plane
  12638. */
  12639. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12640. /**
  12641. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  12642. * @param transform transformation matrix to be applied to the resulting frustum planes
  12643. * @param frustumPlanes the resuling frustum planes
  12644. */
  12645. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  12646. }
  12647. }
  12648. declare module BABYLON {
  12649. /**
  12650. * Contains position and normal vectors for a vertex
  12651. */
  12652. export class PositionNormalVertex {
  12653. /** the position of the vertex (defaut: 0,0,0) */
  12654. position: Vector3;
  12655. /** the normal of the vertex (defaut: 0,1,0) */
  12656. normal: Vector3;
  12657. /**
  12658. * Creates a PositionNormalVertex
  12659. * @param position the position of the vertex (defaut: 0,0,0)
  12660. * @param normal the normal of the vertex (defaut: 0,1,0)
  12661. */
  12662. constructor(
  12663. /** the position of the vertex (defaut: 0,0,0) */
  12664. position?: Vector3,
  12665. /** the normal of the vertex (defaut: 0,1,0) */
  12666. normal?: Vector3);
  12667. /**
  12668. * Clones the PositionNormalVertex
  12669. * @returns the cloned PositionNormalVertex
  12670. */
  12671. clone(): PositionNormalVertex;
  12672. }
  12673. /**
  12674. * Contains position, normal and uv vectors for a vertex
  12675. */
  12676. export class PositionNormalTextureVertex {
  12677. /** the position of the vertex (defaut: 0,0,0) */
  12678. position: Vector3;
  12679. /** the normal of the vertex (defaut: 0,1,0) */
  12680. normal: Vector3;
  12681. /** the uv of the vertex (default: 0,0) */
  12682. uv: Vector2;
  12683. /**
  12684. * Creates a PositionNormalTextureVertex
  12685. * @param position the position of the vertex (defaut: 0,0,0)
  12686. * @param normal the normal of the vertex (defaut: 0,1,0)
  12687. * @param uv the uv of the vertex (default: 0,0)
  12688. */
  12689. constructor(
  12690. /** the position of the vertex (defaut: 0,0,0) */
  12691. position?: Vector3,
  12692. /** the normal of the vertex (defaut: 0,1,0) */
  12693. normal?: Vector3,
  12694. /** the uv of the vertex (default: 0,0) */
  12695. uv?: Vector2);
  12696. /**
  12697. * Clones the PositionNormalTextureVertex
  12698. * @returns the cloned PositionNormalTextureVertex
  12699. */
  12700. clone(): PositionNormalTextureVertex;
  12701. }
  12702. }
  12703. declare module BABYLON {
  12704. /**
  12705. * Enum defining the type of animations supported by InputBlock
  12706. */
  12707. export enum AnimatedInputBlockTypes {
  12708. /** No animation */
  12709. None = 0,
  12710. /** Time based animation. Will only work for floats */
  12711. Time = 1
  12712. }
  12713. }
  12714. declare module BABYLON {
  12715. /**
  12716. * Block used to expose an input value
  12717. */
  12718. export class InputBlock extends NodeMaterialBlock {
  12719. private _mode;
  12720. private _associatedVariableName;
  12721. private _storedValue;
  12722. private _valueCallback;
  12723. private _type;
  12724. private _animationType;
  12725. /** Gets or set a value used to limit the range of float values */
  12726. min: number;
  12727. /** Gets or set a value used to limit the range of float values */
  12728. max: number;
  12729. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  12730. isBoolean: boolean;
  12731. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  12732. matrixMode: number;
  12733. /** @hidden */
  12734. _systemValue: Nullable<NodeMaterialSystemValues>;
  12735. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  12736. isConstant: boolean;
  12737. /** Gets or sets the group to use to display this block in the Inspector */
  12738. groupInInspector: string;
  12739. /** Gets an observable raised when the value is changed */
  12740. onValueChangedObservable: Observable<InputBlock>;
  12741. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  12742. convertToGammaSpace: boolean;
  12743. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  12744. convertToLinearSpace: boolean;
  12745. /**
  12746. * Gets or sets the connection point type (default is float)
  12747. */
  12748. get type(): NodeMaterialBlockConnectionPointTypes;
  12749. /**
  12750. * Creates a new InputBlock
  12751. * @param name defines the block name
  12752. * @param target defines the target of that block (Vertex by default)
  12753. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  12754. */
  12755. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  12756. /**
  12757. * Validates if a name is a reserve word.
  12758. * @param newName the new name to be given to the node.
  12759. * @returns false if the name is a reserve word, else true.
  12760. */
  12761. validateBlockName(newName: string): boolean;
  12762. /**
  12763. * Gets the output component
  12764. */
  12765. get output(): NodeMaterialConnectionPoint;
  12766. /**
  12767. * Set the source of this connection point to a vertex attribute
  12768. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  12769. * @returns the current connection point
  12770. */
  12771. setAsAttribute(attributeName?: string): InputBlock;
  12772. /**
  12773. * Set the source of this connection point to a system value
  12774. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  12775. * @returns the current connection point
  12776. */
  12777. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  12778. /**
  12779. * Gets or sets the value of that point.
  12780. * Please note that this value will be ignored if valueCallback is defined
  12781. */
  12782. get value(): any;
  12783. set value(value: any);
  12784. /**
  12785. * Gets or sets a callback used to get the value of that point.
  12786. * Please note that setting this value will force the connection point to ignore the value property
  12787. */
  12788. get valueCallback(): () => any;
  12789. set valueCallback(value: () => any);
  12790. /**
  12791. * Gets or sets the associated variable name in the shader
  12792. */
  12793. get associatedVariableName(): string;
  12794. set associatedVariableName(value: string);
  12795. /** Gets or sets the type of animation applied to the input */
  12796. get animationType(): AnimatedInputBlockTypes;
  12797. set animationType(value: AnimatedInputBlockTypes);
  12798. /**
  12799. * Gets a boolean indicating that this connection point not defined yet
  12800. */
  12801. get isUndefined(): boolean;
  12802. /**
  12803. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  12804. * In this case the connection point name must be the name of the uniform to use.
  12805. * Can only be set on inputs
  12806. */
  12807. get isUniform(): boolean;
  12808. set isUniform(value: boolean);
  12809. /**
  12810. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  12811. * In this case the connection point name must be the name of the attribute to use
  12812. * Can only be set on inputs
  12813. */
  12814. get isAttribute(): boolean;
  12815. set isAttribute(value: boolean);
  12816. /**
  12817. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  12818. * Can only be set on exit points
  12819. */
  12820. get isVarying(): boolean;
  12821. set isVarying(value: boolean);
  12822. /**
  12823. * Gets a boolean indicating that the current connection point is a system value
  12824. */
  12825. get isSystemValue(): boolean;
  12826. /**
  12827. * Gets or sets the current well known value or null if not defined as a system value
  12828. */
  12829. get systemValue(): Nullable<NodeMaterialSystemValues>;
  12830. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  12831. /**
  12832. * Gets the current class name
  12833. * @returns the class name
  12834. */
  12835. getClassName(): string;
  12836. /**
  12837. * Animate the input if animationType !== None
  12838. * @param scene defines the rendering scene
  12839. */
  12840. animate(scene: Scene): void;
  12841. private _emitDefine;
  12842. initialize(state: NodeMaterialBuildState): void;
  12843. /**
  12844. * Set the input block to its default value (based on its type)
  12845. */
  12846. setDefaultValue(): void;
  12847. private _emitConstant;
  12848. /** @hidden */
  12849. get _noContextSwitch(): boolean;
  12850. private _emit;
  12851. /** @hidden */
  12852. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  12853. /** @hidden */
  12854. _transmit(effect: Effect, scene: Scene): void;
  12855. protected _buildBlock(state: NodeMaterialBuildState): void;
  12856. protected _dumpPropertiesCode(): string;
  12857. dispose(): void;
  12858. serialize(): any;
  12859. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12860. }
  12861. }
  12862. declare module BABYLON {
  12863. /**
  12864. * Enum used to define the compatibility state between two connection points
  12865. */
  12866. export enum NodeMaterialConnectionPointCompatibilityStates {
  12867. /** Points are compatibles */
  12868. Compatible = 0,
  12869. /** Points are incompatible because of their types */
  12870. TypeIncompatible = 1,
  12871. /** Points are incompatible because of their targets (vertex vs fragment) */
  12872. TargetIncompatible = 2
  12873. }
  12874. /**
  12875. * Defines the direction of a connection point
  12876. */
  12877. export enum NodeMaterialConnectionPointDirection {
  12878. /** Input */
  12879. Input = 0,
  12880. /** Output */
  12881. Output = 1
  12882. }
  12883. /**
  12884. * Defines a connection point for a block
  12885. */
  12886. export class NodeMaterialConnectionPoint {
  12887. /**
  12888. * Checks if two types are equivalent
  12889. * @param type1 type 1 to check
  12890. * @param type2 type 2 to check
  12891. * @returns true if both types are equivalent, else false
  12892. */
  12893. static AreEquivalentTypes(type1: number, type2: number): boolean;
  12894. /** @hidden */
  12895. _ownerBlock: NodeMaterialBlock;
  12896. /** @hidden */
  12897. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  12898. private _endpoints;
  12899. private _associatedVariableName;
  12900. private _direction;
  12901. /** @hidden */
  12902. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12903. /** @hidden */
  12904. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12905. /** @hidden */
  12906. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  12907. private _type;
  12908. /** @hidden */
  12909. _enforceAssociatedVariableName: boolean;
  12910. /** Gets the direction of the point */
  12911. get direction(): NodeMaterialConnectionPointDirection;
  12912. /** Indicates that this connection point needs dual validation before being connected to another point */
  12913. needDualDirectionValidation: boolean;
  12914. /**
  12915. * Gets or sets the additional types supported by this connection point
  12916. */
  12917. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12918. /**
  12919. * Gets or sets the additional types excluded by this connection point
  12920. */
  12921. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12922. /**
  12923. * Observable triggered when this point is connected
  12924. */
  12925. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  12926. /**
  12927. * Gets or sets the associated variable name in the shader
  12928. */
  12929. get associatedVariableName(): string;
  12930. set associatedVariableName(value: string);
  12931. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  12932. get innerType(): NodeMaterialBlockConnectionPointTypes;
  12933. /**
  12934. * Gets or sets the connection point type (default is float)
  12935. */
  12936. get type(): NodeMaterialBlockConnectionPointTypes;
  12937. set type(value: NodeMaterialBlockConnectionPointTypes);
  12938. /**
  12939. * Gets or sets the connection point name
  12940. */
  12941. name: string;
  12942. /**
  12943. * Gets or sets the connection point name
  12944. */
  12945. displayName: string;
  12946. /**
  12947. * Gets or sets a boolean indicating that this connection point can be omitted
  12948. */
  12949. isOptional: boolean;
  12950. /**
  12951. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  12952. */
  12953. isExposedOnFrame: boolean;
  12954. /**
  12955. * Gets or sets number indicating the position that the port is exposed to on a frame
  12956. */
  12957. exposedPortPosition: number;
  12958. /**
  12959. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  12960. */
  12961. define: string;
  12962. /** @hidden */
  12963. _prioritizeVertex: boolean;
  12964. private _target;
  12965. /** Gets or sets the target of that connection point */
  12966. get target(): NodeMaterialBlockTargets;
  12967. set target(value: NodeMaterialBlockTargets);
  12968. /**
  12969. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  12970. */
  12971. get isConnected(): boolean;
  12972. /**
  12973. * Gets a boolean indicating that the current point is connected to an input block
  12974. */
  12975. get isConnectedToInputBlock(): boolean;
  12976. /**
  12977. * Gets a the connected input block (if any)
  12978. */
  12979. get connectInputBlock(): Nullable<InputBlock>;
  12980. /** Get the other side of the connection (if any) */
  12981. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  12982. /** Get the block that owns this connection point */
  12983. get ownerBlock(): NodeMaterialBlock;
  12984. /** Get the block connected on the other side of this connection (if any) */
  12985. get sourceBlock(): Nullable<NodeMaterialBlock>;
  12986. /** Get the block connected on the endpoints of this connection (if any) */
  12987. get connectedBlocks(): Array<NodeMaterialBlock>;
  12988. /** Gets the list of connected endpoints */
  12989. get endpoints(): NodeMaterialConnectionPoint[];
  12990. /** Gets a boolean indicating if that output point is connected to at least one input */
  12991. get hasEndpoints(): boolean;
  12992. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  12993. get isConnectedInVertexShader(): boolean;
  12994. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  12995. get isConnectedInFragmentShader(): boolean;
  12996. /**
  12997. * Creates a block suitable to be used as an input for this input point.
  12998. * If null is returned, a block based on the point type will be created.
  12999. * @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
  13000. */
  13001. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  13002. /**
  13003. * Creates a new connection point
  13004. * @param name defines the connection point name
  13005. * @param ownerBlock defines the block hosting this connection point
  13006. * @param direction defines the direction of the connection point
  13007. */
  13008. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  13009. /**
  13010. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  13011. * @returns the class name
  13012. */
  13013. getClassName(): string;
  13014. /**
  13015. * Gets a boolean indicating if the current point can be connected to another point
  13016. * @param connectionPoint defines the other connection point
  13017. * @returns a boolean
  13018. */
  13019. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  13020. /**
  13021. * Gets a number indicating if the current point can be connected to another point
  13022. * @param connectionPoint defines the other connection point
  13023. * @returns a number defining the compatibility state
  13024. */
  13025. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  13026. /**
  13027. * Connect this point to another connection point
  13028. * @param connectionPoint defines the other connection point
  13029. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  13030. * @returns the current connection point
  13031. */
  13032. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  13033. /**
  13034. * Disconnect this point from one of his endpoint
  13035. * @param endpoint defines the other connection point
  13036. * @returns the current connection point
  13037. */
  13038. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  13039. /**
  13040. * Serializes this point in a JSON representation
  13041. * @param isInput defines if the connection point is an input (default is true)
  13042. * @returns the serialized point object
  13043. */
  13044. serialize(isInput?: boolean): any;
  13045. /**
  13046. * Release resources
  13047. */
  13048. dispose(): void;
  13049. }
  13050. }
  13051. declare module BABYLON {
  13052. /**
  13053. * Enum used to define the material modes
  13054. */
  13055. export enum NodeMaterialModes {
  13056. /** Regular material */
  13057. Material = 0,
  13058. /** For post process */
  13059. PostProcess = 1,
  13060. /** For particle system */
  13061. Particle = 2,
  13062. /** For procedural texture */
  13063. ProceduralTexture = 3
  13064. }
  13065. }
  13066. declare module BABYLON {
  13067. /** @hidden */
  13068. export var helperFunctions: {
  13069. name: string;
  13070. shader: string;
  13071. };
  13072. }
  13073. declare module BABYLON {
  13074. /**
  13075. * Block used to read a texture from a sampler
  13076. */
  13077. export class TextureBlock extends NodeMaterialBlock {
  13078. private _defineName;
  13079. private _linearDefineName;
  13080. private _gammaDefineName;
  13081. private _tempTextureRead;
  13082. private _samplerName;
  13083. private _transformedUVName;
  13084. private _textureTransformName;
  13085. private _textureInfoName;
  13086. private _mainUVName;
  13087. private _mainUVDefineName;
  13088. private _fragmentOnly;
  13089. protected _texture: Nullable<Texture>;
  13090. /**
  13091. * Gets or sets the texture associated with the node
  13092. */
  13093. get texture(): Nullable<Texture>;
  13094. set texture(texture: Nullable<Texture>);
  13095. /**
  13096. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13097. */
  13098. convertToGammaSpace: boolean;
  13099. /**
  13100. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13101. */
  13102. convertToLinearSpace: boolean;
  13103. /**
  13104. * Create a new TextureBlock
  13105. * @param name defines the block name
  13106. */
  13107. constructor(name: string, fragmentOnly?: boolean);
  13108. /**
  13109. * Gets the current class name
  13110. * @returns the class name
  13111. */
  13112. getClassName(): string;
  13113. /**
  13114. * Gets the uv input component
  13115. */
  13116. get uv(): NodeMaterialConnectionPoint;
  13117. /**
  13118. * Gets the rgba output component
  13119. */
  13120. get rgba(): NodeMaterialConnectionPoint;
  13121. /**
  13122. * Gets the rgb output component
  13123. */
  13124. get rgb(): NodeMaterialConnectionPoint;
  13125. /**
  13126. * Gets the r output component
  13127. */
  13128. get r(): NodeMaterialConnectionPoint;
  13129. /**
  13130. * Gets the g output component
  13131. */
  13132. get g(): NodeMaterialConnectionPoint;
  13133. /**
  13134. * Gets the b output component
  13135. */
  13136. get b(): NodeMaterialConnectionPoint;
  13137. /**
  13138. * Gets the a output component
  13139. */
  13140. get a(): NodeMaterialConnectionPoint;
  13141. get target(): NodeMaterialBlockTargets;
  13142. autoConfigure(material: NodeMaterial): void;
  13143. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  13144. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13145. isReady(): boolean;
  13146. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  13147. private get _isMixed();
  13148. private _injectVertexCode;
  13149. private _writeTextureRead;
  13150. private _generateConversionCode;
  13151. private _writeOutput;
  13152. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13153. protected _dumpPropertiesCode(): string;
  13154. serialize(): any;
  13155. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13156. }
  13157. }
  13158. declare module BABYLON {
  13159. /** @hidden */
  13160. export var reflectionFunction: {
  13161. name: string;
  13162. shader: string;
  13163. };
  13164. }
  13165. declare module BABYLON {
  13166. /**
  13167. * Base block used to read a reflection texture from a sampler
  13168. */
  13169. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  13170. /** @hidden */
  13171. _define3DName: string;
  13172. /** @hidden */
  13173. _defineCubicName: string;
  13174. /** @hidden */
  13175. _defineExplicitName: string;
  13176. /** @hidden */
  13177. _defineProjectionName: string;
  13178. /** @hidden */
  13179. _defineLocalCubicName: string;
  13180. /** @hidden */
  13181. _defineSphericalName: string;
  13182. /** @hidden */
  13183. _definePlanarName: string;
  13184. /** @hidden */
  13185. _defineEquirectangularName: string;
  13186. /** @hidden */
  13187. _defineMirroredEquirectangularFixedName: string;
  13188. /** @hidden */
  13189. _defineEquirectangularFixedName: string;
  13190. /** @hidden */
  13191. _defineSkyboxName: string;
  13192. /** @hidden */
  13193. _defineOppositeZ: string;
  13194. /** @hidden */
  13195. _cubeSamplerName: string;
  13196. /** @hidden */
  13197. _2DSamplerName: string;
  13198. protected _positionUVWName: string;
  13199. protected _directionWName: string;
  13200. protected _reflectionVectorName: string;
  13201. /** @hidden */
  13202. _reflectionCoordsName: string;
  13203. /** @hidden */
  13204. _reflectionMatrixName: string;
  13205. protected _reflectionColorName: string;
  13206. protected _texture: Nullable<BaseTexture>;
  13207. /**
  13208. * Gets or sets the texture associated with the node
  13209. */
  13210. get texture(): Nullable<BaseTexture>;
  13211. set texture(texture: Nullable<BaseTexture>);
  13212. /**
  13213. * Create a new ReflectionTextureBaseBlock
  13214. * @param name defines the block name
  13215. */
  13216. constructor(name: string);
  13217. /**
  13218. * Gets the current class name
  13219. * @returns the class name
  13220. */
  13221. getClassName(): string;
  13222. /**
  13223. * Gets the world position input component
  13224. */
  13225. abstract get position(): NodeMaterialConnectionPoint;
  13226. /**
  13227. * Gets the world position input component
  13228. */
  13229. abstract get worldPosition(): NodeMaterialConnectionPoint;
  13230. /**
  13231. * Gets the world normal input component
  13232. */
  13233. abstract get worldNormal(): NodeMaterialConnectionPoint;
  13234. /**
  13235. * Gets the world input component
  13236. */
  13237. abstract get world(): NodeMaterialConnectionPoint;
  13238. /**
  13239. * Gets the camera (or eye) position component
  13240. */
  13241. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  13242. /**
  13243. * Gets the view input component
  13244. */
  13245. abstract get view(): NodeMaterialConnectionPoint;
  13246. protected _getTexture(): Nullable<BaseTexture>;
  13247. autoConfigure(material: NodeMaterial): void;
  13248. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13249. isReady(): boolean;
  13250. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  13251. /**
  13252. * Gets the code to inject in the vertex shader
  13253. * @param state current state of the node material building
  13254. * @returns the shader code
  13255. */
  13256. handleVertexSide(state: NodeMaterialBuildState): string;
  13257. /**
  13258. * Handles the inits for the fragment code path
  13259. * @param state node material build state
  13260. */
  13261. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  13262. /**
  13263. * Generates the reflection coords code for the fragment code path
  13264. * @param worldNormalVarName name of the world normal variable
  13265. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  13266. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  13267. * @returns the shader code
  13268. */
  13269. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  13270. /**
  13271. * Generates the reflection color code for the fragment code path
  13272. * @param lodVarName name of the lod variable
  13273. * @param swizzleLookupTexture swizzle to use for the final color variable
  13274. * @returns the shader code
  13275. */
  13276. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  13277. /**
  13278. * Generates the code corresponding to the connected output points
  13279. * @param state node material build state
  13280. * @param varName name of the variable to output
  13281. * @returns the shader code
  13282. */
  13283. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  13284. protected _buildBlock(state: NodeMaterialBuildState): this;
  13285. protected _dumpPropertiesCode(): string;
  13286. serialize(): any;
  13287. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13288. }
  13289. }
  13290. declare module BABYLON {
  13291. /**
  13292. * Defines a connection point to be used for points with a custom object type
  13293. */
  13294. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  13295. private _blockType;
  13296. private _blockName;
  13297. private _nameForCheking?;
  13298. /**
  13299. * Creates a new connection point
  13300. * @param name defines the connection point name
  13301. * @param ownerBlock defines the block hosting this connection point
  13302. * @param direction defines the direction of the connection point
  13303. */
  13304. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  13305. /**
  13306. * Gets a number indicating if the current point can be connected to another point
  13307. * @param connectionPoint defines the other connection point
  13308. * @returns a number defining the compatibility state
  13309. */
  13310. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  13311. /**
  13312. * Creates a block suitable to be used as an input for this input point.
  13313. * If null is returned, a block based on the point type will be created.
  13314. * @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
  13315. */
  13316. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  13317. }
  13318. }
  13319. declare module BABYLON {
  13320. /**
  13321. * Enum defining the type of properties that can be edited in the property pages in the NME
  13322. */
  13323. export enum PropertyTypeForEdition {
  13324. /** property is a boolean */
  13325. Boolean = 0,
  13326. /** property is a float */
  13327. Float = 1,
  13328. /** property is a Vector2 */
  13329. Vector2 = 2,
  13330. /** property is a list of values */
  13331. List = 3
  13332. }
  13333. /**
  13334. * Interface that defines an option in a variable of type list
  13335. */
  13336. export interface IEditablePropertyListOption {
  13337. /** label of the option */
  13338. "label": string;
  13339. /** value of the option */
  13340. "value": number;
  13341. }
  13342. /**
  13343. * Interface that defines the options available for an editable property
  13344. */
  13345. export interface IEditablePropertyOption {
  13346. /** min value */
  13347. "min"?: number;
  13348. /** max value */
  13349. "max"?: number;
  13350. /** notifiers: indicates which actions to take when the property is changed */
  13351. "notifiers"?: {
  13352. /** the material should be rebuilt */
  13353. "rebuild"?: boolean;
  13354. /** the preview should be updated */
  13355. "update"?: boolean;
  13356. };
  13357. /** list of the options for a variable of type list */
  13358. "options"?: IEditablePropertyListOption[];
  13359. }
  13360. /**
  13361. * Interface that describes an editable property
  13362. */
  13363. export interface IPropertyDescriptionForEdition {
  13364. /** name of the property */
  13365. "propertyName": string;
  13366. /** display name of the property */
  13367. "displayName": string;
  13368. /** type of the property */
  13369. "type": PropertyTypeForEdition;
  13370. /** group of the property - all properties with the same group value will be displayed in a specific section */
  13371. "groupName": string;
  13372. /** options for the property */
  13373. "options": IEditablePropertyOption;
  13374. }
  13375. /**
  13376. * Decorator that flags a property in a node material block as being editable
  13377. */
  13378. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  13379. }
  13380. declare module BABYLON {
  13381. /**
  13382. * Block used to implement the refraction part of the sub surface module of the PBR material
  13383. */
  13384. export class RefractionBlock extends NodeMaterialBlock {
  13385. /** @hidden */
  13386. _define3DName: string;
  13387. /** @hidden */
  13388. _refractionMatrixName: string;
  13389. /** @hidden */
  13390. _defineLODRefractionAlpha: string;
  13391. /** @hidden */
  13392. _defineLinearSpecularRefraction: string;
  13393. /** @hidden */
  13394. _defineOppositeZ: string;
  13395. /** @hidden */
  13396. _cubeSamplerName: string;
  13397. /** @hidden */
  13398. _2DSamplerName: string;
  13399. /** @hidden */
  13400. _vRefractionMicrosurfaceInfosName: string;
  13401. /** @hidden */
  13402. _vRefractionInfosName: string;
  13403. /** @hidden */
  13404. _vRefractionFilteringInfoName: string;
  13405. private _scene;
  13406. /**
  13407. * The properties below are set by the main PBR block prior to calling methods of this class.
  13408. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  13409. * It's less burden on the user side in the editor part.
  13410. */
  13411. /** @hidden */
  13412. viewConnectionPoint: NodeMaterialConnectionPoint;
  13413. /** @hidden */
  13414. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  13415. /**
  13416. * This parameters will make the material used its opacity to control how much it is refracting against not.
  13417. * Materials half opaque for instance using refraction could benefit from this control.
  13418. */
  13419. linkRefractionWithTransparency: boolean;
  13420. /**
  13421. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  13422. */
  13423. invertRefractionY: boolean;
  13424. /**
  13425. * Gets or sets the texture associated with the node
  13426. */
  13427. texture: Nullable<BaseTexture>;
  13428. /**
  13429. * Create a new RefractionBlock
  13430. * @param name defines the block name
  13431. */
  13432. constructor(name: string);
  13433. /**
  13434. * Gets the current class name
  13435. * @returns the class name
  13436. */
  13437. getClassName(): string;
  13438. /**
  13439. * Gets the intensity input component
  13440. */
  13441. get intensity(): NodeMaterialConnectionPoint;
  13442. /**
  13443. * Gets the tint at distance input component
  13444. */
  13445. get tintAtDistance(): NodeMaterialConnectionPoint;
  13446. /**
  13447. * Gets the view input component
  13448. */
  13449. get view(): NodeMaterialConnectionPoint;
  13450. /**
  13451. * Gets the refraction object output component
  13452. */
  13453. get refraction(): NodeMaterialConnectionPoint;
  13454. /**
  13455. * Returns true if the block has a texture
  13456. */
  13457. get hasTexture(): boolean;
  13458. protected _getTexture(): Nullable<BaseTexture>;
  13459. autoConfigure(material: NodeMaterial): void;
  13460. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13461. isReady(): boolean;
  13462. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13463. /**
  13464. * Gets the main code of the block (fragment side)
  13465. * @param state current state of the node material building
  13466. * @returns the shader code
  13467. */
  13468. getCode(state: NodeMaterialBuildState): string;
  13469. protected _buildBlock(state: NodeMaterialBuildState): this;
  13470. protected _dumpPropertiesCode(): string;
  13471. serialize(): any;
  13472. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13473. }
  13474. }
  13475. declare module BABYLON {
  13476. /**
  13477. * Base block used as input for post process
  13478. */
  13479. export class CurrentScreenBlock extends NodeMaterialBlock {
  13480. private _samplerName;
  13481. private _linearDefineName;
  13482. private _gammaDefineName;
  13483. private _mainUVName;
  13484. private _tempTextureRead;
  13485. /**
  13486. * Gets or sets the texture associated with the node
  13487. */
  13488. texture: Nullable<BaseTexture>;
  13489. /**
  13490. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13491. */
  13492. convertToGammaSpace: boolean;
  13493. /**
  13494. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13495. */
  13496. convertToLinearSpace: boolean;
  13497. /**
  13498. * Create a new CurrentScreenBlock
  13499. * @param name defines the block name
  13500. */
  13501. constructor(name: string);
  13502. /**
  13503. * Gets the current class name
  13504. * @returns the class name
  13505. */
  13506. getClassName(): string;
  13507. /**
  13508. * Gets the uv input component
  13509. */
  13510. get uv(): NodeMaterialConnectionPoint;
  13511. /**
  13512. * Gets the rgba output component
  13513. */
  13514. get rgba(): NodeMaterialConnectionPoint;
  13515. /**
  13516. * Gets the rgb output component
  13517. */
  13518. get rgb(): NodeMaterialConnectionPoint;
  13519. /**
  13520. * Gets the r output component
  13521. */
  13522. get r(): NodeMaterialConnectionPoint;
  13523. /**
  13524. * Gets the g output component
  13525. */
  13526. get g(): NodeMaterialConnectionPoint;
  13527. /**
  13528. * Gets the b output component
  13529. */
  13530. get b(): NodeMaterialConnectionPoint;
  13531. /**
  13532. * Gets the a output component
  13533. */
  13534. get a(): NodeMaterialConnectionPoint;
  13535. /**
  13536. * Initialize the block and prepare the context for build
  13537. * @param state defines the state that will be used for the build
  13538. */
  13539. initialize(state: NodeMaterialBuildState): void;
  13540. get target(): NodeMaterialBlockTargets;
  13541. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13542. isReady(): boolean;
  13543. private _injectVertexCode;
  13544. private _writeTextureRead;
  13545. private _writeOutput;
  13546. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13547. serialize(): any;
  13548. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13549. }
  13550. }
  13551. declare module BABYLON {
  13552. /**
  13553. * Base block used for the particle texture
  13554. */
  13555. export class ParticleTextureBlock extends NodeMaterialBlock {
  13556. private _samplerName;
  13557. private _linearDefineName;
  13558. private _gammaDefineName;
  13559. private _tempTextureRead;
  13560. /**
  13561. * Gets or sets the texture associated with the node
  13562. */
  13563. texture: Nullable<BaseTexture>;
  13564. /**
  13565. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13566. */
  13567. convertToGammaSpace: boolean;
  13568. /**
  13569. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13570. */
  13571. convertToLinearSpace: boolean;
  13572. /**
  13573. * Create a new ParticleTextureBlock
  13574. * @param name defines the block name
  13575. */
  13576. constructor(name: string);
  13577. /**
  13578. * Gets the current class name
  13579. * @returns the class name
  13580. */
  13581. getClassName(): string;
  13582. /**
  13583. * Gets the uv input component
  13584. */
  13585. get uv(): NodeMaterialConnectionPoint;
  13586. /**
  13587. * Gets the rgba output component
  13588. */
  13589. get rgba(): NodeMaterialConnectionPoint;
  13590. /**
  13591. * Gets the rgb output component
  13592. */
  13593. get rgb(): NodeMaterialConnectionPoint;
  13594. /**
  13595. * Gets the r output component
  13596. */
  13597. get r(): NodeMaterialConnectionPoint;
  13598. /**
  13599. * Gets the g output component
  13600. */
  13601. get g(): NodeMaterialConnectionPoint;
  13602. /**
  13603. * Gets the b output component
  13604. */
  13605. get b(): NodeMaterialConnectionPoint;
  13606. /**
  13607. * Gets the a output component
  13608. */
  13609. get a(): NodeMaterialConnectionPoint;
  13610. /**
  13611. * Initialize the block and prepare the context for build
  13612. * @param state defines the state that will be used for the build
  13613. */
  13614. initialize(state: NodeMaterialBuildState): void;
  13615. autoConfigure(material: NodeMaterial): void;
  13616. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13617. isReady(): boolean;
  13618. private _writeOutput;
  13619. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13620. serialize(): any;
  13621. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13622. }
  13623. }
  13624. declare module BABYLON {
  13625. /**
  13626. * Class used to store shared data between 2 NodeMaterialBuildState
  13627. */
  13628. export class NodeMaterialBuildStateSharedData {
  13629. /**
  13630. * Gets the list of emitted varyings
  13631. */
  13632. temps: string[];
  13633. /**
  13634. * Gets the list of emitted varyings
  13635. */
  13636. varyings: string[];
  13637. /**
  13638. * Gets the varying declaration string
  13639. */
  13640. varyingDeclaration: string;
  13641. /**
  13642. * Input blocks
  13643. */
  13644. inputBlocks: InputBlock[];
  13645. /**
  13646. * Input blocks
  13647. */
  13648. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  13649. /**
  13650. * Bindable blocks (Blocks that need to set data to the effect)
  13651. */
  13652. bindableBlocks: NodeMaterialBlock[];
  13653. /**
  13654. * List of blocks that can provide a compilation fallback
  13655. */
  13656. blocksWithFallbacks: NodeMaterialBlock[];
  13657. /**
  13658. * List of blocks that can provide a define update
  13659. */
  13660. blocksWithDefines: NodeMaterialBlock[];
  13661. /**
  13662. * List of blocks that can provide a repeatable content
  13663. */
  13664. repeatableContentBlocks: NodeMaterialBlock[];
  13665. /**
  13666. * List of blocks that can provide a dynamic list of uniforms
  13667. */
  13668. dynamicUniformBlocks: NodeMaterialBlock[];
  13669. /**
  13670. * List of blocks that can block the isReady function for the material
  13671. */
  13672. blockingBlocks: NodeMaterialBlock[];
  13673. /**
  13674. * Gets the list of animated inputs
  13675. */
  13676. animatedInputs: InputBlock[];
  13677. /**
  13678. * Build Id used to avoid multiple recompilations
  13679. */
  13680. buildId: number;
  13681. /** List of emitted variables */
  13682. variableNames: {
  13683. [key: string]: number;
  13684. };
  13685. /** List of emitted defines */
  13686. defineNames: {
  13687. [key: string]: number;
  13688. };
  13689. /** Should emit comments? */
  13690. emitComments: boolean;
  13691. /** Emit build activity */
  13692. verbose: boolean;
  13693. /** Gets or sets the hosting scene */
  13694. scene: Scene;
  13695. /**
  13696. * Gets the compilation hints emitted at compilation time
  13697. */
  13698. hints: {
  13699. needWorldViewMatrix: boolean;
  13700. needWorldViewProjectionMatrix: boolean;
  13701. needAlphaBlending: boolean;
  13702. needAlphaTesting: boolean;
  13703. };
  13704. /**
  13705. * List of compilation checks
  13706. */
  13707. checks: {
  13708. emitVertex: boolean;
  13709. emitFragment: boolean;
  13710. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  13711. };
  13712. /**
  13713. * Is vertex program allowed to be empty?
  13714. */
  13715. allowEmptyVertexProgram: boolean;
  13716. /** Creates a new shared data */
  13717. constructor();
  13718. /**
  13719. * Emits console errors and exceptions if there is a failing check
  13720. */
  13721. emitErrors(): void;
  13722. }
  13723. }
  13724. declare module BABYLON {
  13725. /**
  13726. * Class used to store node based material build state
  13727. */
  13728. export class NodeMaterialBuildState {
  13729. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  13730. supportUniformBuffers: boolean;
  13731. /**
  13732. * Gets the list of emitted attributes
  13733. */
  13734. attributes: string[];
  13735. /**
  13736. * Gets the list of emitted uniforms
  13737. */
  13738. uniforms: string[];
  13739. /**
  13740. * Gets the list of emitted constants
  13741. */
  13742. constants: string[];
  13743. /**
  13744. * Gets the list of emitted samplers
  13745. */
  13746. samplers: string[];
  13747. /**
  13748. * Gets the list of emitted functions
  13749. */
  13750. functions: {
  13751. [key: string]: string;
  13752. };
  13753. /**
  13754. * Gets the list of emitted extensions
  13755. */
  13756. extensions: {
  13757. [key: string]: string;
  13758. };
  13759. /**
  13760. * Gets the target of the compilation state
  13761. */
  13762. target: NodeMaterialBlockTargets;
  13763. /**
  13764. * Gets the list of emitted counters
  13765. */
  13766. counters: {
  13767. [key: string]: number;
  13768. };
  13769. /**
  13770. * Shared data between multiple NodeMaterialBuildState instances
  13771. */
  13772. sharedData: NodeMaterialBuildStateSharedData;
  13773. /** @hidden */
  13774. _vertexState: NodeMaterialBuildState;
  13775. /** @hidden */
  13776. _attributeDeclaration: string;
  13777. /** @hidden */
  13778. _uniformDeclaration: string;
  13779. /** @hidden */
  13780. _constantDeclaration: string;
  13781. /** @hidden */
  13782. _samplerDeclaration: string;
  13783. /** @hidden */
  13784. _varyingTransfer: string;
  13785. /** @hidden */
  13786. _injectAtEnd: string;
  13787. private _repeatableContentAnchorIndex;
  13788. /** @hidden */
  13789. _builtCompilationString: string;
  13790. /**
  13791. * Gets the emitted compilation strings
  13792. */
  13793. compilationString: string;
  13794. /**
  13795. * Finalize the compilation strings
  13796. * @param state defines the current compilation state
  13797. */
  13798. finalize(state: NodeMaterialBuildState): void;
  13799. /** @hidden */
  13800. get _repeatableContentAnchor(): string;
  13801. /** @hidden */
  13802. _getFreeVariableName(prefix: string): string;
  13803. /** @hidden */
  13804. _getFreeDefineName(prefix: string): string;
  13805. /** @hidden */
  13806. _excludeVariableName(name: string): void;
  13807. /** @hidden */
  13808. _emit2DSampler(name: string): void;
  13809. /** @hidden */
  13810. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  13811. /** @hidden */
  13812. _emitExtension(name: string, extension: string, define?: string): void;
  13813. /** @hidden */
  13814. _emitFunction(name: string, code: string, comments: string): void;
  13815. /** @hidden */
  13816. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  13817. replaceStrings?: {
  13818. search: RegExp;
  13819. replace: string;
  13820. }[];
  13821. repeatKey?: string;
  13822. }): string;
  13823. /** @hidden */
  13824. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  13825. repeatKey?: string;
  13826. removeAttributes?: boolean;
  13827. removeUniforms?: boolean;
  13828. removeVaryings?: boolean;
  13829. removeIfDef?: boolean;
  13830. replaceStrings?: {
  13831. search: RegExp;
  13832. replace: string;
  13833. }[];
  13834. }, storeKey?: string): void;
  13835. /** @hidden */
  13836. _registerTempVariable(name: string): boolean;
  13837. /** @hidden */
  13838. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  13839. /** @hidden */
  13840. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  13841. /** @hidden */
  13842. _emitFloat(value: number): string;
  13843. }
  13844. }
  13845. declare module BABYLON {
  13846. /**
  13847. * Helper class used to generate session unique ID
  13848. */
  13849. export class UniqueIdGenerator {
  13850. private static _UniqueIdCounter;
  13851. /**
  13852. * Gets an unique (relatively to the current scene) Id
  13853. */
  13854. static get UniqueId(): number;
  13855. }
  13856. }
  13857. declare module BABYLON {
  13858. /**
  13859. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  13860. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  13861. */
  13862. export class EffectFallbacks implements IEffectFallbacks {
  13863. private _defines;
  13864. private _currentRank;
  13865. private _maxRank;
  13866. private _mesh;
  13867. /**
  13868. * Removes the fallback from the bound mesh.
  13869. */
  13870. unBindMesh(): void;
  13871. /**
  13872. * Adds a fallback on the specified property.
  13873. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13874. * @param define The name of the define in the shader
  13875. */
  13876. addFallback(rank: number, define: string): void;
  13877. /**
  13878. * Sets the mesh to use CPU skinning when needing to fallback.
  13879. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13880. * @param mesh The mesh to use the fallbacks.
  13881. */
  13882. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  13883. /**
  13884. * Checks to see if more fallbacks are still available.
  13885. */
  13886. get hasMoreFallbacks(): boolean;
  13887. /**
  13888. * Removes the defines that should be removed when falling back.
  13889. * @param currentDefines defines the current define statements for the shader.
  13890. * @param effect defines the current effect we try to compile
  13891. * @returns The resulting defines with defines of the current rank removed.
  13892. */
  13893. reduce(currentDefines: string, effect: Effect): string;
  13894. }
  13895. }
  13896. declare module BABYLON {
  13897. /**
  13898. * Defines a block that can be used inside a node based material
  13899. */
  13900. export class NodeMaterialBlock {
  13901. private _buildId;
  13902. private _buildTarget;
  13903. private _target;
  13904. private _isFinalMerger;
  13905. private _isInput;
  13906. private _name;
  13907. protected _isUnique: boolean;
  13908. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  13909. inputsAreExclusive: boolean;
  13910. /** @hidden */
  13911. _codeVariableName: string;
  13912. /** @hidden */
  13913. _inputs: NodeMaterialConnectionPoint[];
  13914. /** @hidden */
  13915. _outputs: NodeMaterialConnectionPoint[];
  13916. /** @hidden */
  13917. _preparationId: number;
  13918. /** @hidden */
  13919. readonly _originalTargetIsNeutral: boolean;
  13920. /**
  13921. * Gets the name of the block
  13922. */
  13923. get name(): string;
  13924. /**
  13925. * Sets the name of the block. Will check if the name is valid.
  13926. */
  13927. set name(newName: string);
  13928. /**
  13929. * Gets or sets the unique id of the node
  13930. */
  13931. uniqueId: number;
  13932. /**
  13933. * Gets or sets the comments associated with this block
  13934. */
  13935. comments: string;
  13936. /**
  13937. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  13938. */
  13939. get isUnique(): boolean;
  13940. /**
  13941. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  13942. */
  13943. get isFinalMerger(): boolean;
  13944. /**
  13945. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  13946. */
  13947. get isInput(): boolean;
  13948. /**
  13949. * Gets or sets the build Id
  13950. */
  13951. get buildId(): number;
  13952. set buildId(value: number);
  13953. /**
  13954. * Gets or sets the target of the block
  13955. */
  13956. get target(): NodeMaterialBlockTargets;
  13957. set target(value: NodeMaterialBlockTargets);
  13958. /**
  13959. * Gets the list of input points
  13960. */
  13961. get inputs(): NodeMaterialConnectionPoint[];
  13962. /** Gets the list of output points */
  13963. get outputs(): NodeMaterialConnectionPoint[];
  13964. /**
  13965. * Find an input by its name
  13966. * @param name defines the name of the input to look for
  13967. * @returns the input or null if not found
  13968. */
  13969. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13970. /**
  13971. * Find an output by its name
  13972. * @param name defines the name of the output to look for
  13973. * @returns the output or null if not found
  13974. */
  13975. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13976. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  13977. visibleInInspector: boolean;
  13978. /** Gets or sets a boolean indicating that this input can be edited from a collapsed frame*/
  13979. visibleOnFrame: boolean;
  13980. /**
  13981. * Creates a new NodeMaterialBlock
  13982. * @param name defines the block name
  13983. * @param target defines the target of that block (Vertex by default)
  13984. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  13985. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  13986. */
  13987. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  13988. /**
  13989. * Initialize the block and prepare the context for build
  13990. * @param state defines the state that will be used for the build
  13991. */
  13992. initialize(state: NodeMaterialBuildState): void;
  13993. /**
  13994. * Bind data to effect. Will only be called for blocks with isBindable === true
  13995. * @param effect defines the effect to bind data to
  13996. * @param nodeMaterial defines the hosting NodeMaterial
  13997. * @param mesh defines the mesh that will be rendered
  13998. * @param subMesh defines the submesh that will be rendered
  13999. */
  14000. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  14001. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  14002. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  14003. protected _writeFloat(value: number): string;
  14004. /**
  14005. * Gets the current class name e.g. "NodeMaterialBlock"
  14006. * @returns the class name
  14007. */
  14008. getClassName(): string;
  14009. /**
  14010. * Register a new input. Must be called inside a block constructor
  14011. * @param name defines the connection point name
  14012. * @param type defines the connection point type
  14013. * @param isOptional defines a boolean indicating that this input can be omitted
  14014. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  14015. * @param point an already created connection point. If not provided, create a new one
  14016. * @returns the current block
  14017. */
  14018. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  14019. /**
  14020. * Register a new output. Must be called inside a block constructor
  14021. * @param name defines the connection point name
  14022. * @param type defines the connection point type
  14023. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  14024. * @param point an already created connection point. If not provided, create a new one
  14025. * @returns the current block
  14026. */
  14027. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  14028. /**
  14029. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  14030. * @param forOutput defines an optional connection point to check compatibility with
  14031. * @returns the first available input or null
  14032. */
  14033. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  14034. /**
  14035. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  14036. * @param forBlock defines an optional block to check compatibility with
  14037. * @returns the first available input or null
  14038. */
  14039. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  14040. /**
  14041. * Gets the sibling of the given output
  14042. * @param current defines the current output
  14043. * @returns the next output in the list or null
  14044. */
  14045. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  14046. /**
  14047. * Connect current block with another block
  14048. * @param other defines the block to connect with
  14049. * @param options define the various options to help pick the right connections
  14050. * @returns the current block
  14051. */
  14052. connectTo(other: NodeMaterialBlock, options?: {
  14053. input?: string;
  14054. output?: string;
  14055. outputSwizzle?: string;
  14056. }): this | undefined;
  14057. protected _buildBlock(state: NodeMaterialBuildState): void;
  14058. /**
  14059. * Add uniforms, samplers and uniform buffers at compilation time
  14060. * @param state defines the state to update
  14061. * @param nodeMaterial defines the node material requesting the update
  14062. * @param defines defines the material defines to update
  14063. * @param uniformBuffers defines the list of uniform buffer names
  14064. */
  14065. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  14066. /**
  14067. * Add potential fallbacks if shader compilation fails
  14068. * @param mesh defines the mesh to be rendered
  14069. * @param fallbacks defines the current prioritized list of fallbacks
  14070. */
  14071. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  14072. /**
  14073. * Initialize defines for shader compilation
  14074. * @param mesh defines the mesh to be rendered
  14075. * @param nodeMaterial defines the node material requesting the update
  14076. * @param defines defines the material defines to update
  14077. * @param useInstances specifies that instances should be used
  14078. */
  14079. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  14080. /**
  14081. * Update defines for shader compilation
  14082. * @param mesh defines the mesh to be rendered
  14083. * @param nodeMaterial defines the node material requesting the update
  14084. * @param defines defines the material defines to update
  14085. * @param useInstances specifies that instances should be used
  14086. * @param subMesh defines which submesh to render
  14087. */
  14088. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  14089. /**
  14090. * Lets the block try to connect some inputs automatically
  14091. * @param material defines the hosting NodeMaterial
  14092. */
  14093. autoConfigure(material: NodeMaterial): void;
  14094. /**
  14095. * Function called when a block is declared as repeatable content generator
  14096. * @param vertexShaderState defines the current compilation state for the vertex shader
  14097. * @param fragmentShaderState defines the current compilation state for the fragment shader
  14098. * @param mesh defines the mesh to be rendered
  14099. * @param defines defines the material defines to update
  14100. */
  14101. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  14102. /**
  14103. * Checks if the block is ready
  14104. * @param mesh defines the mesh to be rendered
  14105. * @param nodeMaterial defines the node material requesting the update
  14106. * @param defines defines the material defines to update
  14107. * @param useInstances specifies that instances should be used
  14108. * @returns true if the block is ready
  14109. */
  14110. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  14111. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  14112. private _processBuild;
  14113. /**
  14114. * Validates the new name for the block node.
  14115. * @param newName the new name to be given to the node.
  14116. * @returns false if the name is a reserve word, else true.
  14117. */
  14118. validateBlockName(newName: string): boolean;
  14119. /**
  14120. * Compile the current node and generate the shader code
  14121. * @param state defines the current compilation state (uniforms, samplers, current string)
  14122. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  14123. * @returns true if already built
  14124. */
  14125. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  14126. protected _inputRename(name: string): string;
  14127. protected _outputRename(name: string): string;
  14128. protected _dumpPropertiesCode(): string;
  14129. /** @hidden */
  14130. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  14131. /** @hidden */
  14132. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  14133. /**
  14134. * Clone the current block to a new identical block
  14135. * @param scene defines the hosting scene
  14136. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  14137. * @returns a copy of the current block
  14138. */
  14139. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  14140. /**
  14141. * Serializes this block in a JSON representation
  14142. * @returns the serialized block object
  14143. */
  14144. serialize(): any;
  14145. /** @hidden */
  14146. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  14147. private _deserializePortDisplayNamesAndExposedOnFrame;
  14148. /**
  14149. * Release resources
  14150. */
  14151. dispose(): void;
  14152. }
  14153. }
  14154. declare module BABYLON {
  14155. /**
  14156. * Base class of materials working in push mode in babylon JS
  14157. * @hidden
  14158. */
  14159. export class PushMaterial extends Material {
  14160. protected _activeEffect: Effect;
  14161. protected _normalMatrix: Matrix;
  14162. constructor(name: string, scene: Scene);
  14163. getEffect(): Effect;
  14164. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14165. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  14166. /**
  14167. * Binds the given world matrix to the active effect
  14168. *
  14169. * @param world the matrix to bind
  14170. */
  14171. bindOnlyWorldMatrix(world: Matrix): void;
  14172. /**
  14173. * Binds the given normal matrix to the active effect
  14174. *
  14175. * @param normalMatrix the matrix to bind
  14176. */
  14177. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  14178. bind(world: Matrix, mesh?: Mesh): void;
  14179. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  14180. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  14181. }
  14182. }
  14183. declare module BABYLON {
  14184. /**
  14185. * Root class for all node material optimizers
  14186. */
  14187. export class NodeMaterialOptimizer {
  14188. /**
  14189. * Function used to optimize a NodeMaterial graph
  14190. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  14191. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  14192. */
  14193. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  14194. }
  14195. }
  14196. declare module BABYLON {
  14197. /**
  14198. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  14199. */
  14200. export class TransformBlock extends NodeMaterialBlock {
  14201. /**
  14202. * Defines the value to use to complement W value to transform it to a Vector4
  14203. */
  14204. complementW: number;
  14205. /**
  14206. * Defines the value to use to complement z value to transform it to a Vector4
  14207. */
  14208. complementZ: number;
  14209. /**
  14210. * Creates a new TransformBlock
  14211. * @param name defines the block name
  14212. */
  14213. constructor(name: string);
  14214. /**
  14215. * Gets the current class name
  14216. * @returns the class name
  14217. */
  14218. getClassName(): string;
  14219. /**
  14220. * Gets the vector input
  14221. */
  14222. get vector(): NodeMaterialConnectionPoint;
  14223. /**
  14224. * Gets the output component
  14225. */
  14226. get output(): NodeMaterialConnectionPoint;
  14227. /**
  14228. * Gets the xyz output component
  14229. */
  14230. get xyz(): NodeMaterialConnectionPoint;
  14231. /**
  14232. * Gets the matrix transform input
  14233. */
  14234. get transform(): NodeMaterialConnectionPoint;
  14235. protected _buildBlock(state: NodeMaterialBuildState): this;
  14236. /**
  14237. * Update defines for shader compilation
  14238. * @param mesh defines the mesh to be rendered
  14239. * @param nodeMaterial defines the node material requesting the update
  14240. * @param defines defines the material defines to update
  14241. * @param useInstances specifies that instances should be used
  14242. * @param subMesh defines which submesh to render
  14243. */
  14244. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  14245. serialize(): any;
  14246. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  14247. protected _dumpPropertiesCode(): string;
  14248. }
  14249. }
  14250. declare module BABYLON {
  14251. /**
  14252. * Block used to output the vertex position
  14253. */
  14254. export class VertexOutputBlock extends NodeMaterialBlock {
  14255. /**
  14256. * Creates a new VertexOutputBlock
  14257. * @param name defines the block name
  14258. */
  14259. constructor(name: string);
  14260. /**
  14261. * Gets the current class name
  14262. * @returns the class name
  14263. */
  14264. getClassName(): string;
  14265. /**
  14266. * Gets the vector input component
  14267. */
  14268. get vector(): NodeMaterialConnectionPoint;
  14269. protected _buildBlock(state: NodeMaterialBuildState): this;
  14270. }
  14271. }
  14272. declare module BABYLON {
  14273. /**
  14274. * Block used to output the final color
  14275. */
  14276. export class FragmentOutputBlock extends NodeMaterialBlock {
  14277. private _linearDefineName;
  14278. private _gammaDefineName;
  14279. /**
  14280. * Create a new FragmentOutputBlock
  14281. * @param name defines the block name
  14282. */
  14283. constructor(name: string);
  14284. /** Gets or sets a boolean indicating if content needs to be converted to gamma space */
  14285. convertToGammaSpace: boolean;
  14286. /** Gets or sets a boolean indicating if content needs to be converted to linear space */
  14287. convertToLinearSpace: boolean;
  14288. /**
  14289. * Gets the current class name
  14290. * @returns the class name
  14291. */
  14292. getClassName(): string;
  14293. /**
  14294. * Gets the rgba input component
  14295. */
  14296. get rgba(): NodeMaterialConnectionPoint;
  14297. /**
  14298. * Gets the rgb input component
  14299. */
  14300. get rgb(): NodeMaterialConnectionPoint;
  14301. /**
  14302. * Gets the a input component
  14303. */
  14304. get a(): NodeMaterialConnectionPoint;
  14305. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  14306. protected _buildBlock(state: NodeMaterialBuildState): this;
  14307. protected _dumpPropertiesCode(): string;
  14308. serialize(): any;
  14309. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  14310. }
  14311. }
  14312. declare module BABYLON {
  14313. /**
  14314. * Block used for the particle ramp gradient section
  14315. */
  14316. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  14317. /**
  14318. * Create a new ParticleRampGradientBlock
  14319. * @param name defines the block name
  14320. */
  14321. constructor(name: string);
  14322. /**
  14323. * Gets the current class name
  14324. * @returns the class name
  14325. */
  14326. getClassName(): string;
  14327. /**
  14328. * Gets the color input component
  14329. */
  14330. get color(): NodeMaterialConnectionPoint;
  14331. /**
  14332. * Gets the rampColor output component
  14333. */
  14334. get rampColor(): NodeMaterialConnectionPoint;
  14335. /**
  14336. * Initialize the block and prepare the context for build
  14337. * @param state defines the state that will be used for the build
  14338. */
  14339. initialize(state: NodeMaterialBuildState): void;
  14340. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  14341. }
  14342. }
  14343. declare module BABYLON {
  14344. /**
  14345. * Block used for the particle blend multiply section
  14346. */
  14347. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  14348. /**
  14349. * Create a new ParticleBlendMultiplyBlock
  14350. * @param name defines the block name
  14351. */
  14352. constructor(name: string);
  14353. /**
  14354. * Gets the current class name
  14355. * @returns the class name
  14356. */
  14357. getClassName(): string;
  14358. /**
  14359. * Gets the color input component
  14360. */
  14361. get color(): NodeMaterialConnectionPoint;
  14362. /**
  14363. * Gets the alphaTexture input component
  14364. */
  14365. get alphaTexture(): NodeMaterialConnectionPoint;
  14366. /**
  14367. * Gets the alphaColor input component
  14368. */
  14369. get alphaColor(): NodeMaterialConnectionPoint;
  14370. /**
  14371. * Gets the blendColor output component
  14372. */
  14373. get blendColor(): NodeMaterialConnectionPoint;
  14374. /**
  14375. * Initialize the block and prepare the context for build
  14376. * @param state defines the state that will be used for the build
  14377. */
  14378. initialize(state: NodeMaterialBuildState): void;
  14379. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  14380. }
  14381. }
  14382. declare module BABYLON {
  14383. /**
  14384. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  14385. */
  14386. export class VectorMergerBlock extends NodeMaterialBlock {
  14387. /**
  14388. * Create a new VectorMergerBlock
  14389. * @param name defines the block name
  14390. */
  14391. constructor(name: string);
  14392. /**
  14393. * Gets the current class name
  14394. * @returns the class name
  14395. */
  14396. getClassName(): string;
  14397. /**
  14398. * Gets the xyz component (input)
  14399. */
  14400. get xyzIn(): NodeMaterialConnectionPoint;
  14401. /**
  14402. * Gets the xy component (input)
  14403. */
  14404. get xyIn(): NodeMaterialConnectionPoint;
  14405. /**
  14406. * Gets the x component (input)
  14407. */
  14408. get x(): NodeMaterialConnectionPoint;
  14409. /**
  14410. * Gets the y component (input)
  14411. */
  14412. get y(): NodeMaterialConnectionPoint;
  14413. /**
  14414. * Gets the z component (input)
  14415. */
  14416. get z(): NodeMaterialConnectionPoint;
  14417. /**
  14418. * Gets the w component (input)
  14419. */
  14420. get w(): NodeMaterialConnectionPoint;
  14421. /**
  14422. * Gets the xyzw component (output)
  14423. */
  14424. get xyzw(): NodeMaterialConnectionPoint;
  14425. /**
  14426. * Gets the xyz component (output)
  14427. */
  14428. get xyzOut(): NodeMaterialConnectionPoint;
  14429. /**
  14430. * Gets the xy component (output)
  14431. */
  14432. get xyOut(): NodeMaterialConnectionPoint;
  14433. /**
  14434. * Gets the xy component (output)
  14435. * @deprecated Please use xyOut instead.
  14436. */
  14437. get xy(): NodeMaterialConnectionPoint;
  14438. /**
  14439. * Gets the xyz component (output)
  14440. * @deprecated Please use xyzOut instead.
  14441. */
  14442. get xyz(): NodeMaterialConnectionPoint;
  14443. protected _buildBlock(state: NodeMaterialBuildState): this;
  14444. }
  14445. }
  14446. declare module BABYLON {
  14447. /**
  14448. * Block used to remap a float from a range to a new one
  14449. */
  14450. export class RemapBlock extends NodeMaterialBlock {
  14451. /**
  14452. * Gets or sets the source range
  14453. */
  14454. sourceRange: Vector2;
  14455. /**
  14456. * Gets or sets the target range
  14457. */
  14458. targetRange: Vector2;
  14459. /**
  14460. * Creates a new RemapBlock
  14461. * @param name defines the block name
  14462. */
  14463. constructor(name: string);
  14464. /**
  14465. * Gets the current class name
  14466. * @returns the class name
  14467. */
  14468. getClassName(): string;
  14469. /**
  14470. * Gets the input component
  14471. */
  14472. get input(): NodeMaterialConnectionPoint;
  14473. /**
  14474. * Gets the source min input component
  14475. */
  14476. get sourceMin(): NodeMaterialConnectionPoint;
  14477. /**
  14478. * Gets the source max input component
  14479. */
  14480. get sourceMax(): NodeMaterialConnectionPoint;
  14481. /**
  14482. * Gets the target min input component
  14483. */
  14484. get targetMin(): NodeMaterialConnectionPoint;
  14485. /**
  14486. * Gets the target max input component
  14487. */
  14488. get targetMax(): NodeMaterialConnectionPoint;
  14489. /**
  14490. * Gets the output component
  14491. */
  14492. get output(): NodeMaterialConnectionPoint;
  14493. protected _buildBlock(state: NodeMaterialBuildState): this;
  14494. protected _dumpPropertiesCode(): string;
  14495. serialize(): any;
  14496. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  14497. }
  14498. }
  14499. declare module BABYLON {
  14500. /**
  14501. * Block used to multiply 2 values
  14502. */
  14503. export class MultiplyBlock extends NodeMaterialBlock {
  14504. /**
  14505. * Creates a new MultiplyBlock
  14506. * @param name defines the block name
  14507. */
  14508. constructor(name: string);
  14509. /**
  14510. * Gets the current class name
  14511. * @returns the class name
  14512. */
  14513. getClassName(): string;
  14514. /**
  14515. * Gets the left operand input component
  14516. */
  14517. get left(): NodeMaterialConnectionPoint;
  14518. /**
  14519. * Gets the right operand input component
  14520. */
  14521. get right(): NodeMaterialConnectionPoint;
  14522. /**
  14523. * Gets the output component
  14524. */
  14525. get output(): NodeMaterialConnectionPoint;
  14526. protected _buildBlock(state: NodeMaterialBuildState): this;
  14527. }
  14528. }
  14529. declare module BABYLON {
  14530. /** Interface used by value gradients (color, factor, ...) */
  14531. export interface IValueGradient {
  14532. /**
  14533. * Gets or sets the gradient value (between 0 and 1)
  14534. */
  14535. gradient: number;
  14536. }
  14537. /** Class used to store color4 gradient */
  14538. export class ColorGradient implements IValueGradient {
  14539. /**
  14540. * Gets or sets the gradient value (between 0 and 1)
  14541. */
  14542. gradient: number;
  14543. /**
  14544. * Gets or sets first associated color
  14545. */
  14546. color1: Color4;
  14547. /**
  14548. * Gets or sets second associated color
  14549. */
  14550. color2?: Color4 | undefined;
  14551. /**
  14552. * Creates a new color4 gradient
  14553. * @param gradient gets or sets the gradient value (between 0 and 1)
  14554. * @param color1 gets or sets first associated color
  14555. * @param color2 gets or sets first second color
  14556. */
  14557. constructor(
  14558. /**
  14559. * Gets or sets the gradient value (between 0 and 1)
  14560. */
  14561. gradient: number,
  14562. /**
  14563. * Gets or sets first associated color
  14564. */
  14565. color1: Color4,
  14566. /**
  14567. * Gets or sets second associated color
  14568. */
  14569. color2?: Color4 | undefined);
  14570. /**
  14571. * Will get a color picked randomly between color1 and color2.
  14572. * If color2 is undefined then color1 will be used
  14573. * @param result defines the target Color4 to store the result in
  14574. */
  14575. getColorToRef(result: Color4): void;
  14576. }
  14577. /** Class used to store color 3 gradient */
  14578. export class Color3Gradient implements IValueGradient {
  14579. /**
  14580. * Gets or sets the gradient value (between 0 and 1)
  14581. */
  14582. gradient: number;
  14583. /**
  14584. * Gets or sets the associated color
  14585. */
  14586. color: Color3;
  14587. /**
  14588. * Creates a new color3 gradient
  14589. * @param gradient gets or sets the gradient value (between 0 and 1)
  14590. * @param color gets or sets associated color
  14591. */
  14592. constructor(
  14593. /**
  14594. * Gets or sets the gradient value (between 0 and 1)
  14595. */
  14596. gradient: number,
  14597. /**
  14598. * Gets or sets the associated color
  14599. */
  14600. color: Color3);
  14601. }
  14602. /** Class used to store factor gradient */
  14603. export class FactorGradient implements IValueGradient {
  14604. /**
  14605. * Gets or sets the gradient value (between 0 and 1)
  14606. */
  14607. gradient: number;
  14608. /**
  14609. * Gets or sets first associated factor
  14610. */
  14611. factor1: number;
  14612. /**
  14613. * Gets or sets second associated factor
  14614. */
  14615. factor2?: number | undefined;
  14616. /**
  14617. * Creates a new factor gradient
  14618. * @param gradient gets or sets the gradient value (between 0 and 1)
  14619. * @param factor1 gets or sets first associated factor
  14620. * @param factor2 gets or sets second associated factor
  14621. */
  14622. constructor(
  14623. /**
  14624. * Gets or sets the gradient value (between 0 and 1)
  14625. */
  14626. gradient: number,
  14627. /**
  14628. * Gets or sets first associated factor
  14629. */
  14630. factor1: number,
  14631. /**
  14632. * Gets or sets second associated factor
  14633. */
  14634. factor2?: number | undefined);
  14635. /**
  14636. * Will get a number picked randomly between factor1 and factor2.
  14637. * If factor2 is undefined then factor1 will be used
  14638. * @returns the picked number
  14639. */
  14640. getFactor(): number;
  14641. }
  14642. /**
  14643. * Helper used to simplify some generic gradient tasks
  14644. */
  14645. export class GradientHelper {
  14646. /**
  14647. * Gets the current gradient from an array of IValueGradient
  14648. * @param ratio defines the current ratio to get
  14649. * @param gradients defines the array of IValueGradient
  14650. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  14651. */
  14652. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  14653. }
  14654. }
  14655. declare module BABYLON {
  14656. interface ThinEngine {
  14657. /**
  14658. * Creates a raw texture
  14659. * @param data defines the data to store in the texture
  14660. * @param width defines the width of the texture
  14661. * @param height defines the height of the texture
  14662. * @param format defines the format of the data
  14663. * @param generateMipMaps defines if the engine should generate the mip levels
  14664. * @param invertY defines if data must be stored with Y axis inverted
  14665. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  14666. * @param compression defines the compression used (null by default)
  14667. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14668. * @returns the raw texture inside an InternalTexture
  14669. */
  14670. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  14671. /**
  14672. * Update a raw texture
  14673. * @param texture defines the texture to update
  14674. * @param data defines the data to store in the texture
  14675. * @param format defines the format of the data
  14676. * @param invertY defines if data must be stored with Y axis inverted
  14677. */
  14678. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14679. /**
  14680. * Update a raw texture
  14681. * @param texture defines the texture to update
  14682. * @param data defines the data to store in the texture
  14683. * @param format defines the format of the data
  14684. * @param invertY defines if data must be stored with Y axis inverted
  14685. * @param compression defines the compression used (null by default)
  14686. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14687. */
  14688. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  14689. /**
  14690. * Creates a new raw cube texture
  14691. * @param data defines the array of data to use to create each face
  14692. * @param size defines the size of the textures
  14693. * @param format defines the format of the data
  14694. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14695. * @param generateMipMaps defines if the engine should generate the mip levels
  14696. * @param invertY defines if data must be stored with Y axis inverted
  14697. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14698. * @param compression defines the compression used (null by default)
  14699. * @returns the cube texture as an InternalTexture
  14700. */
  14701. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  14702. /**
  14703. * Update a raw cube texture
  14704. * @param texture defines the texture to update
  14705. * @param data defines the data to store
  14706. * @param format defines the data format
  14707. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14708. * @param invertY defines if data must be stored with Y axis inverted
  14709. */
  14710. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  14711. /**
  14712. * Update a raw cube texture
  14713. * @param texture defines the texture to update
  14714. * @param data defines the data to store
  14715. * @param format defines the data format
  14716. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14717. * @param invertY defines if data must be stored with Y axis inverted
  14718. * @param compression defines the compression used (null by default)
  14719. */
  14720. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  14721. /**
  14722. * Update a raw cube texture
  14723. * @param texture defines the texture to update
  14724. * @param data defines the data to store
  14725. * @param format defines the data format
  14726. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14727. * @param invertY defines if data must be stored with Y axis inverted
  14728. * @param compression defines the compression used (null by default)
  14729. * @param level defines which level of the texture to update
  14730. */
  14731. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  14732. /**
  14733. * Creates a new raw cube texture from a specified url
  14734. * @param url defines the url where the data is located
  14735. * @param scene defines the current scene
  14736. * @param size defines the size of the textures
  14737. * @param format defines the format of the data
  14738. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14739. * @param noMipmap defines if the engine should avoid generating the mip levels
  14740. * @param callback defines a callback used to extract texture data from loaded data
  14741. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14742. * @param onLoad defines a callback called when texture is loaded
  14743. * @param onError defines a callback called if there is an error
  14744. * @returns the cube texture as an InternalTexture
  14745. */
  14746. 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;
  14747. /**
  14748. * Creates a new raw cube texture from a specified url
  14749. * @param url defines the url where the data is located
  14750. * @param scene defines the current scene
  14751. * @param size defines the size of the textures
  14752. * @param format defines the format of the data
  14753. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14754. * @param noMipmap defines if the engine should avoid generating the mip levels
  14755. * @param callback defines a callback used to extract texture data from loaded data
  14756. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14757. * @param onLoad defines a callback called when texture is loaded
  14758. * @param onError defines a callback called if there is an error
  14759. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14760. * @param invertY defines if data must be stored with Y axis inverted
  14761. * @returns the cube texture as an InternalTexture
  14762. */
  14763. 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;
  14764. /**
  14765. * Creates a new raw 3D texture
  14766. * @param data defines the data used to create the texture
  14767. * @param width defines the width of the texture
  14768. * @param height defines the height of the texture
  14769. * @param depth defines the depth of the texture
  14770. * @param format defines the format of the texture
  14771. * @param generateMipMaps defines if the engine must generate mip levels
  14772. * @param invertY defines if data must be stored with Y axis inverted
  14773. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14774. * @param compression defines the compressed used (can be null)
  14775. * @param textureType defines the compressed used (can be null)
  14776. * @returns a new raw 3D texture (stored in an InternalTexture)
  14777. */
  14778. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14779. /**
  14780. * Update a raw 3D texture
  14781. * @param texture defines the texture to update
  14782. * @param data defines the data to store
  14783. * @param format defines the data format
  14784. * @param invertY defines if data must be stored with Y axis inverted
  14785. */
  14786. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14787. /**
  14788. * Update a raw 3D texture
  14789. * @param texture defines the texture to update
  14790. * @param data defines the data to store
  14791. * @param format defines the data format
  14792. * @param invertY defines if data must be stored with Y axis inverted
  14793. * @param compression defines the used compression (can be null)
  14794. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14795. */
  14796. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14797. /**
  14798. * Creates a new raw 2D array texture
  14799. * @param data defines the data used to create the texture
  14800. * @param width defines the width of the texture
  14801. * @param height defines the height of the texture
  14802. * @param depth defines the number of layers of the texture
  14803. * @param format defines the format of the texture
  14804. * @param generateMipMaps defines if the engine must generate mip levels
  14805. * @param invertY defines if data must be stored with Y axis inverted
  14806. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14807. * @param compression defines the compressed used (can be null)
  14808. * @param textureType defines the compressed used (can be null)
  14809. * @returns a new raw 2D array texture (stored in an InternalTexture)
  14810. */
  14811. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14812. /**
  14813. * Update a raw 2D array texture
  14814. * @param texture defines the texture to update
  14815. * @param data defines the data to store
  14816. * @param format defines the data format
  14817. * @param invertY defines if data must be stored with Y axis inverted
  14818. */
  14819. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14820. /**
  14821. * Update a raw 2D array texture
  14822. * @param texture defines the texture to update
  14823. * @param data defines the data to store
  14824. * @param format defines the data format
  14825. * @param invertY defines if data must be stored with Y axis inverted
  14826. * @param compression defines the used compression (can be null)
  14827. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14828. */
  14829. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14830. }
  14831. }
  14832. declare module BABYLON {
  14833. /**
  14834. * Raw texture can help creating a texture directly from an array of data.
  14835. * This can be super useful if you either get the data from an uncompressed source or
  14836. * if you wish to create your texture pixel by pixel.
  14837. */
  14838. export class RawTexture extends Texture {
  14839. /**
  14840. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14841. */
  14842. format: number;
  14843. /**
  14844. * Instantiates a new RawTexture.
  14845. * Raw texture can help creating a texture directly from an array of data.
  14846. * This can be super useful if you either get the data from an uncompressed source or
  14847. * if you wish to create your texture pixel by pixel.
  14848. * @param data define the array of data to use to create the texture
  14849. * @param width define the width of the texture
  14850. * @param height define the height of the texture
  14851. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14852. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14853. * @param generateMipMaps define whether mip maps should be generated or not
  14854. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14855. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14856. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14857. */
  14858. constructor(data: ArrayBufferView, width: number, height: number,
  14859. /**
  14860. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14861. */
  14862. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  14863. /**
  14864. * Updates the texture underlying data.
  14865. * @param data Define the new data of the texture
  14866. */
  14867. update(data: ArrayBufferView): void;
  14868. /**
  14869. * Creates a luminance texture from some data.
  14870. * @param data Define the texture data
  14871. * @param width Define the width of the texture
  14872. * @param height Define the height of the texture
  14873. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14874. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14875. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14876. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14877. * @returns the luminance texture
  14878. */
  14879. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14880. /**
  14881. * Creates a luminance alpha texture from some data.
  14882. * @param data Define the texture data
  14883. * @param width Define the width of the texture
  14884. * @param height Define the height of the texture
  14885. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14886. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14887. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14888. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14889. * @returns the luminance alpha texture
  14890. */
  14891. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14892. /**
  14893. * Creates an alpha texture from some data.
  14894. * @param data Define the texture data
  14895. * @param width Define the width of the texture
  14896. * @param height Define the height of the texture
  14897. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14898. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14899. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14900. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14901. * @returns the alpha texture
  14902. */
  14903. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14904. /**
  14905. * Creates a RGB texture from some data.
  14906. * @param data Define the texture data
  14907. * @param width Define the width of the texture
  14908. * @param height Define the height of the texture
  14909. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14910. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14911. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14912. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14913. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14914. * @returns the RGB alpha texture
  14915. */
  14916. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14917. /**
  14918. * Creates a RGBA texture from some data.
  14919. * @param data Define the texture data
  14920. * @param width Define the width of the texture
  14921. * @param height Define the height of the texture
  14922. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14923. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14924. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14925. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14926. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14927. * @returns the RGBA texture
  14928. */
  14929. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14930. /**
  14931. * Creates a R texture from some data.
  14932. * @param data Define the texture data
  14933. * @param width Define the width of the texture
  14934. * @param height Define the height of the texture
  14935. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14936. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14937. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14938. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14939. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14940. * @returns the R texture
  14941. */
  14942. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14943. }
  14944. }
  14945. declare module BABYLON {
  14946. interface ThinEngine {
  14947. /**
  14948. * Update a dynamic index buffer
  14949. * @param indexBuffer defines the target index buffer
  14950. * @param indices defines the data to update
  14951. * @param offset defines the offset in the target index buffer where update should start
  14952. */
  14953. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  14954. /**
  14955. * Updates a dynamic vertex buffer.
  14956. * @param vertexBuffer the vertex buffer to update
  14957. * @param data the data used to update the vertex buffer
  14958. * @param byteOffset the byte offset of the data
  14959. * @param byteLength the byte length of the data
  14960. */
  14961. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  14962. }
  14963. }
  14964. declare module BABYLON {
  14965. interface AbstractScene {
  14966. /**
  14967. * The list of procedural textures added to the scene
  14968. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14969. */
  14970. proceduralTextures: Array<ProceduralTexture>;
  14971. }
  14972. /**
  14973. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14974. * in a given scene.
  14975. */
  14976. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14977. /**
  14978. * The component name helpful to identify the component in the list of scene components.
  14979. */
  14980. readonly name: string;
  14981. /**
  14982. * The scene the component belongs to.
  14983. */
  14984. scene: Scene;
  14985. /**
  14986. * Creates a new instance of the component for the given scene
  14987. * @param scene Defines the scene to register the component in
  14988. */
  14989. constructor(scene: Scene);
  14990. /**
  14991. * Registers the component in a given scene
  14992. */
  14993. register(): void;
  14994. /**
  14995. * Rebuilds the elements related to this component in case of
  14996. * context lost for instance.
  14997. */
  14998. rebuild(): void;
  14999. /**
  15000. * Disposes the component and the associated resources.
  15001. */
  15002. dispose(): void;
  15003. private _beforeClear;
  15004. }
  15005. }
  15006. declare module BABYLON {
  15007. interface ThinEngine {
  15008. /**
  15009. * Creates a new render target cube texture
  15010. * @param size defines the size of the texture
  15011. * @param options defines the options used to create the texture
  15012. * @returns a new render target cube texture stored in an InternalTexture
  15013. */
  15014. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  15015. }
  15016. }
  15017. declare module BABYLON {
  15018. /** @hidden */
  15019. export var proceduralVertexShader: {
  15020. name: string;
  15021. shader: string;
  15022. };
  15023. }
  15024. declare module BABYLON {
  15025. /**
  15026. * 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.
  15027. * This is the base class of any Procedural texture and contains most of the shareable code.
  15028. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15029. */
  15030. export class ProceduralTexture extends Texture {
  15031. /**
  15032. * Define if the texture is enabled or not (disabled texture will not render)
  15033. */
  15034. isEnabled: boolean;
  15035. /**
  15036. * Define if the texture must be cleared before rendering (default is true)
  15037. */
  15038. autoClear: boolean;
  15039. /**
  15040. * Callback called when the texture is generated
  15041. */
  15042. onGenerated: () => void;
  15043. /**
  15044. * Event raised when the texture is generated
  15045. */
  15046. onGeneratedObservable: Observable<ProceduralTexture>;
  15047. /**
  15048. * Event raised before the texture is generated
  15049. */
  15050. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  15051. /**
  15052. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  15053. */
  15054. nodeMaterialSource: Nullable<NodeMaterial>;
  15055. /** @hidden */
  15056. _generateMipMaps: boolean;
  15057. /** @hidden **/
  15058. _effect: Effect;
  15059. /** @hidden */
  15060. _textures: {
  15061. [key: string]: Texture;
  15062. };
  15063. /** @hidden */
  15064. protected _fallbackTexture: Nullable<Texture>;
  15065. private _size;
  15066. private _textureType;
  15067. private _currentRefreshId;
  15068. private _frameId;
  15069. private _refreshRate;
  15070. private _vertexBuffers;
  15071. private _indexBuffer;
  15072. private _uniforms;
  15073. private _samplers;
  15074. private _fragment;
  15075. private _floats;
  15076. private _ints;
  15077. private _floatsArrays;
  15078. private _colors3;
  15079. private _colors4;
  15080. private _vectors2;
  15081. private _vectors3;
  15082. private _matrices;
  15083. private _fallbackTextureUsed;
  15084. private _fullEngine;
  15085. private _cachedDefines;
  15086. private _contentUpdateId;
  15087. private _contentData;
  15088. /**
  15089. * Instantiates a new procedural texture.
  15090. * 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.
  15091. * This is the base class of any Procedural texture and contains most of the shareable code.
  15092. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15093. * @param name Define the name of the texture
  15094. * @param size Define the size of the texture to create
  15095. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  15096. * @param scene Define the scene the texture belongs to
  15097. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  15098. * @param generateMipMaps Define if the texture should creates mip maps or not
  15099. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  15100. * @param textureType The FBO internal texture type
  15101. */
  15102. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  15103. /**
  15104. * The effect that is created when initializing the post process.
  15105. * @returns The created effect corresponding the the postprocess.
  15106. */
  15107. getEffect(): Effect;
  15108. /**
  15109. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  15110. * @returns an ArrayBufferView promise (Uint8Array or Float32Array)
  15111. */
  15112. getContent(): Nullable<Promise<ArrayBufferView>>;
  15113. private _createIndexBuffer;
  15114. /** @hidden */
  15115. _rebuild(): void;
  15116. /**
  15117. * Resets the texture in order to recreate its associated resources.
  15118. * This can be called in case of context loss
  15119. */
  15120. reset(): void;
  15121. protected _getDefines(): string;
  15122. /**
  15123. * Is the texture ready to be used ? (rendered at least once)
  15124. * @returns true if ready, otherwise, false.
  15125. */
  15126. isReady(): boolean;
  15127. /**
  15128. * Resets the refresh counter of the texture and start bak from scratch.
  15129. * Could be useful to regenerate the texture if it is setup to render only once.
  15130. */
  15131. resetRefreshCounter(): void;
  15132. /**
  15133. * Set the fragment shader to use in order to render the texture.
  15134. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  15135. */
  15136. setFragment(fragment: any): void;
  15137. /**
  15138. * Define the refresh rate of the texture or the rendering frequency.
  15139. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  15140. */
  15141. get refreshRate(): number;
  15142. set refreshRate(value: number);
  15143. /** @hidden */
  15144. _shouldRender(): boolean;
  15145. /**
  15146. * Get the size the texture is rendering at.
  15147. * @returns the size (on cube texture it is always squared)
  15148. */
  15149. getRenderSize(): RenderTargetTextureSize;
  15150. /**
  15151. * Resize the texture to new value.
  15152. * @param size Define the new size the texture should have
  15153. * @param generateMipMaps Define whether the new texture should create mip maps
  15154. */
  15155. resize(size: number, generateMipMaps: boolean): void;
  15156. private _checkUniform;
  15157. /**
  15158. * Set a texture in the shader program used to render.
  15159. * @param name Define the name of the uniform samplers as defined in the shader
  15160. * @param texture Define the texture to bind to this sampler
  15161. * @return the texture itself allowing "fluent" like uniform updates
  15162. */
  15163. setTexture(name: string, texture: Texture): ProceduralTexture;
  15164. /**
  15165. * Set a float in the shader.
  15166. * @param name Define the name of the uniform as defined in the shader
  15167. * @param value Define the value to give to the uniform
  15168. * @return the texture itself allowing "fluent" like uniform updates
  15169. */
  15170. setFloat(name: string, value: number): ProceduralTexture;
  15171. /**
  15172. * Set a int in the shader.
  15173. * @param name Define the name of the uniform as defined in the shader
  15174. * @param value Define the value to give to the uniform
  15175. * @return the texture itself allowing "fluent" like uniform updates
  15176. */
  15177. setInt(name: string, value: number): ProceduralTexture;
  15178. /**
  15179. * Set an array of floats in the shader.
  15180. * @param name Define the name of the uniform as defined in the shader
  15181. * @param value Define the value to give to the uniform
  15182. * @return the texture itself allowing "fluent" like uniform updates
  15183. */
  15184. setFloats(name: string, value: number[]): ProceduralTexture;
  15185. /**
  15186. * Set a vec3 in the shader from a Color3.
  15187. * @param name Define the name of the uniform as defined in the shader
  15188. * @param value Define the value to give to the uniform
  15189. * @return the texture itself allowing "fluent" like uniform updates
  15190. */
  15191. setColor3(name: string, value: Color3): ProceduralTexture;
  15192. /**
  15193. * Set a vec4 in the shader from a Color4.
  15194. * @param name Define the name of the uniform as defined in the shader
  15195. * @param value Define the value to give to the uniform
  15196. * @return the texture itself allowing "fluent" like uniform updates
  15197. */
  15198. setColor4(name: string, value: Color4): ProceduralTexture;
  15199. /**
  15200. * Set a vec2 in the shader from a Vector2.
  15201. * @param name Define the name of the uniform as defined in the shader
  15202. * @param value Define the value to give to the uniform
  15203. * @return the texture itself allowing "fluent" like uniform updates
  15204. */
  15205. setVector2(name: string, value: Vector2): ProceduralTexture;
  15206. /**
  15207. * Set a vec3 in the shader from a Vector3.
  15208. * @param name Define the name of the uniform as defined in the shader
  15209. * @param value Define the value to give to the uniform
  15210. * @return the texture itself allowing "fluent" like uniform updates
  15211. */
  15212. setVector3(name: string, value: Vector3): ProceduralTexture;
  15213. /**
  15214. * Set a mat4 in the shader from a MAtrix.
  15215. * @param name Define the name of the uniform as defined in the shader
  15216. * @param value Define the value to give to the uniform
  15217. * @return the texture itself allowing "fluent" like uniform updates
  15218. */
  15219. setMatrix(name: string, value: Matrix): ProceduralTexture;
  15220. /**
  15221. * Render the texture to its associated render target.
  15222. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  15223. */
  15224. render(useCameraPostProcess?: boolean): void;
  15225. /**
  15226. * Clone the texture.
  15227. * @returns the cloned texture
  15228. */
  15229. clone(): ProceduralTexture;
  15230. /**
  15231. * Dispose the texture and release its associated resources.
  15232. */
  15233. dispose(): void;
  15234. }
  15235. }
  15236. declare module BABYLON {
  15237. /**
  15238. * This represents the base class for particle system in Babylon.
  15239. * 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.
  15240. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15241. * @example https://doc.babylonjs.com/babylon101/particles
  15242. */
  15243. export class BaseParticleSystem {
  15244. /**
  15245. * Source color is added to the destination color without alpha affecting the result
  15246. */
  15247. static BLENDMODE_ONEONE: number;
  15248. /**
  15249. * Blend current color and particle color using particle’s alpha
  15250. */
  15251. static BLENDMODE_STANDARD: number;
  15252. /**
  15253. * Add current color and particle color multiplied by particle’s alpha
  15254. */
  15255. static BLENDMODE_ADD: number;
  15256. /**
  15257. * Multiply current color with particle color
  15258. */
  15259. static BLENDMODE_MULTIPLY: number;
  15260. /**
  15261. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  15262. */
  15263. static BLENDMODE_MULTIPLYADD: number;
  15264. /**
  15265. * List of animations used by the particle system.
  15266. */
  15267. animations: Animation[];
  15268. /**
  15269. * Gets or sets the unique id of the particle system
  15270. */
  15271. uniqueId: number;
  15272. /**
  15273. * The id of the Particle system.
  15274. */
  15275. id: string;
  15276. /**
  15277. * The friendly name of the Particle system.
  15278. */
  15279. name: string;
  15280. /**
  15281. * Snippet ID if the particle system was created from the snippet server
  15282. */
  15283. snippetId: string;
  15284. /**
  15285. * The rendering group used by the Particle system to chose when to render.
  15286. */
  15287. renderingGroupId: number;
  15288. /**
  15289. * The emitter represents the Mesh or position we are attaching the particle system to.
  15290. */
  15291. emitter: Nullable<AbstractMesh | Vector3>;
  15292. /**
  15293. * The maximum number of particles to emit per frame
  15294. */
  15295. emitRate: number;
  15296. /**
  15297. * If you want to launch only a few particles at once, that can be done, as well.
  15298. */
  15299. manualEmitCount: number;
  15300. /**
  15301. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15302. */
  15303. updateSpeed: number;
  15304. /**
  15305. * The amount of time the particle system is running (depends of the overall update speed).
  15306. */
  15307. targetStopDuration: number;
  15308. /**
  15309. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  15310. */
  15311. disposeOnStop: boolean;
  15312. /**
  15313. * Minimum power of emitting particles.
  15314. */
  15315. minEmitPower: number;
  15316. /**
  15317. * Maximum power of emitting particles.
  15318. */
  15319. maxEmitPower: number;
  15320. /**
  15321. * Minimum life time of emitting particles.
  15322. */
  15323. minLifeTime: number;
  15324. /**
  15325. * Maximum life time of emitting particles.
  15326. */
  15327. maxLifeTime: number;
  15328. /**
  15329. * Minimum Size of emitting particles.
  15330. */
  15331. minSize: number;
  15332. /**
  15333. * Maximum Size of emitting particles.
  15334. */
  15335. maxSize: number;
  15336. /**
  15337. * Minimum scale of emitting particles on X axis.
  15338. */
  15339. minScaleX: number;
  15340. /**
  15341. * Maximum scale of emitting particles on X axis.
  15342. */
  15343. maxScaleX: number;
  15344. /**
  15345. * Minimum scale of emitting particles on Y axis.
  15346. */
  15347. minScaleY: number;
  15348. /**
  15349. * Maximum scale of emitting particles on Y axis.
  15350. */
  15351. maxScaleY: number;
  15352. /**
  15353. * Gets or sets the minimal initial rotation in radians.
  15354. */
  15355. minInitialRotation: number;
  15356. /**
  15357. * Gets or sets the maximal initial rotation in radians.
  15358. */
  15359. maxInitialRotation: number;
  15360. /**
  15361. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15362. */
  15363. minAngularSpeed: number;
  15364. /**
  15365. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15366. */
  15367. maxAngularSpeed: number;
  15368. /**
  15369. * The texture used to render each particle. (this can be a spritesheet)
  15370. */
  15371. particleTexture: Nullable<BaseTexture>;
  15372. /**
  15373. * The layer mask we are rendering the particles through.
  15374. */
  15375. layerMask: number;
  15376. /**
  15377. * This can help using your own shader to render the particle system.
  15378. * The according effect will be created
  15379. */
  15380. customShader: any;
  15381. /**
  15382. * By default particle system starts as soon as they are created. This prevents the
  15383. * automatic start to happen and let you decide when to start emitting particles.
  15384. */
  15385. preventAutoStart: boolean;
  15386. protected _rootUrl: string;
  15387. private _noiseTexture;
  15388. /**
  15389. * Gets or sets a texture used to add random noise to particle positions
  15390. */
  15391. get noiseTexture(): Nullable<ProceduralTexture>;
  15392. set noiseTexture(value: Nullable<ProceduralTexture>);
  15393. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15394. noiseStrength: Vector3;
  15395. /**
  15396. * Callback triggered when the particle animation is ending.
  15397. */
  15398. onAnimationEnd: Nullable<() => void>;
  15399. /**
  15400. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  15401. */
  15402. blendMode: number;
  15403. /**
  15404. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  15405. * to override the particles.
  15406. */
  15407. forceDepthWrite: boolean;
  15408. /** 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 */
  15409. preWarmCycles: number;
  15410. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  15411. preWarmStepOffset: number;
  15412. /**
  15413. * 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)
  15414. */
  15415. spriteCellChangeSpeed: number;
  15416. /**
  15417. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15418. */
  15419. startSpriteCellID: number;
  15420. /**
  15421. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15422. */
  15423. endSpriteCellID: number;
  15424. /**
  15425. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15426. */
  15427. spriteCellWidth: number;
  15428. /**
  15429. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15430. */
  15431. spriteCellHeight: number;
  15432. /**
  15433. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15434. */
  15435. spriteRandomStartCell: boolean;
  15436. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15437. translationPivot: Vector2;
  15438. /** @hidden */
  15439. protected _isAnimationSheetEnabled: boolean;
  15440. /**
  15441. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15442. */
  15443. beginAnimationOnStart: boolean;
  15444. /**
  15445. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15446. */
  15447. beginAnimationFrom: number;
  15448. /**
  15449. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15450. */
  15451. beginAnimationTo: number;
  15452. /**
  15453. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15454. */
  15455. beginAnimationLoop: boolean;
  15456. /**
  15457. * Gets or sets a world offset applied to all particles
  15458. */
  15459. worldOffset: Vector3;
  15460. /**
  15461. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  15462. */
  15463. get isAnimationSheetEnabled(): boolean;
  15464. set isAnimationSheetEnabled(value: boolean);
  15465. /**
  15466. * Get hosting scene
  15467. * @returns the scene
  15468. */
  15469. getScene(): Nullable<Scene>;
  15470. /**
  15471. * You can use gravity if you want to give an orientation to your particles.
  15472. */
  15473. gravity: Vector3;
  15474. protected _colorGradients: Nullable<Array<ColorGradient>>;
  15475. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  15476. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  15477. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  15478. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  15479. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  15480. protected _dragGradients: Nullable<Array<FactorGradient>>;
  15481. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  15482. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  15483. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  15484. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  15485. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  15486. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  15487. /**
  15488. * Defines the delay in milliseconds before starting the system (0 by default)
  15489. */
  15490. startDelay: number;
  15491. /**
  15492. * Gets the current list of drag gradients.
  15493. * You must use addDragGradient and removeDragGradient to update this list
  15494. * @returns the list of drag gradients
  15495. */
  15496. getDragGradients(): Nullable<Array<FactorGradient>>;
  15497. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15498. limitVelocityDamping: number;
  15499. /**
  15500. * Gets the current list of limit velocity gradients.
  15501. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to update this list
  15502. * @returns the list of limit velocity gradients
  15503. */
  15504. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  15505. /**
  15506. * Gets the current list of color gradients.
  15507. * You must use addColorGradient and removeColorGradient to update this list
  15508. * @returns the list of color gradients
  15509. */
  15510. getColorGradients(): Nullable<Array<ColorGradient>>;
  15511. /**
  15512. * Gets the current list of size gradients.
  15513. * You must use addSizeGradient and removeSizeGradient to update this list
  15514. * @returns the list of size gradients
  15515. */
  15516. getSizeGradients(): Nullable<Array<FactorGradient>>;
  15517. /**
  15518. * Gets the current list of color remap gradients.
  15519. * You must use addColorRemapGradient and removeColorRemapGradient to update this list
  15520. * @returns the list of color remap gradients
  15521. */
  15522. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  15523. /**
  15524. * Gets the current list of alpha remap gradients.
  15525. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to update this list
  15526. * @returns the list of alpha remap gradients
  15527. */
  15528. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15529. /**
  15530. * Gets the current list of life time gradients.
  15531. * You must use addLifeTimeGradient and removeLifeTimeGradient to update this list
  15532. * @returns the list of life time gradients
  15533. */
  15534. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  15535. /**
  15536. * Gets the current list of angular speed gradients.
  15537. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to update this list
  15538. * @returns the list of angular speed gradients
  15539. */
  15540. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  15541. /**
  15542. * Gets the current list of velocity gradients.
  15543. * You must use addVelocityGradient and removeVelocityGradient to update this list
  15544. * @returns the list of velocity gradients
  15545. */
  15546. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15547. /**
  15548. * Gets the current list of start size gradients.
  15549. * You must use addStartSizeGradient and removeStartSizeGradient to update this list
  15550. * @returns the list of start size gradients
  15551. */
  15552. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15553. /**
  15554. * Gets the current list of emit rate gradients.
  15555. * You must use addEmitRateGradient and removeEmitRateGradient to update this list
  15556. * @returns the list of emit rate gradients
  15557. */
  15558. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15559. /**
  15560. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15561. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15562. */
  15563. get direction1(): Vector3;
  15564. set direction1(value: Vector3);
  15565. /**
  15566. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15567. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15568. */
  15569. get direction2(): Vector3;
  15570. set direction2(value: Vector3);
  15571. /**
  15572. * 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.
  15573. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15574. */
  15575. get minEmitBox(): Vector3;
  15576. set minEmitBox(value: Vector3);
  15577. /**
  15578. * 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.
  15579. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15580. */
  15581. get maxEmitBox(): Vector3;
  15582. set maxEmitBox(value: Vector3);
  15583. /**
  15584. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15585. */
  15586. color1: Color4;
  15587. /**
  15588. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15589. */
  15590. color2: Color4;
  15591. /**
  15592. * Color the particle will have at the end of its lifetime
  15593. */
  15594. colorDead: Color4;
  15595. /**
  15596. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15597. */
  15598. textureMask: Color4;
  15599. /**
  15600. * The particle emitter type defines the emitter used by the particle system.
  15601. * It can be for example box, sphere, or cone...
  15602. */
  15603. particleEmitterType: IParticleEmitterType;
  15604. /** @hidden */
  15605. _isSubEmitter: boolean;
  15606. /**
  15607. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15608. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15609. */
  15610. billboardMode: number;
  15611. protected _isBillboardBased: boolean;
  15612. /**
  15613. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15614. */
  15615. get isBillboardBased(): boolean;
  15616. set isBillboardBased(value: boolean);
  15617. /**
  15618. * The scene the particle system belongs to.
  15619. */
  15620. protected _scene: Nullable<Scene>;
  15621. /**
  15622. * The engine the particle system belongs to.
  15623. */
  15624. protected _engine: ThinEngine;
  15625. /**
  15626. * Local cache of defines for image processing.
  15627. */
  15628. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15629. /**
  15630. * Default configuration related to image processing available in the standard Material.
  15631. */
  15632. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  15633. /**
  15634. * Gets the image processing configuration used either in this material.
  15635. */
  15636. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  15637. /**
  15638. * Sets the Default image processing configuration used either in the this material.
  15639. *
  15640. * If sets to null, the scene one is in use.
  15641. */
  15642. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  15643. /**
  15644. * Attaches a new image processing configuration to the Standard Material.
  15645. * @param configuration
  15646. */
  15647. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15648. /** @hidden */
  15649. protected _reset(): void;
  15650. /** @hidden */
  15651. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15652. /**
  15653. * Instantiates a particle system.
  15654. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  15655. * @param name The name of the particle system
  15656. */
  15657. constructor(name: string);
  15658. /**
  15659. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15660. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15661. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15662. * @returns the emitter
  15663. */
  15664. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15665. /**
  15666. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15667. * @param radius The radius of the hemisphere to emit from
  15668. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15669. * @returns the emitter
  15670. */
  15671. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15672. /**
  15673. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15674. * @param radius The radius of the sphere to emit from
  15675. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15676. * @returns the emitter
  15677. */
  15678. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15679. /**
  15680. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15681. * @param radius The radius of the sphere to emit from
  15682. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15683. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15684. * @returns the emitter
  15685. */
  15686. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15687. /**
  15688. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15689. * @param radius The radius of the emission cylinder
  15690. * @param height The height of the emission cylinder
  15691. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15692. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15693. * @returns the emitter
  15694. */
  15695. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15696. /**
  15697. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15698. * @param radius The radius of the cylinder to emit from
  15699. * @param height The height of the emission cylinder
  15700. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15701. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15702. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15703. * @returns the emitter
  15704. */
  15705. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15706. /**
  15707. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15708. * @param radius The radius of the cone to emit from
  15709. * @param angle The base angle of the cone
  15710. * @returns the emitter
  15711. */
  15712. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15713. /**
  15714. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15715. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15716. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15717. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15718. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15719. * @returns the emitter
  15720. */
  15721. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15722. }
  15723. }
  15724. declare module BABYLON {
  15725. /**
  15726. * Type of sub emitter
  15727. */
  15728. export enum SubEmitterType {
  15729. /**
  15730. * Attached to the particle over it's lifetime
  15731. */
  15732. ATTACHED = 0,
  15733. /**
  15734. * Created when the particle dies
  15735. */
  15736. END = 1
  15737. }
  15738. /**
  15739. * Sub emitter class used to emit particles from an existing particle
  15740. */
  15741. export class SubEmitter {
  15742. /**
  15743. * the particle system to be used by the sub emitter
  15744. */
  15745. particleSystem: ParticleSystem;
  15746. /**
  15747. * Type of the submitter (Default: END)
  15748. */
  15749. type: SubEmitterType;
  15750. /**
  15751. * 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)
  15752. * Note: This only is supported when using an emitter of type Mesh
  15753. */
  15754. inheritDirection: boolean;
  15755. /**
  15756. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15757. */
  15758. inheritedVelocityAmount: number;
  15759. /**
  15760. * Creates a sub emitter
  15761. * @param particleSystem the particle system to be used by the sub emitter
  15762. */
  15763. constructor(
  15764. /**
  15765. * the particle system to be used by the sub emitter
  15766. */
  15767. particleSystem: ParticleSystem);
  15768. /**
  15769. * Clones the sub emitter
  15770. * @returns the cloned sub emitter
  15771. */
  15772. clone(): SubEmitter;
  15773. /**
  15774. * Serialize current object to a JSON object
  15775. * @returns the serialized object
  15776. */
  15777. serialize(): any;
  15778. /** @hidden */
  15779. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  15780. /**
  15781. * Creates a new SubEmitter from a serialized JSON version
  15782. * @param serializationObject defines the JSON object to read from
  15783. * @param sceneOrEngine defines the hosting scene or the hosting engine
  15784. * @param rootUrl defines the rootUrl for data loading
  15785. * @returns a new SubEmitter
  15786. */
  15787. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  15788. /** Release associated resources */
  15789. dispose(): void;
  15790. }
  15791. }
  15792. declare module BABYLON {
  15793. /** @hidden */
  15794. export var clipPlaneFragmentDeclaration: {
  15795. name: string;
  15796. shader: string;
  15797. };
  15798. }
  15799. declare module BABYLON {
  15800. /** @hidden */
  15801. export var imageProcessingDeclaration: {
  15802. name: string;
  15803. shader: string;
  15804. };
  15805. }
  15806. declare module BABYLON {
  15807. /** @hidden */
  15808. export var imageProcessingFunctions: {
  15809. name: string;
  15810. shader: string;
  15811. };
  15812. }
  15813. declare module BABYLON {
  15814. /** @hidden */
  15815. export var clipPlaneFragment: {
  15816. name: string;
  15817. shader: string;
  15818. };
  15819. }
  15820. declare module BABYLON {
  15821. /** @hidden */
  15822. export var particlesPixelShader: {
  15823. name: string;
  15824. shader: string;
  15825. };
  15826. }
  15827. declare module BABYLON {
  15828. /** @hidden */
  15829. export var clipPlaneVertexDeclaration: {
  15830. name: string;
  15831. shader: string;
  15832. };
  15833. }
  15834. declare module BABYLON {
  15835. /** @hidden */
  15836. export var clipPlaneVertex: {
  15837. name: string;
  15838. shader: string;
  15839. };
  15840. }
  15841. declare module BABYLON {
  15842. /** @hidden */
  15843. export var particlesVertexShader: {
  15844. name: string;
  15845. shader: string;
  15846. };
  15847. }
  15848. declare module BABYLON {
  15849. /**
  15850. * Interface used to define entities containing multiple clip planes
  15851. */
  15852. export interface IClipPlanesHolder {
  15853. /**
  15854. * Gets or sets the active clipplane 1
  15855. */
  15856. clipPlane: Nullable<Plane>;
  15857. /**
  15858. * Gets or sets the active clipplane 2
  15859. */
  15860. clipPlane2: Nullable<Plane>;
  15861. /**
  15862. * Gets or sets the active clipplane 3
  15863. */
  15864. clipPlane3: Nullable<Plane>;
  15865. /**
  15866. * Gets or sets the active clipplane 4
  15867. */
  15868. clipPlane4: Nullable<Plane>;
  15869. /**
  15870. * Gets or sets the active clipplane 5
  15871. */
  15872. clipPlane5: Nullable<Plane>;
  15873. /**
  15874. * Gets or sets the active clipplane 6
  15875. */
  15876. clipPlane6: Nullable<Plane>;
  15877. }
  15878. }
  15879. declare module BABYLON {
  15880. /**
  15881. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  15882. *
  15883. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  15884. *
  15885. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  15886. */
  15887. export class ThinMaterialHelper {
  15888. /**
  15889. * Binds the clip plane information from the holder to the effect.
  15890. * @param effect The effect we are binding the data to
  15891. * @param holder The entity containing the clip plane information
  15892. */
  15893. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  15894. }
  15895. }
  15896. declare module BABYLON {
  15897. interface ThinEngine {
  15898. /**
  15899. * Sets alpha constants used by some alpha blending modes
  15900. * @param r defines the red component
  15901. * @param g defines the green component
  15902. * @param b defines the blue component
  15903. * @param a defines the alpha component
  15904. */
  15905. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  15906. /**
  15907. * Sets the current alpha mode
  15908. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  15909. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  15910. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15911. */
  15912. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  15913. /**
  15914. * Gets the current alpha mode
  15915. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15916. * @returns the current alpha mode
  15917. */
  15918. getAlphaMode(): number;
  15919. /**
  15920. * Sets the current alpha equation
  15921. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  15922. */
  15923. setAlphaEquation(equation: number): void;
  15924. /**
  15925. * Gets the current alpha equation.
  15926. * @returns the current alpha equation
  15927. */
  15928. getAlphaEquation(): number;
  15929. }
  15930. }
  15931. declare module BABYLON {
  15932. /**
  15933. * This represents a particle system in Babylon.
  15934. * 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.
  15935. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15936. * @example https://doc.babylonjs.com/babylon101/particles
  15937. */
  15938. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15939. /**
  15940. * Billboard mode will only apply to Y axis
  15941. */
  15942. static readonly BILLBOARDMODE_Y: number;
  15943. /**
  15944. * Billboard mode will apply to all axes
  15945. */
  15946. static readonly BILLBOARDMODE_ALL: number;
  15947. /**
  15948. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15949. */
  15950. static readonly BILLBOARDMODE_STRETCHED: number;
  15951. /**
  15952. * This function can be defined to provide custom update for active particles.
  15953. * This function will be called instead of regular update (age, position, color, etc.).
  15954. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15955. */
  15956. updateFunction: (particles: Particle[]) => void;
  15957. private _emitterWorldMatrix;
  15958. /**
  15959. * This function can be defined to specify initial direction for every new particle.
  15960. * It by default use the emitterType defined function
  15961. */
  15962. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15963. /**
  15964. * This function can be defined to specify initial position for every new particle.
  15965. * It by default use the emitterType defined function
  15966. */
  15967. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15968. /**
  15969. * @hidden
  15970. */
  15971. _inheritedVelocityOffset: Vector3;
  15972. /**
  15973. * An event triggered when the system is disposed
  15974. */
  15975. onDisposeObservable: Observable<IParticleSystem>;
  15976. /**
  15977. * An event triggered when the system is stopped
  15978. */
  15979. onStoppedObservable: Observable<IParticleSystem>;
  15980. private _onDisposeObserver;
  15981. /**
  15982. * Sets a callback that will be triggered when the system is disposed
  15983. */
  15984. set onDispose(callback: () => void);
  15985. private _particles;
  15986. private _epsilon;
  15987. private _capacity;
  15988. private _stockParticles;
  15989. private _newPartsExcess;
  15990. private _vertexData;
  15991. private _vertexBuffer;
  15992. private _vertexBuffers;
  15993. private _spriteBuffer;
  15994. private _indexBuffer;
  15995. private _effect;
  15996. private _customEffect;
  15997. private _cachedDefines;
  15998. private _scaledColorStep;
  15999. private _colorDiff;
  16000. private _scaledDirection;
  16001. private _scaledGravity;
  16002. private _currentRenderId;
  16003. private _alive;
  16004. private _useInstancing;
  16005. private _vertexArrayObject;
  16006. private _started;
  16007. private _stopped;
  16008. private _actualFrame;
  16009. private _scaledUpdateSpeed;
  16010. private _vertexBufferSize;
  16011. /** @hidden */
  16012. _currentEmitRateGradient: Nullable<FactorGradient>;
  16013. /** @hidden */
  16014. _currentEmitRate1: number;
  16015. /** @hidden */
  16016. _currentEmitRate2: number;
  16017. /** @hidden */
  16018. _currentStartSizeGradient: Nullable<FactorGradient>;
  16019. /** @hidden */
  16020. _currentStartSize1: number;
  16021. /** @hidden */
  16022. _currentStartSize2: number;
  16023. private readonly _rawTextureWidth;
  16024. private _rampGradientsTexture;
  16025. private _useRampGradients;
  16026. /** Gets or sets a matrix to use to compute projection */
  16027. defaultProjectionMatrix: Matrix;
  16028. /** Gets or sets a matrix to use to compute view */
  16029. defaultViewMatrix: Matrix;
  16030. /** Gets or sets a boolean indicating that ramp gradients must be used
  16031. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16032. */
  16033. get useRampGradients(): boolean;
  16034. set useRampGradients(value: boolean);
  16035. /**
  16036. * 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.
  16037. * 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: [])
  16038. */
  16039. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  16040. private _subEmitters;
  16041. /**
  16042. * @hidden
  16043. * If the particle systems emitter should be disposed when the particle system is disposed
  16044. */
  16045. _disposeEmitterOnDispose: boolean;
  16046. /**
  16047. * The current active Sub-systems, this property is used by the root particle system only.
  16048. */
  16049. activeSubSystems: Array<ParticleSystem>;
  16050. /**
  16051. * Specifies if the particles are updated in emitter local space or world space
  16052. */
  16053. isLocal: boolean;
  16054. private _rootParticleSystem;
  16055. /**
  16056. * Gets the current list of active particles
  16057. */
  16058. get particles(): Particle[];
  16059. /**
  16060. * Gets the number of particles active at the same time.
  16061. * @returns The number of active particles.
  16062. */
  16063. getActiveCount(): number;
  16064. /**
  16065. * Returns the string "ParticleSystem"
  16066. * @returns a string containing the class name
  16067. */
  16068. getClassName(): string;
  16069. /**
  16070. * Gets a boolean indicating that the system is stopping
  16071. * @returns true if the system is currently stopping
  16072. */
  16073. isStopping(): boolean;
  16074. /**
  16075. * Gets the custom effect used to render the particles
  16076. * @param blendMode Blend mode for which the effect should be retrieved
  16077. * @returns The effect
  16078. */
  16079. getCustomEffect(blendMode?: number): Nullable<Effect>;
  16080. /**
  16081. * Sets the custom effect used to render the particles
  16082. * @param effect The effect to set
  16083. * @param blendMode Blend mode for which the effect should be set
  16084. */
  16085. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  16086. /** @hidden */
  16087. private _onBeforeDrawParticlesObservable;
  16088. /**
  16089. * Observable that will be called just before the particles are drawn
  16090. */
  16091. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  16092. /**
  16093. * Gets the name of the particle vertex shader
  16094. */
  16095. get vertexShaderName(): string;
  16096. /**
  16097. * Instantiates a particle system.
  16098. * 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.
  16099. * @param name The name of the particle system
  16100. * @param capacity The max number of particles alive at the same time
  16101. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  16102. * @param customEffect a custom effect used to change the way particles are rendered by default
  16103. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  16104. * @param epsilon Offset used to render the particles
  16105. */
  16106. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  16107. private _addFactorGradient;
  16108. private _removeFactorGradient;
  16109. /**
  16110. * Adds a new life time gradient
  16111. * @param gradient defines the gradient to use (between 0 and 1)
  16112. * @param factor defines the life time factor to affect to the specified gradient
  16113. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16114. * @returns the current particle system
  16115. */
  16116. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16117. /**
  16118. * Remove a specific life time gradient
  16119. * @param gradient defines the gradient to remove
  16120. * @returns the current particle system
  16121. */
  16122. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16123. /**
  16124. * Adds a new size gradient
  16125. * @param gradient defines the gradient to use (between 0 and 1)
  16126. * @param factor defines the size factor to affect to the specified gradient
  16127. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16128. * @returns the current particle system
  16129. */
  16130. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16131. /**
  16132. * Remove a specific size gradient
  16133. * @param gradient defines the gradient to remove
  16134. * @returns the current particle system
  16135. */
  16136. removeSizeGradient(gradient: number): IParticleSystem;
  16137. /**
  16138. * Adds a new color remap gradient
  16139. * @param gradient defines the gradient to use (between 0 and 1)
  16140. * @param min defines the color remap minimal range
  16141. * @param max defines the color remap maximal range
  16142. * @returns the current particle system
  16143. */
  16144. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16145. /**
  16146. * Remove a specific color remap gradient
  16147. * @param gradient defines the gradient to remove
  16148. * @returns the current particle system
  16149. */
  16150. removeColorRemapGradient(gradient: number): IParticleSystem;
  16151. /**
  16152. * Adds a new alpha remap gradient
  16153. * @param gradient defines the gradient to use (between 0 and 1)
  16154. * @param min defines the alpha remap minimal range
  16155. * @param max defines the alpha remap maximal range
  16156. * @returns the current particle system
  16157. */
  16158. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16159. /**
  16160. * Remove a specific alpha remap gradient
  16161. * @param gradient defines the gradient to remove
  16162. * @returns the current particle system
  16163. */
  16164. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  16165. /**
  16166. * Adds a new angular speed gradient
  16167. * @param gradient defines the gradient to use (between 0 and 1)
  16168. * @param factor defines the angular speed to affect to the specified gradient
  16169. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16170. * @returns the current particle system
  16171. */
  16172. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16173. /**
  16174. * Remove a specific angular speed gradient
  16175. * @param gradient defines the gradient to remove
  16176. * @returns the current particle system
  16177. */
  16178. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16179. /**
  16180. * Adds a new velocity gradient
  16181. * @param gradient defines the gradient to use (between 0 and 1)
  16182. * @param factor defines the velocity to affect to the specified gradient
  16183. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16184. * @returns the current particle system
  16185. */
  16186. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16187. /**
  16188. * Remove a specific velocity gradient
  16189. * @param gradient defines the gradient to remove
  16190. * @returns the current particle system
  16191. */
  16192. removeVelocityGradient(gradient: number): IParticleSystem;
  16193. /**
  16194. * Adds a new limit velocity gradient
  16195. * @param gradient defines the gradient to use (between 0 and 1)
  16196. * @param factor defines the limit velocity value to affect to the specified gradient
  16197. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16198. * @returns the current particle system
  16199. */
  16200. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16201. /**
  16202. * Remove a specific limit velocity gradient
  16203. * @param gradient defines the gradient to remove
  16204. * @returns the current particle system
  16205. */
  16206. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16207. /**
  16208. * Adds a new drag gradient
  16209. * @param gradient defines the gradient to use (between 0 and 1)
  16210. * @param factor defines the drag value to affect to the specified gradient
  16211. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16212. * @returns the current particle system
  16213. */
  16214. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16215. /**
  16216. * Remove a specific drag gradient
  16217. * @param gradient defines the gradient to remove
  16218. * @returns the current particle system
  16219. */
  16220. removeDragGradient(gradient: number): IParticleSystem;
  16221. /**
  16222. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16223. * @param gradient defines the gradient to use (between 0 and 1)
  16224. * @param factor defines the emit rate value to affect to the specified gradient
  16225. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16226. * @returns the current particle system
  16227. */
  16228. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16229. /**
  16230. * Remove a specific emit rate gradient
  16231. * @param gradient defines the gradient to remove
  16232. * @returns the current particle system
  16233. */
  16234. removeEmitRateGradient(gradient: number): IParticleSystem;
  16235. /**
  16236. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16237. * @param gradient defines the gradient to use (between 0 and 1)
  16238. * @param factor defines the start size value to affect to the specified gradient
  16239. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16240. * @returns the current particle system
  16241. */
  16242. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16243. /**
  16244. * Remove a specific start size gradient
  16245. * @param gradient defines the gradient to remove
  16246. * @returns the current particle system
  16247. */
  16248. removeStartSizeGradient(gradient: number): IParticleSystem;
  16249. private _createRampGradientTexture;
  16250. /**
  16251. * Gets the current list of ramp gradients.
  16252. * You must use addRampGradient and removeRampGradient to update this list
  16253. * @returns the list of ramp gradients
  16254. */
  16255. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16256. /** Force the system to rebuild all gradients that need to be resync */
  16257. forceRefreshGradients(): void;
  16258. private _syncRampGradientTexture;
  16259. /**
  16260. * Adds a new ramp gradient used to remap particle colors
  16261. * @param gradient defines the gradient to use (between 0 and 1)
  16262. * @param color defines the color to affect to the specified gradient
  16263. * @returns the current particle system
  16264. */
  16265. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  16266. /**
  16267. * Remove a specific ramp gradient
  16268. * @param gradient defines the gradient to remove
  16269. * @returns the current particle system
  16270. */
  16271. removeRampGradient(gradient: number): ParticleSystem;
  16272. /**
  16273. * Adds a new color gradient
  16274. * @param gradient defines the gradient to use (between 0 and 1)
  16275. * @param color1 defines the color to affect to the specified gradient
  16276. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16277. * @returns this particle system
  16278. */
  16279. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16280. /**
  16281. * Remove a specific color gradient
  16282. * @param gradient defines the gradient to remove
  16283. * @returns this particle system
  16284. */
  16285. removeColorGradient(gradient: number): IParticleSystem;
  16286. private _fetchR;
  16287. protected _reset(): void;
  16288. private _resetEffect;
  16289. private _createVertexBuffers;
  16290. private _createIndexBuffer;
  16291. /**
  16292. * Gets the maximum number of particles active at the same time.
  16293. * @returns The max number of active particles.
  16294. */
  16295. getCapacity(): number;
  16296. /**
  16297. * Gets whether there are still active particles in the system.
  16298. * @returns True if it is alive, otherwise false.
  16299. */
  16300. isAlive(): boolean;
  16301. /**
  16302. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16303. * @returns True if it has been started, otherwise false.
  16304. */
  16305. isStarted(): boolean;
  16306. private _prepareSubEmitterInternalArray;
  16307. /**
  16308. * Starts the particle system and begins to emit
  16309. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  16310. */
  16311. start(delay?: number): void;
  16312. /**
  16313. * Stops the particle system.
  16314. * @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.
  16315. */
  16316. stop(stopSubEmitters?: boolean): void;
  16317. /**
  16318. * Remove all active particles
  16319. */
  16320. reset(): void;
  16321. /**
  16322. * @hidden (for internal use only)
  16323. */
  16324. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  16325. /**
  16326. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  16327. * Its lifetime will start back at 0.
  16328. */
  16329. recycleParticle: (particle: Particle) => void;
  16330. private _stopSubEmitters;
  16331. private _createParticle;
  16332. private _removeFromRoot;
  16333. private _emitFromParticle;
  16334. private _update;
  16335. /** @hidden */
  16336. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  16337. /** @hidden */
  16338. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  16339. /**
  16340. * Fill the defines array according to the current settings of the particle system
  16341. * @param defines Array to be updated
  16342. * @param blendMode blend mode to take into account when updating the array
  16343. */
  16344. fillDefines(defines: Array<string>, blendMode: number): void;
  16345. /**
  16346. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  16347. * @param uniforms Uniforms array to fill
  16348. * @param attributes Attributes array to fill
  16349. * @param samplers Samplers array to fill
  16350. */
  16351. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  16352. /** @hidden */
  16353. private _getEffect;
  16354. /**
  16355. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  16356. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  16357. */
  16358. animate(preWarmOnly?: boolean): void;
  16359. private _appendParticleVertices;
  16360. /**
  16361. * Rebuilds the particle system.
  16362. */
  16363. rebuild(): void;
  16364. /**
  16365. * Is this system ready to be used/rendered
  16366. * @return true if the system is ready
  16367. */
  16368. isReady(): boolean;
  16369. private _render;
  16370. /**
  16371. * Renders the particle system in its current state.
  16372. * @returns the current number of particles
  16373. */
  16374. render(): number;
  16375. /**
  16376. * Disposes the particle system and free the associated resources
  16377. * @param disposeTexture defines if the particle texture must be disposed as well (true by default)
  16378. */
  16379. dispose(disposeTexture?: boolean): void;
  16380. /**
  16381. * Clones the particle system.
  16382. * @param name The name of the cloned object
  16383. * @param newEmitter The new emitter to use
  16384. * @returns the cloned particle system
  16385. */
  16386. clone(name: string, newEmitter: any): ParticleSystem;
  16387. /**
  16388. * Serializes the particle system to a JSON object
  16389. * @param serializeTexture defines if the texture must be serialized as well
  16390. * @returns the JSON object
  16391. */
  16392. serialize(serializeTexture?: boolean): any;
  16393. /** @hidden */
  16394. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  16395. /** @hidden */
  16396. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  16397. /**
  16398. * Parses a JSON object to create a particle system.
  16399. * @param parsedParticleSystem The JSON object to parse
  16400. * @param sceneOrEngine The scene or the engine to create the particle system in
  16401. * @param rootUrl The root url to use to load external dependencies like texture
  16402. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  16403. * @returns the Parsed particle system
  16404. */
  16405. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  16406. }
  16407. }
  16408. declare module BABYLON {
  16409. /**
  16410. * A particle represents one of the element emitted by a particle system.
  16411. * This is mainly define by its coordinates, direction, velocity and age.
  16412. */
  16413. export class Particle {
  16414. /**
  16415. * The particle system the particle belongs to.
  16416. */
  16417. particleSystem: ParticleSystem;
  16418. private static _Count;
  16419. /**
  16420. * Unique ID of the particle
  16421. */
  16422. id: number;
  16423. /**
  16424. * The world position of the particle in the scene.
  16425. */
  16426. position: Vector3;
  16427. /**
  16428. * The world direction of the particle in the scene.
  16429. */
  16430. direction: Vector3;
  16431. /**
  16432. * The color of the particle.
  16433. */
  16434. color: Color4;
  16435. /**
  16436. * The color change of the particle per step.
  16437. */
  16438. colorStep: Color4;
  16439. /**
  16440. * Defines how long will the life of the particle be.
  16441. */
  16442. lifeTime: number;
  16443. /**
  16444. * The current age of the particle.
  16445. */
  16446. age: number;
  16447. /**
  16448. * The current size of the particle.
  16449. */
  16450. size: number;
  16451. /**
  16452. * The current scale of the particle.
  16453. */
  16454. scale: Vector2;
  16455. /**
  16456. * The current angle of the particle.
  16457. */
  16458. angle: number;
  16459. /**
  16460. * Defines how fast is the angle changing.
  16461. */
  16462. angularSpeed: number;
  16463. /**
  16464. * Defines the cell index used by the particle to be rendered from a sprite.
  16465. */
  16466. cellIndex: number;
  16467. /**
  16468. * The information required to support color remapping
  16469. */
  16470. remapData: Vector4;
  16471. /** @hidden */
  16472. _randomCellOffset?: number;
  16473. /** @hidden */
  16474. _initialDirection: Nullable<Vector3>;
  16475. /** @hidden */
  16476. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  16477. /** @hidden */
  16478. _initialStartSpriteCellID: number;
  16479. /** @hidden */
  16480. _initialEndSpriteCellID: number;
  16481. /** @hidden */
  16482. _currentColorGradient: Nullable<ColorGradient>;
  16483. /** @hidden */
  16484. _currentColor1: Color4;
  16485. /** @hidden */
  16486. _currentColor2: Color4;
  16487. /** @hidden */
  16488. _currentSizeGradient: Nullable<FactorGradient>;
  16489. /** @hidden */
  16490. _currentSize1: number;
  16491. /** @hidden */
  16492. _currentSize2: number;
  16493. /** @hidden */
  16494. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  16495. /** @hidden */
  16496. _currentAngularSpeed1: number;
  16497. /** @hidden */
  16498. _currentAngularSpeed2: number;
  16499. /** @hidden */
  16500. _currentVelocityGradient: Nullable<FactorGradient>;
  16501. /** @hidden */
  16502. _currentVelocity1: number;
  16503. /** @hidden */
  16504. _currentVelocity2: number;
  16505. /** @hidden */
  16506. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  16507. /** @hidden */
  16508. _currentLimitVelocity1: number;
  16509. /** @hidden */
  16510. _currentLimitVelocity2: number;
  16511. /** @hidden */
  16512. _currentDragGradient: Nullable<FactorGradient>;
  16513. /** @hidden */
  16514. _currentDrag1: number;
  16515. /** @hidden */
  16516. _currentDrag2: number;
  16517. /** @hidden */
  16518. _randomNoiseCoordinates1: Vector3;
  16519. /** @hidden */
  16520. _randomNoiseCoordinates2: Vector3;
  16521. /** @hidden */
  16522. _localPosition?: Vector3;
  16523. /**
  16524. * Creates a new instance Particle
  16525. * @param particleSystem the particle system the particle belongs to
  16526. */
  16527. constructor(
  16528. /**
  16529. * The particle system the particle belongs to.
  16530. */
  16531. particleSystem: ParticleSystem);
  16532. private updateCellInfoFromSystem;
  16533. /**
  16534. * Defines how the sprite cell index is updated for the particle
  16535. */
  16536. updateCellIndex(): void;
  16537. /** @hidden */
  16538. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  16539. /** @hidden */
  16540. _inheritParticleInfoToSubEmitters(): void;
  16541. /** @hidden */
  16542. _reset(): void;
  16543. /**
  16544. * Copy the properties of particle to another one.
  16545. * @param other the particle to copy the information to.
  16546. */
  16547. copyTo(other: Particle): void;
  16548. }
  16549. }
  16550. declare module BABYLON {
  16551. /**
  16552. * Particle emitter represents a volume emitting particles.
  16553. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  16554. */
  16555. export interface IParticleEmitterType {
  16556. /**
  16557. * Called by the particle System when the direction is computed for the created particle.
  16558. * @param worldMatrix is the world matrix of the particle system
  16559. * @param directionToUpdate is the direction vector to update with the result
  16560. * @param particle is the particle we are computed the direction for
  16561. * @param isLocal defines if the direction should be set in local space
  16562. */
  16563. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16564. /**
  16565. * Called by the particle System when the position is computed for the created particle.
  16566. * @param worldMatrix is the world matrix of the particle system
  16567. * @param positionToUpdate is the position vector to update with the result
  16568. * @param particle is the particle we are computed the position for
  16569. * @param isLocal defines if the position should be set in local space
  16570. */
  16571. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16572. /**
  16573. * Clones the current emitter and returns a copy of it
  16574. * @returns the new emitter
  16575. */
  16576. clone(): IParticleEmitterType;
  16577. /**
  16578. * Called by the GPUParticleSystem to setup the update shader
  16579. * @param effect defines the update shader
  16580. */
  16581. applyToShader(effect: Effect): void;
  16582. /**
  16583. * Returns a string to use to update the GPU particles update shader
  16584. * @returns the effect defines string
  16585. */
  16586. getEffectDefines(): string;
  16587. /**
  16588. * Returns a string representing the class name
  16589. * @returns a string containing the class name
  16590. */
  16591. getClassName(): string;
  16592. /**
  16593. * Serializes the particle system to a JSON object.
  16594. * @returns the JSON object
  16595. */
  16596. serialize(): any;
  16597. /**
  16598. * Parse properties from a JSON object
  16599. * @param serializationObject defines the JSON object
  16600. * @param scene defines the hosting scene
  16601. */
  16602. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16603. }
  16604. }
  16605. declare module BABYLON {
  16606. /**
  16607. * Particle emitter emitting particles from the inside of a box.
  16608. * It emits the particles randomly between 2 given directions.
  16609. */
  16610. export class BoxParticleEmitter implements IParticleEmitterType {
  16611. /**
  16612. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16613. */
  16614. direction1: Vector3;
  16615. /**
  16616. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16617. */
  16618. direction2: Vector3;
  16619. /**
  16620. * 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.
  16621. */
  16622. minEmitBox: Vector3;
  16623. /**
  16624. * 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.
  16625. */
  16626. maxEmitBox: Vector3;
  16627. /**
  16628. * Creates a new instance BoxParticleEmitter
  16629. */
  16630. constructor();
  16631. /**
  16632. * Called by the particle System when the direction is computed for the created particle.
  16633. * @param worldMatrix is the world matrix of the particle system
  16634. * @param directionToUpdate is the direction vector to update with the result
  16635. * @param particle is the particle we are computed the direction for
  16636. * @param isLocal defines if the direction should be set in local space
  16637. */
  16638. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16639. /**
  16640. * Called by the particle System when the position is computed for the created particle.
  16641. * @param worldMatrix is the world matrix of the particle system
  16642. * @param positionToUpdate is the position vector to update with the result
  16643. * @param particle is the particle we are computed the position for
  16644. * @param isLocal defines if the position should be set in local space
  16645. */
  16646. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16647. /**
  16648. * Clones the current emitter and returns a copy of it
  16649. * @returns the new emitter
  16650. */
  16651. clone(): BoxParticleEmitter;
  16652. /**
  16653. * Called by the GPUParticleSystem to setup the update shader
  16654. * @param effect defines the update shader
  16655. */
  16656. applyToShader(effect: Effect): void;
  16657. /**
  16658. * Returns a string to use to update the GPU particles update shader
  16659. * @returns a string containing the defines string
  16660. */
  16661. getEffectDefines(): string;
  16662. /**
  16663. * Returns the string "BoxParticleEmitter"
  16664. * @returns a string containing the class name
  16665. */
  16666. getClassName(): string;
  16667. /**
  16668. * Serializes the particle system to a JSON object.
  16669. * @returns the JSON object
  16670. */
  16671. serialize(): any;
  16672. /**
  16673. * Parse properties from a JSON object
  16674. * @param serializationObject defines the JSON object
  16675. */
  16676. parse(serializationObject: any): void;
  16677. }
  16678. }
  16679. declare module BABYLON {
  16680. /**
  16681. * Particle emitter emitting particles from the inside of a cone.
  16682. * It emits the particles alongside the cone volume from the base to the particle.
  16683. * The emission direction might be randomized.
  16684. */
  16685. export class ConeParticleEmitter implements IParticleEmitterType {
  16686. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16687. directionRandomizer: number;
  16688. private _radius;
  16689. private _angle;
  16690. private _height;
  16691. /**
  16692. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16693. */
  16694. radiusRange: number;
  16695. /**
  16696. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16697. */
  16698. heightRange: number;
  16699. /**
  16700. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16701. */
  16702. emitFromSpawnPointOnly: boolean;
  16703. /**
  16704. * Gets or sets the radius of the emission cone
  16705. */
  16706. get radius(): number;
  16707. set radius(value: number);
  16708. /**
  16709. * Gets or sets the angle of the emission cone
  16710. */
  16711. get angle(): number;
  16712. set angle(value: number);
  16713. private _buildHeight;
  16714. /**
  16715. * Creates a new instance ConeParticleEmitter
  16716. * @param radius the radius of the emission cone (1 by default)
  16717. * @param angle the cone base angle (PI by default)
  16718. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16719. */
  16720. constructor(radius?: number, angle?: number,
  16721. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16722. directionRandomizer?: number);
  16723. /**
  16724. * Called by the particle System when the direction is computed for the created particle.
  16725. * @param worldMatrix is the world matrix of the particle system
  16726. * @param directionToUpdate is the direction vector to update with the result
  16727. * @param particle is the particle we are computed the direction for
  16728. * @param isLocal defines if the direction should be set in local space
  16729. */
  16730. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16731. /**
  16732. * Called by the particle System when the position is computed for the created particle.
  16733. * @param worldMatrix is the world matrix of the particle system
  16734. * @param positionToUpdate is the position vector to update with the result
  16735. * @param particle is the particle we are computed the position for
  16736. * @param isLocal defines if the position should be set in local space
  16737. */
  16738. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16739. /**
  16740. * Clones the current emitter and returns a copy of it
  16741. * @returns the new emitter
  16742. */
  16743. clone(): ConeParticleEmitter;
  16744. /**
  16745. * Called by the GPUParticleSystem to setup the update shader
  16746. * @param effect defines the update shader
  16747. */
  16748. applyToShader(effect: Effect): void;
  16749. /**
  16750. * Returns a string to use to update the GPU particles update shader
  16751. * @returns a string containing the defines string
  16752. */
  16753. getEffectDefines(): string;
  16754. /**
  16755. * Returns the string "ConeParticleEmitter"
  16756. * @returns a string containing the class name
  16757. */
  16758. getClassName(): string;
  16759. /**
  16760. * Serializes the particle system to a JSON object.
  16761. * @returns the JSON object
  16762. */
  16763. serialize(): any;
  16764. /**
  16765. * Parse properties from a JSON object
  16766. * @param serializationObject defines the JSON object
  16767. */
  16768. parse(serializationObject: any): void;
  16769. }
  16770. }
  16771. declare module BABYLON {
  16772. /**
  16773. * Particle emitter emitting particles from the inside of a cylinder.
  16774. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16775. */
  16776. export class CylinderParticleEmitter implements IParticleEmitterType {
  16777. /**
  16778. * The radius of the emission cylinder.
  16779. */
  16780. radius: number;
  16781. /**
  16782. * The height of the emission cylinder.
  16783. */
  16784. height: number;
  16785. /**
  16786. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16787. */
  16788. radiusRange: number;
  16789. /**
  16790. * How much to randomize the particle direction [0-1].
  16791. */
  16792. directionRandomizer: number;
  16793. /**
  16794. * Creates a new instance CylinderParticleEmitter
  16795. * @param radius the radius of the emission cylinder (1 by default)
  16796. * @param height the height of the emission cylinder (1 by default)
  16797. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16798. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16799. */
  16800. constructor(
  16801. /**
  16802. * The radius of the emission cylinder.
  16803. */
  16804. radius?: number,
  16805. /**
  16806. * The height of the emission cylinder.
  16807. */
  16808. height?: number,
  16809. /**
  16810. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16811. */
  16812. radiusRange?: number,
  16813. /**
  16814. * How much to randomize the particle direction [0-1].
  16815. */
  16816. directionRandomizer?: number);
  16817. /**
  16818. * Called by the particle System when the direction is computed for the created particle.
  16819. * @param worldMatrix is the world matrix of the particle system
  16820. * @param directionToUpdate is the direction vector to update with the result
  16821. * @param particle is the particle we are computed the direction for
  16822. * @param isLocal defines if the direction should be set in local space
  16823. */
  16824. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16825. /**
  16826. * Called by the particle System when the position is computed for the created particle.
  16827. * @param worldMatrix is the world matrix of the particle system
  16828. * @param positionToUpdate is the position vector to update with the result
  16829. * @param particle is the particle we are computed the position for
  16830. * @param isLocal defines if the position should be set in local space
  16831. */
  16832. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16833. /**
  16834. * Clones the current emitter and returns a copy of it
  16835. * @returns the new emitter
  16836. */
  16837. clone(): CylinderParticleEmitter;
  16838. /**
  16839. * Called by the GPUParticleSystem to setup the update shader
  16840. * @param effect defines the update shader
  16841. */
  16842. applyToShader(effect: Effect): void;
  16843. /**
  16844. * Returns a string to use to update the GPU particles update shader
  16845. * @returns a string containing the defines string
  16846. */
  16847. getEffectDefines(): string;
  16848. /**
  16849. * Returns the string "CylinderParticleEmitter"
  16850. * @returns a string containing the class name
  16851. */
  16852. getClassName(): string;
  16853. /**
  16854. * Serializes the particle system to a JSON object.
  16855. * @returns the JSON object
  16856. */
  16857. serialize(): any;
  16858. /**
  16859. * Parse properties from a JSON object
  16860. * @param serializationObject defines the JSON object
  16861. */
  16862. parse(serializationObject: any): void;
  16863. }
  16864. /**
  16865. * Particle emitter emitting particles from the inside of a cylinder.
  16866. * It emits the particles randomly between two vectors.
  16867. */
  16868. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16869. /**
  16870. * The min limit of the emission direction.
  16871. */
  16872. direction1: Vector3;
  16873. /**
  16874. * The max limit of the emission direction.
  16875. */
  16876. direction2: Vector3;
  16877. /**
  16878. * Creates a new instance CylinderDirectedParticleEmitter
  16879. * @param radius the radius of the emission cylinder (1 by default)
  16880. * @param height the height of the emission cylinder (1 by default)
  16881. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16882. * @param direction1 the min limit of the emission direction (up vector by default)
  16883. * @param direction2 the max limit of the emission direction (up vector by default)
  16884. */
  16885. constructor(radius?: number, height?: number, radiusRange?: number,
  16886. /**
  16887. * The min limit of the emission direction.
  16888. */
  16889. direction1?: Vector3,
  16890. /**
  16891. * The max limit of the emission direction.
  16892. */
  16893. direction2?: Vector3);
  16894. /**
  16895. * Called by the particle System when the direction is computed for the created particle.
  16896. * @param worldMatrix is the world matrix of the particle system
  16897. * @param directionToUpdate is the direction vector to update with the result
  16898. * @param particle is the particle we are computed the direction for
  16899. */
  16900. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16901. /**
  16902. * Clones the current emitter and returns a copy of it
  16903. * @returns the new emitter
  16904. */
  16905. clone(): CylinderDirectedParticleEmitter;
  16906. /**
  16907. * Called by the GPUParticleSystem to setup the update shader
  16908. * @param effect defines the update shader
  16909. */
  16910. applyToShader(effect: Effect): void;
  16911. /**
  16912. * Returns a string to use to update the GPU particles update shader
  16913. * @returns a string containing the defines string
  16914. */
  16915. getEffectDefines(): string;
  16916. /**
  16917. * Returns the string "CylinderDirectedParticleEmitter"
  16918. * @returns a string containing the class name
  16919. */
  16920. getClassName(): string;
  16921. /**
  16922. * Serializes the particle system to a JSON object.
  16923. * @returns the JSON object
  16924. */
  16925. serialize(): any;
  16926. /**
  16927. * Parse properties from a JSON object
  16928. * @param serializationObject defines the JSON object
  16929. */
  16930. parse(serializationObject: any): void;
  16931. }
  16932. }
  16933. declare module BABYLON {
  16934. /**
  16935. * Particle emitter emitting particles from the inside of a hemisphere.
  16936. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16937. */
  16938. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16939. /**
  16940. * The radius of the emission hemisphere.
  16941. */
  16942. radius: number;
  16943. /**
  16944. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16945. */
  16946. radiusRange: number;
  16947. /**
  16948. * How much to randomize the particle direction [0-1].
  16949. */
  16950. directionRandomizer: number;
  16951. /**
  16952. * Creates a new instance HemisphericParticleEmitter
  16953. * @param radius the radius of the emission hemisphere (1 by default)
  16954. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16955. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16956. */
  16957. constructor(
  16958. /**
  16959. * The radius of the emission hemisphere.
  16960. */
  16961. radius?: number,
  16962. /**
  16963. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16964. */
  16965. radiusRange?: number,
  16966. /**
  16967. * How much to randomize the particle direction [0-1].
  16968. */
  16969. directionRandomizer?: number);
  16970. /**
  16971. * Called by the particle System when the direction is computed for the created particle.
  16972. * @param worldMatrix is the world matrix of the particle system
  16973. * @param directionToUpdate is the direction vector to update with the result
  16974. * @param particle is the particle we are computed the direction for
  16975. * @param isLocal defines if the direction should be set in local space
  16976. */
  16977. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16978. /**
  16979. * Called by the particle System when the position is computed for the created particle.
  16980. * @param worldMatrix is the world matrix of the particle system
  16981. * @param positionToUpdate is the position vector to update with the result
  16982. * @param particle is the particle we are computed the position for
  16983. * @param isLocal defines if the position should be set in local space
  16984. */
  16985. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16986. /**
  16987. * Clones the current emitter and returns a copy of it
  16988. * @returns the new emitter
  16989. */
  16990. clone(): HemisphericParticleEmitter;
  16991. /**
  16992. * Called by the GPUParticleSystem to setup the update shader
  16993. * @param effect defines the update shader
  16994. */
  16995. applyToShader(effect: Effect): void;
  16996. /**
  16997. * Returns a string to use to update the GPU particles update shader
  16998. * @returns a string containing the defines string
  16999. */
  17000. getEffectDefines(): string;
  17001. /**
  17002. * Returns the string "HemisphericParticleEmitter"
  17003. * @returns a string containing the class name
  17004. */
  17005. getClassName(): string;
  17006. /**
  17007. * Serializes the particle system to a JSON object.
  17008. * @returns the JSON object
  17009. */
  17010. serialize(): any;
  17011. /**
  17012. * Parse properties from a JSON object
  17013. * @param serializationObject defines the JSON object
  17014. */
  17015. parse(serializationObject: any): void;
  17016. }
  17017. }
  17018. declare module BABYLON {
  17019. /**
  17020. * Particle emitter emitting particles from a point.
  17021. * It emits the particles randomly between 2 given directions.
  17022. */
  17023. export class PointParticleEmitter implements IParticleEmitterType {
  17024. /**
  17025. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17026. */
  17027. direction1: Vector3;
  17028. /**
  17029. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17030. */
  17031. direction2: Vector3;
  17032. /**
  17033. * Creates a new instance PointParticleEmitter
  17034. */
  17035. constructor();
  17036. /**
  17037. * Called by the particle System when the direction is computed for the created particle.
  17038. * @param worldMatrix is the world matrix of the particle system
  17039. * @param directionToUpdate is the direction vector to update with the result
  17040. * @param particle is the particle we are computed the direction for
  17041. * @param isLocal defines if the direction should be set in local space
  17042. */
  17043. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17044. /**
  17045. * Called by the particle System when the position is computed for the created particle.
  17046. * @param worldMatrix is the world matrix of the particle system
  17047. * @param positionToUpdate is the position vector to update with the result
  17048. * @param particle is the particle we are computed the position for
  17049. * @param isLocal defines if the position should be set in local space
  17050. */
  17051. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17052. /**
  17053. * Clones the current emitter and returns a copy of it
  17054. * @returns the new emitter
  17055. */
  17056. clone(): PointParticleEmitter;
  17057. /**
  17058. * Called by the GPUParticleSystem to setup the update shader
  17059. * @param effect defines the update shader
  17060. */
  17061. applyToShader(effect: Effect): void;
  17062. /**
  17063. * Returns a string to use to update the GPU particles update shader
  17064. * @returns a string containing the defines string
  17065. */
  17066. getEffectDefines(): string;
  17067. /**
  17068. * Returns the string "PointParticleEmitter"
  17069. * @returns a string containing the class name
  17070. */
  17071. getClassName(): string;
  17072. /**
  17073. * Serializes the particle system to a JSON object.
  17074. * @returns the JSON object
  17075. */
  17076. serialize(): any;
  17077. /**
  17078. * Parse properties from a JSON object
  17079. * @param serializationObject defines the JSON object
  17080. */
  17081. parse(serializationObject: any): void;
  17082. }
  17083. }
  17084. declare module BABYLON {
  17085. /**
  17086. * Particle emitter emitting particles from the inside of a sphere.
  17087. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  17088. */
  17089. export class SphereParticleEmitter implements IParticleEmitterType {
  17090. /**
  17091. * The radius of the emission sphere.
  17092. */
  17093. radius: number;
  17094. /**
  17095. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17096. */
  17097. radiusRange: number;
  17098. /**
  17099. * How much to randomize the particle direction [0-1].
  17100. */
  17101. directionRandomizer: number;
  17102. /**
  17103. * Creates a new instance SphereParticleEmitter
  17104. * @param radius the radius of the emission sphere (1 by default)
  17105. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17106. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17107. */
  17108. constructor(
  17109. /**
  17110. * The radius of the emission sphere.
  17111. */
  17112. radius?: number,
  17113. /**
  17114. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17115. */
  17116. radiusRange?: number,
  17117. /**
  17118. * How much to randomize the particle direction [0-1].
  17119. */
  17120. directionRandomizer?: number);
  17121. /**
  17122. * Called by the particle System when the direction is computed for the created particle.
  17123. * @param worldMatrix is the world matrix of the particle system
  17124. * @param directionToUpdate is the direction vector to update with the result
  17125. * @param particle is the particle we are computed the direction for
  17126. * @param isLocal defines if the direction should be set in local space
  17127. */
  17128. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17129. /**
  17130. * Called by the particle System when the position is computed for the created particle.
  17131. * @param worldMatrix is the world matrix of the particle system
  17132. * @param positionToUpdate is the position vector to update with the result
  17133. * @param particle is the particle we are computed the position for
  17134. * @param isLocal defines if the position should be set in local space
  17135. */
  17136. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17137. /**
  17138. * Clones the current emitter and returns a copy of it
  17139. * @returns the new emitter
  17140. */
  17141. clone(): SphereParticleEmitter;
  17142. /**
  17143. * Called by the GPUParticleSystem to setup the update shader
  17144. * @param effect defines the update shader
  17145. */
  17146. applyToShader(effect: Effect): void;
  17147. /**
  17148. * Returns a string to use to update the GPU particles update shader
  17149. * @returns a string containing the defines string
  17150. */
  17151. getEffectDefines(): string;
  17152. /**
  17153. * Returns the string "SphereParticleEmitter"
  17154. * @returns a string containing the class name
  17155. */
  17156. getClassName(): string;
  17157. /**
  17158. * Serializes the particle system to a JSON object.
  17159. * @returns the JSON object
  17160. */
  17161. serialize(): any;
  17162. /**
  17163. * Parse properties from a JSON object
  17164. * @param serializationObject defines the JSON object
  17165. */
  17166. parse(serializationObject: any): void;
  17167. }
  17168. /**
  17169. * Particle emitter emitting particles from the inside of a sphere.
  17170. * It emits the particles randomly between two vectors.
  17171. */
  17172. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  17173. /**
  17174. * The min limit of the emission direction.
  17175. */
  17176. direction1: Vector3;
  17177. /**
  17178. * The max limit of the emission direction.
  17179. */
  17180. direction2: Vector3;
  17181. /**
  17182. * Creates a new instance SphereDirectedParticleEmitter
  17183. * @param radius the radius of the emission sphere (1 by default)
  17184. * @param direction1 the min limit of the emission direction (up vector by default)
  17185. * @param direction2 the max limit of the emission direction (up vector by default)
  17186. */
  17187. constructor(radius?: number,
  17188. /**
  17189. * The min limit of the emission direction.
  17190. */
  17191. direction1?: Vector3,
  17192. /**
  17193. * The max limit of the emission direction.
  17194. */
  17195. direction2?: Vector3);
  17196. /**
  17197. * Called by the particle System when the direction is computed for the created particle.
  17198. * @param worldMatrix is the world matrix of the particle system
  17199. * @param directionToUpdate is the direction vector to update with the result
  17200. * @param particle is the particle we are computed the direction for
  17201. */
  17202. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17203. /**
  17204. * Clones the current emitter and returns a copy of it
  17205. * @returns the new emitter
  17206. */
  17207. clone(): SphereDirectedParticleEmitter;
  17208. /**
  17209. * Called by the GPUParticleSystem to setup the update shader
  17210. * @param effect defines the update shader
  17211. */
  17212. applyToShader(effect: Effect): void;
  17213. /**
  17214. * Returns a string to use to update the GPU particles update shader
  17215. * @returns a string containing the defines string
  17216. */
  17217. getEffectDefines(): string;
  17218. /**
  17219. * Returns the string "SphereDirectedParticleEmitter"
  17220. * @returns a string containing the class name
  17221. */
  17222. getClassName(): string;
  17223. /**
  17224. * Serializes the particle system to a JSON object.
  17225. * @returns the JSON object
  17226. */
  17227. serialize(): any;
  17228. /**
  17229. * Parse properties from a JSON object
  17230. * @param serializationObject defines the JSON object
  17231. */
  17232. parse(serializationObject: any): void;
  17233. }
  17234. }
  17235. declare module BABYLON {
  17236. /**
  17237. * Particle emitter emitting particles from a custom list of positions.
  17238. */
  17239. export class CustomParticleEmitter implements IParticleEmitterType {
  17240. /**
  17241. * Gets or sets the position generator that will create the initial position of each particle.
  17242. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  17243. */
  17244. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  17245. /**
  17246. * Gets or sets the destination generator that will create the final destination of each particle.
  17247. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  17248. */
  17249. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  17250. /**
  17251. * Creates a new instance CustomParticleEmitter
  17252. */
  17253. constructor();
  17254. /**
  17255. * Called by the particle System when the direction is computed for the created particle.
  17256. * @param worldMatrix is the world matrix of the particle system
  17257. * @param directionToUpdate is the direction vector to update with the result
  17258. * @param particle is the particle we are computed the direction for
  17259. * @param isLocal defines if the direction should be set in local space
  17260. */
  17261. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17262. /**
  17263. * Called by the particle System when the position is computed for the created particle.
  17264. * @param worldMatrix is the world matrix of the particle system
  17265. * @param positionToUpdate is the position vector to update with the result
  17266. * @param particle is the particle we are computed the position for
  17267. * @param isLocal defines if the position should be set in local space
  17268. */
  17269. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17270. /**
  17271. * Clones the current emitter and returns a copy of it
  17272. * @returns the new emitter
  17273. */
  17274. clone(): CustomParticleEmitter;
  17275. /**
  17276. * Called by the GPUParticleSystem to setup the update shader
  17277. * @param effect defines the update shader
  17278. */
  17279. applyToShader(effect: Effect): void;
  17280. /**
  17281. * Returns a string to use to update the GPU particles update shader
  17282. * @returns a string containing the defines string
  17283. */
  17284. getEffectDefines(): string;
  17285. /**
  17286. * Returns the string "PointParticleEmitter"
  17287. * @returns a string containing the class name
  17288. */
  17289. getClassName(): string;
  17290. /**
  17291. * Serializes the particle system to a JSON object.
  17292. * @returns the JSON object
  17293. */
  17294. serialize(): any;
  17295. /**
  17296. * Parse properties from a JSON object
  17297. * @param serializationObject defines the JSON object
  17298. */
  17299. parse(serializationObject: any): void;
  17300. }
  17301. }
  17302. declare module BABYLON {
  17303. /**
  17304. * Particle emitter emitting particles from the inside of a box.
  17305. * It emits the particles randomly between 2 given directions.
  17306. */
  17307. export class MeshParticleEmitter implements IParticleEmitterType {
  17308. private _indices;
  17309. private _positions;
  17310. private _normals;
  17311. private _storedNormal;
  17312. private _mesh;
  17313. /**
  17314. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17315. */
  17316. direction1: Vector3;
  17317. /**
  17318. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17319. */
  17320. direction2: Vector3;
  17321. /**
  17322. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  17323. */
  17324. useMeshNormalsForDirection: boolean;
  17325. /** Defines the mesh to use as source */
  17326. get mesh(): Nullable<AbstractMesh>;
  17327. set mesh(value: Nullable<AbstractMesh>);
  17328. /**
  17329. * Creates a new instance MeshParticleEmitter
  17330. * @param mesh defines the mesh to use as source
  17331. */
  17332. constructor(mesh?: Nullable<AbstractMesh>);
  17333. /**
  17334. * Called by the particle System when the direction is computed for the created particle.
  17335. * @param worldMatrix is the world matrix of the particle system
  17336. * @param directionToUpdate is the direction vector to update with the result
  17337. * @param particle is the particle we are computed the direction for
  17338. * @param isLocal defines if the direction should be set in local space
  17339. */
  17340. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17341. /**
  17342. * Called by the particle System when the position is computed for the created particle.
  17343. * @param worldMatrix is the world matrix of the particle system
  17344. * @param positionToUpdate is the position vector to update with the result
  17345. * @param particle is the particle we are computed the position for
  17346. * @param isLocal defines if the position should be set in local space
  17347. */
  17348. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17349. /**
  17350. * Clones the current emitter and returns a copy of it
  17351. * @returns the new emitter
  17352. */
  17353. clone(): MeshParticleEmitter;
  17354. /**
  17355. * Called by the GPUParticleSystem to setup the update shader
  17356. * @param effect defines the update shader
  17357. */
  17358. applyToShader(effect: Effect): void;
  17359. /**
  17360. * Returns a string to use to update the GPU particles update shader
  17361. * @returns a string containing the defines string
  17362. */
  17363. getEffectDefines(): string;
  17364. /**
  17365. * Returns the string "BoxParticleEmitter"
  17366. * @returns a string containing the class name
  17367. */
  17368. getClassName(): string;
  17369. /**
  17370. * Serializes the particle system to a JSON object.
  17371. * @returns the JSON object
  17372. */
  17373. serialize(): any;
  17374. /**
  17375. * Parse properties from a JSON object
  17376. * @param serializationObject defines the JSON object
  17377. * @param scene defines the hosting scene
  17378. */
  17379. parse(serializationObject: any, scene: Nullable<Scene>): void;
  17380. }
  17381. }
  17382. declare module BABYLON {
  17383. /**
  17384. * Interface representing a particle system in Babylon.js.
  17385. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17386. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17387. */
  17388. export interface IParticleSystem {
  17389. /**
  17390. * List of animations used by the particle system.
  17391. */
  17392. animations: Animation[];
  17393. /**
  17394. * The id of the Particle system.
  17395. */
  17396. id: string;
  17397. /**
  17398. * The name of the Particle system.
  17399. */
  17400. name: string;
  17401. /**
  17402. * The emitter represents the Mesh or position we are attaching the particle system to.
  17403. */
  17404. emitter: Nullable<AbstractMesh | Vector3>;
  17405. /**
  17406. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17407. */
  17408. isBillboardBased: boolean;
  17409. /**
  17410. * The rendering group used by the Particle system to chose when to render.
  17411. */
  17412. renderingGroupId: number;
  17413. /**
  17414. * The layer mask we are rendering the particles through.
  17415. */
  17416. layerMask: number;
  17417. /**
  17418. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17419. */
  17420. updateSpeed: number;
  17421. /**
  17422. * The amount of time the particle system is running (depends of the overall update speed).
  17423. */
  17424. targetStopDuration: number;
  17425. /**
  17426. * The texture used to render each particle. (this can be a spritesheet)
  17427. */
  17428. particleTexture: Nullable<BaseTexture>;
  17429. /**
  17430. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  17431. */
  17432. blendMode: number;
  17433. /**
  17434. * Minimum life time of emitting particles.
  17435. */
  17436. minLifeTime: number;
  17437. /**
  17438. * Maximum life time of emitting particles.
  17439. */
  17440. maxLifeTime: number;
  17441. /**
  17442. * Minimum Size of emitting particles.
  17443. */
  17444. minSize: number;
  17445. /**
  17446. * Maximum Size of emitting particles.
  17447. */
  17448. maxSize: number;
  17449. /**
  17450. * Minimum scale of emitting particles on X axis.
  17451. */
  17452. minScaleX: number;
  17453. /**
  17454. * Maximum scale of emitting particles on X axis.
  17455. */
  17456. maxScaleX: number;
  17457. /**
  17458. * Minimum scale of emitting particles on Y axis.
  17459. */
  17460. minScaleY: number;
  17461. /**
  17462. * Maximum scale of emitting particles on Y axis.
  17463. */
  17464. maxScaleY: number;
  17465. /**
  17466. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17467. */
  17468. color1: Color4;
  17469. /**
  17470. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17471. */
  17472. color2: Color4;
  17473. /**
  17474. * Color the particle will have at the end of its lifetime.
  17475. */
  17476. colorDead: Color4;
  17477. /**
  17478. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17479. */
  17480. emitRate: number;
  17481. /**
  17482. * You can use gravity if you want to give an orientation to your particles.
  17483. */
  17484. gravity: Vector3;
  17485. /**
  17486. * Minimum power of emitting particles.
  17487. */
  17488. minEmitPower: number;
  17489. /**
  17490. * Maximum power of emitting particles.
  17491. */
  17492. maxEmitPower: number;
  17493. /**
  17494. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17495. */
  17496. minAngularSpeed: number;
  17497. /**
  17498. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17499. */
  17500. maxAngularSpeed: number;
  17501. /**
  17502. * Gets or sets the minimal initial rotation in radians.
  17503. */
  17504. minInitialRotation: number;
  17505. /**
  17506. * Gets or sets the maximal initial rotation in radians.
  17507. */
  17508. maxInitialRotation: number;
  17509. /**
  17510. * The particle emitter type defines the emitter used by the particle system.
  17511. * It can be for example box, sphere, or cone...
  17512. */
  17513. particleEmitterType: Nullable<IParticleEmitterType>;
  17514. /**
  17515. * Defines the delay in milliseconds before starting the system (0 by default)
  17516. */
  17517. startDelay: number;
  17518. /**
  17519. * 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
  17520. */
  17521. preWarmCycles: number;
  17522. /**
  17523. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  17524. */
  17525. preWarmStepOffset: number;
  17526. /**
  17527. * 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)
  17528. */
  17529. spriteCellChangeSpeed: number;
  17530. /**
  17531. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17532. */
  17533. startSpriteCellID: number;
  17534. /**
  17535. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17536. */
  17537. endSpriteCellID: number;
  17538. /**
  17539. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17540. */
  17541. spriteCellWidth: number;
  17542. /**
  17543. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17544. */
  17545. spriteCellHeight: number;
  17546. /**
  17547. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17548. */
  17549. spriteRandomStartCell: boolean;
  17550. /**
  17551. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  17552. */
  17553. isAnimationSheetEnabled: boolean;
  17554. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17555. translationPivot: Vector2;
  17556. /**
  17557. * Gets or sets a texture used to add random noise to particle positions
  17558. */
  17559. noiseTexture: Nullable<BaseTexture>;
  17560. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17561. noiseStrength: Vector3;
  17562. /**
  17563. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17564. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17565. */
  17566. billboardMode: number;
  17567. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17568. limitVelocityDamping: number;
  17569. /**
  17570. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17571. */
  17572. beginAnimationOnStart: boolean;
  17573. /**
  17574. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17575. */
  17576. beginAnimationFrom: number;
  17577. /**
  17578. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17579. */
  17580. beginAnimationTo: number;
  17581. /**
  17582. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17583. */
  17584. beginAnimationLoop: boolean;
  17585. /**
  17586. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17587. */
  17588. disposeOnStop: boolean;
  17589. /**
  17590. * If you want to launch only a few particles at once, that can be done, as well.
  17591. */
  17592. manualEmitCount: number;
  17593. /**
  17594. * Specifies if the particles are updated in emitter local space or world space
  17595. */
  17596. isLocal: boolean;
  17597. /** Snippet ID if the particle system was created from the snippet server */
  17598. snippetId: string;
  17599. /** Gets or sets a matrix to use to compute projection */
  17600. defaultProjectionMatrix: Matrix;
  17601. /**
  17602. * Gets the maximum number of particles active at the same time.
  17603. * @returns The max number of active particles.
  17604. */
  17605. getCapacity(): number;
  17606. /**
  17607. * Gets the number of particles active at the same time.
  17608. * @returns The number of active particles.
  17609. */
  17610. getActiveCount(): number;
  17611. /**
  17612. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17613. * @returns True if it has been started, otherwise false.
  17614. */
  17615. isStarted(): boolean;
  17616. /**
  17617. * Animates the particle system for this frame.
  17618. */
  17619. animate(): void;
  17620. /**
  17621. * Renders the particle system in its current state.
  17622. * @returns the current number of particles
  17623. */
  17624. render(): number;
  17625. /**
  17626. * Dispose the particle system and frees its associated resources.
  17627. * @param disposeTexture defines if the particle texture must be disposed as well (true by default)
  17628. */
  17629. dispose(disposeTexture?: boolean): void;
  17630. /**
  17631. * An event triggered when the system is disposed
  17632. */
  17633. onDisposeObservable: Observable<IParticleSystem>;
  17634. /**
  17635. * An event triggered when the system is stopped
  17636. */
  17637. onStoppedObservable: Observable<IParticleSystem>;
  17638. /**
  17639. * Clones the particle system.
  17640. * @param name The name of the cloned object
  17641. * @param newEmitter The new emitter to use
  17642. * @returns the cloned particle system
  17643. */
  17644. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  17645. /**
  17646. * Serializes the particle system to a JSON object
  17647. * @param serializeTexture defines if the texture must be serialized as well
  17648. * @returns the JSON object
  17649. */
  17650. serialize(serializeTexture: boolean): any;
  17651. /**
  17652. * Rebuild the particle system
  17653. */
  17654. rebuild(): void;
  17655. /** Force the system to rebuild all gradients that need to be resync */
  17656. forceRefreshGradients(): void;
  17657. /**
  17658. * Starts the particle system and begins to emit
  17659. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  17660. */
  17661. start(delay?: number): void;
  17662. /**
  17663. * Stops the particle system.
  17664. */
  17665. stop(): void;
  17666. /**
  17667. * Remove all active particles
  17668. */
  17669. reset(): void;
  17670. /**
  17671. * Gets a boolean indicating that the system is stopping
  17672. * @returns true if the system is currently stopping
  17673. */
  17674. isStopping(): boolean;
  17675. /**
  17676. * Is this system ready to be used/rendered
  17677. * @return true if the system is ready
  17678. */
  17679. isReady(): boolean;
  17680. /**
  17681. * Returns the string "ParticleSystem"
  17682. * @returns a string containing the class name
  17683. */
  17684. getClassName(): string;
  17685. /**
  17686. * Gets the custom effect used to render the particles
  17687. * @param blendMode Blend mode for which the effect should be retrieved
  17688. * @returns The effect
  17689. */
  17690. getCustomEffect(blendMode: number): Nullable<Effect>;
  17691. /**
  17692. * Sets the custom effect used to render the particles
  17693. * @param effect The effect to set
  17694. * @param blendMode Blend mode for which the effect should be set
  17695. */
  17696. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  17697. /**
  17698. * Fill the defines array according to the current settings of the particle system
  17699. * @param defines Array to be updated
  17700. * @param blendMode blend mode to take into account when updating the array
  17701. */
  17702. fillDefines(defines: Array<string>, blendMode: number): void;
  17703. /**
  17704. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  17705. * @param uniforms Uniforms array to fill
  17706. * @param attributes Attributes array to fill
  17707. * @param samplers Samplers array to fill
  17708. */
  17709. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  17710. /**
  17711. * Observable that will be called just before the particles are drawn
  17712. */
  17713. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  17714. /**
  17715. * Gets the name of the particle vertex shader
  17716. */
  17717. vertexShaderName: string;
  17718. /**
  17719. * Adds a new color gradient
  17720. * @param gradient defines the gradient to use (between 0 and 1)
  17721. * @param color1 defines the color to affect to the specified gradient
  17722. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17723. * @returns the current particle system
  17724. */
  17725. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17726. /**
  17727. * Remove a specific color gradient
  17728. * @param gradient defines the gradient to remove
  17729. * @returns the current particle system
  17730. */
  17731. removeColorGradient(gradient: number): IParticleSystem;
  17732. /**
  17733. * Adds a new size gradient
  17734. * @param gradient defines the gradient to use (between 0 and 1)
  17735. * @param factor defines the size factor to affect to the specified gradient
  17736. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17737. * @returns the current particle system
  17738. */
  17739. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17740. /**
  17741. * Remove a specific size gradient
  17742. * @param gradient defines the gradient to remove
  17743. * @returns the current particle system
  17744. */
  17745. removeSizeGradient(gradient: number): IParticleSystem;
  17746. /**
  17747. * Gets the current list of color gradients.
  17748. * You must use addColorGradient and removeColorGradient to update this list
  17749. * @returns the list of color gradients
  17750. */
  17751. getColorGradients(): Nullable<Array<ColorGradient>>;
  17752. /**
  17753. * Gets the current list of size gradients.
  17754. * You must use addSizeGradient and removeSizeGradient to update this list
  17755. * @returns the list of size gradients
  17756. */
  17757. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17758. /**
  17759. * Gets the current list of angular speed gradients.
  17760. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to update this list
  17761. * @returns the list of angular speed gradients
  17762. */
  17763. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17764. /**
  17765. * Adds a new angular speed gradient
  17766. * @param gradient defines the gradient to use (between 0 and 1)
  17767. * @param factor defines the angular speed to affect to the specified gradient
  17768. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17769. * @returns the current particle system
  17770. */
  17771. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17772. /**
  17773. * Remove a specific angular speed gradient
  17774. * @param gradient defines the gradient to remove
  17775. * @returns the current particle system
  17776. */
  17777. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17778. /**
  17779. * Gets the current list of velocity gradients.
  17780. * You must use addVelocityGradient and removeVelocityGradient to update this list
  17781. * @returns the list of velocity gradients
  17782. */
  17783. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17784. /**
  17785. * Adds a new velocity gradient
  17786. * @param gradient defines the gradient to use (between 0 and 1)
  17787. * @param factor defines the velocity to affect to the specified gradient
  17788. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17789. * @returns the current particle system
  17790. */
  17791. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17792. /**
  17793. * Remove a specific velocity gradient
  17794. * @param gradient defines the gradient to remove
  17795. * @returns the current particle system
  17796. */
  17797. removeVelocityGradient(gradient: number): IParticleSystem;
  17798. /**
  17799. * Gets the current list of limit velocity gradients.
  17800. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to update this list
  17801. * @returns the list of limit velocity gradients
  17802. */
  17803. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17804. /**
  17805. * Adds a new limit velocity gradient
  17806. * @param gradient defines the gradient to use (between 0 and 1)
  17807. * @param factor defines the limit velocity to affect to the specified gradient
  17808. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17809. * @returns the current particle system
  17810. */
  17811. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17812. /**
  17813. * Remove a specific limit velocity gradient
  17814. * @param gradient defines the gradient to remove
  17815. * @returns the current particle system
  17816. */
  17817. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17818. /**
  17819. * Adds a new drag gradient
  17820. * @param gradient defines the gradient to use (between 0 and 1)
  17821. * @param factor defines the drag to affect to the specified gradient
  17822. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17823. * @returns the current particle system
  17824. */
  17825. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17826. /**
  17827. * Remove a specific drag gradient
  17828. * @param gradient defines the gradient to remove
  17829. * @returns the current particle system
  17830. */
  17831. removeDragGradient(gradient: number): IParticleSystem;
  17832. /**
  17833. * Gets the current list of drag gradients.
  17834. * You must use addDragGradient and removeDragGradient to update this list
  17835. * @returns the list of drag gradients
  17836. */
  17837. getDragGradients(): Nullable<Array<FactorGradient>>;
  17838. /**
  17839. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17840. * @param gradient defines the gradient to use (between 0 and 1)
  17841. * @param factor defines the emit rate to affect to the specified gradient
  17842. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17843. * @returns the current particle system
  17844. */
  17845. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17846. /**
  17847. * Remove a specific emit rate gradient
  17848. * @param gradient defines the gradient to remove
  17849. * @returns the current particle system
  17850. */
  17851. removeEmitRateGradient(gradient: number): IParticleSystem;
  17852. /**
  17853. * Gets the current list of emit rate gradients.
  17854. * You must use addEmitRateGradient and removeEmitRateGradient to update this list
  17855. * @returns the list of emit rate gradients
  17856. */
  17857. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17858. /**
  17859. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17860. * @param gradient defines the gradient to use (between 0 and 1)
  17861. * @param factor defines the start size to affect to the specified gradient
  17862. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17863. * @returns the current particle system
  17864. */
  17865. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17866. /**
  17867. * Remove a specific start size gradient
  17868. * @param gradient defines the gradient to remove
  17869. * @returns the current particle system
  17870. */
  17871. removeStartSizeGradient(gradient: number): IParticleSystem;
  17872. /**
  17873. * Gets the current list of start size gradients.
  17874. * You must use addStartSizeGradient and removeStartSizeGradient to update this list
  17875. * @returns the list of start size gradients
  17876. */
  17877. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17878. /**
  17879. * Adds a new life time gradient
  17880. * @param gradient defines the gradient to use (between 0 and 1)
  17881. * @param factor defines the life time factor to affect to the specified gradient
  17882. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17883. * @returns the current particle system
  17884. */
  17885. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17886. /**
  17887. * Remove a specific life time gradient
  17888. * @param gradient defines the gradient to remove
  17889. * @returns the current particle system
  17890. */
  17891. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17892. /**
  17893. * Gets the current list of life time gradients.
  17894. * You must use addLifeTimeGradient and removeLifeTimeGradient to update this list
  17895. * @returns the list of life time gradients
  17896. */
  17897. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17898. /**
  17899. * Gets the current list of color gradients.
  17900. * You must use addColorGradient and removeColorGradient to update this list
  17901. * @returns the list of color gradients
  17902. */
  17903. getColorGradients(): Nullable<Array<ColorGradient>>;
  17904. /**
  17905. * Adds a new ramp gradient used to remap particle colors
  17906. * @param gradient defines the gradient to use (between 0 and 1)
  17907. * @param color defines the color to affect to the specified gradient
  17908. * @returns the current particle system
  17909. */
  17910. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  17911. /**
  17912. * Gets the current list of ramp gradients.
  17913. * You must use addRampGradient and removeRampGradient to update this list
  17914. * @returns the list of ramp gradients
  17915. */
  17916. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17917. /** Gets or sets a boolean indicating that ramp gradients must be used
  17918. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17919. */
  17920. useRampGradients: boolean;
  17921. /**
  17922. * Adds a new color remap gradient
  17923. * @param gradient defines the gradient to use (between 0 and 1)
  17924. * @param min defines the color remap minimal range
  17925. * @param max defines the color remap maximal range
  17926. * @returns the current particle system
  17927. */
  17928. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17929. /**
  17930. * Gets the current list of color remap gradients.
  17931. * You must use addColorRemapGradient and removeColorRemapGradient to update this list
  17932. * @returns the list of color remap gradients
  17933. */
  17934. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17935. /**
  17936. * Adds a new alpha remap gradient
  17937. * @param gradient defines the gradient to use (between 0 and 1)
  17938. * @param min defines the alpha remap minimal range
  17939. * @param max defines the alpha remap maximal range
  17940. * @returns the current particle system
  17941. */
  17942. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17943. /**
  17944. * Gets the current list of alpha remap gradients.
  17945. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to update this list
  17946. * @returns the list of alpha remap gradients
  17947. */
  17948. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17949. /**
  17950. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17951. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17952. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17953. * @returns the emitter
  17954. */
  17955. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17956. /**
  17957. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17958. * @param radius The radius of the hemisphere to emit from
  17959. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17960. * @returns the emitter
  17961. */
  17962. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17963. /**
  17964. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17965. * @param radius The radius of the sphere to emit from
  17966. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17967. * @returns the emitter
  17968. */
  17969. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17970. /**
  17971. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17972. * @param radius The radius of the sphere to emit from
  17973. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17974. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17975. * @returns the emitter
  17976. */
  17977. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17978. /**
  17979. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17980. * @param radius The radius of the emission cylinder
  17981. * @param height The height of the emission cylinder
  17982. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17983. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17984. * @returns the emitter
  17985. */
  17986. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17987. /**
  17988. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17989. * @param radius The radius of the cylinder to emit from
  17990. * @param height The height of the emission cylinder
  17991. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17992. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17993. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17994. * @returns the emitter
  17995. */
  17996. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17997. /**
  17998. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17999. * @param radius The radius of the cone to emit from
  18000. * @param angle The base angle of the cone
  18001. * @returns the emitter
  18002. */
  18003. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18004. /**
  18005. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18006. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18007. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18008. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18009. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18010. * @returns the emitter
  18011. */
  18012. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18013. /**
  18014. * Get hosting scene
  18015. * @returns the scene
  18016. */
  18017. getScene(): Nullable<Scene>;
  18018. }
  18019. }
  18020. declare module BABYLON {
  18021. /**
  18022. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  18023. */
  18024. export class ColorSplitterBlock extends NodeMaterialBlock {
  18025. /**
  18026. * Create a new ColorSplitterBlock
  18027. * @param name defines the block name
  18028. */
  18029. constructor(name: string);
  18030. /**
  18031. * Gets the current class name
  18032. * @returns the class name
  18033. */
  18034. getClassName(): string;
  18035. /**
  18036. * Gets the rgba component (input)
  18037. */
  18038. get rgba(): NodeMaterialConnectionPoint;
  18039. /**
  18040. * Gets the rgb component (input)
  18041. */
  18042. get rgbIn(): NodeMaterialConnectionPoint;
  18043. /**
  18044. * Gets the rgb component (output)
  18045. */
  18046. get rgbOut(): NodeMaterialConnectionPoint;
  18047. /**
  18048. * Gets the r component (output)
  18049. */
  18050. get r(): NodeMaterialConnectionPoint;
  18051. /**
  18052. * Gets the g component (output)
  18053. */
  18054. get g(): NodeMaterialConnectionPoint;
  18055. /**
  18056. * Gets the b component (output)
  18057. */
  18058. get b(): NodeMaterialConnectionPoint;
  18059. /**
  18060. * Gets the a component (output)
  18061. */
  18062. get a(): NodeMaterialConnectionPoint;
  18063. protected _inputRename(name: string): string;
  18064. protected _outputRename(name: string): string;
  18065. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  18066. }
  18067. }
  18068. declare module BABYLON {
  18069. /**
  18070. * Operations supported by the Trigonometry block
  18071. */
  18072. export enum TrigonometryBlockOperations {
  18073. /** Cos */
  18074. Cos = 0,
  18075. /** Sin */
  18076. Sin = 1,
  18077. /** Abs */
  18078. Abs = 2,
  18079. /** Exp */
  18080. Exp = 3,
  18081. /** Exp2 */
  18082. Exp2 = 4,
  18083. /** Round */
  18084. Round = 5,
  18085. /** Floor */
  18086. Floor = 6,
  18087. /** Ceiling */
  18088. Ceiling = 7,
  18089. /** Square root */
  18090. Sqrt = 8,
  18091. /** Log */
  18092. Log = 9,
  18093. /** Tangent */
  18094. Tan = 10,
  18095. /** Arc tangent */
  18096. ArcTan = 11,
  18097. /** Arc cosinus */
  18098. ArcCos = 12,
  18099. /** Arc sinus */
  18100. ArcSin = 13,
  18101. /** Fraction */
  18102. Fract = 14,
  18103. /** Sign */
  18104. Sign = 15,
  18105. /** To radians (from degrees) */
  18106. Radians = 16,
  18107. /** To degrees (from radians) */
  18108. Degrees = 17
  18109. }
  18110. /**
  18111. * Block used to apply trigonometry operation to floats
  18112. */
  18113. export class TrigonometryBlock extends NodeMaterialBlock {
  18114. /**
  18115. * Gets or sets the operation applied by the block
  18116. */
  18117. operation: TrigonometryBlockOperations;
  18118. /**
  18119. * Creates a new TrigonometryBlock
  18120. * @param name defines the block name
  18121. */
  18122. constructor(name: string);
  18123. /**
  18124. * Gets the current class name
  18125. * @returns the class name
  18126. */
  18127. getClassName(): string;
  18128. /**
  18129. * Gets the input component
  18130. */
  18131. get input(): NodeMaterialConnectionPoint;
  18132. /**
  18133. * Gets the output component
  18134. */
  18135. get output(): NodeMaterialConnectionPoint;
  18136. protected _buildBlock(state: NodeMaterialBuildState): this;
  18137. serialize(): any;
  18138. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  18139. protected _dumpPropertiesCode(): string;
  18140. }
  18141. }
  18142. declare module BABYLON {
  18143. /**
  18144. * Interface used to configure the node material editor
  18145. */
  18146. export interface INodeMaterialEditorOptions {
  18147. /** Define the URl to load node editor script */
  18148. editorURL?: string;
  18149. }
  18150. /** @hidden */
  18151. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  18152. NORMAL: boolean;
  18153. TANGENT: boolean;
  18154. UV1: boolean;
  18155. /** BONES */
  18156. NUM_BONE_INFLUENCERS: number;
  18157. BonesPerMesh: number;
  18158. BONETEXTURE: boolean;
  18159. /** MORPH TARGETS */
  18160. MORPHTARGETS: boolean;
  18161. MORPHTARGETS_NORMAL: boolean;
  18162. MORPHTARGETS_TANGENT: boolean;
  18163. MORPHTARGETS_UV: boolean;
  18164. NUM_MORPH_INFLUENCERS: number;
  18165. MORPHTARGETS_TEXTURE: boolean;
  18166. /** IMAGE PROCESSING */
  18167. IMAGEPROCESSING: boolean;
  18168. VIGNETTE: boolean;
  18169. VIGNETTEBLENDMODEMULTIPLY: boolean;
  18170. VIGNETTEBLENDMODEOPAQUE: boolean;
  18171. TONEMAPPING: boolean;
  18172. TONEMAPPING_ACES: boolean;
  18173. CONTRAST: boolean;
  18174. EXPOSURE: boolean;
  18175. COLORCURVES: boolean;
  18176. COLORGRADING: boolean;
  18177. COLORGRADING3D: boolean;
  18178. SAMPLER3DGREENDEPTH: boolean;
  18179. SAMPLER3DBGRMAP: boolean;
  18180. IMAGEPROCESSINGPOSTPROCESS: boolean;
  18181. /** MISC. */
  18182. BUMPDIRECTUV: number;
  18183. constructor();
  18184. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  18185. }
  18186. /**
  18187. * Class used to configure NodeMaterial
  18188. */
  18189. export interface INodeMaterialOptions {
  18190. /**
  18191. * Defines if blocks should emit comments
  18192. */
  18193. emitComments: boolean;
  18194. }
  18195. /**
  18196. * Class used to create a node based material built by assembling shader blocks
  18197. */
  18198. export class NodeMaterial extends PushMaterial {
  18199. private static _BuildIdGenerator;
  18200. private _options;
  18201. private _vertexCompilationState;
  18202. private _fragmentCompilationState;
  18203. private _sharedData;
  18204. private _buildId;
  18205. private _buildWasSuccessful;
  18206. private _cachedWorldViewMatrix;
  18207. private _cachedWorldViewProjectionMatrix;
  18208. private _optimizers;
  18209. private _animationFrame;
  18210. /** Define the Url to load node editor script */
  18211. static EditorURL: string;
  18212. /** Define the Url to load snippets */
  18213. static SnippetUrl: string;
  18214. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  18215. static IgnoreTexturesAtLoadTime: boolean;
  18216. private BJSNODEMATERIALEDITOR;
  18217. /** Get the inspector from bundle or global */
  18218. private _getGlobalNodeMaterialEditor;
  18219. /**
  18220. * Snippet ID if the material was created from the snippet server
  18221. */
  18222. snippetId: string;
  18223. /**
  18224. * Gets or sets data used by visual editor
  18225. * @see https://nme.babylonjs.com
  18226. */
  18227. editorData: any;
  18228. /**
  18229. * 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)
  18230. */
  18231. ignoreAlpha: boolean;
  18232. /**
  18233. * Defines the maximum number of lights that can be used in the material
  18234. */
  18235. maxSimultaneousLights: number;
  18236. /**
  18237. * Observable raised when the material is built
  18238. */
  18239. onBuildObservable: Observable<NodeMaterial>;
  18240. /**
  18241. * Gets or sets the root nodes of the material vertex shader
  18242. */
  18243. _vertexOutputNodes: NodeMaterialBlock[];
  18244. /**
  18245. * Gets or sets the root nodes of the material fragment (pixel) shader
  18246. */
  18247. _fragmentOutputNodes: NodeMaterialBlock[];
  18248. /** Gets or sets options to control the node material overall behavior */
  18249. get options(): INodeMaterialOptions;
  18250. set options(options: INodeMaterialOptions);
  18251. /**
  18252. * Default configuration related to image processing available in the standard Material.
  18253. */
  18254. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18255. /**
  18256. * Gets the image processing configuration used either in this material.
  18257. */
  18258. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  18259. /**
  18260. * Sets the Default image processing configuration used either in the this material.
  18261. *
  18262. * If sets to null, the scene one is in use.
  18263. */
  18264. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  18265. /**
  18266. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  18267. */
  18268. attachedBlocks: NodeMaterialBlock[];
  18269. /**
  18270. * Specifies the mode of the node material
  18271. * @hidden
  18272. */
  18273. _mode: NodeMaterialModes;
  18274. /**
  18275. * Gets the mode property
  18276. */
  18277. get mode(): NodeMaterialModes;
  18278. /**
  18279. * A free comment about the material
  18280. */
  18281. comment: string;
  18282. /**
  18283. * Create a new node based material
  18284. * @param name defines the material name
  18285. * @param scene defines the hosting scene
  18286. * @param options defines creation option
  18287. */
  18288. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  18289. /**
  18290. * Gets the current class name of the material e.g. "NodeMaterial"
  18291. * @returns the class name
  18292. */
  18293. getClassName(): string;
  18294. /**
  18295. * Keep track of the image processing observer to allow dispose and replace.
  18296. */
  18297. private _imageProcessingObserver;
  18298. /**
  18299. * Attaches a new image processing configuration to the Standard Material.
  18300. * @param configuration
  18301. */
  18302. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  18303. /**
  18304. * Get a block by its name
  18305. * @param name defines the name of the block to retrieve
  18306. * @returns the required block or null if not found
  18307. */
  18308. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  18309. /**
  18310. * Get a block by its name
  18311. * @param predicate defines the predicate used to find the good candidate
  18312. * @returns the required block or null if not found
  18313. */
  18314. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  18315. /**
  18316. * Get an input block by its name
  18317. * @param predicate defines the predicate used to find the good candidate
  18318. * @returns the required input block or null if not found
  18319. */
  18320. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  18321. /**
  18322. * Gets the list of input blocks attached to this material
  18323. * @returns an array of InputBlocks
  18324. */
  18325. getInputBlocks(): InputBlock[];
  18326. /**
  18327. * Adds a new optimizer to the list of optimizers
  18328. * @param optimizer defines the optimizers to add
  18329. * @returns the current material
  18330. */
  18331. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  18332. /**
  18333. * Remove an optimizer from the list of optimizers
  18334. * @param optimizer defines the optimizers to remove
  18335. * @returns the current material
  18336. */
  18337. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  18338. /**
  18339. * Add a new block to the list of output nodes
  18340. * @param node defines the node to add
  18341. * @returns the current material
  18342. */
  18343. addOutputNode(node: NodeMaterialBlock): this;
  18344. /**
  18345. * Remove a block from the list of root nodes
  18346. * @param node defines the node to remove
  18347. * @returns the current material
  18348. */
  18349. removeOutputNode(node: NodeMaterialBlock): this;
  18350. private _addVertexOutputNode;
  18351. private _removeVertexOutputNode;
  18352. private _addFragmentOutputNode;
  18353. private _removeFragmentOutputNode;
  18354. /**
  18355. * Specifies if the material will require alpha blending
  18356. * @returns a boolean specifying if alpha blending is needed
  18357. */
  18358. needAlphaBlending(): boolean;
  18359. /**
  18360. * Specifies if this material should be rendered in alpha test mode
  18361. * @returns a boolean specifying if an alpha test is needed.
  18362. */
  18363. needAlphaTesting(): boolean;
  18364. private _initializeBlock;
  18365. private _resetDualBlocks;
  18366. /**
  18367. * Remove a block from the current node material
  18368. * @param block defines the block to remove
  18369. */
  18370. removeBlock(block: NodeMaterialBlock): void;
  18371. /**
  18372. * Build the material and generates the inner effect
  18373. * @param verbose defines if the build should log activity
  18374. */
  18375. build(verbose?: boolean): void;
  18376. /**
  18377. * Runs an otpimization phase to try to improve the shader code
  18378. */
  18379. optimize(): void;
  18380. private _prepareDefinesForAttributes;
  18381. /**
  18382. * Create a post process from the material
  18383. * @param camera The camera to apply the render pass to.
  18384. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18385. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18386. * @param engine The engine which the post process will be applied. (default: current engine)
  18387. * @param reusable If the post process can be reused on the same frame. (default: false)
  18388. * @param textureType Type of textures used when performing the post process. (default: 0)
  18389. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  18390. * @returns the post process created
  18391. */
  18392. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  18393. /**
  18394. * Create the post process effect from the material
  18395. * @param postProcess The post process to create the effect for
  18396. */
  18397. createEffectForPostProcess(postProcess: PostProcess): void;
  18398. private _createEffectForPostProcess;
  18399. /**
  18400. * Create a new procedural texture based on this node material
  18401. * @param size defines the size of the texture
  18402. * @param scene defines the hosting scene
  18403. * @returns the new procedural texture attached to this node material
  18404. */
  18405. createProceduralTexture(size: number | {
  18406. width: number;
  18407. height: number;
  18408. layers?: number;
  18409. }, scene: Scene): Nullable<ProceduralTexture>;
  18410. private _createEffectForParticles;
  18411. private _checkInternals;
  18412. /**
  18413. * Create the effect to be used as the custom effect for a particle system
  18414. * @param particleSystem Particle system to create the effect for
  18415. * @param onCompiled defines a function to call when the effect creation is successful
  18416. * @param onError defines a function to call when the effect creation has failed
  18417. */
  18418. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18419. private _processDefines;
  18420. /**
  18421. * Get if the submesh is ready to be used and all its information available.
  18422. * Child classes can use it to update shaders
  18423. * @param mesh defines the mesh to check
  18424. * @param subMesh defines which submesh to check
  18425. * @param useInstances specifies that instances should be used
  18426. * @returns a boolean indicating that the submesh is ready or not
  18427. */
  18428. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  18429. /**
  18430. * Get a string representing the shaders built by the current node graph
  18431. */
  18432. get compiledShaders(): string;
  18433. /**
  18434. * Binds the world matrix to the material
  18435. * @param world defines the world transformation matrix
  18436. */
  18437. bindOnlyWorldMatrix(world: Matrix): void;
  18438. /**
  18439. * Binds the submesh to this material by preparing the effect and shader to draw
  18440. * @param world defines the world transformation matrix
  18441. * @param mesh defines the mesh containing the submesh
  18442. * @param subMesh defines the submesh to bind the material to
  18443. */
  18444. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18445. /**
  18446. * Gets the active textures from the material
  18447. * @returns an array of textures
  18448. */
  18449. getActiveTextures(): BaseTexture[];
  18450. /**
  18451. * Gets the list of texture blocks
  18452. * @returns an array of texture blocks
  18453. */
  18454. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  18455. /**
  18456. * Specifies if the material uses a texture
  18457. * @param texture defines the texture to check against the material
  18458. * @returns a boolean specifying if the material uses the texture
  18459. */
  18460. hasTexture(texture: BaseTexture): boolean;
  18461. /**
  18462. * Disposes the material
  18463. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18464. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18465. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18466. */
  18467. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18468. /** Creates the node editor window. */
  18469. private _createNodeEditor;
  18470. /**
  18471. * Launch the node material editor
  18472. * @param config Define the configuration of the editor
  18473. * @return a promise fulfilled when the node editor is visible
  18474. */
  18475. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  18476. /**
  18477. * Clear the current material
  18478. */
  18479. clear(): void;
  18480. /**
  18481. * Clear the current material and set it to a default state
  18482. */
  18483. setToDefault(): void;
  18484. /**
  18485. * Clear the current material and set it to a default state for post process
  18486. */
  18487. setToDefaultPostProcess(): void;
  18488. /**
  18489. * Clear the current material and set it to a default state for procedural texture
  18490. */
  18491. setToDefaultProceduralTexture(): void;
  18492. /**
  18493. * Clear the current material and set it to a default state for particle
  18494. */
  18495. setToDefaultParticle(): void;
  18496. /**
  18497. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  18498. * @param url defines the url to load from
  18499. * @returns a promise that will fulfil when the material is fully loaded
  18500. */
  18501. loadAsync(url: string): Promise<void>;
  18502. private _gatherBlocks;
  18503. /**
  18504. * Generate a string containing the code declaration required to create an equivalent of this material
  18505. * @returns a string
  18506. */
  18507. generateCode(): string;
  18508. /**
  18509. * Serializes this material in a JSON representation
  18510. * @returns the serialized material object
  18511. */
  18512. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  18513. private _restoreConnections;
  18514. /**
  18515. * Clear the current graph and load a new one from a serialization object
  18516. * @param source defines the JSON representation of the material
  18517. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18518. * @param merge defines whether or not the source must be merged or replace the current content
  18519. */
  18520. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  18521. /**
  18522. * Makes a duplicate of the current material.
  18523. * @param name - name to use for the new material.
  18524. */
  18525. clone(name: string): NodeMaterial;
  18526. /**
  18527. * Creates a node material from parsed material data
  18528. * @param source defines the JSON representation of the material
  18529. * @param scene defines the hosting scene
  18530. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18531. * @returns a new node material
  18532. */
  18533. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  18534. /**
  18535. * Creates a node material from a snippet saved in a remote file
  18536. * @param name defines the name of the material to create
  18537. * @param url defines the url to load from
  18538. * @param scene defines the hosting scene
  18539. * @returns a promise that will resolve to the new node material
  18540. */
  18541. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  18542. /**
  18543. * Creates a node material from a snippet saved by the node material editor
  18544. * @param snippetId defines the snippet to load
  18545. * @param scene defines the hosting scene
  18546. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18547. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  18548. * @returns a promise that will resolve to the new node material
  18549. */
  18550. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  18551. /**
  18552. * Creates a new node material set to default basic configuration
  18553. * @param name defines the name of the material
  18554. * @param scene defines the hosting scene
  18555. * @returns a new NodeMaterial
  18556. */
  18557. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  18558. }
  18559. }
  18560. declare module BABYLON {
  18561. interface ThinEngine {
  18562. /**
  18563. * Unbind a list of render target textures from the webGL context
  18564. * This is used only when drawBuffer extension or webGL2 are active
  18565. * @param textures defines the render target textures to unbind
  18566. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  18567. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  18568. */
  18569. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  18570. /**
  18571. * Create a multi render target texture
  18572. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  18573. * @param size defines the size of the texture
  18574. * @param options defines the creation options
  18575. * @param initializeBuffers if set to true, the engine will make an initializing call of drawBuffers
  18576. * @returns the cube texture as an InternalTexture
  18577. */
  18578. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions, initializeBuffers?: boolean): InternalTexture[];
  18579. /**
  18580. * Update the sample count for a given multiple render target texture
  18581. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  18582. * @param textures defines the textures to update
  18583. * @param samples defines the sample count to set
  18584. * @param initializeBuffers if set to true, the engine will make an initializing call of drawBuffers
  18585. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  18586. */
  18587. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number, initializeBuffers?: boolean): number;
  18588. /**
  18589. * Select a subsets of attachments to draw to.
  18590. * @param attachments gl attachments
  18591. */
  18592. bindAttachments(attachments: number[]): void;
  18593. /**
  18594. * Creates a layout object to draw/clear on specific textures in a MRT
  18595. * @param textureStatus textureStatus[i] indicates if the i-th is active
  18596. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  18597. */
  18598. buildTextureLayout(textureStatus: boolean[]): number[];
  18599. /**
  18600. * Restores the webgl state to only draw on the main color attachment
  18601. * when the frame buffer associated is the canvas frame buffer
  18602. */
  18603. restoreSingleAttachment(): void;
  18604. /**
  18605. * Restores the webgl state to only draw on the main color attachment
  18606. * when the frame buffer associated is not the canvas frame buffer
  18607. */
  18608. restoreSingleAttachmentForRenderTarget(): void;
  18609. /**
  18610. * Clears a list of attachments
  18611. * @param attachments list of the attachments
  18612. * @param colorMain clear color for the main attachment (the first one)
  18613. * @param colorOthers clear color for the other attachments
  18614. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  18615. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  18616. */
  18617. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  18618. }
  18619. }
  18620. declare module BABYLON {
  18621. /**
  18622. * Creation options of the multi render target texture.
  18623. */
  18624. export interface IMultiRenderTargetOptions {
  18625. /**
  18626. * Define if the texture needs to create mip maps after render.
  18627. */
  18628. generateMipMaps?: boolean;
  18629. /**
  18630. * Define the types of all the draw buffers we want to create
  18631. */
  18632. types?: number[];
  18633. /**
  18634. * Define the sampling modes of all the draw buffers we want to create
  18635. */
  18636. samplingModes?: number[];
  18637. /**
  18638. * Define if a depth buffer is required
  18639. */
  18640. generateDepthBuffer?: boolean;
  18641. /**
  18642. * Define if a stencil buffer is required
  18643. */
  18644. generateStencilBuffer?: boolean;
  18645. /**
  18646. * Define if a depth texture is required instead of a depth buffer
  18647. */
  18648. generateDepthTexture?: boolean;
  18649. /**
  18650. * Define the number of desired draw buffers
  18651. */
  18652. textureCount?: number;
  18653. /**
  18654. * Define if aspect ratio should be adapted to the texture or stay the scene one
  18655. */
  18656. doNotChangeAspectRatio?: boolean;
  18657. /**
  18658. * Define the default type of the buffers we are creating
  18659. */
  18660. defaultType?: number;
  18661. /**
  18662. * Define the default type of the buffers we are creating
  18663. */
  18664. drawOnlyOnFirstAttachmentByDefault?: boolean;
  18665. }
  18666. /**
  18667. * A multi render target, like a render target provides the ability to render to a texture.
  18668. * Unlike the render target, it can render to several draw buffers in one draw.
  18669. * This is specially interesting in deferred rendering or for any effects requiring more than
  18670. * just one color from a single pass.
  18671. */
  18672. export class MultiRenderTarget extends RenderTargetTexture {
  18673. private _internalTextures;
  18674. private _textures;
  18675. private _multiRenderTargetOptions;
  18676. private _count;
  18677. private _drawOnlyOnFirstAttachmentByDefault;
  18678. /**
  18679. * Get if draw buffers are currently supported by the used hardware and browser.
  18680. */
  18681. get isSupported(): boolean;
  18682. /**
  18683. * Get the list of textures generated by the multi render target.
  18684. */
  18685. get textures(): Texture[];
  18686. /**
  18687. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  18688. */
  18689. get count(): number;
  18690. /**
  18691. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  18692. */
  18693. get depthTexture(): Texture;
  18694. /**
  18695. * Set the wrapping mode on U of all the textures we are rendering to.
  18696. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18697. */
  18698. set wrapU(wrap: number);
  18699. /**
  18700. * Set the wrapping mode on V of all the textures we are rendering to.
  18701. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18702. */
  18703. set wrapV(wrap: number);
  18704. /**
  18705. * Instantiate a new multi render target texture.
  18706. * A multi render target, like a render target provides the ability to render to a texture.
  18707. * Unlike the render target, it can render to several draw buffers in one draw.
  18708. * This is specially interesting in deferred rendering or for any effects requiring more than
  18709. * just one color from a single pass.
  18710. * @param name Define the name of the texture
  18711. * @param size Define the size of the buffers to render to
  18712. * @param count Define the number of target we are rendering into
  18713. * @param scene Define the scene the texture belongs to
  18714. * @param options Define the options used to create the multi render target
  18715. */
  18716. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  18717. private _initTypes;
  18718. /** @hidden */
  18719. _rebuild(forceFullRebuild?: boolean): void;
  18720. private _createInternalTextures;
  18721. private _createTextures;
  18722. /**
  18723. * Replaces a texture within the MRT.
  18724. * @param texture The new texture to insert in the MRT
  18725. * @param index The index of the texture to replace
  18726. */
  18727. replaceTexture(texture: Texture, index: number): void;
  18728. /**
  18729. * Define the number of samples used if MSAA is enabled.
  18730. */
  18731. get samples(): number;
  18732. set samples(value: number);
  18733. /**
  18734. * Resize all the textures in the multi render target.
  18735. * Be careful as it will recreate all the data in the new texture.
  18736. * @param size Define the new size
  18737. */
  18738. resize(size: any): void;
  18739. /**
  18740. * Changes the number of render targets in this MRT
  18741. * Be careful as it will recreate all the data in the new texture.
  18742. * @param count new texture count
  18743. * @param options Specifies texture types and sampling modes for new textures
  18744. */
  18745. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  18746. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18747. /**
  18748. * Dispose the render targets and their associated resources
  18749. */
  18750. dispose(): void;
  18751. /**
  18752. * Release all the underlying texture used as draw buffers.
  18753. */
  18754. releaseInternalTextures(): void;
  18755. }
  18756. }
  18757. declare module BABYLON {
  18758. /** @hidden */
  18759. export var imageProcessingPixelShader: {
  18760. name: string;
  18761. shader: string;
  18762. };
  18763. }
  18764. declare module BABYLON {
  18765. /**
  18766. * ImageProcessingPostProcess
  18767. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  18768. */
  18769. export class ImageProcessingPostProcess extends PostProcess {
  18770. /**
  18771. * Default configuration related to image processing available in the PBR Material.
  18772. */
  18773. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18774. /**
  18775. * Gets the image processing configuration used either in this material.
  18776. */
  18777. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  18778. /**
  18779. * Sets the Default image processing configuration used either in the this material.
  18780. *
  18781. * If sets to null, the scene one is in use.
  18782. */
  18783. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  18784. /**
  18785. * Keep track of the image processing observer to allow dispose and replace.
  18786. */
  18787. private _imageProcessingObserver;
  18788. /**
  18789. * Attaches a new image processing configuration to the PBR Material.
  18790. * @param configuration
  18791. */
  18792. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  18793. /**
  18794. * If the post process is supported.
  18795. */
  18796. get isSupported(): boolean;
  18797. /**
  18798. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18799. */
  18800. get colorCurves(): Nullable<ColorCurves>;
  18801. /**
  18802. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18803. */
  18804. set colorCurves(value: Nullable<ColorCurves>);
  18805. /**
  18806. * Gets whether the color curves effect is enabled.
  18807. */
  18808. get colorCurvesEnabled(): boolean;
  18809. /**
  18810. * Sets whether the color curves effect is enabled.
  18811. */
  18812. set colorCurvesEnabled(value: boolean);
  18813. /**
  18814. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18815. */
  18816. get colorGradingTexture(): Nullable<BaseTexture>;
  18817. /**
  18818. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18819. */
  18820. set colorGradingTexture(value: Nullable<BaseTexture>);
  18821. /**
  18822. * Gets whether the color grading effect is enabled.
  18823. */
  18824. get colorGradingEnabled(): boolean;
  18825. /**
  18826. * Gets whether the color grading effect is enabled.
  18827. */
  18828. set colorGradingEnabled(value: boolean);
  18829. /**
  18830. * Gets exposure used in the effect.
  18831. */
  18832. get exposure(): number;
  18833. /**
  18834. * Sets exposure used in the effect.
  18835. */
  18836. set exposure(value: number);
  18837. /**
  18838. * Gets whether tonemapping is enabled or not.
  18839. */
  18840. get toneMappingEnabled(): boolean;
  18841. /**
  18842. * Sets whether tonemapping is enabled or not
  18843. */
  18844. set toneMappingEnabled(value: boolean);
  18845. /**
  18846. * Gets the type of tone mapping effect.
  18847. */
  18848. get toneMappingType(): number;
  18849. /**
  18850. * Sets the type of tone mapping effect.
  18851. */
  18852. set toneMappingType(value: number);
  18853. /**
  18854. * Gets contrast used in the effect.
  18855. */
  18856. get contrast(): number;
  18857. /**
  18858. * Sets contrast used in the effect.
  18859. */
  18860. set contrast(value: number);
  18861. /**
  18862. * Gets Vignette stretch size.
  18863. */
  18864. get vignetteStretch(): number;
  18865. /**
  18866. * Sets Vignette stretch size.
  18867. */
  18868. set vignetteStretch(value: number);
  18869. /**
  18870. * Gets Vignette centre X Offset.
  18871. */
  18872. get vignetteCentreX(): number;
  18873. /**
  18874. * Sets Vignette centre X Offset.
  18875. */
  18876. set vignetteCentreX(value: number);
  18877. /**
  18878. * Gets Vignette centre Y Offset.
  18879. */
  18880. get vignetteCentreY(): number;
  18881. /**
  18882. * Sets Vignette centre Y Offset.
  18883. */
  18884. set vignetteCentreY(value: number);
  18885. /**
  18886. * Gets Vignette weight or intensity of the vignette effect.
  18887. */
  18888. get vignetteWeight(): number;
  18889. /**
  18890. * Sets Vignette weight or intensity of the vignette effect.
  18891. */
  18892. set vignetteWeight(value: number);
  18893. /**
  18894. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18895. * if vignetteEnabled is set to true.
  18896. */
  18897. get vignetteColor(): Color4;
  18898. /**
  18899. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18900. * if vignetteEnabled is set to true.
  18901. */
  18902. set vignetteColor(value: Color4);
  18903. /**
  18904. * Gets Camera field of view used by the Vignette effect.
  18905. */
  18906. get vignetteCameraFov(): number;
  18907. /**
  18908. * Sets Camera field of view used by the Vignette effect.
  18909. */
  18910. set vignetteCameraFov(value: number);
  18911. /**
  18912. * Gets the vignette blend mode allowing different kind of effect.
  18913. */
  18914. get vignetteBlendMode(): number;
  18915. /**
  18916. * Sets the vignette blend mode allowing different kind of effect.
  18917. */
  18918. set vignetteBlendMode(value: number);
  18919. /**
  18920. * Gets whether the vignette effect is enabled.
  18921. */
  18922. get vignetteEnabled(): boolean;
  18923. /**
  18924. * Sets whether the vignette effect is enabled.
  18925. */
  18926. set vignetteEnabled(value: boolean);
  18927. private _fromLinearSpace;
  18928. /**
  18929. * Gets whether the input of the processing is in Gamma or Linear Space.
  18930. */
  18931. get fromLinearSpace(): boolean;
  18932. /**
  18933. * Sets whether the input of the processing is in Gamma or Linear Space.
  18934. */
  18935. set fromLinearSpace(value: boolean);
  18936. /**
  18937. * Defines cache preventing GC.
  18938. */
  18939. private _defines;
  18940. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  18941. /**
  18942. * "ImageProcessingPostProcess"
  18943. * @returns "ImageProcessingPostProcess"
  18944. */
  18945. getClassName(): string;
  18946. /**
  18947. * @hidden
  18948. */
  18949. _updateParameters(): void;
  18950. dispose(camera?: Camera): void;
  18951. }
  18952. }
  18953. declare module BABYLON {
  18954. /**
  18955. * A multi render target designed to render the prepass.
  18956. * Prepass is a scene component used to render information in multiple textures
  18957. * alongside with the scene materials rendering.
  18958. * Note : This is an internal class, and you should NOT need to instanciate this.
  18959. * Only the `PrePassRenderer` should instanciate this class.
  18960. * It is more likely that you need a regular `MultiRenderTarget`
  18961. * @hidden
  18962. */
  18963. export class PrePassRenderTarget extends MultiRenderTarget {
  18964. /**
  18965. * @hidden
  18966. */
  18967. _beforeCompositionPostProcesses: PostProcess[];
  18968. /**
  18969. * Image processing post process for composition
  18970. */
  18971. imageProcessingPostProcess: ImageProcessingPostProcess;
  18972. /**
  18973. * @hidden
  18974. */
  18975. _engine: Engine;
  18976. /**
  18977. * @hidden
  18978. */
  18979. _scene: Scene;
  18980. /**
  18981. * @hidden
  18982. */
  18983. _outputPostProcess: Nullable<PostProcess>;
  18984. /**
  18985. * @hidden
  18986. */
  18987. _internalTextureDirty: boolean;
  18988. /**
  18989. * Is this render target enabled for prepass rendering
  18990. */
  18991. enabled: boolean;
  18992. /**
  18993. * Render target associated with this prePassRenderTarget
  18994. * If this is `null`, it means this prePassRenderTarget is associated with the scene
  18995. */
  18996. renderTargetTexture: Nullable<RenderTargetTexture>;
  18997. constructor(name: string, renderTargetTexture: Nullable<RenderTargetTexture>, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions | undefined);
  18998. /**
  18999. * Creates a composition effect for this RT
  19000. * @hidden
  19001. */
  19002. _createCompositionEffect(): void;
  19003. /**
  19004. * Checks that the size of this RT is still adapted to the desired render size.
  19005. * @hidden
  19006. */
  19007. _checkSize(): void;
  19008. /**
  19009. * Changes the number of render targets in this MRT
  19010. * Be careful as it will recreate all the data in the new texture.
  19011. * @param count new texture count
  19012. * @param options Specifies texture types and sampling modes for new textures
  19013. */
  19014. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  19015. /**
  19016. * Resets the post processes chains applied to this RT.
  19017. * @hidden
  19018. */
  19019. _resetPostProcessChain(): void;
  19020. /**
  19021. * Diposes this render target
  19022. */
  19023. dispose(): void;
  19024. }
  19025. }
  19026. declare module BABYLON {
  19027. /**
  19028. * Interface for defining prepass effects in the prepass post-process pipeline
  19029. */
  19030. export interface PrePassEffectConfiguration {
  19031. /**
  19032. * Name of the effect
  19033. */
  19034. name: string;
  19035. /**
  19036. * Post process to attach for this effect
  19037. */
  19038. postProcess?: PostProcess;
  19039. /**
  19040. * Textures required in the MRT
  19041. */
  19042. texturesRequired: number[];
  19043. /**
  19044. * Is the effect enabled
  19045. */
  19046. enabled: boolean;
  19047. /**
  19048. * Does the output of this prepass need to go through imageprocessing
  19049. */
  19050. needsImageProcessing?: boolean;
  19051. /**
  19052. * Disposes the effect configuration
  19053. */
  19054. dispose?: () => void;
  19055. /**
  19056. * Creates the associated post process
  19057. */
  19058. createPostProcess?: () => PostProcess;
  19059. }
  19060. }
  19061. declare module BABYLON {
  19062. /**
  19063. * Options to be used when creating a FresnelParameters.
  19064. */
  19065. export type IFresnelParametersCreationOptions = {
  19066. /**
  19067. * Define the color used on edges (grazing angle)
  19068. */
  19069. leftColor?: Color3;
  19070. /**
  19071. * Define the color used on center
  19072. */
  19073. rightColor?: Color3;
  19074. /**
  19075. * Define bias applied to computed fresnel term
  19076. */
  19077. bias?: number;
  19078. /**
  19079. * Defined the power exponent applied to fresnel term
  19080. */
  19081. power?: number;
  19082. /**
  19083. * Define if the fresnel effect is enable or not.
  19084. */
  19085. isEnabled?: boolean;
  19086. };
  19087. /**
  19088. * Serialized format for FresnelParameters.
  19089. */
  19090. export type IFresnelParametersSerialized = {
  19091. /**
  19092. * Define the color used on edges (grazing angle) [as an array]
  19093. */
  19094. leftColor: number[];
  19095. /**
  19096. * Define the color used on center [as an array]
  19097. */
  19098. rightColor: number[];
  19099. /**
  19100. * Define bias applied to computed fresnel term
  19101. */
  19102. bias: number;
  19103. /**
  19104. * Defined the power exponent applied to fresnel term
  19105. */
  19106. power?: number;
  19107. /**
  19108. * Define if the fresnel effect is enable or not.
  19109. */
  19110. isEnabled: boolean;
  19111. };
  19112. /**
  19113. * This represents all the required information to add a fresnel effect on a material:
  19114. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19115. */
  19116. export class FresnelParameters {
  19117. private _isEnabled;
  19118. /**
  19119. * Define if the fresnel effect is enable or not.
  19120. */
  19121. get isEnabled(): boolean;
  19122. set isEnabled(value: boolean);
  19123. /**
  19124. * Define the color used on edges (grazing angle)
  19125. */
  19126. leftColor: Color3;
  19127. /**
  19128. * Define the color used on center
  19129. */
  19130. rightColor: Color3;
  19131. /**
  19132. * Define bias applied to computed fresnel term
  19133. */
  19134. bias: number;
  19135. /**
  19136. * Defined the power exponent applied to fresnel term
  19137. */
  19138. power: number;
  19139. /**
  19140. * Creates a new FresnelParameters object.
  19141. *
  19142. * @param options provide your own settings to optionally to override defaults
  19143. */
  19144. constructor(options?: IFresnelParametersCreationOptions);
  19145. /**
  19146. * Clones the current fresnel and its values
  19147. * @returns a clone fresnel configuration
  19148. */
  19149. clone(): FresnelParameters;
  19150. /**
  19151. * Determines equality between FresnelParameters objects
  19152. * @param otherFresnelParameters defines the second operand
  19153. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  19154. */
  19155. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  19156. /**
  19157. * Serializes the current fresnel parameters to a JSON representation.
  19158. * @return the JSON serialization
  19159. */
  19160. serialize(): IFresnelParametersSerialized;
  19161. /**
  19162. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  19163. * @param parsedFresnelParameters Define the JSON representation
  19164. * @returns the parsed parameters
  19165. */
  19166. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  19167. }
  19168. }
  19169. declare module BABYLON {
  19170. /**
  19171. * This groups all the flags used to control the materials channel.
  19172. */
  19173. export class MaterialFlags {
  19174. private static _DiffuseTextureEnabled;
  19175. /**
  19176. * Are diffuse textures enabled in the application.
  19177. */
  19178. static get DiffuseTextureEnabled(): boolean;
  19179. static set DiffuseTextureEnabled(value: boolean);
  19180. private static _DetailTextureEnabled;
  19181. /**
  19182. * Are detail textures enabled in the application.
  19183. */
  19184. static get DetailTextureEnabled(): boolean;
  19185. static set DetailTextureEnabled(value: boolean);
  19186. private static _AmbientTextureEnabled;
  19187. /**
  19188. * Are ambient textures enabled in the application.
  19189. */
  19190. static get AmbientTextureEnabled(): boolean;
  19191. static set AmbientTextureEnabled(value: boolean);
  19192. private static _OpacityTextureEnabled;
  19193. /**
  19194. * Are opacity textures enabled in the application.
  19195. */
  19196. static get OpacityTextureEnabled(): boolean;
  19197. static set OpacityTextureEnabled(value: boolean);
  19198. private static _ReflectionTextureEnabled;
  19199. /**
  19200. * Are reflection textures enabled in the application.
  19201. */
  19202. static get ReflectionTextureEnabled(): boolean;
  19203. static set ReflectionTextureEnabled(value: boolean);
  19204. private static _EmissiveTextureEnabled;
  19205. /**
  19206. * Are emissive textures enabled in the application.
  19207. */
  19208. static get EmissiveTextureEnabled(): boolean;
  19209. static set EmissiveTextureEnabled(value: boolean);
  19210. private static _SpecularTextureEnabled;
  19211. /**
  19212. * Are specular textures enabled in the application.
  19213. */
  19214. static get SpecularTextureEnabled(): boolean;
  19215. static set SpecularTextureEnabled(value: boolean);
  19216. private static _BumpTextureEnabled;
  19217. /**
  19218. * Are bump textures enabled in the application.
  19219. */
  19220. static get BumpTextureEnabled(): boolean;
  19221. static set BumpTextureEnabled(value: boolean);
  19222. private static _LightmapTextureEnabled;
  19223. /**
  19224. * Are lightmap textures enabled in the application.
  19225. */
  19226. static get LightmapTextureEnabled(): boolean;
  19227. static set LightmapTextureEnabled(value: boolean);
  19228. private static _RefractionTextureEnabled;
  19229. /**
  19230. * Are refraction textures enabled in the application.
  19231. */
  19232. static get RefractionTextureEnabled(): boolean;
  19233. static set RefractionTextureEnabled(value: boolean);
  19234. private static _ColorGradingTextureEnabled;
  19235. /**
  19236. * Are color grading textures enabled in the application.
  19237. */
  19238. static get ColorGradingTextureEnabled(): boolean;
  19239. static set ColorGradingTextureEnabled(value: boolean);
  19240. private static _FresnelEnabled;
  19241. /**
  19242. * Are fresnels enabled in the application.
  19243. */
  19244. static get FresnelEnabled(): boolean;
  19245. static set FresnelEnabled(value: boolean);
  19246. private static _ClearCoatTextureEnabled;
  19247. /**
  19248. * Are clear coat textures enabled in the application.
  19249. */
  19250. static get ClearCoatTextureEnabled(): boolean;
  19251. static set ClearCoatTextureEnabled(value: boolean);
  19252. private static _ClearCoatBumpTextureEnabled;
  19253. /**
  19254. * Are clear coat bump textures enabled in the application.
  19255. */
  19256. static get ClearCoatBumpTextureEnabled(): boolean;
  19257. static set ClearCoatBumpTextureEnabled(value: boolean);
  19258. private static _ClearCoatTintTextureEnabled;
  19259. /**
  19260. * Are clear coat tint textures enabled in the application.
  19261. */
  19262. static get ClearCoatTintTextureEnabled(): boolean;
  19263. static set ClearCoatTintTextureEnabled(value: boolean);
  19264. private static _SheenTextureEnabled;
  19265. /**
  19266. * Are sheen textures enabled in the application.
  19267. */
  19268. static get SheenTextureEnabled(): boolean;
  19269. static set SheenTextureEnabled(value: boolean);
  19270. private static _AnisotropicTextureEnabled;
  19271. /**
  19272. * Are anisotropic textures enabled in the application.
  19273. */
  19274. static get AnisotropicTextureEnabled(): boolean;
  19275. static set AnisotropicTextureEnabled(value: boolean);
  19276. private static _ThicknessTextureEnabled;
  19277. /**
  19278. * Are thickness textures enabled in the application.
  19279. */
  19280. static get ThicknessTextureEnabled(): boolean;
  19281. static set ThicknessTextureEnabled(value: boolean);
  19282. }
  19283. }
  19284. declare module BABYLON {
  19285. /** @hidden */
  19286. export var defaultFragmentDeclaration: {
  19287. name: string;
  19288. shader: string;
  19289. };
  19290. }
  19291. declare module BABYLON {
  19292. /** @hidden */
  19293. export var sceneUboDeclaration: {
  19294. name: string;
  19295. shader: string;
  19296. };
  19297. }
  19298. declare module BABYLON {
  19299. /** @hidden */
  19300. export var meshUboDeclaration: {
  19301. name: string;
  19302. shader: string;
  19303. };
  19304. }
  19305. declare module BABYLON {
  19306. /** @hidden */
  19307. export var defaultUboDeclaration: {
  19308. name: string;
  19309. shader: string;
  19310. };
  19311. }
  19312. declare module BABYLON {
  19313. /** @hidden */
  19314. export var prePassDeclaration: {
  19315. name: string;
  19316. shader: string;
  19317. };
  19318. }
  19319. declare module BABYLON {
  19320. /** @hidden */
  19321. export var lightFragmentDeclaration: {
  19322. name: string;
  19323. shader: string;
  19324. };
  19325. }
  19326. declare module BABYLON {
  19327. /** @hidden */
  19328. export var lightUboDeclaration: {
  19329. name: string;
  19330. shader: string;
  19331. };
  19332. }
  19333. declare module BABYLON {
  19334. /** @hidden */
  19335. export var lightsFragmentFunctions: {
  19336. name: string;
  19337. shader: string;
  19338. };
  19339. }
  19340. declare module BABYLON {
  19341. /** @hidden */
  19342. export var shadowsFragmentFunctions: {
  19343. name: string;
  19344. shader: string;
  19345. };
  19346. }
  19347. declare module BABYLON {
  19348. /** @hidden */
  19349. export var fresnelFunction: {
  19350. name: string;
  19351. shader: string;
  19352. };
  19353. }
  19354. declare module BABYLON {
  19355. /** @hidden */
  19356. export var bumpFragmentMainFunctions: {
  19357. name: string;
  19358. shader: string;
  19359. };
  19360. }
  19361. declare module BABYLON {
  19362. /** @hidden */
  19363. export var bumpFragmentFunctions: {
  19364. name: string;
  19365. shader: string;
  19366. };
  19367. }
  19368. declare module BABYLON {
  19369. /** @hidden */
  19370. export var logDepthDeclaration: {
  19371. name: string;
  19372. shader: string;
  19373. };
  19374. }
  19375. declare module BABYLON {
  19376. /** @hidden */
  19377. export var fogFragmentDeclaration: {
  19378. name: string;
  19379. shader: string;
  19380. };
  19381. }
  19382. declare module BABYLON {
  19383. /** @hidden */
  19384. export var bumpFragment: {
  19385. name: string;
  19386. shader: string;
  19387. };
  19388. }
  19389. declare module BABYLON {
  19390. /** @hidden */
  19391. export var depthPrePass: {
  19392. name: string;
  19393. shader: string;
  19394. };
  19395. }
  19396. declare module BABYLON {
  19397. /** @hidden */
  19398. export var lightFragment: {
  19399. name: string;
  19400. shader: string;
  19401. };
  19402. }
  19403. declare module BABYLON {
  19404. /** @hidden */
  19405. export var logDepthFragment: {
  19406. name: string;
  19407. shader: string;
  19408. };
  19409. }
  19410. declare module BABYLON {
  19411. /** @hidden */
  19412. export var fogFragment: {
  19413. name: string;
  19414. shader: string;
  19415. };
  19416. }
  19417. declare module BABYLON {
  19418. /** @hidden */
  19419. export var defaultPixelShader: {
  19420. name: string;
  19421. shader: string;
  19422. };
  19423. }
  19424. declare module BABYLON {
  19425. /** @hidden */
  19426. export var defaultVertexDeclaration: {
  19427. name: string;
  19428. shader: string;
  19429. };
  19430. }
  19431. declare module BABYLON {
  19432. /** @hidden */
  19433. export var bonesDeclaration: {
  19434. name: string;
  19435. shader: string;
  19436. };
  19437. }
  19438. declare module BABYLON {
  19439. /** @hidden */
  19440. export var prePassVertexDeclaration: {
  19441. name: string;
  19442. shader: string;
  19443. };
  19444. }
  19445. declare module BABYLON {
  19446. /** @hidden */
  19447. export var bumpVertexDeclaration: {
  19448. name: string;
  19449. shader: string;
  19450. };
  19451. }
  19452. declare module BABYLON {
  19453. /** @hidden */
  19454. export var fogVertexDeclaration: {
  19455. name: string;
  19456. shader: string;
  19457. };
  19458. }
  19459. declare module BABYLON {
  19460. /** @hidden */
  19461. export var lightVxFragmentDeclaration: {
  19462. name: string;
  19463. shader: string;
  19464. };
  19465. }
  19466. declare module BABYLON {
  19467. /** @hidden */
  19468. export var lightVxUboDeclaration: {
  19469. name: string;
  19470. shader: string;
  19471. };
  19472. }
  19473. declare module BABYLON {
  19474. /** @hidden */
  19475. export var morphTargetsVertexGlobalDeclaration: {
  19476. name: string;
  19477. shader: string;
  19478. };
  19479. }
  19480. declare module BABYLON {
  19481. /** @hidden */
  19482. export var morphTargetsVertexDeclaration: {
  19483. name: string;
  19484. shader: string;
  19485. };
  19486. }
  19487. declare module BABYLON {
  19488. /** @hidden */
  19489. export var morphTargetsVertexGlobal: {
  19490. name: string;
  19491. shader: string;
  19492. };
  19493. }
  19494. declare module BABYLON {
  19495. /** @hidden */
  19496. export var morphTargetsVertex: {
  19497. name: string;
  19498. shader: string;
  19499. };
  19500. }
  19501. declare module BABYLON {
  19502. /** @hidden */
  19503. export var instancesVertex: {
  19504. name: string;
  19505. shader: string;
  19506. };
  19507. }
  19508. declare module BABYLON {
  19509. /** @hidden */
  19510. export var bonesVertex: {
  19511. name: string;
  19512. shader: string;
  19513. };
  19514. }
  19515. declare module BABYLON {
  19516. /** @hidden */
  19517. export var prePassVertex: {
  19518. name: string;
  19519. shader: string;
  19520. };
  19521. }
  19522. declare module BABYLON {
  19523. /** @hidden */
  19524. export var bumpVertex: {
  19525. name: string;
  19526. shader: string;
  19527. };
  19528. }
  19529. declare module BABYLON {
  19530. /** @hidden */
  19531. export var fogVertex: {
  19532. name: string;
  19533. shader: string;
  19534. };
  19535. }
  19536. declare module BABYLON {
  19537. /** @hidden */
  19538. export var shadowsVertex: {
  19539. name: string;
  19540. shader: string;
  19541. };
  19542. }
  19543. declare module BABYLON {
  19544. /** @hidden */
  19545. export var pointCloudVertex: {
  19546. name: string;
  19547. shader: string;
  19548. };
  19549. }
  19550. declare module BABYLON {
  19551. /** @hidden */
  19552. export var logDepthVertex: {
  19553. name: string;
  19554. shader: string;
  19555. };
  19556. }
  19557. declare module BABYLON {
  19558. /** @hidden */
  19559. export var defaultVertexShader: {
  19560. name: string;
  19561. shader: string;
  19562. };
  19563. }
  19564. declare module BABYLON {
  19565. /**
  19566. * @hidden
  19567. */
  19568. export interface IMaterialDetailMapDefines {
  19569. DETAIL: boolean;
  19570. DETAILDIRECTUV: number;
  19571. DETAIL_NORMALBLENDMETHOD: number;
  19572. /** @hidden */
  19573. _areTexturesDirty: boolean;
  19574. }
  19575. /**
  19576. * Define the code related to the detail map parameters of a material
  19577. *
  19578. * Inspired from:
  19579. * 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
  19580. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  19581. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  19582. */
  19583. export class DetailMapConfiguration {
  19584. private _texture;
  19585. /**
  19586. * The detail texture of the material.
  19587. */
  19588. texture: Nullable<BaseTexture>;
  19589. /**
  19590. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  19591. * Bigger values mean stronger blending
  19592. */
  19593. diffuseBlendLevel: number;
  19594. /**
  19595. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  19596. * Bigger values mean stronger blending. Only used with PBR materials
  19597. */
  19598. roughnessBlendLevel: number;
  19599. /**
  19600. * Defines how strong the bump effect from the detail map is
  19601. * Bigger values mean stronger effect
  19602. */
  19603. bumpLevel: number;
  19604. private _normalBlendMethod;
  19605. /**
  19606. * The method used to blend the bump and detail normals together
  19607. */
  19608. normalBlendMethod: number;
  19609. private _isEnabled;
  19610. /**
  19611. * Enable or disable the detail map on this material
  19612. */
  19613. isEnabled: boolean;
  19614. /** @hidden */
  19615. private _internalMarkAllSubMeshesAsTexturesDirty;
  19616. /** @hidden */
  19617. _markAllSubMeshesAsTexturesDirty(): void;
  19618. /**
  19619. * Instantiate a new detail map
  19620. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19621. */
  19622. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19623. /**
  19624. * Gets whether the submesh is ready to be used or not.
  19625. * @param defines the list of "defines" to update.
  19626. * @param scene defines the scene the material belongs to.
  19627. * @returns - boolean indicating that the submesh is ready or not.
  19628. */
  19629. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  19630. /**
  19631. * Update the defines for detail map usage
  19632. * @param defines the list of "defines" to update.
  19633. * @param scene defines the scene the material belongs to.
  19634. */
  19635. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  19636. /**
  19637. * Binds the material data.
  19638. * @param uniformBuffer defines the Uniform buffer to fill in.
  19639. * @param scene defines the scene the material belongs to.
  19640. * @param isFrozen defines whether the material is frozen or not.
  19641. */
  19642. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  19643. /**
  19644. * Checks to see if a texture is used in the material.
  19645. * @param texture - Base texture to use.
  19646. * @returns - Boolean specifying if a texture is used in the material.
  19647. */
  19648. hasTexture(texture: BaseTexture): boolean;
  19649. /**
  19650. * Returns an array of the actively used textures.
  19651. * @param activeTextures Array of BaseTextures
  19652. */
  19653. getActiveTextures(activeTextures: BaseTexture[]): void;
  19654. /**
  19655. * Returns the animatable textures.
  19656. * @param animatables Array of animatable textures.
  19657. */
  19658. getAnimatables(animatables: IAnimatable[]): void;
  19659. /**
  19660. * Disposes the resources of the material.
  19661. * @param forceDisposeTextures - Forces the disposal of all textures.
  19662. */
  19663. dispose(forceDisposeTextures?: boolean): void;
  19664. /**
  19665. * Get the current class name useful for serialization or dynamic coding.
  19666. * @returns "DetailMap"
  19667. */
  19668. getClassName(): string;
  19669. /**
  19670. * Add the required uniforms to the current list.
  19671. * @param uniforms defines the current uniform list.
  19672. */
  19673. static AddUniforms(uniforms: string[]): void;
  19674. /**
  19675. * Add the required samplers to the current list.
  19676. * @param samplers defines the current sampler list.
  19677. */
  19678. static AddSamplers(samplers: string[]): void;
  19679. /**
  19680. * Add the required uniforms to the current buffer.
  19681. * @param uniformBuffer defines the current uniform buffer.
  19682. */
  19683. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19684. /**
  19685. * Makes a duplicate of the current instance into another one.
  19686. * @param detailMap define the instance where to copy the info
  19687. */
  19688. copyTo(detailMap: DetailMapConfiguration): void;
  19689. /**
  19690. * Serializes this detail map instance
  19691. * @returns - An object with the serialized instance.
  19692. */
  19693. serialize(): any;
  19694. /**
  19695. * Parses a detail map setting from a serialized object.
  19696. * @param source - Serialized object.
  19697. * @param scene Defines the scene we are parsing for
  19698. * @param rootUrl Defines the rootUrl to load from
  19699. */
  19700. parse(source: any, scene: Scene, rootUrl: string): void;
  19701. }
  19702. }
  19703. declare module BABYLON {
  19704. /** @hidden */
  19705. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  19706. MAINUV1: boolean;
  19707. MAINUV2: boolean;
  19708. DIFFUSE: boolean;
  19709. DIFFUSEDIRECTUV: number;
  19710. DETAIL: boolean;
  19711. DETAILDIRECTUV: number;
  19712. DETAIL_NORMALBLENDMETHOD: number;
  19713. AMBIENT: boolean;
  19714. AMBIENTDIRECTUV: number;
  19715. OPACITY: boolean;
  19716. OPACITYDIRECTUV: number;
  19717. OPACITYRGB: boolean;
  19718. REFLECTION: boolean;
  19719. EMISSIVE: boolean;
  19720. EMISSIVEDIRECTUV: number;
  19721. SPECULAR: boolean;
  19722. SPECULARDIRECTUV: number;
  19723. BUMP: boolean;
  19724. BUMPDIRECTUV: number;
  19725. PARALLAX: boolean;
  19726. PARALLAXOCCLUSION: boolean;
  19727. SPECULAROVERALPHA: boolean;
  19728. CLIPPLANE: boolean;
  19729. CLIPPLANE2: boolean;
  19730. CLIPPLANE3: boolean;
  19731. CLIPPLANE4: boolean;
  19732. CLIPPLANE5: boolean;
  19733. CLIPPLANE6: boolean;
  19734. ALPHATEST: boolean;
  19735. DEPTHPREPASS: boolean;
  19736. ALPHAFROMDIFFUSE: boolean;
  19737. POINTSIZE: boolean;
  19738. FOG: boolean;
  19739. SPECULARTERM: boolean;
  19740. DIFFUSEFRESNEL: boolean;
  19741. OPACITYFRESNEL: boolean;
  19742. REFLECTIONFRESNEL: boolean;
  19743. REFRACTIONFRESNEL: boolean;
  19744. EMISSIVEFRESNEL: boolean;
  19745. FRESNEL: boolean;
  19746. NORMAL: boolean;
  19747. UV1: boolean;
  19748. UV2: boolean;
  19749. VERTEXCOLOR: boolean;
  19750. VERTEXALPHA: boolean;
  19751. NUM_BONE_INFLUENCERS: number;
  19752. BonesPerMesh: number;
  19753. BONETEXTURE: boolean;
  19754. BONES_VELOCITY_ENABLED: boolean;
  19755. INSTANCES: boolean;
  19756. THIN_INSTANCES: boolean;
  19757. GLOSSINESS: boolean;
  19758. ROUGHNESS: boolean;
  19759. EMISSIVEASILLUMINATION: boolean;
  19760. LINKEMISSIVEWITHDIFFUSE: boolean;
  19761. REFLECTIONFRESNELFROMSPECULAR: boolean;
  19762. LIGHTMAP: boolean;
  19763. LIGHTMAPDIRECTUV: number;
  19764. OBJECTSPACE_NORMALMAP: boolean;
  19765. USELIGHTMAPASSHADOWMAP: boolean;
  19766. REFLECTIONMAP_3D: boolean;
  19767. REFLECTIONMAP_SPHERICAL: boolean;
  19768. REFLECTIONMAP_PLANAR: boolean;
  19769. REFLECTIONMAP_CUBIC: boolean;
  19770. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  19771. REFLECTIONMAP_PROJECTION: boolean;
  19772. REFLECTIONMAP_SKYBOX: boolean;
  19773. REFLECTIONMAP_EXPLICIT: boolean;
  19774. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19775. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19776. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19777. REFLECTIONMAP_OPPOSITEZ: boolean;
  19778. INVERTCUBICMAP: boolean;
  19779. LOGARITHMICDEPTH: boolean;
  19780. REFRACTION: boolean;
  19781. REFRACTIONMAP_3D: boolean;
  19782. REFLECTIONOVERALPHA: boolean;
  19783. TWOSIDEDLIGHTING: boolean;
  19784. SHADOWFLOAT: boolean;
  19785. MORPHTARGETS: boolean;
  19786. MORPHTARGETS_NORMAL: boolean;
  19787. MORPHTARGETS_TANGENT: boolean;
  19788. MORPHTARGETS_UV: boolean;
  19789. NUM_MORPH_INFLUENCERS: number;
  19790. MORPHTARGETS_TEXTURE: boolean;
  19791. NONUNIFORMSCALING: boolean;
  19792. PREMULTIPLYALPHA: boolean;
  19793. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  19794. ALPHABLEND: boolean;
  19795. PREPASS: boolean;
  19796. PREPASS_IRRADIANCE: boolean;
  19797. PREPASS_IRRADIANCE_INDEX: number;
  19798. PREPASS_ALBEDO: boolean;
  19799. PREPASS_ALBEDO_INDEX: number;
  19800. PREPASS_DEPTH: boolean;
  19801. PREPASS_DEPTH_INDEX: number;
  19802. PREPASS_NORMAL: boolean;
  19803. PREPASS_NORMAL_INDEX: number;
  19804. PREPASS_POSITION: boolean;
  19805. PREPASS_POSITION_INDEX: number;
  19806. PREPASS_VELOCITY: boolean;
  19807. PREPASS_VELOCITY_INDEX: number;
  19808. PREPASS_REFLECTIVITY: boolean;
  19809. PREPASS_REFLECTIVITY_INDEX: number;
  19810. SCENE_MRT_COUNT: number;
  19811. RGBDLIGHTMAP: boolean;
  19812. RGBDREFLECTION: boolean;
  19813. RGBDREFRACTION: boolean;
  19814. IMAGEPROCESSING: boolean;
  19815. VIGNETTE: boolean;
  19816. VIGNETTEBLENDMODEMULTIPLY: boolean;
  19817. VIGNETTEBLENDMODEOPAQUE: boolean;
  19818. TONEMAPPING: boolean;
  19819. TONEMAPPING_ACES: boolean;
  19820. CONTRAST: boolean;
  19821. COLORCURVES: boolean;
  19822. COLORGRADING: boolean;
  19823. COLORGRADING3D: boolean;
  19824. SAMPLER3DGREENDEPTH: boolean;
  19825. SAMPLER3DBGRMAP: boolean;
  19826. IMAGEPROCESSINGPOSTPROCESS: boolean;
  19827. MULTIVIEW: boolean;
  19828. /**
  19829. * If the reflection texture on this material is in linear color space
  19830. * @hidden
  19831. */
  19832. IS_REFLECTION_LINEAR: boolean;
  19833. /**
  19834. * If the refraction texture on this material is in linear color space
  19835. * @hidden
  19836. */
  19837. IS_REFRACTION_LINEAR: boolean;
  19838. EXPOSURE: boolean;
  19839. constructor();
  19840. setReflectionMode(modeToEnable: string): void;
  19841. }
  19842. /**
  19843. * This is the default material used in Babylon. It is the best trade off between quality
  19844. * and performances.
  19845. * @see https://doc.babylonjs.com/babylon101/materials
  19846. */
  19847. export class StandardMaterial extends PushMaterial {
  19848. private _diffuseTexture;
  19849. /**
  19850. * The basic texture of the material as viewed under a light.
  19851. */
  19852. diffuseTexture: Nullable<BaseTexture>;
  19853. private _ambientTexture;
  19854. /**
  19855. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  19856. */
  19857. ambientTexture: Nullable<BaseTexture>;
  19858. private _opacityTexture;
  19859. /**
  19860. * Define the transparency of the material from a texture.
  19861. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  19862. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  19863. */
  19864. opacityTexture: Nullable<BaseTexture>;
  19865. private _reflectionTexture;
  19866. /**
  19867. * Define the texture used to display the reflection.
  19868. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19869. */
  19870. reflectionTexture: Nullable<BaseTexture>;
  19871. private _emissiveTexture;
  19872. /**
  19873. * Define texture of the material as if self lit.
  19874. * This will be mixed in the final result even in the absence of light.
  19875. */
  19876. emissiveTexture: Nullable<BaseTexture>;
  19877. private _specularTexture;
  19878. /**
  19879. * Define how the color and intensity of the highlight given by the light in the material.
  19880. */
  19881. specularTexture: Nullable<BaseTexture>;
  19882. private _bumpTexture;
  19883. /**
  19884. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19885. * 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.
  19886. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  19887. */
  19888. bumpTexture: Nullable<BaseTexture>;
  19889. private _lightmapTexture;
  19890. /**
  19891. * Complex lighting can be computationally expensive to compute at runtime.
  19892. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19893. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  19894. */
  19895. lightmapTexture: Nullable<BaseTexture>;
  19896. private _refractionTexture;
  19897. /**
  19898. * Define the texture used to display the refraction.
  19899. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19900. */
  19901. refractionTexture: Nullable<BaseTexture>;
  19902. /**
  19903. * The color of the material lit by the environmental background lighting.
  19904. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19905. */
  19906. ambientColor: Color3;
  19907. /**
  19908. * The basic color of the material as viewed under a light.
  19909. */
  19910. diffuseColor: Color3;
  19911. /**
  19912. * Define how the color and intensity of the highlight given by the light in the material.
  19913. */
  19914. specularColor: Color3;
  19915. /**
  19916. * Define the color of the material as if self lit.
  19917. * This will be mixed in the final result even in the absence of light.
  19918. */
  19919. emissiveColor: Color3;
  19920. /**
  19921. * Defines how sharp are the highlights in the material.
  19922. * The bigger the value the sharper giving a more glossy feeling to the result.
  19923. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19924. */
  19925. specularPower: number;
  19926. private _useAlphaFromDiffuseTexture;
  19927. /**
  19928. * Does the transparency come from the diffuse texture alpha channel.
  19929. */
  19930. useAlphaFromDiffuseTexture: boolean;
  19931. private _useEmissiveAsIllumination;
  19932. /**
  19933. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19934. */
  19935. useEmissiveAsIllumination: boolean;
  19936. private _linkEmissiveWithDiffuse;
  19937. /**
  19938. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19939. * the emissive level when the final color is close to one.
  19940. */
  19941. linkEmissiveWithDiffuse: boolean;
  19942. private _useSpecularOverAlpha;
  19943. /**
  19944. * Specifies that the material will keep the specular highlights over a transparent surface (only the most luminous ones).
  19945. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19946. */
  19947. useSpecularOverAlpha: boolean;
  19948. private _useReflectionOverAlpha;
  19949. /**
  19950. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  19951. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19952. */
  19953. useReflectionOverAlpha: boolean;
  19954. private _disableLighting;
  19955. /**
  19956. * Does lights from the scene impacts this material.
  19957. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19958. */
  19959. disableLighting: boolean;
  19960. private _useObjectSpaceNormalMap;
  19961. /**
  19962. * Allows using an object space normal map (instead of tangent space).
  19963. */
  19964. useObjectSpaceNormalMap: boolean;
  19965. private _useParallax;
  19966. /**
  19967. * Is parallax enabled or not.
  19968. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19969. */
  19970. useParallax: boolean;
  19971. private _useParallaxOcclusion;
  19972. /**
  19973. * Is parallax occlusion enabled or not.
  19974. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19975. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19976. */
  19977. useParallaxOcclusion: boolean;
  19978. /**
  19979. * 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.
  19980. */
  19981. parallaxScaleBias: number;
  19982. private _roughness;
  19983. /**
  19984. * Helps to define how blurry the reflections should appears in the material.
  19985. */
  19986. roughness: number;
  19987. /**
  19988. * In case of refraction, define the value of the index of refraction.
  19989. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19990. */
  19991. indexOfRefraction: number;
  19992. /**
  19993. * Invert the refraction texture alongside the y axis.
  19994. * It can be useful with procedural textures or probe for instance.
  19995. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19996. */
  19997. invertRefractionY: boolean;
  19998. /**
  19999. * Defines the alpha limits in alpha test mode.
  20000. */
  20001. alphaCutOff: number;
  20002. private _useLightmapAsShadowmap;
  20003. /**
  20004. * In case of light mapping, define whether the map contains light or shadow informations.
  20005. */
  20006. useLightmapAsShadowmap: boolean;
  20007. private _diffuseFresnelParameters;
  20008. /**
  20009. * Define the diffuse fresnel parameters of the material.
  20010. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20011. */
  20012. diffuseFresnelParameters: FresnelParameters;
  20013. private _opacityFresnelParameters;
  20014. /**
  20015. * Define the opacity fresnel parameters of the material.
  20016. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20017. */
  20018. opacityFresnelParameters: FresnelParameters;
  20019. private _reflectionFresnelParameters;
  20020. /**
  20021. * Define the reflection fresnel parameters of the material.
  20022. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20023. */
  20024. reflectionFresnelParameters: FresnelParameters;
  20025. private _refractionFresnelParameters;
  20026. /**
  20027. * Define the refraction fresnel parameters of the material.
  20028. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20029. */
  20030. refractionFresnelParameters: FresnelParameters;
  20031. private _emissiveFresnelParameters;
  20032. /**
  20033. * Define the emissive fresnel parameters of the material.
  20034. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20035. */
  20036. emissiveFresnelParameters: FresnelParameters;
  20037. private _useReflectionFresnelFromSpecular;
  20038. /**
  20039. * If true automatically deducts the fresnels values from the material specularity.
  20040. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20041. */
  20042. useReflectionFresnelFromSpecular: boolean;
  20043. private _useGlossinessFromSpecularMapAlpha;
  20044. /**
  20045. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  20046. */
  20047. useGlossinessFromSpecularMapAlpha: boolean;
  20048. private _maxSimultaneousLights;
  20049. /**
  20050. * Defines the maximum number of lights that can be used in the material
  20051. */
  20052. maxSimultaneousLights: number;
  20053. private _invertNormalMapX;
  20054. /**
  20055. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  20056. */
  20057. invertNormalMapX: boolean;
  20058. private _invertNormalMapY;
  20059. /**
  20060. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  20061. */
  20062. invertNormalMapY: boolean;
  20063. private _twoSidedLighting;
  20064. /**
  20065. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  20066. */
  20067. twoSidedLighting: boolean;
  20068. /**
  20069. * Default configuration related to image processing available in the standard Material.
  20070. */
  20071. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  20072. /**
  20073. * Gets the image processing configuration used either in this material.
  20074. */
  20075. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  20076. /**
  20077. * Sets the Default image processing configuration used either in the this material.
  20078. *
  20079. * If sets to null, the scene one is in use.
  20080. */
  20081. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  20082. /**
  20083. * Keep track of the image processing observer to allow dispose and replace.
  20084. */
  20085. private _imageProcessingObserver;
  20086. /**
  20087. * Attaches a new image processing configuration to the Standard Material.
  20088. * @param configuration
  20089. */
  20090. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  20091. /**
  20092. * Defines additional PrePass parameters for the material.
  20093. */
  20094. readonly prePassConfiguration: PrePassConfiguration;
  20095. /**
  20096. * Can this material render to prepass
  20097. */
  20098. get isPrePassCapable(): boolean;
  20099. /**
  20100. * Gets whether the color curves effect is enabled.
  20101. */
  20102. get cameraColorCurvesEnabled(): boolean;
  20103. /**
  20104. * Sets whether the color curves effect is enabled.
  20105. */
  20106. set cameraColorCurvesEnabled(value: boolean);
  20107. /**
  20108. * Gets whether the color grading effect is enabled.
  20109. */
  20110. get cameraColorGradingEnabled(): boolean;
  20111. /**
  20112. * Gets whether the color grading effect is enabled.
  20113. */
  20114. set cameraColorGradingEnabled(value: boolean);
  20115. /**
  20116. * Gets whether tonemapping is enabled or not.
  20117. */
  20118. get cameraToneMappingEnabled(): boolean;
  20119. /**
  20120. * Sets whether tonemapping is enabled or not
  20121. */
  20122. set cameraToneMappingEnabled(value: boolean);
  20123. /**
  20124. * The camera exposure used on this material.
  20125. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  20126. * This corresponds to a photographic exposure.
  20127. */
  20128. get cameraExposure(): number;
  20129. /**
  20130. * The camera exposure used on this material.
  20131. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  20132. * This corresponds to a photographic exposure.
  20133. */
  20134. set cameraExposure(value: number);
  20135. /**
  20136. * Gets The camera contrast used on this material.
  20137. */
  20138. get cameraContrast(): number;
  20139. /**
  20140. * Sets The camera contrast used on this material.
  20141. */
  20142. set cameraContrast(value: number);
  20143. /**
  20144. * Gets the Color Grading 2D Lookup Texture.
  20145. */
  20146. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  20147. /**
  20148. * Sets the Color Grading 2D Lookup Texture.
  20149. */
  20150. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  20151. /**
  20152. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  20153. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  20154. * 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;
  20155. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  20156. */
  20157. get cameraColorCurves(): Nullable<ColorCurves>;
  20158. /**
  20159. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  20160. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  20161. * 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;
  20162. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  20163. */
  20164. set cameraColorCurves(value: Nullable<ColorCurves>);
  20165. /**
  20166. * Can this material render to several textures at once
  20167. */
  20168. get canRenderToMRT(): boolean;
  20169. /**
  20170. * Defines the detail map parameters for the material.
  20171. */
  20172. readonly detailMap: DetailMapConfiguration;
  20173. protected _renderTargets: SmartArray<RenderTargetTexture>;
  20174. protected _worldViewProjectionMatrix: Matrix;
  20175. protected _globalAmbientColor: Color3;
  20176. protected _useLogarithmicDepth: boolean;
  20177. protected _rebuildInParallel: boolean;
  20178. /**
  20179. * Instantiates a new standard material.
  20180. * This is the default material used in Babylon. It is the best trade off between quality
  20181. * and performances.
  20182. * @see https://doc.babylonjs.com/babylon101/materials
  20183. * @param name Define the name of the material in the scene
  20184. * @param scene Define the scene the material belong to
  20185. */
  20186. constructor(name: string, scene: Scene);
  20187. /**
  20188. * Gets a boolean indicating that current material needs to register RTT
  20189. */
  20190. get hasRenderTargetTextures(): boolean;
  20191. /**
  20192. * Gets the current class name of the material e.g. "StandardMaterial"
  20193. * Mainly use in serialization.
  20194. * @returns the class name
  20195. */
  20196. getClassName(): string;
  20197. /**
  20198. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  20199. * You can try switching to logarithmic depth.
  20200. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  20201. */
  20202. get useLogarithmicDepth(): boolean;
  20203. set useLogarithmicDepth(value: boolean);
  20204. /**
  20205. * Specifies if the material will require alpha blending
  20206. * @returns a boolean specifying if alpha blending is needed
  20207. */
  20208. needAlphaBlending(): boolean;
  20209. /**
  20210. * Specifies if this material should be rendered in alpha test mode
  20211. * @returns a boolean specifying if an alpha test is needed.
  20212. */
  20213. needAlphaTesting(): boolean;
  20214. /**
  20215. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  20216. */
  20217. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  20218. /**
  20219. * Specifies whether or not there is a usable alpha channel for transparency.
  20220. */
  20221. protected _hasAlphaChannel(): boolean;
  20222. /**
  20223. * Get the texture used for alpha test purpose.
  20224. * @returns the diffuse texture in case of the standard material.
  20225. */
  20226. getAlphaTestTexture(): Nullable<BaseTexture>;
  20227. /**
  20228. * Get if the submesh is ready to be used and all its information available.
  20229. * Child classes can use it to update shaders
  20230. * @param mesh defines the mesh to check
  20231. * @param subMesh defines which submesh to check
  20232. * @param useInstances specifies that instances should be used
  20233. * @returns a boolean indicating that the submesh is ready or not
  20234. */
  20235. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  20236. /**
  20237. * Builds the material UBO layouts.
  20238. * Used internally during the effect preparation.
  20239. */
  20240. buildUniformLayout(): void;
  20241. /**
  20242. * Unbinds the material from the mesh
  20243. */
  20244. unbind(): void;
  20245. /**
  20246. * Binds the submesh to this material by preparing the effect and shader to draw
  20247. * @param world defines the world transformation matrix
  20248. * @param mesh defines the mesh containing the submesh
  20249. * @param subMesh defines the submesh to bind the material to
  20250. */
  20251. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20252. /**
  20253. * Get the list of animatables in the material.
  20254. * @returns the list of animatables object used in the material
  20255. */
  20256. getAnimatables(): IAnimatable[];
  20257. /**
  20258. * Gets the active textures from the material
  20259. * @returns an array of textures
  20260. */
  20261. getActiveTextures(): BaseTexture[];
  20262. /**
  20263. * Specifies if the material uses a texture
  20264. * @param texture defines the texture to check against the material
  20265. * @returns a boolean specifying if the material uses the texture
  20266. */
  20267. hasTexture(texture: BaseTexture): boolean;
  20268. /**
  20269. * Disposes the material
  20270. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20271. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20272. */
  20273. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  20274. /**
  20275. * Makes a duplicate of the material, and gives it a new name
  20276. * @param name defines the new name for the duplicated material
  20277. * @returns the cloned material
  20278. */
  20279. clone(name: string): StandardMaterial;
  20280. /**
  20281. * Serializes this material in a JSON representation
  20282. * @returns the serialized material object
  20283. */
  20284. serialize(): any;
  20285. /**
  20286. * Creates a standard material from parsed material data
  20287. * @param source defines the JSON representation of the material
  20288. * @param scene defines the hosting scene
  20289. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20290. * @returns a new standard material
  20291. */
  20292. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  20293. /**
  20294. * Are diffuse textures enabled in the application.
  20295. */
  20296. static get DiffuseTextureEnabled(): boolean;
  20297. static set DiffuseTextureEnabled(value: boolean);
  20298. /**
  20299. * Are detail textures enabled in the application.
  20300. */
  20301. static get DetailTextureEnabled(): boolean;
  20302. static set DetailTextureEnabled(value: boolean);
  20303. /**
  20304. * Are ambient textures enabled in the application.
  20305. */
  20306. static get AmbientTextureEnabled(): boolean;
  20307. static set AmbientTextureEnabled(value: boolean);
  20308. /**
  20309. * Are opacity textures enabled in the application.
  20310. */
  20311. static get OpacityTextureEnabled(): boolean;
  20312. static set OpacityTextureEnabled(value: boolean);
  20313. /**
  20314. * Are reflection textures enabled in the application.
  20315. */
  20316. static get ReflectionTextureEnabled(): boolean;
  20317. static set ReflectionTextureEnabled(value: boolean);
  20318. /**
  20319. * Are emissive textures enabled in the application.
  20320. */
  20321. static get EmissiveTextureEnabled(): boolean;
  20322. static set EmissiveTextureEnabled(value: boolean);
  20323. /**
  20324. * Are specular textures enabled in the application.
  20325. */
  20326. static get SpecularTextureEnabled(): boolean;
  20327. static set SpecularTextureEnabled(value: boolean);
  20328. /**
  20329. * Are bump textures enabled in the application.
  20330. */
  20331. static get BumpTextureEnabled(): boolean;
  20332. static set BumpTextureEnabled(value: boolean);
  20333. /**
  20334. * Are lightmap textures enabled in the application.
  20335. */
  20336. static get LightmapTextureEnabled(): boolean;
  20337. static set LightmapTextureEnabled(value: boolean);
  20338. /**
  20339. * Are refraction textures enabled in the application.
  20340. */
  20341. static get RefractionTextureEnabled(): boolean;
  20342. static set RefractionTextureEnabled(value: boolean);
  20343. /**
  20344. * Are color grading textures enabled in the application.
  20345. */
  20346. static get ColorGradingTextureEnabled(): boolean;
  20347. static set ColorGradingTextureEnabled(value: boolean);
  20348. /**
  20349. * Are fresnels enabled in the application.
  20350. */
  20351. static get FresnelEnabled(): boolean;
  20352. static set FresnelEnabled(value: boolean);
  20353. }
  20354. }
  20355. declare module BABYLON {
  20356. /** @hidden */
  20357. export var rgbdDecodePixelShader: {
  20358. name: string;
  20359. shader: string;
  20360. };
  20361. }
  20362. declare module BABYLON {
  20363. /** @hidden */
  20364. export var passPixelShader: {
  20365. name: string;
  20366. shader: string;
  20367. };
  20368. }
  20369. declare module BABYLON {
  20370. /** @hidden */
  20371. export var passCubePixelShader: {
  20372. name: string;
  20373. shader: string;
  20374. };
  20375. }
  20376. declare module BABYLON {
  20377. /**
  20378. * PassPostProcess which produces an output the same as it's input
  20379. */
  20380. export class PassPostProcess extends PostProcess {
  20381. /**
  20382. * Gets a string identifying the name of the class
  20383. * @returns "PassPostProcess" string
  20384. */
  20385. getClassName(): string;
  20386. /**
  20387. * Creates the PassPostProcess
  20388. * @param name The name of the effect.
  20389. * @param options The required width/height ratio to downsize to before computing the render pass.
  20390. * @param camera The camera to apply the render pass to.
  20391. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20392. * @param engine The engine which the post process will be applied. (default: current engine)
  20393. * @param reusable If the post process can be reused on the same frame. (default: false)
  20394. * @param textureType The type of texture to be used when performing the post processing.
  20395. * @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)
  20396. */
  20397. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20398. /** @hidden */
  20399. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  20400. }
  20401. /**
  20402. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  20403. */
  20404. export class PassCubePostProcess extends PostProcess {
  20405. private _face;
  20406. /**
  20407. * Gets or sets the cube face to display.
  20408. * * 0 is +X
  20409. * * 1 is -X
  20410. * * 2 is +Y
  20411. * * 3 is -Y
  20412. * * 4 is +Z
  20413. * * 5 is -Z
  20414. */
  20415. get face(): number;
  20416. set face(value: number);
  20417. /**
  20418. * Gets a string identifying the name of the class
  20419. * @returns "PassCubePostProcess" string
  20420. */
  20421. getClassName(): string;
  20422. /**
  20423. * Creates the PassCubePostProcess
  20424. * @param name The name of the effect.
  20425. * @param options The required width/height ratio to downsize to before computing the render pass.
  20426. * @param camera The camera to apply the render pass to.
  20427. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20428. * @param engine The engine which the post process will be applied. (default: current engine)
  20429. * @param reusable If the post process can be reused on the same frame. (default: false)
  20430. * @param textureType The type of texture to be used when performing the post processing.
  20431. * @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)
  20432. */
  20433. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20434. /** @hidden */
  20435. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  20436. }
  20437. }
  20438. declare module BABYLON {
  20439. /**
  20440. * Class used to host texture specific utilities
  20441. */
  20442. export class TextureTools {
  20443. /**
  20444. * Uses the GPU to create a copy texture rescaled at a given size
  20445. * @param texture Texture to copy from
  20446. * @param width defines the desired width
  20447. * @param height defines the desired height
  20448. * @param useBilinearMode defines if bilinear mode has to be used
  20449. * @return the generated texture
  20450. */
  20451. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  20452. /**
  20453. * Apply a post process to a texture
  20454. * @param postProcessName name of the fragment post process
  20455. * @param internalTexture the texture to encode
  20456. * @param scene the scene hosting the texture
  20457. * @param type type of the output texture. If not provided, use the one from internalTexture
  20458. * @param samplingMode sampling mode to use to sample the source texture. If not provided, use the one from internalTexture
  20459. * @param format format of the output texture. If not provided, use the one from internalTexture
  20460. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  20461. */
  20462. static ApplyPostProcess(postProcessName: string, internalTexture: InternalTexture, scene: Scene, type?: number, samplingMode?: number, format?: number): Promise<InternalTexture>;
  20463. }
  20464. }
  20465. declare module BABYLON {
  20466. /**
  20467. * Class used to host RGBD texture specific utilities
  20468. */
  20469. export class RGBDTextureTools {
  20470. /**
  20471. * Expand the RGBD Texture from RGBD to Half Float if possible.
  20472. * @param texture the texture to expand.
  20473. */
  20474. static ExpandRGBDTexture(texture: Texture): void;
  20475. /**
  20476. * Encode the texture to RGBD if possible.
  20477. * @param internalTexture the texture to encode
  20478. * @param scene the scene hosting the texture
  20479. * @param outputTextureType type of the texture in which the encoding is performed
  20480. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  20481. */
  20482. static EncodeTextureToRGBD(internalTexture: InternalTexture, scene: Scene, outputTextureType?: number): Promise<InternalTexture>;
  20483. }
  20484. }
  20485. declare module BABYLON {
  20486. /**
  20487. * Class used to host texture specific utilities
  20488. */
  20489. export class BRDFTextureTools {
  20490. /**
  20491. * Prevents texture cache collision
  20492. */
  20493. private static _instanceNumber;
  20494. /**
  20495. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  20496. * @param scene defines the hosting scene
  20497. * @returns the environment BRDF texture
  20498. */
  20499. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  20500. private static _environmentBRDFBase64Texture;
  20501. }
  20502. }
  20503. declare module BABYLON {
  20504. /**
  20505. * @hidden
  20506. */
  20507. export interface IMaterialClearCoatDefines {
  20508. CLEARCOAT: boolean;
  20509. CLEARCOAT_DEFAULTIOR: boolean;
  20510. CLEARCOAT_TEXTURE: boolean;
  20511. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  20512. CLEARCOAT_TEXTUREDIRECTUV: number;
  20513. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  20514. CLEARCOAT_BUMP: boolean;
  20515. CLEARCOAT_BUMPDIRECTUV: number;
  20516. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20517. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20518. CLEARCOAT_REMAP_F0: boolean;
  20519. CLEARCOAT_TINT: boolean;
  20520. CLEARCOAT_TINT_TEXTURE: boolean;
  20521. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  20522. /** @hidden */
  20523. _areTexturesDirty: boolean;
  20524. }
  20525. /**
  20526. * Define the code related to the clear coat parameters of the pbr material.
  20527. */
  20528. export class PBRClearCoatConfiguration {
  20529. /**
  20530. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20531. * The default fits with a polyurethane material.
  20532. * @hidden
  20533. */
  20534. static readonly _DefaultIndexOfRefraction: number;
  20535. private _isEnabled;
  20536. /**
  20537. * Defines if the clear coat is enabled in the material.
  20538. */
  20539. isEnabled: boolean;
  20540. /**
  20541. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  20542. */
  20543. intensity: number;
  20544. /**
  20545. * Defines the clear coat layer roughness.
  20546. */
  20547. roughness: number;
  20548. private _indexOfRefraction;
  20549. /**
  20550. * Defines the index of refraction of the clear coat.
  20551. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20552. * The default fits with a polyurethane material.
  20553. * Changing the default value is more performance intensive.
  20554. */
  20555. indexOfRefraction: number;
  20556. private _texture;
  20557. /**
  20558. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  20559. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  20560. * if textureRoughness is not empty, else no texture roughness is used
  20561. */
  20562. texture: Nullable<BaseTexture>;
  20563. private _useRoughnessFromMainTexture;
  20564. /**
  20565. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  20566. * If false, the green channel from textureRoughness is used for roughness
  20567. */
  20568. useRoughnessFromMainTexture: boolean;
  20569. private _textureRoughness;
  20570. /**
  20571. * Stores the clear coat roughness in a texture (green channel)
  20572. * Not used if useRoughnessFromMainTexture is true
  20573. */
  20574. textureRoughness: Nullable<BaseTexture>;
  20575. private _remapF0OnInterfaceChange;
  20576. /**
  20577. * Defines if the F0 value should be remapped to account for the interface change in the material.
  20578. */
  20579. remapF0OnInterfaceChange: boolean;
  20580. private _bumpTexture;
  20581. /**
  20582. * Define the clear coat specific bump texture.
  20583. */
  20584. bumpTexture: Nullable<BaseTexture>;
  20585. private _isTintEnabled;
  20586. /**
  20587. * Defines if the clear coat tint is enabled in the material.
  20588. */
  20589. isTintEnabled: boolean;
  20590. /**
  20591. * Defines the clear coat tint of the material.
  20592. * This is only use if tint is enabled
  20593. */
  20594. tintColor: Color3;
  20595. /**
  20596. * Defines the distance at which the tint color should be found in the
  20597. * clear coat media.
  20598. * This is only use if tint is enabled
  20599. */
  20600. tintColorAtDistance: number;
  20601. /**
  20602. * Defines the clear coat layer thickness.
  20603. * This is only use if tint is enabled
  20604. */
  20605. tintThickness: number;
  20606. private _tintTexture;
  20607. /**
  20608. * Stores the clear tint values in a texture.
  20609. * rgb is tint
  20610. * a is a thickness factor
  20611. */
  20612. tintTexture: Nullable<BaseTexture>;
  20613. /** @hidden */
  20614. private _internalMarkAllSubMeshesAsTexturesDirty;
  20615. /** @hidden */
  20616. _markAllSubMeshesAsTexturesDirty(): void;
  20617. /**
  20618. * Instantiate a new instance of clear coat configuration.
  20619. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20620. */
  20621. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20622. /**
  20623. * Gets whether the submesh is ready to be used or not.
  20624. * @param defines the list of "defines" to update.
  20625. * @param scene defines the scene the material belongs to.
  20626. * @param engine defines the engine the material belongs to.
  20627. * @param disableBumpMap defines whether the material disables bump or not.
  20628. * @returns - boolean indicating that the submesh is ready or not.
  20629. */
  20630. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  20631. /**
  20632. * Checks to see if a texture is used in the material.
  20633. * @param defines the list of "defines" to update.
  20634. * @param scene defines the scene to the material belongs to.
  20635. */
  20636. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  20637. /**
  20638. * Binds the material data.
  20639. * @param uniformBuffer defines the Uniform buffer to fill in.
  20640. * @param scene defines the scene the material belongs to.
  20641. * @param engine defines the engine the material belongs to.
  20642. * @param disableBumpMap defines whether the material disables bump or not.
  20643. * @param isFrozen defines whether the material is frozen or not.
  20644. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  20645. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  20646. * @param subMesh the submesh to bind data for
  20647. */
  20648. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  20649. /**
  20650. * Checks to see if a texture is used in the material.
  20651. * @param texture - Base texture to use.
  20652. * @returns - Boolean specifying if a texture is used in the material.
  20653. */
  20654. hasTexture(texture: BaseTexture): boolean;
  20655. /**
  20656. * Returns an array of the actively used textures.
  20657. * @param activeTextures Array of BaseTextures
  20658. */
  20659. getActiveTextures(activeTextures: BaseTexture[]): void;
  20660. /**
  20661. * Returns the animatable textures.
  20662. * @param animatables Array of animatable textures.
  20663. */
  20664. getAnimatables(animatables: IAnimatable[]): void;
  20665. /**
  20666. * Disposes the resources of the material.
  20667. * @param forceDisposeTextures - Forces the disposal of all textures.
  20668. */
  20669. dispose(forceDisposeTextures?: boolean): void;
  20670. /**
  20671. * Get the current class name of the texture useful for serialization or dynamic coding.
  20672. * @returns "PBRClearCoatConfiguration"
  20673. */
  20674. getClassName(): string;
  20675. /**
  20676. * Add fallbacks to the effect fallbacks list.
  20677. * @param defines defines the Base texture to use.
  20678. * @param fallbacks defines the current fallback list.
  20679. * @param currentRank defines the current fallback rank.
  20680. * @returns the new fallback rank.
  20681. */
  20682. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20683. /**
  20684. * Add the required uniforms to the current list.
  20685. * @param uniforms defines the current uniform list.
  20686. */
  20687. static AddUniforms(uniforms: string[]): void;
  20688. /**
  20689. * Add the required samplers to the current list.
  20690. * @param samplers defines the current sampler list.
  20691. */
  20692. static AddSamplers(samplers: string[]): void;
  20693. /**
  20694. * Add the required uniforms to the current buffer.
  20695. * @param uniformBuffer defines the current uniform buffer.
  20696. */
  20697. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20698. /**
  20699. * Makes a duplicate of the current configuration into another one.
  20700. * @param clearCoatConfiguration define the config where to copy the info
  20701. */
  20702. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  20703. /**
  20704. * Serializes this clear coat configuration.
  20705. * @returns - An object with the serialized config.
  20706. */
  20707. serialize(): any;
  20708. /**
  20709. * Parses a anisotropy Configuration from a serialized object.
  20710. * @param source - Serialized object.
  20711. * @param scene Defines the scene we are parsing for
  20712. * @param rootUrl Defines the rootUrl to load from
  20713. */
  20714. parse(source: any, scene: Scene, rootUrl: string): void;
  20715. }
  20716. }
  20717. declare module BABYLON {
  20718. /**
  20719. * @hidden
  20720. */
  20721. export interface IMaterialAnisotropicDefines {
  20722. ANISOTROPIC: boolean;
  20723. ANISOTROPIC_TEXTURE: boolean;
  20724. ANISOTROPIC_TEXTUREDIRECTUV: number;
  20725. MAINUV1: boolean;
  20726. _areTexturesDirty: boolean;
  20727. _needUVs: boolean;
  20728. }
  20729. /**
  20730. * Define the code related to the anisotropic parameters of the pbr material.
  20731. */
  20732. export class PBRAnisotropicConfiguration {
  20733. private _isEnabled;
  20734. /**
  20735. * Defines if the anisotropy is enabled in the material.
  20736. */
  20737. isEnabled: boolean;
  20738. /**
  20739. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  20740. */
  20741. intensity: number;
  20742. /**
  20743. * Defines if the effect is along the tangents, bitangents or in between.
  20744. * By default, the effect is "stretching" the highlights along the tangents.
  20745. */
  20746. direction: Vector2;
  20747. private _texture;
  20748. /**
  20749. * Stores the anisotropy values in a texture.
  20750. * rg is direction (like normal from -1 to 1)
  20751. * b is a intensity
  20752. */
  20753. texture: Nullable<BaseTexture>;
  20754. /** @hidden */
  20755. private _internalMarkAllSubMeshesAsTexturesDirty;
  20756. /** @hidden */
  20757. _markAllSubMeshesAsTexturesDirty(): void;
  20758. /**
  20759. * Instantiate a new instance of anisotropy configuration.
  20760. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20761. */
  20762. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20763. /**
  20764. * Specifies that the submesh is ready to be used.
  20765. * @param defines the list of "defines" to update.
  20766. * @param scene defines the scene the material belongs to.
  20767. * @returns - boolean indicating that the submesh is ready or not.
  20768. */
  20769. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  20770. /**
  20771. * Checks to see if a texture is used in the material.
  20772. * @param defines the list of "defines" to update.
  20773. * @param mesh the mesh we are preparing the defines for.
  20774. * @param scene defines the scene the material belongs to.
  20775. */
  20776. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  20777. /**
  20778. * Binds the material data.
  20779. * @param uniformBuffer defines the Uniform buffer to fill in.
  20780. * @param scene defines the scene the material belongs to.
  20781. * @param isFrozen defines whether the material is frozen or not.
  20782. */
  20783. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  20784. /**
  20785. * Checks to see if a texture is used in the material.
  20786. * @param texture - Base texture to use.
  20787. * @returns - Boolean specifying if a texture is used in the material.
  20788. */
  20789. hasTexture(texture: BaseTexture): boolean;
  20790. /**
  20791. * Returns an array of the actively used textures.
  20792. * @param activeTextures Array of BaseTextures
  20793. */
  20794. getActiveTextures(activeTextures: BaseTexture[]): void;
  20795. /**
  20796. * Returns the animatable textures.
  20797. * @param animatables Array of animatable textures.
  20798. */
  20799. getAnimatables(animatables: IAnimatable[]): void;
  20800. /**
  20801. * Disposes the resources of the material.
  20802. * @param forceDisposeTextures - Forces the disposal of all textures.
  20803. */
  20804. dispose(forceDisposeTextures?: boolean): void;
  20805. /**
  20806. * Get the current class name of the texture useful for serialization or dynamic coding.
  20807. * @returns "PBRAnisotropicConfiguration"
  20808. */
  20809. getClassName(): string;
  20810. /**
  20811. * Add fallbacks to the effect fallbacks list.
  20812. * @param defines defines the Base texture to use.
  20813. * @param fallbacks defines the current fallback list.
  20814. * @param currentRank defines the current fallback rank.
  20815. * @returns the new fallback rank.
  20816. */
  20817. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20818. /**
  20819. * Add the required uniforms to the current list.
  20820. * @param uniforms defines the current uniform list.
  20821. */
  20822. static AddUniforms(uniforms: string[]): void;
  20823. /**
  20824. * Add the required uniforms to the current buffer.
  20825. * @param uniformBuffer defines the current uniform buffer.
  20826. */
  20827. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20828. /**
  20829. * Add the required samplers to the current list.
  20830. * @param samplers defines the current sampler list.
  20831. */
  20832. static AddSamplers(samplers: string[]): void;
  20833. /**
  20834. * Makes a duplicate of the current configuration into another one.
  20835. * @param anisotropicConfiguration define the config where to copy the info
  20836. */
  20837. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  20838. /**
  20839. * Serializes this anisotropy configuration.
  20840. * @returns - An object with the serialized config.
  20841. */
  20842. serialize(): any;
  20843. /**
  20844. * Parses a anisotropy Configuration from a serialized object.
  20845. * @param source - Serialized object.
  20846. * @param scene Defines the scene we are parsing for
  20847. * @param rootUrl Defines the rootUrl to load from
  20848. */
  20849. parse(source: any, scene: Scene, rootUrl: string): void;
  20850. }
  20851. }
  20852. declare module BABYLON {
  20853. /**
  20854. * @hidden
  20855. */
  20856. export interface IMaterialBRDFDefines {
  20857. BRDF_V_HEIGHT_CORRELATED: boolean;
  20858. MS_BRDF_ENERGY_CONSERVATION: boolean;
  20859. SPHERICAL_HARMONICS: boolean;
  20860. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  20861. /** @hidden */
  20862. _areMiscDirty: boolean;
  20863. }
  20864. /**
  20865. * Define the code related to the BRDF parameters of the pbr material.
  20866. */
  20867. export class PBRBRDFConfiguration {
  20868. /**
  20869. * Default value used for the energy conservation.
  20870. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20871. */
  20872. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  20873. /**
  20874. * Default value used for the Smith Visibility Height Correlated mode.
  20875. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20876. */
  20877. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  20878. /**
  20879. * Default value used for the IBL diffuse part.
  20880. * This can help switching back to the polynomials mode globally which is a tiny bit
  20881. * less GPU intensive at the drawback of a lower quality.
  20882. */
  20883. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  20884. /**
  20885. * Default value used for activating energy conservation for the specular workflow.
  20886. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20887. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20888. */
  20889. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  20890. private _useEnergyConservation;
  20891. /**
  20892. * Defines if the material uses energy conservation.
  20893. */
  20894. useEnergyConservation: boolean;
  20895. private _useSmithVisibilityHeightCorrelated;
  20896. /**
  20897. * LEGACY Mode set to false
  20898. * Defines if the material uses height smith correlated visibility term.
  20899. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  20900. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  20901. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  20902. * Not relying on height correlated will also disable energy conservation.
  20903. */
  20904. useSmithVisibilityHeightCorrelated: boolean;
  20905. private _useSphericalHarmonics;
  20906. /**
  20907. * LEGACY Mode set to false
  20908. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  20909. * diffuse part of the IBL.
  20910. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  20911. * to the ground truth.
  20912. */
  20913. useSphericalHarmonics: boolean;
  20914. private _useSpecularGlossinessInputEnergyConservation;
  20915. /**
  20916. * Defines if the material uses energy conservation, when the specular workflow is active.
  20917. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20918. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20919. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  20920. */
  20921. useSpecularGlossinessInputEnergyConservation: boolean;
  20922. /** @hidden */
  20923. private _internalMarkAllSubMeshesAsMiscDirty;
  20924. /** @hidden */
  20925. _markAllSubMeshesAsMiscDirty(): void;
  20926. /**
  20927. * Instantiate a new instance of clear coat configuration.
  20928. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  20929. */
  20930. constructor(markAllSubMeshesAsMiscDirty: () => void);
  20931. /**
  20932. * Checks to see if a texture is used in the material.
  20933. * @param defines the list of "defines" to update.
  20934. */
  20935. prepareDefines(defines: IMaterialBRDFDefines): void;
  20936. /**
  20937. * Get the current class name of the texture useful for serialization or dynamic coding.
  20938. * @returns "PBRClearCoatConfiguration"
  20939. */
  20940. getClassName(): string;
  20941. /**
  20942. * Makes a duplicate of the current configuration into another one.
  20943. * @param brdfConfiguration define the config where to copy the info
  20944. */
  20945. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  20946. /**
  20947. * Serializes this BRDF configuration.
  20948. * @returns - An object with the serialized config.
  20949. */
  20950. serialize(): any;
  20951. /**
  20952. * Parses a anisotropy Configuration from a serialized object.
  20953. * @param source - Serialized object.
  20954. * @param scene Defines the scene we are parsing for
  20955. * @param rootUrl Defines the rootUrl to load from
  20956. */
  20957. parse(source: any, scene: Scene, rootUrl: string): void;
  20958. }
  20959. }
  20960. declare module BABYLON {
  20961. /**
  20962. * @hidden
  20963. */
  20964. export interface IMaterialSheenDefines {
  20965. SHEEN: boolean;
  20966. SHEEN_TEXTURE: boolean;
  20967. SHEEN_TEXTURE_ROUGHNESS: boolean;
  20968. SHEEN_TEXTUREDIRECTUV: number;
  20969. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  20970. SHEEN_LINKWITHALBEDO: boolean;
  20971. SHEEN_ROUGHNESS: boolean;
  20972. SHEEN_ALBEDOSCALING: boolean;
  20973. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20974. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20975. /** @hidden */
  20976. _areTexturesDirty: boolean;
  20977. }
  20978. /**
  20979. * Define the code related to the Sheen parameters of the pbr material.
  20980. */
  20981. export class PBRSheenConfiguration {
  20982. private _isEnabled;
  20983. /**
  20984. * Defines if the material uses sheen.
  20985. */
  20986. isEnabled: boolean;
  20987. private _linkSheenWithAlbedo;
  20988. /**
  20989. * Defines if the sheen is linked to the sheen color.
  20990. */
  20991. linkSheenWithAlbedo: boolean;
  20992. /**
  20993. * Defines the sheen intensity.
  20994. */
  20995. intensity: number;
  20996. /**
  20997. * Defines the sheen color.
  20998. */
  20999. color: Color3;
  21000. private _texture;
  21001. /**
  21002. * Stores the sheen tint values in a texture.
  21003. * rgb is tint
  21004. * 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)
  21005. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  21006. */
  21007. texture: Nullable<BaseTexture>;
  21008. private _useRoughnessFromMainTexture;
  21009. /**
  21010. * Indicates that the alpha channel of the texture property will be used for roughness.
  21011. * Has no effect if the roughness (and texture!) property is not defined
  21012. */
  21013. useRoughnessFromMainTexture: boolean;
  21014. private _roughness;
  21015. /**
  21016. * Defines the sheen roughness.
  21017. * It is not taken into account if linkSheenWithAlbedo is true.
  21018. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  21019. */
  21020. roughness: Nullable<number>;
  21021. private _textureRoughness;
  21022. /**
  21023. * Stores the sheen roughness in a texture.
  21024. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  21025. */
  21026. textureRoughness: Nullable<BaseTexture>;
  21027. private _albedoScaling;
  21028. /**
  21029. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  21030. * It allows the strength of the sheen effect to not depend on the base color of the material,
  21031. * making it easier to setup and tweak the effect
  21032. */
  21033. albedoScaling: boolean;
  21034. /** @hidden */
  21035. private _internalMarkAllSubMeshesAsTexturesDirty;
  21036. /** @hidden */
  21037. _markAllSubMeshesAsTexturesDirty(): void;
  21038. /**
  21039. * Instantiate a new instance of clear coat configuration.
  21040. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  21041. */
  21042. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  21043. /**
  21044. * Specifies that the submesh is ready to be used.
  21045. * @param defines the list of "defines" to update.
  21046. * @param scene defines the scene the material belongs to.
  21047. * @returns - boolean indicating that the submesh is ready or not.
  21048. */
  21049. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  21050. /**
  21051. * Checks to see if a texture is used in the material.
  21052. * @param defines the list of "defines" to update.
  21053. * @param scene defines the scene the material belongs to.
  21054. */
  21055. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  21056. /**
  21057. * Binds the material data.
  21058. * @param uniformBuffer defines the Uniform buffer to fill in.
  21059. * @param scene defines the scene the material belongs to.
  21060. * @param isFrozen defines whether the material is frozen or not.
  21061. * @param subMesh the submesh to bind data for
  21062. */
  21063. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  21064. /**
  21065. * Checks to see if a texture is used in the material.
  21066. * @param texture - Base texture to use.
  21067. * @returns - Boolean specifying if a texture is used in the material.
  21068. */
  21069. hasTexture(texture: BaseTexture): boolean;
  21070. /**
  21071. * Returns an array of the actively used textures.
  21072. * @param activeTextures Array of BaseTextures
  21073. */
  21074. getActiveTextures(activeTextures: BaseTexture[]): void;
  21075. /**
  21076. * Returns the animatable textures.
  21077. * @param animatables Array of animatable textures.
  21078. */
  21079. getAnimatables(animatables: IAnimatable[]): void;
  21080. /**
  21081. * Disposes the resources of the material.
  21082. * @param forceDisposeTextures - Forces the disposal of all textures.
  21083. */
  21084. dispose(forceDisposeTextures?: boolean): void;
  21085. /**
  21086. * Get the current class name of the texture useful for serialization or dynamic coding.
  21087. * @returns "PBRSheenConfiguration"
  21088. */
  21089. getClassName(): string;
  21090. /**
  21091. * Add fallbacks to the effect fallbacks list.
  21092. * @param defines defines the Base texture to use.
  21093. * @param fallbacks defines the current fallback list.
  21094. * @param currentRank defines the current fallback rank.
  21095. * @returns the new fallback rank.
  21096. */
  21097. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  21098. /**
  21099. * Add the required uniforms to the current list.
  21100. * @param uniforms defines the current uniform list.
  21101. */
  21102. static AddUniforms(uniforms: string[]): void;
  21103. /**
  21104. * Add the required uniforms to the current buffer.
  21105. * @param uniformBuffer defines the current uniform buffer.
  21106. */
  21107. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  21108. /**
  21109. * Add the required samplers to the current list.
  21110. * @param samplers defines the current sampler list.
  21111. */
  21112. static AddSamplers(samplers: string[]): void;
  21113. /**
  21114. * Makes a duplicate of the current configuration into another one.
  21115. * @param sheenConfiguration define the config where to copy the info
  21116. */
  21117. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  21118. /**
  21119. * Serializes this BRDF configuration.
  21120. * @returns - An object with the serialized config.
  21121. */
  21122. serialize(): any;
  21123. /**
  21124. * Parses a anisotropy Configuration from a serialized object.
  21125. * @param source - Serialized object.
  21126. * @param scene Defines the scene we are parsing for
  21127. * @param rootUrl Defines the rootUrl to load from
  21128. */
  21129. parse(source: any, scene: Scene, rootUrl: string): void;
  21130. }
  21131. }
  21132. declare module BABYLON {
  21133. /**
  21134. * @hidden
  21135. */
  21136. export interface IMaterialSubSurfaceDefines {
  21137. SUBSURFACE: boolean;
  21138. SS_REFRACTION: boolean;
  21139. SS_TRANSLUCENCY: boolean;
  21140. SS_SCATTERING: boolean;
  21141. SS_THICKNESSANDMASK_TEXTURE: boolean;
  21142. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  21143. SS_REFRACTIONMAP_3D: boolean;
  21144. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  21145. SS_LODINREFRACTIONALPHA: boolean;
  21146. SS_GAMMAREFRACTION: boolean;
  21147. SS_RGBDREFRACTION: boolean;
  21148. SS_LINEARSPECULARREFRACTION: boolean;
  21149. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  21150. SS_ALBEDOFORREFRACTIONTINT: boolean;
  21151. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  21152. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  21153. /** @hidden */
  21154. _areTexturesDirty: boolean;
  21155. }
  21156. /**
  21157. * Define the code related to the sub surface parameters of the pbr material.
  21158. */
  21159. export class PBRSubSurfaceConfiguration {
  21160. private _isRefractionEnabled;
  21161. /**
  21162. * Defines if the refraction is enabled in the material.
  21163. */
  21164. isRefractionEnabled: boolean;
  21165. private _isTranslucencyEnabled;
  21166. /**
  21167. * Defines if the translucency is enabled in the material.
  21168. */
  21169. isTranslucencyEnabled: boolean;
  21170. private _isScatteringEnabled;
  21171. /**
  21172. * Defines if the sub surface scattering is enabled in the material.
  21173. */
  21174. isScatteringEnabled: boolean;
  21175. private _scatteringDiffusionProfileIndex;
  21176. /**
  21177. * Diffusion profile for subsurface scattering.
  21178. * Useful for better scattering in the skins or foliages.
  21179. */
  21180. get scatteringDiffusionProfile(): Nullable<Color3>;
  21181. set scatteringDiffusionProfile(c: Nullable<Color3>);
  21182. /**
  21183. * Defines the refraction intensity of the material.
  21184. * The refraction when enabled replaces the Diffuse part of the material.
  21185. * The intensity helps transitioning between diffuse and refraction.
  21186. */
  21187. refractionIntensity: number;
  21188. /**
  21189. * Defines the translucency intensity of the material.
  21190. * When translucency has been enabled, this defines how much of the "translucency"
  21191. * is added to the diffuse part of the material.
  21192. */
  21193. translucencyIntensity: number;
  21194. /**
  21195. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  21196. */
  21197. useAlbedoToTintRefraction: boolean;
  21198. private _thicknessTexture;
  21199. /**
  21200. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  21201. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  21202. * 0 would mean minimumThickness
  21203. * 1 would mean maximumThickness
  21204. * The other channels might be use as a mask to vary the different effects intensity.
  21205. */
  21206. thicknessTexture: Nullable<BaseTexture>;
  21207. private _refractionTexture;
  21208. /**
  21209. * Defines the texture to use for refraction.
  21210. */
  21211. refractionTexture: Nullable<BaseTexture>;
  21212. private _indexOfRefraction;
  21213. /**
  21214. * Index of refraction of the material base layer.
  21215. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  21216. *
  21217. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  21218. *
  21219. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  21220. */
  21221. indexOfRefraction: number;
  21222. private _volumeIndexOfRefraction;
  21223. /**
  21224. * Index of refraction of the material's volume.
  21225. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  21226. *
  21227. * This ONLY impacts refraction. If not provided or given a non-valid value,
  21228. * the volume will use the same IOR as the surface.
  21229. */
  21230. get volumeIndexOfRefraction(): number;
  21231. set volumeIndexOfRefraction(value: number);
  21232. private _invertRefractionY;
  21233. /**
  21234. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21235. */
  21236. invertRefractionY: boolean;
  21237. private _linkRefractionWithTransparency;
  21238. /**
  21239. * This parameters will make the material used its opacity to control how much it is refracting against not.
  21240. * Materials half opaque for instance using refraction could benefit from this control.
  21241. */
  21242. linkRefractionWithTransparency: boolean;
  21243. /**
  21244. * Defines the minimum thickness stored in the thickness map.
  21245. * If no thickness map is defined, this value will be used to simulate thickness.
  21246. */
  21247. minimumThickness: number;
  21248. /**
  21249. * Defines the maximum thickness stored in the thickness map.
  21250. */
  21251. maximumThickness: number;
  21252. /**
  21253. * Defines the volume tint of the material.
  21254. * This is used for both translucency and scattering.
  21255. */
  21256. tintColor: Color3;
  21257. /**
  21258. * Defines the distance at which the tint color should be found in the media.
  21259. * This is used for refraction only.
  21260. */
  21261. tintColorAtDistance: number;
  21262. /**
  21263. * Defines how far each channel transmit through the media.
  21264. * It is defined as a color to simplify it selection.
  21265. */
  21266. diffusionDistance: Color3;
  21267. private _useMaskFromThicknessTexture;
  21268. /**
  21269. * Stores the intensity of the different subsurface effects in the thickness texture.
  21270. * * the green channel is the translucency intensity.
  21271. * * the blue channel is the scattering intensity.
  21272. * * the alpha channel is the refraction intensity.
  21273. */
  21274. useMaskFromThicknessTexture: boolean;
  21275. private _scene;
  21276. private _useMaskFromThicknessTextureGltf;
  21277. /**
  21278. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  21279. * matches the channel-packing that is used by glTF.
  21280. * * the red channel is the transmission/translucency intensity.
  21281. * * the green channel is the thickness.
  21282. */
  21283. useMaskFromThicknessTextureGltf: boolean;
  21284. /** @hidden */
  21285. private _internalMarkAllSubMeshesAsTexturesDirty;
  21286. private _internalMarkScenePrePassDirty;
  21287. /** @hidden */
  21288. _markAllSubMeshesAsTexturesDirty(): void;
  21289. /** @hidden */
  21290. _markScenePrePassDirty(): void;
  21291. /**
  21292. * Instantiate a new instance of sub surface configuration.
  21293. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  21294. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  21295. * @param scene The scene
  21296. */
  21297. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  21298. /**
  21299. * Gets whether the submesh is ready to be used or not.
  21300. * @param defines the list of "defines" to update.
  21301. * @param scene defines the scene the material belongs to.
  21302. * @returns - boolean indicating that the submesh is ready or not.
  21303. */
  21304. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  21305. /**
  21306. * Checks to see if a texture is used in the material.
  21307. * @param defines the list of "defines" to update.
  21308. * @param scene defines the scene to the material belongs to.
  21309. */
  21310. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  21311. /**
  21312. * Binds the material data.
  21313. * @param uniformBuffer defines the Uniform buffer to fill in.
  21314. * @param scene defines the scene the material belongs to.
  21315. * @param engine defines the engine the material belongs to.
  21316. * @param isFrozen defines whether the material is frozen or not.
  21317. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  21318. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  21319. */
  21320. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  21321. /**
  21322. * Unbinds the material from the mesh.
  21323. * @param activeEffect defines the effect that should be unbound from.
  21324. * @returns true if unbound, otherwise false
  21325. */
  21326. unbind(activeEffect: Effect): boolean;
  21327. /**
  21328. * Returns the texture used for refraction or null if none is used.
  21329. * @param scene defines the scene the material belongs to.
  21330. * @returns - Refraction texture if present. If no refraction texture and refraction
  21331. * is linked with transparency, returns environment texture. Otherwise, returns null.
  21332. */
  21333. private _getRefractionTexture;
  21334. /**
  21335. * Returns true if alpha blending should be disabled.
  21336. */
  21337. get disableAlphaBlending(): boolean;
  21338. /**
  21339. * Fills the list of render target textures.
  21340. * @param renderTargets the list of render targets to update
  21341. */
  21342. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  21343. /**
  21344. * Checks to see if a texture is used in the material.
  21345. * @param texture - Base texture to use.
  21346. * @returns - Boolean specifying if a texture is used in the material.
  21347. */
  21348. hasTexture(texture: BaseTexture): boolean;
  21349. /**
  21350. * Gets a boolean indicating that current material needs to register RTT
  21351. * @returns true if this uses a render target otherwise false.
  21352. */
  21353. hasRenderTargetTextures(): boolean;
  21354. /**
  21355. * Returns an array of the actively used textures.
  21356. * @param activeTextures Array of BaseTextures
  21357. */
  21358. getActiveTextures(activeTextures: BaseTexture[]): void;
  21359. /**
  21360. * Returns the animatable textures.
  21361. * @param animatables Array of animatable textures.
  21362. */
  21363. getAnimatables(animatables: IAnimatable[]): void;
  21364. /**
  21365. * Disposes the resources of the material.
  21366. * @param forceDisposeTextures - Forces the disposal of all textures.
  21367. */
  21368. dispose(forceDisposeTextures?: boolean): void;
  21369. /**
  21370. * Get the current class name of the texture useful for serialization or dynamic coding.
  21371. * @returns "PBRSubSurfaceConfiguration"
  21372. */
  21373. getClassName(): string;
  21374. /**
  21375. * Add fallbacks to the effect fallbacks list.
  21376. * @param defines defines the Base texture to use.
  21377. * @param fallbacks defines the current fallback list.
  21378. * @param currentRank defines the current fallback rank.
  21379. * @returns the new fallback rank.
  21380. */
  21381. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  21382. /**
  21383. * Add the required uniforms to the current list.
  21384. * @param uniforms defines the current uniform list.
  21385. */
  21386. static AddUniforms(uniforms: string[]): void;
  21387. /**
  21388. * Add the required samplers to the current list.
  21389. * @param samplers defines the current sampler list.
  21390. */
  21391. static AddSamplers(samplers: string[]): void;
  21392. /**
  21393. * Add the required uniforms to the current buffer.
  21394. * @param uniformBuffer defines the current uniform buffer.
  21395. */
  21396. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  21397. /**
  21398. * Makes a duplicate of the current configuration into another one.
  21399. * @param configuration define the config where to copy the info
  21400. */
  21401. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  21402. /**
  21403. * Serializes this Sub Surface configuration.
  21404. * @returns - An object with the serialized config.
  21405. */
  21406. serialize(): any;
  21407. /**
  21408. * Parses a anisotropy Configuration from a serialized object.
  21409. * @param source - Serialized object.
  21410. * @param scene Defines the scene we are parsing for
  21411. * @param rootUrl Defines the rootUrl to load from
  21412. */
  21413. parse(source: any, scene: Scene, rootUrl: string): void;
  21414. }
  21415. }
  21416. declare module BABYLON {
  21417. /**
  21418. * Class representing spherical harmonics coefficients to the 3rd degree
  21419. */
  21420. export class SphericalHarmonics {
  21421. /**
  21422. * Defines whether or not the harmonics have been prescaled for rendering.
  21423. */
  21424. preScaled: boolean;
  21425. /**
  21426. * The l0,0 coefficients of the spherical harmonics
  21427. */
  21428. l00: Vector3;
  21429. /**
  21430. * The l1,-1 coefficients of the spherical harmonics
  21431. */
  21432. l1_1: Vector3;
  21433. /**
  21434. * The l1,0 coefficients of the spherical harmonics
  21435. */
  21436. l10: Vector3;
  21437. /**
  21438. * The l1,1 coefficients of the spherical harmonics
  21439. */
  21440. l11: Vector3;
  21441. /**
  21442. * The l2,-2 coefficients of the spherical harmonics
  21443. */
  21444. l2_2: Vector3;
  21445. /**
  21446. * The l2,-1 coefficients of the spherical harmonics
  21447. */
  21448. l2_1: Vector3;
  21449. /**
  21450. * The l2,0 coefficients of the spherical harmonics
  21451. */
  21452. l20: Vector3;
  21453. /**
  21454. * The l2,1 coefficients of the spherical harmonics
  21455. */
  21456. l21: Vector3;
  21457. /**
  21458. * The l2,2 coefficients of the spherical harmonics
  21459. */
  21460. l22: Vector3;
  21461. /**
  21462. * Adds a light to the spherical harmonics
  21463. * @param direction the direction of the light
  21464. * @param color the color of the light
  21465. * @param deltaSolidAngle the delta solid angle of the light
  21466. */
  21467. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  21468. /**
  21469. * Scales the spherical harmonics by the given amount
  21470. * @param scale the amount to scale
  21471. */
  21472. scaleInPlace(scale: number): void;
  21473. /**
  21474. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  21475. *
  21476. * ```
  21477. * E_lm = A_l * L_lm
  21478. * ```
  21479. *
  21480. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  21481. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  21482. * the scaling factors are given in equation 9.
  21483. */
  21484. convertIncidentRadianceToIrradiance(): void;
  21485. /**
  21486. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  21487. *
  21488. * ```
  21489. * L = (1/pi) * E * rho
  21490. * ```
  21491. *
  21492. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  21493. */
  21494. convertIrradianceToLambertianRadiance(): void;
  21495. /**
  21496. * Integrates the reconstruction coefficients directly in to the SH preventing further
  21497. * required operations at run time.
  21498. *
  21499. * This is simply done by scaling back the SH with Ylm constants parameter.
  21500. * The trigonometric part being applied by the shader at run time.
  21501. */
  21502. preScaleForRendering(): void;
  21503. /**
  21504. * Constructs a spherical harmonics from an array.
  21505. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  21506. * @returns the spherical harmonics
  21507. */
  21508. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  21509. /**
  21510. * Gets the spherical harmonics from polynomial
  21511. * @param polynomial the spherical polynomial
  21512. * @returns the spherical harmonics
  21513. */
  21514. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  21515. }
  21516. /**
  21517. * Class representing spherical polynomial coefficients to the 3rd degree
  21518. */
  21519. export class SphericalPolynomial {
  21520. private _harmonics;
  21521. /**
  21522. * The spherical harmonics used to create the polynomials.
  21523. */
  21524. get preScaledHarmonics(): SphericalHarmonics;
  21525. /**
  21526. * The x coefficients of the spherical polynomial
  21527. */
  21528. x: Vector3;
  21529. /**
  21530. * The y coefficients of the spherical polynomial
  21531. */
  21532. y: Vector3;
  21533. /**
  21534. * The z coefficients of the spherical polynomial
  21535. */
  21536. z: Vector3;
  21537. /**
  21538. * The xx coefficients of the spherical polynomial
  21539. */
  21540. xx: Vector3;
  21541. /**
  21542. * The yy coefficients of the spherical polynomial
  21543. */
  21544. yy: Vector3;
  21545. /**
  21546. * The zz coefficients of the spherical polynomial
  21547. */
  21548. zz: Vector3;
  21549. /**
  21550. * The xy coefficients of the spherical polynomial
  21551. */
  21552. xy: Vector3;
  21553. /**
  21554. * The yz coefficients of the spherical polynomial
  21555. */
  21556. yz: Vector3;
  21557. /**
  21558. * The zx coefficients of the spherical polynomial
  21559. */
  21560. zx: Vector3;
  21561. /**
  21562. * Adds an ambient color to the spherical polynomial
  21563. * @param color the color to add
  21564. */
  21565. addAmbient(color: Color3): void;
  21566. /**
  21567. * Scales the spherical polynomial by the given amount
  21568. * @param scale the amount to scale
  21569. */
  21570. scaleInPlace(scale: number): void;
  21571. /**
  21572. * Gets the spherical polynomial from harmonics
  21573. * @param harmonics the spherical harmonics
  21574. * @returns the spherical polynomial
  21575. */
  21576. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  21577. /**
  21578. * Constructs a spherical polynomial from an array.
  21579. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  21580. * @returns the spherical polynomial
  21581. */
  21582. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  21583. }
  21584. }
  21585. declare module BABYLON {
  21586. /**
  21587. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  21588. */
  21589. export interface CubeMapInfo {
  21590. /**
  21591. * The pixel array for the front face.
  21592. * This is stored in format, left to right, up to down format.
  21593. */
  21594. front: Nullable<ArrayBufferView>;
  21595. /**
  21596. * The pixel array for the back face.
  21597. * This is stored in format, left to right, up to down format.
  21598. */
  21599. back: Nullable<ArrayBufferView>;
  21600. /**
  21601. * The pixel array for the left face.
  21602. * This is stored in format, left to right, up to down format.
  21603. */
  21604. left: Nullable<ArrayBufferView>;
  21605. /**
  21606. * The pixel array for the right face.
  21607. * This is stored in format, left to right, up to down format.
  21608. */
  21609. right: Nullable<ArrayBufferView>;
  21610. /**
  21611. * The pixel array for the up face.
  21612. * This is stored in format, left to right, up to down format.
  21613. */
  21614. up: Nullable<ArrayBufferView>;
  21615. /**
  21616. * The pixel array for the down face.
  21617. * This is stored in format, left to right, up to down format.
  21618. */
  21619. down: Nullable<ArrayBufferView>;
  21620. /**
  21621. * The size of the cubemap stored.
  21622. *
  21623. * Each faces will be size * size pixels.
  21624. */
  21625. size: number;
  21626. /**
  21627. * The format of the texture.
  21628. *
  21629. * RGBA, RGB.
  21630. */
  21631. format: number;
  21632. /**
  21633. * The type of the texture data.
  21634. *
  21635. * UNSIGNED_INT, FLOAT.
  21636. */
  21637. type: number;
  21638. /**
  21639. * Specifies whether the texture is in gamma space.
  21640. */
  21641. gammaSpace: boolean;
  21642. }
  21643. /**
  21644. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  21645. */
  21646. export class PanoramaToCubeMapTools {
  21647. private static FACE_LEFT;
  21648. private static FACE_RIGHT;
  21649. private static FACE_FRONT;
  21650. private static FACE_BACK;
  21651. private static FACE_DOWN;
  21652. private static FACE_UP;
  21653. /**
  21654. * Converts a panorama stored in RGB right to left up to down format into a cubemap (6 faces).
  21655. *
  21656. * @param float32Array The source data.
  21657. * @param inputWidth The width of the input panorama.
  21658. * @param inputHeight The height of the input panorama.
  21659. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  21660. * @return The cubemap data
  21661. */
  21662. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  21663. private static CreateCubemapTexture;
  21664. private static CalcProjectionSpherical;
  21665. }
  21666. }
  21667. declare module BABYLON {
  21668. /**
  21669. * Helper class dealing with the extraction of spherical polynomial dataArray
  21670. * from a cube map.
  21671. */
  21672. export class CubeMapToSphericalPolynomialTools {
  21673. private static FileFaces;
  21674. /**
  21675. * Converts a texture to the according Spherical Polynomial data.
  21676. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21677. *
  21678. * @param texture The texture to extract the information from.
  21679. * @return The Spherical Polynomial data.
  21680. */
  21681. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<Promise<SphericalPolynomial>>;
  21682. /**
  21683. * Converts a cubemap to the according Spherical Polynomial data.
  21684. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21685. *
  21686. * @param cubeInfo The Cube map to extract the information from.
  21687. * @return The Spherical Polynomial data.
  21688. */
  21689. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  21690. }
  21691. }
  21692. declare module BABYLON {
  21693. interface BaseTexture {
  21694. /**
  21695. * Get the polynomial representation of the texture data.
  21696. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  21697. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  21698. */
  21699. sphericalPolynomial: Nullable<SphericalPolynomial>;
  21700. }
  21701. }
  21702. declare module BABYLON {
  21703. /** @hidden */
  21704. export var pbrFragmentDeclaration: {
  21705. name: string;
  21706. shader: string;
  21707. };
  21708. }
  21709. declare module BABYLON {
  21710. /** @hidden */
  21711. export var pbrUboDeclaration: {
  21712. name: string;
  21713. shader: string;
  21714. };
  21715. }
  21716. declare module BABYLON {
  21717. /** @hidden */
  21718. export var pbrFragmentExtraDeclaration: {
  21719. name: string;
  21720. shader: string;
  21721. };
  21722. }
  21723. declare module BABYLON {
  21724. /** @hidden */
  21725. export var pbrFragmentSamplersDeclaration: {
  21726. name: string;
  21727. shader: string;
  21728. };
  21729. }
  21730. declare module BABYLON {
  21731. /** @hidden */
  21732. export var subSurfaceScatteringFunctions: {
  21733. name: string;
  21734. shader: string;
  21735. };
  21736. }
  21737. declare module BABYLON {
  21738. /** @hidden */
  21739. export var importanceSampling: {
  21740. name: string;
  21741. shader: string;
  21742. };
  21743. }
  21744. declare module BABYLON {
  21745. /** @hidden */
  21746. export var pbrHelperFunctions: {
  21747. name: string;
  21748. shader: string;
  21749. };
  21750. }
  21751. declare module BABYLON {
  21752. /** @hidden */
  21753. export var harmonicsFunctions: {
  21754. name: string;
  21755. shader: string;
  21756. };
  21757. }
  21758. declare module BABYLON {
  21759. /** @hidden */
  21760. export var pbrDirectLightingSetupFunctions: {
  21761. name: string;
  21762. shader: string;
  21763. };
  21764. }
  21765. declare module BABYLON {
  21766. /** @hidden */
  21767. export var pbrDirectLightingFalloffFunctions: {
  21768. name: string;
  21769. shader: string;
  21770. };
  21771. }
  21772. declare module BABYLON {
  21773. /** @hidden */
  21774. export var pbrBRDFFunctions: {
  21775. name: string;
  21776. shader: string;
  21777. };
  21778. }
  21779. declare module BABYLON {
  21780. /** @hidden */
  21781. export var hdrFilteringFunctions: {
  21782. name: string;
  21783. shader: string;
  21784. };
  21785. }
  21786. declare module BABYLON {
  21787. /** @hidden */
  21788. export var pbrDirectLightingFunctions: {
  21789. name: string;
  21790. shader: string;
  21791. };
  21792. }
  21793. declare module BABYLON {
  21794. /** @hidden */
  21795. export var pbrIBLFunctions: {
  21796. name: string;
  21797. shader: string;
  21798. };
  21799. }
  21800. declare module BABYLON {
  21801. /** @hidden */
  21802. export var pbrBlockAlbedoOpacity: {
  21803. name: string;
  21804. shader: string;
  21805. };
  21806. }
  21807. declare module BABYLON {
  21808. /** @hidden */
  21809. export var pbrBlockReflectivity: {
  21810. name: string;
  21811. shader: string;
  21812. };
  21813. }
  21814. declare module BABYLON {
  21815. /** @hidden */
  21816. export var pbrBlockAmbientOcclusion: {
  21817. name: string;
  21818. shader: string;
  21819. };
  21820. }
  21821. declare module BABYLON {
  21822. /** @hidden */
  21823. export var pbrBlockAlphaFresnel: {
  21824. name: string;
  21825. shader: string;
  21826. };
  21827. }
  21828. declare module BABYLON {
  21829. /** @hidden */
  21830. export var pbrBlockAnisotropic: {
  21831. name: string;
  21832. shader: string;
  21833. };
  21834. }
  21835. declare module BABYLON {
  21836. /** @hidden */
  21837. export var pbrBlockReflection: {
  21838. name: string;
  21839. shader: string;
  21840. };
  21841. }
  21842. declare module BABYLON {
  21843. /** @hidden */
  21844. export var pbrBlockSheen: {
  21845. name: string;
  21846. shader: string;
  21847. };
  21848. }
  21849. declare module BABYLON {
  21850. /** @hidden */
  21851. export var pbrBlockClearcoat: {
  21852. name: string;
  21853. shader: string;
  21854. };
  21855. }
  21856. declare module BABYLON {
  21857. /** @hidden */
  21858. export var pbrBlockSubSurface: {
  21859. name: string;
  21860. shader: string;
  21861. };
  21862. }
  21863. declare module BABYLON {
  21864. /** @hidden */
  21865. export var pbrBlockNormalGeometric: {
  21866. name: string;
  21867. shader: string;
  21868. };
  21869. }
  21870. declare module BABYLON {
  21871. /** @hidden */
  21872. export var pbrBlockNormalFinal: {
  21873. name: string;
  21874. shader: string;
  21875. };
  21876. }
  21877. declare module BABYLON {
  21878. /** @hidden */
  21879. export var pbrBlockLightmapInit: {
  21880. name: string;
  21881. shader: string;
  21882. };
  21883. }
  21884. declare module BABYLON {
  21885. /** @hidden */
  21886. export var pbrBlockGeometryInfo: {
  21887. name: string;
  21888. shader: string;
  21889. };
  21890. }
  21891. declare module BABYLON {
  21892. /** @hidden */
  21893. export var pbrBlockReflectance0: {
  21894. name: string;
  21895. shader: string;
  21896. };
  21897. }
  21898. declare module BABYLON {
  21899. /** @hidden */
  21900. export var pbrBlockReflectance: {
  21901. name: string;
  21902. shader: string;
  21903. };
  21904. }
  21905. declare module BABYLON {
  21906. /** @hidden */
  21907. export var pbrBlockDirectLighting: {
  21908. name: string;
  21909. shader: string;
  21910. };
  21911. }
  21912. declare module BABYLON {
  21913. /** @hidden */
  21914. export var pbrBlockFinalLitComponents: {
  21915. name: string;
  21916. shader: string;
  21917. };
  21918. }
  21919. declare module BABYLON {
  21920. /** @hidden */
  21921. export var pbrBlockFinalUnlitComponents: {
  21922. name: string;
  21923. shader: string;
  21924. };
  21925. }
  21926. declare module BABYLON {
  21927. /** @hidden */
  21928. export var pbrBlockFinalColorComposition: {
  21929. name: string;
  21930. shader: string;
  21931. };
  21932. }
  21933. declare module BABYLON {
  21934. /** @hidden */
  21935. export var pbrBlockImageProcessing: {
  21936. name: string;
  21937. shader: string;
  21938. };
  21939. }
  21940. declare module BABYLON {
  21941. /** @hidden */
  21942. export var pbrDebug: {
  21943. name: string;
  21944. shader: string;
  21945. };
  21946. }
  21947. declare module BABYLON {
  21948. /** @hidden */
  21949. export var pbrPixelShader: {
  21950. name: string;
  21951. shader: string;
  21952. };
  21953. }
  21954. declare module BABYLON {
  21955. /** @hidden */
  21956. export var pbrVertexDeclaration: {
  21957. name: string;
  21958. shader: string;
  21959. };
  21960. }
  21961. declare module BABYLON {
  21962. /** @hidden */
  21963. export var pbrVertexShader: {
  21964. name: string;
  21965. shader: string;
  21966. };
  21967. }
  21968. declare module BABYLON {
  21969. /**
  21970. * Manages the defines for the PBR Material.
  21971. * @hidden
  21972. */
  21973. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  21974. PBR: boolean;
  21975. NUM_SAMPLES: string;
  21976. REALTIME_FILTERING: boolean;
  21977. MAINUV1: boolean;
  21978. MAINUV2: boolean;
  21979. UV1: boolean;
  21980. UV2: boolean;
  21981. ALBEDO: boolean;
  21982. GAMMAALBEDO: boolean;
  21983. ALBEDODIRECTUV: number;
  21984. VERTEXCOLOR: boolean;
  21985. DETAIL: boolean;
  21986. DETAILDIRECTUV: number;
  21987. DETAIL_NORMALBLENDMETHOD: number;
  21988. AMBIENT: boolean;
  21989. AMBIENTDIRECTUV: number;
  21990. AMBIENTINGRAYSCALE: boolean;
  21991. OPACITY: boolean;
  21992. VERTEXALPHA: boolean;
  21993. OPACITYDIRECTUV: number;
  21994. OPACITYRGB: boolean;
  21995. ALPHATEST: boolean;
  21996. DEPTHPREPASS: boolean;
  21997. ALPHABLEND: boolean;
  21998. ALPHAFROMALBEDO: boolean;
  21999. ALPHATESTVALUE: string;
  22000. SPECULAROVERALPHA: boolean;
  22001. RADIANCEOVERALPHA: boolean;
  22002. ALPHAFRESNEL: boolean;
  22003. LINEARALPHAFRESNEL: boolean;
  22004. PREMULTIPLYALPHA: boolean;
  22005. EMISSIVE: boolean;
  22006. EMISSIVEDIRECTUV: number;
  22007. REFLECTIVITY: boolean;
  22008. REFLECTIVITYDIRECTUV: number;
  22009. SPECULARTERM: boolean;
  22010. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  22011. MICROSURFACEAUTOMATIC: boolean;
  22012. LODBASEDMICROSFURACE: boolean;
  22013. MICROSURFACEMAP: boolean;
  22014. MICROSURFACEMAPDIRECTUV: number;
  22015. METALLICWORKFLOW: boolean;
  22016. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  22017. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  22018. METALLNESSSTOREINMETALMAPBLUE: boolean;
  22019. AOSTOREINMETALMAPRED: boolean;
  22020. METALLIC_REFLECTANCE: boolean;
  22021. METALLIC_REFLECTANCEDIRECTUV: number;
  22022. ENVIRONMENTBRDF: boolean;
  22023. ENVIRONMENTBRDF_RGBD: boolean;
  22024. NORMAL: boolean;
  22025. TANGENT: boolean;
  22026. BUMP: boolean;
  22027. BUMPDIRECTUV: number;
  22028. OBJECTSPACE_NORMALMAP: boolean;
  22029. PARALLAX: boolean;
  22030. PARALLAXOCCLUSION: boolean;
  22031. NORMALXYSCALE: boolean;
  22032. LIGHTMAP: boolean;
  22033. LIGHTMAPDIRECTUV: number;
  22034. USELIGHTMAPASSHADOWMAP: boolean;
  22035. GAMMALIGHTMAP: boolean;
  22036. RGBDLIGHTMAP: boolean;
  22037. REFLECTION: boolean;
  22038. REFLECTIONMAP_3D: boolean;
  22039. REFLECTIONMAP_SPHERICAL: boolean;
  22040. REFLECTIONMAP_PLANAR: boolean;
  22041. REFLECTIONMAP_CUBIC: boolean;
  22042. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  22043. REFLECTIONMAP_PROJECTION: boolean;
  22044. REFLECTIONMAP_SKYBOX: boolean;
  22045. REFLECTIONMAP_EXPLICIT: boolean;
  22046. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  22047. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  22048. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  22049. INVERTCUBICMAP: boolean;
  22050. USESPHERICALFROMREFLECTIONMAP: boolean;
  22051. USEIRRADIANCEMAP: boolean;
  22052. SPHERICAL_HARMONICS: boolean;
  22053. USESPHERICALINVERTEX: boolean;
  22054. REFLECTIONMAP_OPPOSITEZ: boolean;
  22055. LODINREFLECTIONALPHA: boolean;
  22056. GAMMAREFLECTION: boolean;
  22057. RGBDREFLECTION: boolean;
  22058. LINEARSPECULARREFLECTION: boolean;
  22059. RADIANCEOCCLUSION: boolean;
  22060. HORIZONOCCLUSION: boolean;
  22061. INSTANCES: boolean;
  22062. THIN_INSTANCES: boolean;
  22063. PREPASS: boolean;
  22064. PREPASS_IRRADIANCE: boolean;
  22065. PREPASS_IRRADIANCE_INDEX: number;
  22066. PREPASS_ALBEDO: boolean;
  22067. PREPASS_ALBEDO_INDEX: number;
  22068. PREPASS_DEPTH: boolean;
  22069. PREPASS_DEPTH_INDEX: number;
  22070. PREPASS_NORMAL: boolean;
  22071. PREPASS_NORMAL_INDEX: number;
  22072. PREPASS_POSITION: boolean;
  22073. PREPASS_POSITION_INDEX: number;
  22074. PREPASS_VELOCITY: boolean;
  22075. PREPASS_VELOCITY_INDEX: number;
  22076. PREPASS_REFLECTIVITY: boolean;
  22077. PREPASS_REFLECTIVITY_INDEX: number;
  22078. SCENE_MRT_COUNT: number;
  22079. NUM_BONE_INFLUENCERS: number;
  22080. BonesPerMesh: number;
  22081. BONETEXTURE: boolean;
  22082. BONES_VELOCITY_ENABLED: boolean;
  22083. NONUNIFORMSCALING: boolean;
  22084. MORPHTARGETS: boolean;
  22085. MORPHTARGETS_NORMAL: boolean;
  22086. MORPHTARGETS_TANGENT: boolean;
  22087. MORPHTARGETS_UV: boolean;
  22088. NUM_MORPH_INFLUENCERS: number;
  22089. MORPHTARGETS_TEXTURE: boolean;
  22090. IMAGEPROCESSING: boolean;
  22091. VIGNETTE: boolean;
  22092. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22093. VIGNETTEBLENDMODEOPAQUE: boolean;
  22094. TONEMAPPING: boolean;
  22095. TONEMAPPING_ACES: boolean;
  22096. CONTRAST: boolean;
  22097. COLORCURVES: boolean;
  22098. COLORGRADING: boolean;
  22099. COLORGRADING3D: boolean;
  22100. SAMPLER3DGREENDEPTH: boolean;
  22101. SAMPLER3DBGRMAP: boolean;
  22102. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22103. EXPOSURE: boolean;
  22104. MULTIVIEW: boolean;
  22105. USEPHYSICALLIGHTFALLOFF: boolean;
  22106. USEGLTFLIGHTFALLOFF: boolean;
  22107. TWOSIDEDLIGHTING: boolean;
  22108. SHADOWFLOAT: boolean;
  22109. CLIPPLANE: boolean;
  22110. CLIPPLANE2: boolean;
  22111. CLIPPLANE3: boolean;
  22112. CLIPPLANE4: boolean;
  22113. CLIPPLANE5: boolean;
  22114. CLIPPLANE6: boolean;
  22115. POINTSIZE: boolean;
  22116. FOG: boolean;
  22117. LOGARITHMICDEPTH: boolean;
  22118. FORCENORMALFORWARD: boolean;
  22119. SPECULARAA: boolean;
  22120. CLEARCOAT: boolean;
  22121. CLEARCOAT_DEFAULTIOR: boolean;
  22122. CLEARCOAT_TEXTURE: boolean;
  22123. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  22124. CLEARCOAT_TEXTUREDIRECTUV: number;
  22125. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  22126. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  22127. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  22128. CLEARCOAT_BUMP: boolean;
  22129. CLEARCOAT_BUMPDIRECTUV: number;
  22130. CLEARCOAT_REMAP_F0: boolean;
  22131. CLEARCOAT_TINT: boolean;
  22132. CLEARCOAT_TINT_TEXTURE: boolean;
  22133. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  22134. ANISOTROPIC: boolean;
  22135. ANISOTROPIC_TEXTURE: boolean;
  22136. ANISOTROPIC_TEXTUREDIRECTUV: number;
  22137. BRDF_V_HEIGHT_CORRELATED: boolean;
  22138. MS_BRDF_ENERGY_CONSERVATION: boolean;
  22139. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  22140. SHEEN: boolean;
  22141. SHEEN_TEXTURE: boolean;
  22142. SHEEN_TEXTURE_ROUGHNESS: boolean;
  22143. SHEEN_TEXTUREDIRECTUV: number;
  22144. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  22145. SHEEN_LINKWITHALBEDO: boolean;
  22146. SHEEN_ROUGHNESS: boolean;
  22147. SHEEN_ALBEDOSCALING: boolean;
  22148. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  22149. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  22150. SUBSURFACE: boolean;
  22151. SS_REFRACTION: boolean;
  22152. SS_TRANSLUCENCY: boolean;
  22153. SS_SCATTERING: boolean;
  22154. SS_THICKNESSANDMASK_TEXTURE: boolean;
  22155. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  22156. SS_REFRACTIONMAP_3D: boolean;
  22157. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  22158. SS_LODINREFRACTIONALPHA: boolean;
  22159. SS_GAMMAREFRACTION: boolean;
  22160. SS_RGBDREFRACTION: boolean;
  22161. SS_LINEARSPECULARREFRACTION: boolean;
  22162. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  22163. SS_ALBEDOFORREFRACTIONTINT: boolean;
  22164. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  22165. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  22166. UNLIT: boolean;
  22167. DEBUGMODE: number;
  22168. /**
  22169. * Initializes the PBR Material defines.
  22170. */
  22171. constructor();
  22172. /**
  22173. * Resets the PBR Material defines.
  22174. */
  22175. reset(): void;
  22176. }
  22177. /**
  22178. * The Physically based material base class of BJS.
  22179. *
  22180. * This offers the main features of a standard PBR material.
  22181. * For more information, please refer to the documentation :
  22182. * https://doc.babylonjs.com/how_to/physically_based_rendering
  22183. */
  22184. export abstract class PBRBaseMaterial extends PushMaterial {
  22185. /**
  22186. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  22187. */
  22188. static readonly PBRMATERIAL_OPAQUE: number;
  22189. /**
  22190. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  22191. */
  22192. static readonly PBRMATERIAL_ALPHATEST: number;
  22193. /**
  22194. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22195. */
  22196. static readonly PBRMATERIAL_ALPHABLEND: number;
  22197. /**
  22198. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22199. * They are also discarded below the alpha cutoff threshold to improve performances.
  22200. */
  22201. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  22202. /**
  22203. * Defines the default value of how much AO map is occluding the analytical lights
  22204. * (point spot...).
  22205. */
  22206. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  22207. /**
  22208. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  22209. */
  22210. static readonly LIGHTFALLOFF_PHYSICAL: number;
  22211. /**
  22212. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  22213. * to enhance interoperability with other engines.
  22214. */
  22215. static readonly LIGHTFALLOFF_GLTF: number;
  22216. /**
  22217. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  22218. * to enhance interoperability with other materials.
  22219. */
  22220. static readonly LIGHTFALLOFF_STANDARD: number;
  22221. /**
  22222. * Intensity of the direct lights e.g. the four lights available in your scene.
  22223. * This impacts both the direct diffuse and specular highlights.
  22224. */
  22225. protected _directIntensity: number;
  22226. /**
  22227. * Intensity of the emissive part of the material.
  22228. * This helps controlling the emissive effect without modifying the emissive color.
  22229. */
  22230. protected _emissiveIntensity: number;
  22231. /**
  22232. * Intensity of the environment e.g. how much the environment will light the object
  22233. * either through harmonics for rough material or through the reflection for shiny ones.
  22234. */
  22235. protected _environmentIntensity: number;
  22236. /**
  22237. * This is a special control allowing the reduction of the specular highlights coming from the
  22238. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  22239. */
  22240. protected _specularIntensity: number;
  22241. /**
  22242. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  22243. */
  22244. private _lightingInfos;
  22245. /**
  22246. * Debug Control allowing disabling the bump map on this material.
  22247. */
  22248. protected _disableBumpMap: boolean;
  22249. /**
  22250. * AKA Diffuse Texture in standard nomenclature.
  22251. */
  22252. protected _albedoTexture: Nullable<BaseTexture>;
  22253. /**
  22254. * AKA Occlusion Texture in other nomenclature.
  22255. */
  22256. protected _ambientTexture: Nullable<BaseTexture>;
  22257. /**
  22258. * AKA Occlusion Texture Intensity in other nomenclature.
  22259. */
  22260. protected _ambientTextureStrength: number;
  22261. /**
  22262. * Defines how much the AO map is occluding the analytical lights (point spot...).
  22263. * 1 means it completely occludes it
  22264. * 0 mean it has no impact
  22265. */
  22266. protected _ambientTextureImpactOnAnalyticalLights: number;
  22267. /**
  22268. * Stores the alpha values in a texture.
  22269. */
  22270. protected _opacityTexture: Nullable<BaseTexture>;
  22271. /**
  22272. * Stores the reflection values in a texture.
  22273. */
  22274. protected _reflectionTexture: Nullable<BaseTexture>;
  22275. /**
  22276. * Stores the emissive values in a texture.
  22277. */
  22278. protected _emissiveTexture: Nullable<BaseTexture>;
  22279. /**
  22280. * AKA Specular texture in other nomenclature.
  22281. */
  22282. protected _reflectivityTexture: Nullable<BaseTexture>;
  22283. /**
  22284. * Used to switch from specular/glossiness to metallic/roughness workflow.
  22285. */
  22286. protected _metallicTexture: Nullable<BaseTexture>;
  22287. /**
  22288. * Specifies the metallic scalar of the metallic/roughness workflow.
  22289. * Can also be used to scale the metalness values of the metallic texture.
  22290. */
  22291. protected _metallic: Nullable<number>;
  22292. /**
  22293. * Specifies the roughness scalar of the metallic/roughness workflow.
  22294. * Can also be used to scale the roughness values of the metallic texture.
  22295. */
  22296. protected _roughness: Nullable<number>;
  22297. /**
  22298. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  22299. * By default the indexOfrefraction is used to compute F0;
  22300. *
  22301. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  22302. *
  22303. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  22304. * F90 = metallicReflectanceColor;
  22305. */
  22306. protected _metallicF0Factor: number;
  22307. /**
  22308. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  22309. * By default the F90 is always 1;
  22310. *
  22311. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  22312. *
  22313. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  22314. * F90 = metallicReflectanceColor;
  22315. */
  22316. protected _metallicReflectanceColor: Color3;
  22317. /**
  22318. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  22319. * This is multiply against the scalar values defined in the material.
  22320. */
  22321. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  22322. /**
  22323. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  22324. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  22325. */
  22326. protected _microSurfaceTexture: Nullable<BaseTexture>;
  22327. /**
  22328. * Stores surface normal data used to displace a mesh in a texture.
  22329. */
  22330. protected _bumpTexture: Nullable<BaseTexture>;
  22331. /**
  22332. * Stores the pre-calculated light information of a mesh in a texture.
  22333. */
  22334. protected _lightmapTexture: Nullable<BaseTexture>;
  22335. /**
  22336. * The color of a material in ambient lighting.
  22337. */
  22338. protected _ambientColor: Color3;
  22339. /**
  22340. * AKA Diffuse Color in other nomenclature.
  22341. */
  22342. protected _albedoColor: Color3;
  22343. /**
  22344. * AKA Specular Color in other nomenclature.
  22345. */
  22346. protected _reflectivityColor: Color3;
  22347. /**
  22348. * The color applied when light is reflected from a material.
  22349. */
  22350. protected _reflectionColor: Color3;
  22351. /**
  22352. * The color applied when light is emitted from a material.
  22353. */
  22354. protected _emissiveColor: Color3;
  22355. /**
  22356. * AKA Glossiness in other nomenclature.
  22357. */
  22358. protected _microSurface: number;
  22359. /**
  22360. * Specifies that the material will use the light map as a show map.
  22361. */
  22362. protected _useLightmapAsShadowmap: boolean;
  22363. /**
  22364. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  22365. * makes the reflect vector face the model (under horizon).
  22366. */
  22367. protected _useHorizonOcclusion: boolean;
  22368. /**
  22369. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  22370. * too much the area relying on ambient texture to define their ambient occlusion.
  22371. */
  22372. protected _useRadianceOcclusion: boolean;
  22373. /**
  22374. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  22375. */
  22376. protected _useAlphaFromAlbedoTexture: boolean;
  22377. /**
  22378. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  22379. * A car glass is a good example of that. When sun reflects on it you can not see what is behind.
  22380. */
  22381. protected _useSpecularOverAlpha: boolean;
  22382. /**
  22383. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  22384. */
  22385. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  22386. /**
  22387. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  22388. */
  22389. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  22390. /**
  22391. * Specifies if the metallic texture contains the roughness information in its green channel.
  22392. */
  22393. protected _useRoughnessFromMetallicTextureGreen: boolean;
  22394. /**
  22395. * Specifies if the metallic texture contains the metallness information in its blue channel.
  22396. */
  22397. protected _useMetallnessFromMetallicTextureBlue: boolean;
  22398. /**
  22399. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  22400. */
  22401. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  22402. /**
  22403. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  22404. */
  22405. protected _useAmbientInGrayScale: boolean;
  22406. /**
  22407. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  22408. * The material will try to infer what glossiness each pixel should be.
  22409. */
  22410. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  22411. /**
  22412. * Defines the falloff type used in this material.
  22413. * It by default is Physical.
  22414. */
  22415. protected _lightFalloff: number;
  22416. /**
  22417. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  22418. * A car glass is a good example of that. When the street lights reflects on it you can not see what is behind.
  22419. */
  22420. protected _useRadianceOverAlpha: boolean;
  22421. /**
  22422. * Allows using an object space normal map (instead of tangent space).
  22423. */
  22424. protected _useObjectSpaceNormalMap: boolean;
  22425. /**
  22426. * Allows using the bump map in parallax mode.
  22427. */
  22428. protected _useParallax: boolean;
  22429. /**
  22430. * Allows using the bump map in parallax occlusion mode.
  22431. */
  22432. protected _useParallaxOcclusion: boolean;
  22433. /**
  22434. * Controls the scale bias of the parallax mode.
  22435. */
  22436. protected _parallaxScaleBias: number;
  22437. /**
  22438. * If sets to true, disables all the lights affecting the material.
  22439. */
  22440. protected _disableLighting: boolean;
  22441. /**
  22442. * Number of Simultaneous lights allowed on the material.
  22443. */
  22444. protected _maxSimultaneousLights: number;
  22445. /**
  22446. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  22447. */
  22448. protected _invertNormalMapX: boolean;
  22449. /**
  22450. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  22451. */
  22452. protected _invertNormalMapY: boolean;
  22453. /**
  22454. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22455. */
  22456. protected _twoSidedLighting: boolean;
  22457. /**
  22458. * Defines the alpha limits in alpha test mode.
  22459. */
  22460. protected _alphaCutOff: number;
  22461. /**
  22462. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22463. */
  22464. protected _forceAlphaTest: boolean;
  22465. /**
  22466. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22467. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22468. */
  22469. protected _useAlphaFresnel: boolean;
  22470. /**
  22471. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22472. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22473. */
  22474. protected _useLinearAlphaFresnel: boolean;
  22475. /**
  22476. * Specifies the environment BRDF texture used to compute the scale and offset roughness values
  22477. * from cos theta and roughness:
  22478. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  22479. */
  22480. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  22481. /**
  22482. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22483. */
  22484. protected _forceIrradianceInFragment: boolean;
  22485. private _realTimeFiltering;
  22486. /**
  22487. * Enables realtime filtering on the texture.
  22488. */
  22489. get realTimeFiltering(): boolean;
  22490. set realTimeFiltering(b: boolean);
  22491. private _realTimeFilteringQuality;
  22492. /**
  22493. * Quality switch for realtime filtering
  22494. */
  22495. get realTimeFilteringQuality(): number;
  22496. set realTimeFilteringQuality(n: number);
  22497. /**
  22498. * Can this material render to several textures at once
  22499. */
  22500. get canRenderToMRT(): boolean;
  22501. /**
  22502. * Force normal to face away from face.
  22503. */
  22504. protected _forceNormalForward: boolean;
  22505. /**
  22506. * Enables specular anti aliasing in the PBR shader.
  22507. * It will both interacts on the Geometry for analytical and IBL lighting.
  22508. * It also prefilter the roughness map based on the bump values.
  22509. */
  22510. protected _enableSpecularAntiAliasing: boolean;
  22511. /**
  22512. * Default configuration related to image processing available in the PBR Material.
  22513. */
  22514. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22515. /**
  22516. * Keep track of the image processing observer to allow dispose and replace.
  22517. */
  22518. private _imageProcessingObserver;
  22519. /**
  22520. * Attaches a new image processing configuration to the PBR Material.
  22521. * @param configuration
  22522. */
  22523. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22524. /**
  22525. * Stores the available render targets.
  22526. */
  22527. private _renderTargets;
  22528. /**
  22529. * Sets the global ambient color for the material used in lighting calculations.
  22530. */
  22531. private _globalAmbientColor;
  22532. /**
  22533. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  22534. */
  22535. private _useLogarithmicDepth;
  22536. /**
  22537. * If set to true, no lighting calculations will be applied.
  22538. */
  22539. private _unlit;
  22540. private _debugMode;
  22541. /**
  22542. * @hidden
  22543. * This is reserved for the inspector.
  22544. * Defines the material debug mode.
  22545. * It helps seeing only some components of the material while troubleshooting.
  22546. */
  22547. debugMode: number;
  22548. /**
  22549. * @hidden
  22550. * This is reserved for the inspector.
  22551. * Specify from where on screen the debug mode should start.
  22552. * The value goes from -1 (full screen) to 1 (not visible)
  22553. * It helps with side by side comparison against the final render
  22554. * This defaults to -1
  22555. */
  22556. private debugLimit;
  22557. /**
  22558. * @hidden
  22559. * This is reserved for the inspector.
  22560. * As the default viewing range might not be enough (if the ambient is really small for instance)
  22561. * You can use the factor to better multiply the final value.
  22562. */
  22563. private debugFactor;
  22564. /**
  22565. * Defines the clear coat layer parameters for the material.
  22566. */
  22567. readonly clearCoat: PBRClearCoatConfiguration;
  22568. /**
  22569. * Defines the anisotropic parameters for the material.
  22570. */
  22571. readonly anisotropy: PBRAnisotropicConfiguration;
  22572. /**
  22573. * Defines the BRDF parameters for the material.
  22574. */
  22575. readonly brdf: PBRBRDFConfiguration;
  22576. /**
  22577. * Defines the Sheen parameters for the material.
  22578. */
  22579. readonly sheen: PBRSheenConfiguration;
  22580. /**
  22581. * Defines the SubSurface parameters for the material.
  22582. */
  22583. readonly subSurface: PBRSubSurfaceConfiguration;
  22584. /**
  22585. * Defines additional PrePass parameters for the material.
  22586. */
  22587. readonly prePassConfiguration: PrePassConfiguration;
  22588. /**
  22589. * Defines the detail map parameters for the material.
  22590. */
  22591. readonly detailMap: DetailMapConfiguration;
  22592. protected _rebuildInParallel: boolean;
  22593. /**
  22594. * Instantiates a new PBRMaterial instance.
  22595. *
  22596. * @param name The material name
  22597. * @param scene The scene the material will be use in.
  22598. */
  22599. constructor(name: string, scene: Scene);
  22600. /**
  22601. * Gets a boolean indicating that current material needs to register RTT
  22602. */
  22603. get hasRenderTargetTextures(): boolean;
  22604. /**
  22605. * Can this material render to prepass
  22606. */
  22607. get isPrePassCapable(): boolean;
  22608. /**
  22609. * Gets the name of the material class.
  22610. */
  22611. getClassName(): string;
  22612. /**
  22613. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22614. */
  22615. get useLogarithmicDepth(): boolean;
  22616. /**
  22617. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22618. */
  22619. set useLogarithmicDepth(value: boolean);
  22620. /**
  22621. * Returns true if alpha blending should be disabled.
  22622. */
  22623. protected get _disableAlphaBlending(): boolean;
  22624. /**
  22625. * Specifies whether or not this material should be rendered in alpha blend mode.
  22626. */
  22627. needAlphaBlending(): boolean;
  22628. /**
  22629. * Specifies whether or not this material should be rendered in alpha test mode.
  22630. */
  22631. needAlphaTesting(): boolean;
  22632. /**
  22633. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  22634. */
  22635. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  22636. /**
  22637. * Specifies whether or not there is a usable alpha channel for transparency.
  22638. */
  22639. protected _hasAlphaChannel(): boolean;
  22640. /**
  22641. * Gets the texture used for the alpha test.
  22642. */
  22643. getAlphaTestTexture(): Nullable<BaseTexture>;
  22644. /**
  22645. * Specifies that the submesh is ready to be used.
  22646. * @param mesh - BJS mesh.
  22647. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  22648. * @param useInstances - Specifies that instances should be used.
  22649. * @returns - boolean indicating that the submesh is ready or not.
  22650. */
  22651. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22652. /**
  22653. * Specifies if the material uses metallic roughness workflow.
  22654. * @returns boolean specifying if the material uses metallic roughness workflow.
  22655. */
  22656. isMetallicWorkflow(): boolean;
  22657. private _prepareEffect;
  22658. private _prepareDefines;
  22659. /**
  22660. * Force shader compilation
  22661. */
  22662. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  22663. /**
  22664. * Initializes the uniform buffer layout for the shader.
  22665. */
  22666. buildUniformLayout(): void;
  22667. /**
  22668. * Unbinds the material from the mesh
  22669. */
  22670. unbind(): void;
  22671. /**
  22672. * Binds the submesh data.
  22673. * @param world - The world matrix.
  22674. * @param mesh - The BJS mesh.
  22675. * @param subMesh - A submesh of the BJS mesh.
  22676. */
  22677. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22678. /**
  22679. * Returns the animatable textures.
  22680. * @returns - Array of animatable textures.
  22681. */
  22682. getAnimatables(): IAnimatable[];
  22683. /**
  22684. * Returns the texture used for reflections.
  22685. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  22686. */
  22687. private _getReflectionTexture;
  22688. /**
  22689. * Returns an array of the actively used textures.
  22690. * @returns - Array of BaseTextures
  22691. */
  22692. getActiveTextures(): BaseTexture[];
  22693. /**
  22694. * Checks to see if a texture is used in the material.
  22695. * @param texture - Base texture to use.
  22696. * @returns - Boolean specifying if a texture is used in the material.
  22697. */
  22698. hasTexture(texture: BaseTexture): boolean;
  22699. /**
  22700. * Sets the required values to the prepass renderer.
  22701. * @param prePassRenderer defines the prepass renderer to setup
  22702. */
  22703. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  22704. /**
  22705. * Disposes the resources of the material.
  22706. * @param forceDisposeEffect - Forces the disposal of effects.
  22707. * @param forceDisposeTextures - Forces the disposal of all textures.
  22708. */
  22709. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  22710. }
  22711. }
  22712. declare module BABYLON {
  22713. /**
  22714. * The Physically based material of BJS.
  22715. *
  22716. * This offers the main features of a standard PBR material.
  22717. * For more information, please refer to the documentation :
  22718. * https://doc.babylonjs.com/how_to/physically_based_rendering
  22719. */
  22720. export class PBRMaterial extends PBRBaseMaterial {
  22721. /**
  22722. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  22723. */
  22724. static readonly PBRMATERIAL_OPAQUE: number;
  22725. /**
  22726. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  22727. */
  22728. static readonly PBRMATERIAL_ALPHATEST: number;
  22729. /**
  22730. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22731. */
  22732. static readonly PBRMATERIAL_ALPHABLEND: number;
  22733. /**
  22734. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22735. * They are also discarded below the alpha cutoff threshold to improve performances.
  22736. */
  22737. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  22738. /**
  22739. * Defines the default value of how much AO map is occluding the analytical lights
  22740. * (point spot...).
  22741. */
  22742. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  22743. /**
  22744. * Intensity of the direct lights e.g. the four lights available in your scene.
  22745. * This impacts both the direct diffuse and specular highlights.
  22746. */
  22747. directIntensity: number;
  22748. /**
  22749. * Intensity of the emissive part of the material.
  22750. * This helps controlling the emissive effect without modifying the emissive color.
  22751. */
  22752. emissiveIntensity: number;
  22753. /**
  22754. * Intensity of the environment e.g. how much the environment will light the object
  22755. * either through harmonics for rough material or through the reflection for shiny ones.
  22756. */
  22757. environmentIntensity: number;
  22758. /**
  22759. * This is a special control allowing the reduction of the specular highlights coming from the
  22760. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  22761. */
  22762. specularIntensity: number;
  22763. /**
  22764. * Debug Control allowing disabling the bump map on this material.
  22765. */
  22766. disableBumpMap: boolean;
  22767. /**
  22768. * AKA Diffuse Texture in standard nomenclature.
  22769. */
  22770. albedoTexture: BaseTexture;
  22771. /**
  22772. * AKA Occlusion Texture in other nomenclature.
  22773. */
  22774. ambientTexture: BaseTexture;
  22775. /**
  22776. * AKA Occlusion Texture Intensity in other nomenclature.
  22777. */
  22778. ambientTextureStrength: number;
  22779. /**
  22780. * Defines how much the AO map is occluding the analytical lights (point spot...).
  22781. * 1 means it completely occludes it
  22782. * 0 mean it has no impact
  22783. */
  22784. ambientTextureImpactOnAnalyticalLights: number;
  22785. /**
  22786. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  22787. */
  22788. opacityTexture: BaseTexture;
  22789. /**
  22790. * Stores the reflection values in a texture.
  22791. */
  22792. reflectionTexture: Nullable<BaseTexture>;
  22793. /**
  22794. * Stores the emissive values in a texture.
  22795. */
  22796. emissiveTexture: BaseTexture;
  22797. /**
  22798. * AKA Specular texture in other nomenclature.
  22799. */
  22800. reflectivityTexture: BaseTexture;
  22801. /**
  22802. * Used to switch from specular/glossiness to metallic/roughness workflow.
  22803. */
  22804. metallicTexture: BaseTexture;
  22805. /**
  22806. * Specifies the metallic scalar of the metallic/roughness workflow.
  22807. * Can also be used to scale the metalness values of the metallic texture.
  22808. */
  22809. metallic: Nullable<number>;
  22810. /**
  22811. * Specifies the roughness scalar of the metallic/roughness workflow.
  22812. * Can also be used to scale the roughness values of the metallic texture.
  22813. */
  22814. roughness: Nullable<number>;
  22815. /**
  22816. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  22817. * By default the indexOfrefraction is used to compute F0;
  22818. *
  22819. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  22820. *
  22821. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  22822. * F90 = metallicReflectanceColor;
  22823. */
  22824. metallicF0Factor: number;
  22825. /**
  22826. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  22827. * By default the F90 is always 1;
  22828. *
  22829. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  22830. *
  22831. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  22832. * F90 = metallicReflectanceColor;
  22833. */
  22834. metallicReflectanceColor: Color3;
  22835. /**
  22836. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  22837. * This is multiply against the scalar values defined in the material.
  22838. */
  22839. metallicReflectanceTexture: Nullable<BaseTexture>;
  22840. /**
  22841. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  22842. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  22843. */
  22844. microSurfaceTexture: BaseTexture;
  22845. /**
  22846. * Stores surface normal data used to displace a mesh in a texture.
  22847. */
  22848. bumpTexture: BaseTexture;
  22849. /**
  22850. * Stores the pre-calculated light information of a mesh in a texture.
  22851. */
  22852. lightmapTexture: BaseTexture;
  22853. /**
  22854. * Stores the refracted light information in a texture.
  22855. */
  22856. get refractionTexture(): Nullable<BaseTexture>;
  22857. set refractionTexture(value: Nullable<BaseTexture>);
  22858. /**
  22859. * The color of a material in ambient lighting.
  22860. */
  22861. ambientColor: Color3;
  22862. /**
  22863. * AKA Diffuse Color in other nomenclature.
  22864. */
  22865. albedoColor: Color3;
  22866. /**
  22867. * AKA Specular Color in other nomenclature.
  22868. */
  22869. reflectivityColor: Color3;
  22870. /**
  22871. * The color reflected from the material.
  22872. */
  22873. reflectionColor: Color3;
  22874. /**
  22875. * The color emitted from the material.
  22876. */
  22877. emissiveColor: Color3;
  22878. /**
  22879. * AKA Glossiness in other nomenclature.
  22880. */
  22881. microSurface: number;
  22882. /**
  22883. * Index of refraction of the material base layer.
  22884. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  22885. *
  22886. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  22887. *
  22888. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  22889. */
  22890. get indexOfRefraction(): number;
  22891. set indexOfRefraction(value: number);
  22892. /**
  22893. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  22894. */
  22895. get invertRefractionY(): boolean;
  22896. set invertRefractionY(value: boolean);
  22897. /**
  22898. * This parameters will make the material used its opacity to control how much it is refracting against not.
  22899. * Materials half opaque for instance using refraction could benefit from this control.
  22900. */
  22901. get linkRefractionWithTransparency(): boolean;
  22902. set linkRefractionWithTransparency(value: boolean);
  22903. /**
  22904. * If true, the light map contains occlusion information instead of lighting info.
  22905. */
  22906. useLightmapAsShadowmap: boolean;
  22907. /**
  22908. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  22909. */
  22910. useAlphaFromAlbedoTexture: boolean;
  22911. /**
  22912. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22913. */
  22914. forceAlphaTest: boolean;
  22915. /**
  22916. * Defines the alpha limits in alpha test mode.
  22917. */
  22918. alphaCutOff: number;
  22919. /**
  22920. * Specifies that the material will keep the specular highlights over a transparent surface (only the most luminous ones).
  22921. * A car glass is a good example of that. When sun reflects on it you can not see what is behind.
  22922. */
  22923. useSpecularOverAlpha: boolean;
  22924. /**
  22925. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  22926. */
  22927. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  22928. /**
  22929. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  22930. */
  22931. useRoughnessFromMetallicTextureAlpha: boolean;
  22932. /**
  22933. * Specifies if the metallic texture contains the roughness information in its green channel.
  22934. */
  22935. useRoughnessFromMetallicTextureGreen: boolean;
  22936. /**
  22937. * Specifies if the metallic texture contains the metallness information in its blue channel.
  22938. */
  22939. useMetallnessFromMetallicTextureBlue: boolean;
  22940. /**
  22941. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  22942. */
  22943. useAmbientOcclusionFromMetallicTextureRed: boolean;
  22944. /**
  22945. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  22946. */
  22947. useAmbientInGrayScale: boolean;
  22948. /**
  22949. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  22950. * The material will try to infer what glossiness each pixel should be.
  22951. */
  22952. useAutoMicroSurfaceFromReflectivityMap: boolean;
  22953. /**
  22954. * BJS is using an hardcoded light falloff based on a manually sets up range.
  22955. * In PBR, one way to represents the falloff is to use the inverse squared root algorithm.
  22956. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22957. */
  22958. get usePhysicalLightFalloff(): boolean;
  22959. /**
  22960. * BJS is using an hardcoded light falloff based on a manually sets up range.
  22961. * In PBR, one way to represents the falloff is to use the inverse squared root algorithm.
  22962. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22963. */
  22964. set usePhysicalLightFalloff(value: boolean);
  22965. /**
  22966. * In order to support the falloff compatibility with gltf, a special mode has been added
  22967. * to reproduce the gltf light falloff.
  22968. */
  22969. get useGLTFLightFalloff(): boolean;
  22970. /**
  22971. * In order to support the falloff compatibility with gltf, a special mode has been added
  22972. * to reproduce the gltf light falloff.
  22973. */
  22974. set useGLTFLightFalloff(value: boolean);
  22975. /**
  22976. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  22977. * A car glass is a good example of that. When the street lights reflects on it you can not see what is behind.
  22978. */
  22979. useRadianceOverAlpha: boolean;
  22980. /**
  22981. * Allows using an object space normal map (instead of tangent space).
  22982. */
  22983. useObjectSpaceNormalMap: boolean;
  22984. /**
  22985. * Allows using the bump map in parallax mode.
  22986. */
  22987. useParallax: boolean;
  22988. /**
  22989. * Allows using the bump map in parallax occlusion mode.
  22990. */
  22991. useParallaxOcclusion: boolean;
  22992. /**
  22993. * Controls the scale bias of the parallax mode.
  22994. */
  22995. parallaxScaleBias: number;
  22996. /**
  22997. * If sets to true, disables all the lights affecting the material.
  22998. */
  22999. disableLighting: boolean;
  23000. /**
  23001. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  23002. */
  23003. forceIrradianceInFragment: boolean;
  23004. /**
  23005. * Number of Simultaneous lights allowed on the material.
  23006. */
  23007. maxSimultaneousLights: number;
  23008. /**
  23009. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  23010. */
  23011. invertNormalMapX: boolean;
  23012. /**
  23013. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  23014. */
  23015. invertNormalMapY: boolean;
  23016. /**
  23017. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  23018. */
  23019. twoSidedLighting: boolean;
  23020. /**
  23021. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  23022. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  23023. */
  23024. useAlphaFresnel: boolean;
  23025. /**
  23026. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  23027. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  23028. */
  23029. useLinearAlphaFresnel: boolean;
  23030. /**
  23031. * Let user defines the brdf lookup texture used for IBL.
  23032. * A default 8bit version is embedded but you could point at :
  23033. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  23034. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  23035. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  23036. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  23037. */
  23038. environmentBRDFTexture: Nullable<BaseTexture>;
  23039. /**
  23040. * Force normal to face away from face.
  23041. */
  23042. forceNormalForward: boolean;
  23043. /**
  23044. * Enables specular anti aliasing in the PBR shader.
  23045. * It will both interacts on the Geometry for analytical and IBL lighting.
  23046. * It also prefilter the roughness map based on the bump values.
  23047. */
  23048. enableSpecularAntiAliasing: boolean;
  23049. /**
  23050. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  23051. * makes the reflect vector face the model (under horizon).
  23052. */
  23053. useHorizonOcclusion: boolean;
  23054. /**
  23055. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  23056. * too much the area relying on ambient texture to define their ambient occlusion.
  23057. */
  23058. useRadianceOcclusion: boolean;
  23059. /**
  23060. * If set to true, no lighting calculations will be applied.
  23061. */
  23062. unlit: boolean;
  23063. /**
  23064. * Gets the image processing configuration used either in this material.
  23065. */
  23066. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23067. /**
  23068. * Sets the Default image processing configuration used either in the this material.
  23069. *
  23070. * If sets to null, the scene one is in use.
  23071. */
  23072. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23073. /**
  23074. * Gets whether the color curves effect is enabled.
  23075. */
  23076. get cameraColorCurvesEnabled(): boolean;
  23077. /**
  23078. * Sets whether the color curves effect is enabled.
  23079. */
  23080. set cameraColorCurvesEnabled(value: boolean);
  23081. /**
  23082. * Gets whether the color grading effect is enabled.
  23083. */
  23084. get cameraColorGradingEnabled(): boolean;
  23085. /**
  23086. * Gets whether the color grading effect is enabled.
  23087. */
  23088. set cameraColorGradingEnabled(value: boolean);
  23089. /**
  23090. * Gets whether tonemapping is enabled or not.
  23091. */
  23092. get cameraToneMappingEnabled(): boolean;
  23093. /**
  23094. * Sets whether tonemapping is enabled or not
  23095. */
  23096. set cameraToneMappingEnabled(value: boolean);
  23097. /**
  23098. * The camera exposure used on this material.
  23099. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  23100. * This corresponds to a photographic exposure.
  23101. */
  23102. get cameraExposure(): number;
  23103. /**
  23104. * The camera exposure used on this material.
  23105. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  23106. * This corresponds to a photographic exposure.
  23107. */
  23108. set cameraExposure(value: number);
  23109. /**
  23110. * Gets The camera contrast used on this material.
  23111. */
  23112. get cameraContrast(): number;
  23113. /**
  23114. * Sets The camera contrast used on this material.
  23115. */
  23116. set cameraContrast(value: number);
  23117. /**
  23118. * Gets the Color Grading 2D Lookup Texture.
  23119. */
  23120. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  23121. /**
  23122. * Sets the Color Grading 2D Lookup Texture.
  23123. */
  23124. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  23125. /**
  23126. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  23127. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  23128. * 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;
  23129. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  23130. */
  23131. get cameraColorCurves(): Nullable<ColorCurves>;
  23132. /**
  23133. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  23134. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  23135. * 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;
  23136. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  23137. */
  23138. set cameraColorCurves(value: Nullable<ColorCurves>);
  23139. /**
  23140. * Instantiates a new PBRMaterial instance.
  23141. *
  23142. * @param name The material name
  23143. * @param scene The scene the material will be use in.
  23144. */
  23145. constructor(name: string, scene: Scene);
  23146. /**
  23147. * Returns the name of this material class.
  23148. */
  23149. getClassName(): string;
  23150. /**
  23151. * Makes a duplicate of the current material.
  23152. * @param name - name to use for the new material.
  23153. */
  23154. clone(name: string): PBRMaterial;
  23155. /**
  23156. * Serializes this PBR Material.
  23157. * @returns - An object with the serialized material.
  23158. */
  23159. serialize(): any;
  23160. /**
  23161. * Parses a PBR Material from a serialized object.
  23162. * @param source - Serialized object.
  23163. * @param scene - BJS scene instance.
  23164. * @param rootUrl - url for the scene object
  23165. * @returns - PBRMaterial
  23166. */
  23167. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  23168. }
  23169. }
  23170. declare module BABYLON {
  23171. /** @hidden */
  23172. export var mrtFragmentDeclaration: {
  23173. name: string;
  23174. shader: string;
  23175. };
  23176. }
  23177. declare module BABYLON {
  23178. /** @hidden */
  23179. export var geometryPixelShader: {
  23180. name: string;
  23181. shader: string;
  23182. };
  23183. }
  23184. declare module BABYLON {
  23185. /** @hidden */
  23186. export var instancesDeclaration: {
  23187. name: string;
  23188. shader: string;
  23189. };
  23190. }
  23191. declare module BABYLON {
  23192. /** @hidden */
  23193. export var geometryVertexDeclaration: {
  23194. name: string;
  23195. shader: string;
  23196. };
  23197. }
  23198. declare module BABYLON {
  23199. /** @hidden */
  23200. export var geometryUboDeclaration: {
  23201. name: string;
  23202. shader: string;
  23203. };
  23204. }
  23205. declare module BABYLON {
  23206. /** @hidden */
  23207. export var geometryVertexShader: {
  23208. name: string;
  23209. shader: string;
  23210. };
  23211. }
  23212. declare module BABYLON {
  23213. /** @hidden */
  23214. interface ISavedTransformationMatrix {
  23215. world: Matrix;
  23216. viewProjection: Matrix;
  23217. }
  23218. /**
  23219. * This renderer is helpful to fill one of the render target with a geometry buffer.
  23220. */
  23221. export class GeometryBufferRenderer {
  23222. /**
  23223. * Constant used to retrieve the depth texture index in the G-Buffer textures array
  23224. * using getIndex(GeometryBufferRenderer.DEPTH_TEXTURE_INDEX)
  23225. */
  23226. static readonly DEPTH_TEXTURE_TYPE: number;
  23227. /**
  23228. * Constant used to retrieve the normal texture index in the G-Buffer textures array
  23229. * using getIndex(GeometryBufferRenderer.NORMAL_TEXTURE_INDEX)
  23230. */
  23231. static readonly NORMAL_TEXTURE_TYPE: number;
  23232. /**
  23233. * Constant used to retrieve the position texture index in the G-Buffer textures array
  23234. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  23235. */
  23236. static readonly POSITION_TEXTURE_TYPE: number;
  23237. /**
  23238. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  23239. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  23240. */
  23241. static readonly VELOCITY_TEXTURE_TYPE: number;
  23242. /**
  23243. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  23244. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  23245. */
  23246. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  23247. /**
  23248. * Dictionary used to store the previous transformation matrices of each rendered mesh
  23249. * in order to compute objects velocities when enableVelocity is set to "true"
  23250. * @hidden
  23251. */
  23252. _previousTransformationMatrices: {
  23253. [index: number]: ISavedTransformationMatrix;
  23254. };
  23255. /**
  23256. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  23257. * in order to compute objects velocities when enableVelocity is set to "true"
  23258. * @hidden
  23259. */
  23260. _previousBonesTransformationMatrices: {
  23261. [index: number]: Float32Array;
  23262. };
  23263. /**
  23264. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  23265. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  23266. */
  23267. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  23268. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  23269. renderTransparentMeshes: boolean;
  23270. private _scene;
  23271. private _resizeObserver;
  23272. private _multiRenderTarget;
  23273. private _ratio;
  23274. private _enablePosition;
  23275. private _enableVelocity;
  23276. private _enableReflectivity;
  23277. private _positionIndex;
  23278. private _velocityIndex;
  23279. private _reflectivityIndex;
  23280. private _depthIndex;
  23281. private _normalIndex;
  23282. private _linkedWithPrePass;
  23283. private _prePassRenderer;
  23284. private _attachments;
  23285. private _useUbo;
  23286. protected _effect: Effect;
  23287. protected _cachedDefines: string;
  23288. /**
  23289. * @hidden
  23290. * Sets up internal structures to share outputs with PrePassRenderer
  23291. * This method should only be called by the PrePassRenderer itself
  23292. */
  23293. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  23294. /**
  23295. * @hidden
  23296. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  23297. * This method should only be called by the PrePassRenderer itself
  23298. */
  23299. _unlinkPrePassRenderer(): void;
  23300. /**
  23301. * @hidden
  23302. * Resets the geometry buffer layout
  23303. */
  23304. _resetLayout(): void;
  23305. /**
  23306. * @hidden
  23307. * Replaces a texture in the geometry buffer renderer
  23308. * Useful when linking textures of the prepass renderer
  23309. */
  23310. _forceTextureType(geometryBufferType: number, index: number): void;
  23311. /**
  23312. * @hidden
  23313. * Sets texture attachments
  23314. * Useful when linking textures of the prepass renderer
  23315. */
  23316. _setAttachments(attachments: number[]): void;
  23317. /**
  23318. * @hidden
  23319. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  23320. * Useful when linking textures of the prepass renderer
  23321. */
  23322. _linkInternalTexture(internalTexture: InternalTexture): void;
  23323. /**
  23324. * Gets the render list (meshes to be rendered) used in the G buffer.
  23325. */
  23326. get renderList(): Nullable<AbstractMesh[]>;
  23327. /**
  23328. * Set the render list (meshes to be rendered) used in the G buffer.
  23329. */
  23330. set renderList(meshes: Nullable<AbstractMesh[]>);
  23331. /**
  23332. * Gets whether or not G buffer are supported by the running hardware.
  23333. * This requires draw buffer supports
  23334. */
  23335. get isSupported(): boolean;
  23336. /**
  23337. * Returns the index of the given texture type in the G-Buffer textures array
  23338. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  23339. * @returns the index of the given texture type in the G-Buffer textures array
  23340. */
  23341. getTextureIndex(textureType: number): number;
  23342. /**
  23343. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  23344. */
  23345. get enablePosition(): boolean;
  23346. /**
  23347. * Sets whether or not objects positions are enabled for the G buffer.
  23348. */
  23349. set enablePosition(enable: boolean);
  23350. /**
  23351. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  23352. */
  23353. get enableVelocity(): boolean;
  23354. /**
  23355. * Sets whether or not objects velocities are enabled for the G buffer.
  23356. */
  23357. set enableVelocity(enable: boolean);
  23358. /**
  23359. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  23360. */
  23361. get enableReflectivity(): boolean;
  23362. /**
  23363. * Sets whether or not objects roughness are enabled for the G buffer.
  23364. */
  23365. set enableReflectivity(enable: boolean);
  23366. /**
  23367. * Gets the scene associated with the buffer.
  23368. */
  23369. get scene(): Scene;
  23370. /**
  23371. * Gets the ratio used by the buffer during its creation.
  23372. * How big is the buffer related to the main canvas.
  23373. */
  23374. get ratio(): number;
  23375. /** @hidden */
  23376. static _SceneComponentInitialization: (scene: Scene) => void;
  23377. /**
  23378. * Creates a new G Buffer for the scene
  23379. * @param scene The scene the buffer belongs to
  23380. * @param ratio How big is the buffer related to the main canvas.
  23381. */
  23382. constructor(scene: Scene, ratio?: number);
  23383. /**
  23384. * Checks whether everything is ready to render a submesh to the G buffer.
  23385. * @param subMesh the submesh to check readiness for
  23386. * @param useInstances is the mesh drawn using instance or not
  23387. * @returns true if ready otherwise false
  23388. */
  23389. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  23390. /**
  23391. * Gets the current underlying G Buffer.
  23392. * @returns the buffer
  23393. */
  23394. getGBuffer(): MultiRenderTarget;
  23395. /**
  23396. * Gets the number of samples used to render the buffer (anti aliasing).
  23397. */
  23398. get samples(): number;
  23399. /**
  23400. * Sets the number of samples used to render the buffer (anti aliasing).
  23401. */
  23402. set samples(value: number);
  23403. /**
  23404. * Disposes the renderer and frees up associated resources.
  23405. */
  23406. dispose(): void;
  23407. private _assignRenderTargetIndices;
  23408. protected _createRenderTargets(): void;
  23409. private _copyBonesTransformationMatrices;
  23410. }
  23411. }
  23412. declare module BABYLON {
  23413. /**
  23414. * Renders a pre pass of the scene
  23415. * This means every mesh in the scene will be rendered to a render target texture
  23416. * And then this texture will be composited to the rendering canvas with post processes
  23417. * It is necessary for effects like subsurface scattering or deferred shading
  23418. */
  23419. export class PrePassRenderer {
  23420. /** @hidden */
  23421. static _SceneComponentInitialization: (scene: Scene) => void;
  23422. /**
  23423. * To save performance, we can excluded skinned meshes from the prepass
  23424. */
  23425. excludedSkinnedMesh: AbstractMesh[];
  23426. /**
  23427. * Force material to be excluded from the prepass
  23428. * Can be useful when `useGeometryBufferFallback` is set to `true`
  23429. * and you don't want a material to show in the effect.
  23430. */
  23431. excludedMaterials: Material[];
  23432. private _scene;
  23433. private _engine;
  23434. /**
  23435. * Number of textures in the multi render target texture where the scene is directly rendered
  23436. */
  23437. mrtCount: number;
  23438. private _mrtFormats;
  23439. private _mrtLayout;
  23440. private _textureIndices;
  23441. private _multiRenderAttachments;
  23442. private _defaultAttachments;
  23443. private _clearAttachments;
  23444. /**
  23445. * Returns the index of a texture in the multi render target texture array.
  23446. * @param type Texture type
  23447. * @return The index
  23448. */
  23449. getIndex(type: number): number;
  23450. /**
  23451. * How many samples are used for MSAA of the scene render target
  23452. */
  23453. get samples(): number;
  23454. set samples(n: number);
  23455. private static _textureFormats;
  23456. private _isDirty;
  23457. /**
  23458. * The render target where the scene is directly rendered
  23459. */
  23460. defaultRT: PrePassRenderTarget;
  23461. /**
  23462. * Configuration for prepass effects
  23463. */
  23464. private _effectConfigurations;
  23465. /**
  23466. * @return the prepass render target for the rendering pass.
  23467. * If we are currently rendering a render target, it returns the PrePassRenderTarget
  23468. * associated with that render target. Otherwise, it returns the scene default PrePassRenderTarget
  23469. */
  23470. getRenderTarget(): PrePassRenderTarget;
  23471. /**
  23472. * @hidden
  23473. * Managed by the scene component
  23474. * @param prePassRenderTarget
  23475. */
  23476. _setRenderTarget(prePassRenderTarget: Nullable<PrePassRenderTarget>): void;
  23477. /**
  23478. * Returns true if the currently rendered prePassRenderTarget is the one
  23479. * associated with the scene.
  23480. */
  23481. get currentRTisSceneRT(): boolean;
  23482. private _geometryBuffer;
  23483. /**
  23484. * Prevents the PrePassRenderer from using the GeometryBufferRenderer as a fallback
  23485. */
  23486. doNotUseGeometryRendererFallback: boolean;
  23487. private _refreshGeometryBufferRendererLink;
  23488. private _currentTarget;
  23489. /**
  23490. * All the render targets generated by prepass
  23491. */
  23492. renderTargets: PrePassRenderTarget[];
  23493. private readonly _clearColor;
  23494. private _enabled;
  23495. private _needsCompositionForThisPass;
  23496. private _postProcessesSourceForThisPass;
  23497. /**
  23498. * Indicates if the prepass is enabled
  23499. */
  23500. get enabled(): boolean;
  23501. /**
  23502. * Set to true to disable gamma transform in PrePass.
  23503. * Can be useful in case you already proceed to gamma transform on a material level
  23504. * and your post processes don't need to be in linear color space.
  23505. */
  23506. disableGammaTransform: boolean;
  23507. /**
  23508. * Instanciates a prepass renderer
  23509. * @param scene The scene
  23510. */
  23511. constructor(scene: Scene);
  23512. /**
  23513. * Creates a new PrePassRenderTarget
  23514. * This should be the only way to instanciate a `PrePassRenderTarget`
  23515. * @param name Name of the `PrePassRenderTarget`
  23516. * @param renderTargetTexture RenderTarget the `PrePassRenderTarget` will be attached to.
  23517. * Can be `null` if the created `PrePassRenderTarget` is attached to the scene (default framebuffer).
  23518. * @hidden
  23519. */
  23520. _createRenderTarget(name: string, renderTargetTexture: Nullable<RenderTargetTexture>): PrePassRenderTarget;
  23521. /**
  23522. * Indicates if rendering a prepass is supported
  23523. */
  23524. get isSupported(): boolean;
  23525. /**
  23526. * Sets the proper output textures to draw in the engine.
  23527. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  23528. * @param subMesh Submesh on which the effect is applied
  23529. */
  23530. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  23531. private _reinitializeAttachments;
  23532. private _resetLayout;
  23533. private _updateGeometryBufferLayout;
  23534. /**
  23535. * Restores attachments for single texture draw.
  23536. */
  23537. restoreAttachments(): void;
  23538. /**
  23539. * @hidden
  23540. */
  23541. _beforeDraw(camera?: Camera, faceIndex?: number, layer?: number): void;
  23542. private _prepareFrame;
  23543. private _renderPostProcesses;
  23544. /**
  23545. * @hidden
  23546. */
  23547. _afterDraw(faceIndex?: number, layer?: number): void;
  23548. /**
  23549. * Clears the current prepass render target (in the sense of settings pixels to the scene clear color value)
  23550. * @hidden
  23551. */
  23552. _clear(): void;
  23553. private _bindFrameBuffer;
  23554. private _setEnabled;
  23555. private _setRenderTargetEnabled;
  23556. /**
  23557. * Adds an effect configuration to the prepass render target.
  23558. * If an effect has already been added, it won't add it twice and will return the configuration
  23559. * already present.
  23560. * @param cfg the effect configuration
  23561. * @return the effect configuration now used by the prepass
  23562. */
  23563. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  23564. private _enable;
  23565. private _disable;
  23566. private _getPostProcessesSource;
  23567. private _setupOutputForThisPass;
  23568. private _linkInternalTexture;
  23569. private _needsImageProcessing;
  23570. private _hasImageProcessing;
  23571. /**
  23572. * Internal, gets the first post proces.
  23573. * @returns the first post process to be run on this camera.
  23574. */
  23575. private _getFirstPostProcess;
  23576. /**
  23577. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  23578. */
  23579. markAsDirty(): void;
  23580. /**
  23581. * Enables a texture on the MultiRenderTarget for prepass
  23582. */
  23583. private _enableTextures;
  23584. private _update;
  23585. private _markAllMaterialsAsPrePassDirty;
  23586. /**
  23587. * Disposes the prepass renderer.
  23588. */
  23589. dispose(): void;
  23590. }
  23591. }
  23592. declare module BABYLON {
  23593. /**
  23594. * Size options for a post process
  23595. */
  23596. export type PostProcessOptions = {
  23597. width: number;
  23598. height: number;
  23599. };
  23600. /**
  23601. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23602. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23603. */
  23604. export class PostProcess {
  23605. /**
  23606. * Gets or sets the unique id of the post process
  23607. */
  23608. uniqueId: number;
  23609. /** Name of the PostProcess. */
  23610. name: string;
  23611. /**
  23612. * Width of the texture to apply the post process on
  23613. */
  23614. width: number;
  23615. /**
  23616. * Height of the texture to apply the post process on
  23617. */
  23618. height: number;
  23619. /**
  23620. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23621. */
  23622. nodeMaterialSource: Nullable<NodeMaterial>;
  23623. /**
  23624. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23625. * @hidden
  23626. */
  23627. _outputTexture: Nullable<InternalTexture>;
  23628. /**
  23629. * Sampling mode used by the shader
  23630. * See https://doc.babylonjs.com/classes/3.1/texture
  23631. */
  23632. renderTargetSamplingMode: number;
  23633. /**
  23634. * Clear color to use when screen clearing
  23635. */
  23636. clearColor: Color4;
  23637. /**
  23638. * If the buffer needs to be cleared before applying the post process. (default: true)
  23639. * Should be set to false if shader will overwrite all previous pixels.
  23640. */
  23641. autoClear: boolean;
  23642. /**
  23643. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23644. */
  23645. alphaMode: number;
  23646. /**
  23647. * Sets the setAlphaBlendConstants of the babylon engine
  23648. */
  23649. alphaConstants: Color4;
  23650. /**
  23651. * Animations to be used for the post processing
  23652. */
  23653. animations: Animation[];
  23654. /**
  23655. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23656. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23657. */
  23658. enablePixelPerfectMode: boolean;
  23659. /**
  23660. * Force the postprocess to be applied without taking in account viewport
  23661. */
  23662. forceFullscreenViewport: boolean;
  23663. /**
  23664. * List of inspectable custom properties (used by the Inspector)
  23665. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23666. */
  23667. inspectableCustomProperties: IInspectable[];
  23668. /**
  23669. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23670. *
  23671. * | Value | Type | Description |
  23672. * | ----- | ----------------------------------- | ----------- |
  23673. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23674. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23675. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23676. *
  23677. */
  23678. scaleMode: number;
  23679. /**
  23680. * Force textures to be a power of two (default: false)
  23681. */
  23682. alwaysForcePOT: boolean;
  23683. private _samples;
  23684. /**
  23685. * Number of sample textures (default: 1)
  23686. */
  23687. get samples(): number;
  23688. set samples(n: number);
  23689. /**
  23690. * Modify the scale of the post process to be the same as the viewport (default: false)
  23691. */
  23692. adaptScaleToCurrentViewport: boolean;
  23693. private _camera;
  23694. protected _scene: Scene;
  23695. private _engine;
  23696. private _options;
  23697. private _reusable;
  23698. private _renderId;
  23699. private _textureType;
  23700. private _textureFormat;
  23701. /**
  23702. * Smart array of input and output textures for the post process.
  23703. * @hidden
  23704. */
  23705. _textures: SmartArray<InternalTexture>;
  23706. /**
  23707. * Smart array of input and output textures for the post process.
  23708. * @hidden
  23709. */
  23710. private _textureCache;
  23711. /**
  23712. * The index in _textures that corresponds to the output texture.
  23713. * @hidden
  23714. */
  23715. _currentRenderTextureInd: number;
  23716. private _effect;
  23717. private _samplers;
  23718. private _fragmentUrl;
  23719. private _vertexUrl;
  23720. private _parameters;
  23721. protected _postProcessDefines: Nullable<string>;
  23722. private _scaleRatio;
  23723. protected _indexParameters: any;
  23724. private _shareOutputWithPostProcess;
  23725. private _texelSize;
  23726. /** @hidden */
  23727. _forcedOutputTexture: Nullable<InternalTexture>;
  23728. /**
  23729. * Prepass configuration in case this post process needs a texture from prepass
  23730. * @hidden
  23731. */
  23732. _prePassEffectConfiguration: PrePassEffectConfiguration;
  23733. /**
  23734. * Returns the fragment url or shader name used in the post process.
  23735. * @returns the fragment url or name in the shader store.
  23736. */
  23737. getEffectName(): string;
  23738. /**
  23739. * An event triggered when the postprocess is activated.
  23740. */
  23741. onActivateObservable: Observable<Camera>;
  23742. private _onActivateObserver;
  23743. /**
  23744. * A function that is added to the onActivateObservable
  23745. */
  23746. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23747. /**
  23748. * An event triggered when the postprocess changes its size.
  23749. */
  23750. onSizeChangedObservable: Observable<PostProcess>;
  23751. private _onSizeChangedObserver;
  23752. /**
  23753. * A function that is added to the onSizeChangedObservable
  23754. */
  23755. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23756. /**
  23757. * An event triggered when the postprocess applies its effect.
  23758. */
  23759. onApplyObservable: Observable<Effect>;
  23760. private _onApplyObserver;
  23761. /**
  23762. * A function that is added to the onApplyObservable
  23763. */
  23764. set onApply(callback: (effect: Effect) => void);
  23765. /**
  23766. * An event triggered before rendering the postprocess
  23767. */
  23768. onBeforeRenderObservable: Observable<Effect>;
  23769. private _onBeforeRenderObserver;
  23770. /**
  23771. * A function that is added to the onBeforeRenderObservable
  23772. */
  23773. set onBeforeRender(callback: (effect: Effect) => void);
  23774. /**
  23775. * An event triggered after rendering the postprocess
  23776. */
  23777. onAfterRenderObservable: Observable<Effect>;
  23778. private _onAfterRenderObserver;
  23779. /**
  23780. * A function that is added to the onAfterRenderObservable
  23781. */
  23782. set onAfterRender(callback: (efect: Effect) => void);
  23783. /**
  23784. * 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
  23785. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23786. */
  23787. get inputTexture(): InternalTexture;
  23788. set inputTexture(value: InternalTexture);
  23789. /**
  23790. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23791. * the only way to unset it is to use this function to restore its internal state
  23792. */
  23793. restoreDefaultInputTexture(): void;
  23794. /**
  23795. * Gets the camera which post process is applied to.
  23796. * @returns The camera the post process is applied to.
  23797. */
  23798. getCamera(): Camera;
  23799. /**
  23800. * Gets the texel size of the postprocess.
  23801. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23802. */
  23803. get texelSize(): Vector2;
  23804. /**
  23805. * Creates a new instance PostProcess
  23806. * @param name The name of the PostProcess.
  23807. * @param fragmentUrl The url of the fragment shader to be used.
  23808. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23809. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23810. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23811. * @param camera The camera to apply the render pass to.
  23812. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23813. * @param engine The engine which the post process will be applied. (default: current engine)
  23814. * @param reusable If the post process can be reused on the same frame. (default: false)
  23815. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23816. * @param textureType Type of textures used when performing the post process. (default: 0)
  23817. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23818. * @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
  23819. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  23820. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23821. */
  23822. 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);
  23823. /**
  23824. * Gets a string identifying the name of the class
  23825. * @returns "PostProcess" string
  23826. */
  23827. getClassName(): string;
  23828. /**
  23829. * Gets the engine which this post process belongs to.
  23830. * @returns The engine the post process was enabled with.
  23831. */
  23832. getEngine(): Engine;
  23833. /**
  23834. * The effect that is created when initializing the post process.
  23835. * @returns The created effect corresponding the the postprocess.
  23836. */
  23837. getEffect(): Effect;
  23838. /**
  23839. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23840. * @param postProcess The post process to share the output with.
  23841. * @returns This post process.
  23842. */
  23843. shareOutputWith(postProcess: PostProcess): PostProcess;
  23844. /**
  23845. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23846. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23847. */
  23848. useOwnOutput(): void;
  23849. /**
  23850. * Updates the effect with the current post process compile time values and recompiles the shader.
  23851. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23852. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23853. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23854. * @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
  23855. * @param onCompiled Called when the shader has been compiled.
  23856. * @param onError Called if there is an error when compiling a shader.
  23857. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23858. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23859. */
  23860. 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;
  23861. /**
  23862. * The post process is reusable if it can be used multiple times within one frame.
  23863. * @returns If the post process is reusable
  23864. */
  23865. isReusable(): boolean;
  23866. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23867. markTextureDirty(): void;
  23868. private _createRenderTargetTexture;
  23869. private _flushTextureCache;
  23870. private _resize;
  23871. /**
  23872. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23873. * 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.
  23874. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23875. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23876. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23877. * @returns The target texture that was bound to be written to.
  23878. */
  23879. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23880. /**
  23881. * If the post process is supported.
  23882. */
  23883. get isSupported(): boolean;
  23884. /**
  23885. * The aspect ratio of the output texture.
  23886. */
  23887. get aspectRatio(): number;
  23888. /**
  23889. * Get a value indicating if the post-process is ready to be used
  23890. * @returns true if the post-process is ready (shader is compiled)
  23891. */
  23892. isReady(): boolean;
  23893. /**
  23894. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23895. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23896. */
  23897. apply(): Nullable<Effect>;
  23898. private _disposeTextures;
  23899. private _disposeTextureCache;
  23900. /**
  23901. * Sets the required values to the prepass renderer.
  23902. * @param prePassRenderer defines the prepass renderer to setup.
  23903. * @returns true if the pre pass is needed.
  23904. */
  23905. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  23906. /**
  23907. * Disposes the post process.
  23908. * @param camera The camera to dispose the post process on.
  23909. */
  23910. dispose(camera?: Camera): void;
  23911. /**
  23912. * Serializes the particle system to a JSON object
  23913. * @returns the JSON object
  23914. */
  23915. serialize(): any;
  23916. /**
  23917. * Clones this post process
  23918. * @returns a new post process similar to this one
  23919. */
  23920. clone(): Nullable<PostProcess>;
  23921. /**
  23922. * Creates a material from parsed material data
  23923. * @param parsedPostProcess defines parsed post process data
  23924. * @param scene defines the hosting scene
  23925. * @param rootUrl defines the root URL to use to load textures
  23926. * @returns a new post process
  23927. */
  23928. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23929. /** @hidden */
  23930. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23931. }
  23932. }
  23933. declare module BABYLON {
  23934. /** @hidden */
  23935. export var kernelBlurVaryingDeclaration: {
  23936. name: string;
  23937. shader: string;
  23938. };
  23939. }
  23940. declare module BABYLON {
  23941. /** @hidden */
  23942. export var packingFunctions: {
  23943. name: string;
  23944. shader: string;
  23945. };
  23946. }
  23947. declare module BABYLON {
  23948. /** @hidden */
  23949. export var kernelBlurFragment: {
  23950. name: string;
  23951. shader: string;
  23952. };
  23953. }
  23954. declare module BABYLON {
  23955. /** @hidden */
  23956. export var kernelBlurFragment2: {
  23957. name: string;
  23958. shader: string;
  23959. };
  23960. }
  23961. declare module BABYLON {
  23962. /** @hidden */
  23963. export var kernelBlurPixelShader: {
  23964. name: string;
  23965. shader: string;
  23966. };
  23967. }
  23968. declare module BABYLON {
  23969. /** @hidden */
  23970. export var kernelBlurVertex: {
  23971. name: string;
  23972. shader: string;
  23973. };
  23974. }
  23975. declare module BABYLON {
  23976. /** @hidden */
  23977. export var kernelBlurVertexShader: {
  23978. name: string;
  23979. shader: string;
  23980. };
  23981. }
  23982. declare module BABYLON {
  23983. /**
  23984. * The Blur Post Process which blurs an image based on a kernel and direction.
  23985. * Can be used twice in x and y directions to perform a gaussian blur in two passes.
  23986. */
  23987. export class BlurPostProcess extends PostProcess {
  23988. private blockCompilation;
  23989. protected _kernel: number;
  23990. protected _idealKernel: number;
  23991. protected _packedFloat: boolean;
  23992. private _staticDefines;
  23993. /** The direction in which to blur the image. */
  23994. direction: Vector2;
  23995. /**
  23996. * Sets the length in pixels of the blur sample region
  23997. */
  23998. set kernel(v: number);
  23999. /**
  24000. * Gets the length in pixels of the blur sample region
  24001. */
  24002. get kernel(): number;
  24003. /**
  24004. * Sets whether or not the blur needs to unpack/repack floats
  24005. */
  24006. set packedFloat(v: boolean);
  24007. /**
  24008. * Gets whether or not the blur is unpacking/repacking floats
  24009. */
  24010. get packedFloat(): boolean;
  24011. /**
  24012. * Gets a string identifying the name of the class
  24013. * @returns "BlurPostProcess" string
  24014. */
  24015. getClassName(): string;
  24016. /**
  24017. * Creates a new instance BlurPostProcess
  24018. * @param name The name of the effect.
  24019. * @param direction The direction in which to blur the image.
  24020. * @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.
  24021. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  24022. * @param camera The camera to apply the render pass to.
  24023. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24024. * @param engine The engine which the post process will be applied. (default: current engine)
  24025. * @param reusable If the post process can be reused on the same frame. (default: false)
  24026. * @param textureType Type of textures used when performing the post process. (default: 0)
  24027. * @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)
  24028. */
  24029. 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);
  24030. /**
  24031. * Updates the effect with the current post process compile time values and recompiles the shader.
  24032. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  24033. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  24034. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  24035. * @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
  24036. * @param onCompiled Called when the shader has been compiled.
  24037. * @param onError Called if there is an error when compiling a shader.
  24038. */
  24039. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  24040. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  24041. /**
  24042. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  24043. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  24044. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  24045. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  24046. * The gaps between physical kernels are compensated for in the weighting of the samples
  24047. * @param idealKernel Ideal blur kernel.
  24048. * @return Nearest best kernel.
  24049. */
  24050. protected _nearestBestKernel(idealKernel: number): number;
  24051. /**
  24052. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  24053. * @param x The point on the Gaussian distribution to sample.
  24054. * @return the value of the Gaussian function at x.
  24055. */
  24056. protected _gaussianWeight(x: number): number;
  24057. /**
  24058. * Generates a string that can be used as a floating point number in GLSL.
  24059. * @param x Value to print.
  24060. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  24061. * @return GLSL float string.
  24062. */
  24063. protected _glslFloat(x: number, decimalFigures?: number): string;
  24064. /** @hidden */
  24065. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  24066. }
  24067. }
  24068. declare module BABYLON {
  24069. /**
  24070. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24071. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24072. * You can then easily use it as a reflectionTexture on a flat surface.
  24073. * In case the surface is not a plane, please consider relying on reflection probes.
  24074. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24075. */
  24076. export class MirrorTexture extends RenderTargetTexture {
  24077. private scene;
  24078. /**
  24079. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  24080. * 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.
  24081. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24082. */
  24083. mirrorPlane: Plane;
  24084. /**
  24085. * Define the blur ratio used to blur the reflection if needed.
  24086. */
  24087. set blurRatio(value: number);
  24088. get blurRatio(): number;
  24089. /**
  24090. * Define the adaptive blur kernel used to blur the reflection if needed.
  24091. * This will autocompute the closest best match for the `blurKernel`
  24092. */
  24093. set adaptiveBlurKernel(value: number);
  24094. /**
  24095. * Define the blur kernel used to blur the reflection if needed.
  24096. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24097. */
  24098. set blurKernel(value: number);
  24099. /**
  24100. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  24101. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24102. */
  24103. set blurKernelX(value: number);
  24104. get blurKernelX(): number;
  24105. /**
  24106. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  24107. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24108. */
  24109. set blurKernelY(value: number);
  24110. get blurKernelY(): number;
  24111. private _autoComputeBlurKernel;
  24112. protected _onRatioRescale(): void;
  24113. private _updateGammaSpace;
  24114. private _imageProcessingConfigChangeObserver;
  24115. private _transformMatrix;
  24116. private _mirrorMatrix;
  24117. private _blurX;
  24118. private _blurY;
  24119. private _adaptiveBlurKernel;
  24120. private _blurKernelX;
  24121. private _blurKernelY;
  24122. private _blurRatio;
  24123. /**
  24124. * Instantiates a Mirror Texture.
  24125. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24126. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24127. * You can then easily use it as a reflectionTexture on a flat surface.
  24128. * In case the surface is not a plane, please consider relying on reflection probes.
  24129. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24130. * @param name
  24131. * @param size
  24132. * @param scene
  24133. * @param generateMipMaps
  24134. * @param type
  24135. * @param samplingMode
  24136. * @param generateDepthBuffer
  24137. */
  24138. constructor(name: string, size: number | {
  24139. width: number;
  24140. height: number;
  24141. } | {
  24142. ratio: number;
  24143. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  24144. private _preparePostProcesses;
  24145. /**
  24146. * Clone the mirror texture.
  24147. * @returns the cloned texture
  24148. */
  24149. clone(): MirrorTexture;
  24150. /**
  24151. * Serialize the texture to a JSON representation you could use in Parse later on
  24152. * @returns the serialized JSON representation
  24153. */
  24154. serialize(): any;
  24155. /**
  24156. * Dispose the texture and release its associated resources.
  24157. */
  24158. dispose(): void;
  24159. }
  24160. }
  24161. declare module BABYLON {
  24162. /**
  24163. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24164. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24165. */
  24166. export class Texture extends BaseTexture {
  24167. /**
  24168. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  24169. */
  24170. static SerializeBuffers: boolean;
  24171. /**
  24172. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  24173. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  24174. */
  24175. static ForceSerializeBuffers: boolean;
  24176. /** @hidden */
  24177. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  24178. /** @hidden */
  24179. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  24180. /** @hidden */
  24181. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  24182. /** nearest is mag = nearest and min = nearest and mip = linear */
  24183. static readonly NEAREST_SAMPLINGMODE: number;
  24184. /** nearest is mag = nearest and min = nearest and mip = linear */
  24185. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  24186. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24187. static readonly BILINEAR_SAMPLINGMODE: number;
  24188. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24189. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  24190. /** Trilinear is mag = linear and min = linear and mip = linear */
  24191. static readonly TRILINEAR_SAMPLINGMODE: number;
  24192. /** Trilinear is mag = linear and min = linear and mip = linear */
  24193. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  24194. /** mag = nearest and min = nearest and mip = nearest */
  24195. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  24196. /** mag = nearest and min = linear and mip = nearest */
  24197. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  24198. /** mag = nearest and min = linear and mip = linear */
  24199. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  24200. /** mag = nearest and min = linear and mip = none */
  24201. static readonly NEAREST_LINEAR: number;
  24202. /** mag = nearest and min = nearest and mip = none */
  24203. static readonly NEAREST_NEAREST: number;
  24204. /** mag = linear and min = nearest and mip = nearest */
  24205. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  24206. /** mag = linear and min = nearest and mip = linear */
  24207. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  24208. /** mag = linear and min = linear and mip = none */
  24209. static readonly LINEAR_LINEAR: number;
  24210. /** mag = linear and min = nearest and mip = none */
  24211. static readonly LINEAR_NEAREST: number;
  24212. /** Explicit coordinates mode */
  24213. static readonly EXPLICIT_MODE: number;
  24214. /** Spherical coordinates mode */
  24215. static readonly SPHERICAL_MODE: number;
  24216. /** Planar coordinates mode */
  24217. static readonly PLANAR_MODE: number;
  24218. /** Cubic coordinates mode */
  24219. static readonly CUBIC_MODE: number;
  24220. /** Projection coordinates mode */
  24221. static readonly PROJECTION_MODE: number;
  24222. /** Inverse Cubic coordinates mode */
  24223. static readonly SKYBOX_MODE: number;
  24224. /** Inverse Cubic coordinates mode */
  24225. static readonly INVCUBIC_MODE: number;
  24226. /** Equirectangular coordinates mode */
  24227. static readonly EQUIRECTANGULAR_MODE: number;
  24228. /** Equirectangular Fixed coordinates mode */
  24229. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  24230. /** Equirectangular Fixed Mirrored coordinates mode */
  24231. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  24232. /** Texture is not repeating outside of 0..1 UVs */
  24233. static readonly CLAMP_ADDRESSMODE: number;
  24234. /** Texture is repeating outside of 0..1 UVs */
  24235. static readonly WRAP_ADDRESSMODE: number;
  24236. /** Texture is repeating and mirrored */
  24237. static readonly MIRROR_ADDRESSMODE: number;
  24238. /**
  24239. * 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
  24240. */
  24241. static UseSerializedUrlIfAny: boolean;
  24242. /**
  24243. * Define the url of the texture.
  24244. */
  24245. url: Nullable<string>;
  24246. /**
  24247. * Define an offset on the texture to offset the u coordinates of the UVs
  24248. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24249. */
  24250. uOffset: number;
  24251. /**
  24252. * Define an offset on the texture to offset the v coordinates of the UVs
  24253. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24254. */
  24255. vOffset: number;
  24256. /**
  24257. * Define an offset on the texture to scale the u coordinates of the UVs
  24258. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24259. */
  24260. uScale: number;
  24261. /**
  24262. * Define an offset on the texture to scale the v coordinates of the UVs
  24263. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24264. */
  24265. vScale: number;
  24266. /**
  24267. * Define an offset on the texture to rotate around the u coordinates of the UVs
  24268. * @see https://doc.babylonjs.com/how_to/more_materials
  24269. */
  24270. uAng: number;
  24271. /**
  24272. * Define an offset on the texture to rotate around the v coordinates of the UVs
  24273. * @see https://doc.babylonjs.com/how_to/more_materials
  24274. */
  24275. vAng: number;
  24276. /**
  24277. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  24278. * @see https://doc.babylonjs.com/how_to/more_materials
  24279. */
  24280. wAng: number;
  24281. /**
  24282. * Defines the center of rotation (U)
  24283. */
  24284. uRotationCenter: number;
  24285. /**
  24286. * Defines the center of rotation (V)
  24287. */
  24288. vRotationCenter: number;
  24289. /**
  24290. * Defines the center of rotation (W)
  24291. */
  24292. wRotationCenter: number;
  24293. /**
  24294. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  24295. */
  24296. homogeneousRotationInUVTransform: boolean;
  24297. /**
  24298. * Are mip maps generated for this texture or not.
  24299. */
  24300. get noMipmap(): boolean;
  24301. /**
  24302. * List of inspectable custom properties (used by the Inspector)
  24303. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24304. */
  24305. inspectableCustomProperties: Nullable<IInspectable[]>;
  24306. private _noMipmap;
  24307. /** @hidden */
  24308. _invertY: boolean;
  24309. private _rowGenerationMatrix;
  24310. private _cachedTextureMatrix;
  24311. private _projectionModeMatrix;
  24312. private _t0;
  24313. private _t1;
  24314. private _t2;
  24315. private _cachedUOffset;
  24316. private _cachedVOffset;
  24317. private _cachedUScale;
  24318. private _cachedVScale;
  24319. private _cachedUAng;
  24320. private _cachedVAng;
  24321. private _cachedWAng;
  24322. private _cachedProjectionMatrixId;
  24323. private _cachedURotationCenter;
  24324. private _cachedVRotationCenter;
  24325. private _cachedWRotationCenter;
  24326. private _cachedHomogeneousRotationInUVTransform;
  24327. private _cachedCoordinatesMode;
  24328. /** @hidden */
  24329. protected _initialSamplingMode: number;
  24330. /** @hidden */
  24331. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  24332. private _deleteBuffer;
  24333. protected _format: Nullable<number>;
  24334. private _delayedOnLoad;
  24335. private _delayedOnError;
  24336. private _mimeType?;
  24337. private _loaderOptions?;
  24338. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  24339. get mimeType(): string | undefined;
  24340. /**
  24341. * Observable triggered once the texture has been loaded.
  24342. */
  24343. onLoadObservable: Observable<Texture>;
  24344. protected _isBlocking: boolean;
  24345. /**
  24346. * Is the texture preventing material to render while loading.
  24347. * If false, a default texture will be used instead of the loading one during the preparation step.
  24348. */
  24349. set isBlocking(value: boolean);
  24350. get isBlocking(): boolean;
  24351. /**
  24352. * Get the current sampling mode associated with the texture.
  24353. */
  24354. get samplingMode(): number;
  24355. /**
  24356. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  24357. */
  24358. get invertY(): boolean;
  24359. /**
  24360. * Instantiates a new texture.
  24361. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24362. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24363. * @param url defines the url of the picture to load as a texture
  24364. * @param sceneOrEngine defines the scene or engine the texture will belong to
  24365. * @param noMipmap defines if the texture will require mip maps or not
  24366. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  24367. * @param samplingMode defines the sampling mode we want for the texture while fetching from it (Texture.NEAREST_SAMPLINGMODE...)
  24368. * @param onLoad defines a callback triggered when the texture has been loaded
  24369. * @param onError defines a callback triggered when an error occurred during the loading session
  24370. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  24371. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  24372. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24373. * @param mimeType defines an optional mime type information
  24374. * @param loaderOptions options to be passed to the loader
  24375. */
  24376. 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);
  24377. /**
  24378. * Update the url (and optional buffer) of this texture if url was null during construction.
  24379. * @param url the url of the texture
  24380. * @param buffer the buffer of the texture (defaults to null)
  24381. * @param onLoad callback called when the texture is loaded (defaults to null)
  24382. */
  24383. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  24384. /**
  24385. * Finish the loading sequence of a texture flagged as delayed load.
  24386. * @hidden
  24387. */
  24388. delayLoad(): void;
  24389. private _prepareRowForTextureGeneration;
  24390. /**
  24391. * Checks if the texture has the same transform matrix than another texture
  24392. * @param texture texture to check against
  24393. * @returns true if the transforms are the same, else false
  24394. */
  24395. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  24396. /**
  24397. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  24398. * @returns the transform matrix of the texture.
  24399. */
  24400. getTextureMatrix(uBase?: number): Matrix;
  24401. /**
  24402. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  24403. * @returns The reflection texture transform
  24404. */
  24405. getReflectionTextureMatrix(): Matrix;
  24406. /**
  24407. * Clones the texture.
  24408. * @returns the cloned texture
  24409. */
  24410. clone(): Texture;
  24411. /**
  24412. * Serialize the texture to a JSON representation we can easily use in the respective Parse function.
  24413. * @returns The JSON representation of the texture
  24414. */
  24415. serialize(): any;
  24416. /**
  24417. * Get the current class name of the texture useful for serialization or dynamic coding.
  24418. * @returns "Texture"
  24419. */
  24420. getClassName(): string;
  24421. /**
  24422. * Dispose the texture and release its associated resources.
  24423. */
  24424. dispose(): void;
  24425. /**
  24426. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24427. * @param parsedTexture Define the JSON representation of the texture
  24428. * @param scene Define the scene the parsed texture should be instantiated in
  24429. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24430. * @returns The parsed texture if successful
  24431. */
  24432. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24433. /**
  24434. * Creates a texture from its base 64 representation.
  24435. * @param data Define the base64 payload without the data: prefix
  24436. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24437. * @param scene Define the scene the texture should belong to
  24438. * @param noMipmap Forces the texture to not create mip map information if true
  24439. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24440. * @param samplingMode define the sampling mode we want for the texture while fetching from it (Texture.NEAREST_SAMPLINGMODE...)
  24441. * @param onLoad define a callback triggered when the texture has been loaded
  24442. * @param onError define a callback triggered when an error occurred during the loading session
  24443. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24444. * @returns the created texture
  24445. */
  24446. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24447. /**
  24448. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24449. * @param data Define the base64 payload without the data: prefix
  24450. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24451. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24452. * @param scene Define the scene the texture should belong to
  24453. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24454. * @param noMipmap Forces the texture to not create mip map information if true
  24455. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24456. * @param samplingMode define the sampling mode we want for the texture while fetching from it (Texture.NEAREST_SAMPLINGMODE...)
  24457. * @param onLoad define a callback triggered when the texture has been loaded
  24458. * @param onError define a callback triggered when an error occurred during the loading session
  24459. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24460. * @returns the created texture
  24461. */
  24462. 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;
  24463. }
  24464. }
  24465. declare module BABYLON {
  24466. /**
  24467. * ThinSprite Class used to represent a thin sprite
  24468. * This is the base class for sprites but can also directly be used with ThinEngine
  24469. * @see https://doc.babylonjs.com/babylon101/sprites
  24470. */
  24471. export class ThinSprite {
  24472. /** Gets or sets the cell index in the sprite sheet */
  24473. cellIndex: number;
  24474. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  24475. cellRef: string;
  24476. /** Gets or sets the current world position */
  24477. position: IVector3Like;
  24478. /** Gets or sets the main color */
  24479. color: IColor4Like;
  24480. /** Gets or sets the width */
  24481. width: number;
  24482. /** Gets or sets the height */
  24483. height: number;
  24484. /** Gets or sets rotation angle */
  24485. angle: number;
  24486. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  24487. invertU: boolean;
  24488. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  24489. invertV: boolean;
  24490. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  24491. isVisible: boolean;
  24492. /**
  24493. * Returns a boolean indicating if the animation is started
  24494. */
  24495. get animationStarted(): boolean;
  24496. /** Gets the initial key for the animation (setting it will restart the animation) */
  24497. get fromIndex(): number;
  24498. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24499. get toIndex(): number;
  24500. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24501. get loopAnimation(): boolean;
  24502. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24503. get delay(): number;
  24504. /** @hidden */
  24505. _xOffset: number;
  24506. /** @hidden */
  24507. _yOffset: number;
  24508. /** @hidden */
  24509. _xSize: number;
  24510. /** @hidden */
  24511. _ySize: number;
  24512. private _animationStarted;
  24513. protected _loopAnimation: boolean;
  24514. protected _fromIndex: number;
  24515. protected _toIndex: number;
  24516. protected _delay: number;
  24517. private _direction;
  24518. private _time;
  24519. private _onBaseAnimationEnd;
  24520. /**
  24521. * Creates a new Thin Sprite
  24522. */
  24523. constructor();
  24524. /**
  24525. * Starts an animation
  24526. * @param from defines the initial key
  24527. * @param to defines the end key
  24528. * @param loop defines if the animation must loop
  24529. * @param delay defines the start delay (in ms)
  24530. * @param onAnimationEnd defines a callback for when the animation ends
  24531. */
  24532. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  24533. /** Stops current animation (if any) */
  24534. stopAnimation(): void;
  24535. /** @hidden */
  24536. _animate(deltaTime: number): void;
  24537. }
  24538. }
  24539. declare module BABYLON {
  24540. /** @hidden */
  24541. export var imageProcessingCompatibility: {
  24542. name: string;
  24543. shader: string;
  24544. };
  24545. }
  24546. declare module BABYLON {
  24547. /** @hidden */
  24548. export var spritesPixelShader: {
  24549. name: string;
  24550. shader: string;
  24551. };
  24552. }
  24553. declare module BABYLON {
  24554. /** @hidden */
  24555. export var spritesVertexShader: {
  24556. name: string;
  24557. shader: string;
  24558. };
  24559. }
  24560. declare module BABYLON {
  24561. /**
  24562. * Class used to render sprites.
  24563. *
  24564. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  24565. */
  24566. export class SpriteRenderer {
  24567. /**
  24568. * Defines the texture of the spritesheet
  24569. */
  24570. texture: Nullable<ThinTexture>;
  24571. /**
  24572. * Defines the default width of a cell in the spritesheet
  24573. */
  24574. cellWidth: number;
  24575. /**
  24576. * Defines the default height of a cell in the spritesheet
  24577. */
  24578. cellHeight: number;
  24579. /**
  24580. * Blend mode use to render the particle, it can be any of
  24581. * the static Constants.ALPHA_x properties provided in this class.
  24582. * Default value is Constants.ALPHA_COMBINE
  24583. */
  24584. blendMode: number;
  24585. /**
  24586. * Gets or sets a boolean indicating if alpha mode is automatically
  24587. * reset.
  24588. */
  24589. autoResetAlpha: boolean;
  24590. /**
  24591. * Disables writing to the depth buffer when rendering the sprites.
  24592. * It can be handy to disable depth writing when using textures without alpha channel
  24593. * and setting some specific blend modes.
  24594. */
  24595. disableDepthWrite: boolean;
  24596. /**
  24597. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  24598. */
  24599. fogEnabled: boolean;
  24600. /**
  24601. * Gets the capacity of the manager
  24602. */
  24603. get capacity(): number;
  24604. private readonly _engine;
  24605. private readonly _useVAO;
  24606. private readonly _useInstancing;
  24607. private readonly _scene;
  24608. private readonly _capacity;
  24609. private readonly _epsilon;
  24610. private _vertexBufferSize;
  24611. private _vertexData;
  24612. private _buffer;
  24613. private _vertexBuffers;
  24614. private _spriteBuffer;
  24615. private _indexBuffer;
  24616. private _effectBase;
  24617. private _effectFog;
  24618. private _vertexArrayObject;
  24619. /**
  24620. * Creates a new sprite Renderer
  24621. * @param engine defines the engine the renderer works with
  24622. * @param capacity defines the maximum allowed number of sprites
  24623. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24624. * @param scene defines the hosting scene
  24625. */
  24626. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  24627. /**
  24628. * Render all child sprites
  24629. * @param sprites defines the list of sprites to render
  24630. * @param deltaTime defines the time since last frame
  24631. * @param viewMatrix defines the viewMatrix to use to render the sprites
  24632. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  24633. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  24634. */
  24635. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  24636. private _appendSpriteVertex;
  24637. /**
  24638. * Release associated resources
  24639. */
  24640. dispose(): void;
  24641. }
  24642. }
  24643. declare module BABYLON {
  24644. /**
  24645. * Defines the minimum interface to fulfill in order to be a sprite manager.
  24646. */
  24647. export interface ISpriteManager extends IDisposable {
  24648. /**
  24649. * Gets manager's name
  24650. */
  24651. name: string;
  24652. /**
  24653. * Restricts the camera to viewing objects with the same layerMask.
  24654. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  24655. */
  24656. layerMask: number;
  24657. /**
  24658. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24659. */
  24660. isPickable: boolean;
  24661. /**
  24662. * Gets the hosting scene
  24663. */
  24664. scene: Scene;
  24665. /**
  24666. * Specifies the rendering group id for this mesh (0 by default)
  24667. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24668. */
  24669. renderingGroupId: number;
  24670. /**
  24671. * Defines the list of sprites managed by the manager.
  24672. */
  24673. sprites: Array<Sprite>;
  24674. /**
  24675. * Gets or sets the spritesheet texture
  24676. */
  24677. texture: Texture;
  24678. /** Defines the default width of a cell in the spritesheet */
  24679. cellWidth: number;
  24680. /** Defines the default height of a cell in the spritesheet */
  24681. cellHeight: number;
  24682. /**
  24683. * Tests the intersection of a sprite with a specific ray.
  24684. * @param ray The ray we are sending to test the collision
  24685. * @param camera The camera space we are sending rays in
  24686. * @param predicate A predicate allowing excluding sprites from the list of object to test
  24687. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24688. * @returns picking info or null.
  24689. */
  24690. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24691. /**
  24692. * Intersects the sprites with a ray
  24693. * @param ray defines the ray to intersect with
  24694. * @param camera defines the current active camera
  24695. * @param predicate defines a predicate used to select candidate sprites
  24696. * @returns null if no hit or a PickingInfo array
  24697. */
  24698. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24699. /**
  24700. * Renders the list of sprites on screen.
  24701. */
  24702. render(): void;
  24703. }
  24704. /**
  24705. * Class used to manage multiple sprites on the same spritesheet
  24706. * @see https://doc.babylonjs.com/babylon101/sprites
  24707. */
  24708. export class SpriteManager implements ISpriteManager {
  24709. /** defines the manager's name */
  24710. name: string;
  24711. /** Define the Url to load snippets */
  24712. static SnippetUrl: string;
  24713. /** Snippet ID if the manager was created from the snippet server */
  24714. snippetId: string;
  24715. /** Gets the list of sprites */
  24716. sprites: Sprite[];
  24717. /** Gets or sets the rendering group id (0 by default) */
  24718. renderingGroupId: number;
  24719. /** Gets or sets camera layer mask */
  24720. layerMask: number;
  24721. /** Gets or sets a boolean indicating if the sprites are pickable */
  24722. isPickable: boolean;
  24723. /**
  24724. * An event triggered when the manager is disposed.
  24725. */
  24726. onDisposeObservable: Observable<SpriteManager>;
  24727. /**
  24728. * Callback called when the manager is disposed
  24729. */
  24730. set onDispose(callback: () => void);
  24731. /**
  24732. * Gets or sets the unique id of the sprite
  24733. */
  24734. uniqueId: number;
  24735. /**
  24736. * Gets the array of sprites
  24737. */
  24738. get children(): Sprite[];
  24739. /**
  24740. * Gets the hosting scene
  24741. */
  24742. get scene(): Scene;
  24743. /**
  24744. * Gets the capacity of the manager
  24745. */
  24746. get capacity(): number;
  24747. /**
  24748. * Gets or sets the spritesheet texture
  24749. */
  24750. get texture(): Texture;
  24751. set texture(value: Texture);
  24752. /** Defines the default width of a cell in the spritesheet */
  24753. get cellWidth(): number;
  24754. set cellWidth(value: number);
  24755. /** Defines the default height of a cell in the spritesheet */
  24756. get cellHeight(): number;
  24757. set cellHeight(value: number);
  24758. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  24759. get fogEnabled(): boolean;
  24760. set fogEnabled(value: boolean);
  24761. /**
  24762. * Blend mode use to render the particle, it can be any of
  24763. * the static Constants.ALPHA_x properties provided in this class.
  24764. * Default value is Constants.ALPHA_COMBINE
  24765. */
  24766. get blendMode(): number;
  24767. set blendMode(blendMode: number);
  24768. /** Disables writing to the depth buffer when rendering the sprites.
  24769. * It can be handy to disable depth writing when using textures without alpha channel
  24770. * and setting some specific blend modes.
  24771. */
  24772. disableDepthWrite: boolean;
  24773. private _spriteRenderer;
  24774. /** Associative array from JSON sprite data file */
  24775. private _cellData;
  24776. /** Array of sprite names from JSON sprite data file */
  24777. private _spriteMap;
  24778. /** True when packed cell data from JSON file is ready*/
  24779. private _packedAndReady;
  24780. private _textureContent;
  24781. private _onDisposeObserver;
  24782. private _fromPacked;
  24783. private _scene;
  24784. /**
  24785. * Creates a new sprite manager
  24786. * @param name defines the manager's name
  24787. * @param imgUrl defines the sprite sheet url
  24788. * @param capacity defines the maximum allowed number of sprites
  24789. * @param cellSize defines the size of a sprite cell
  24790. * @param scene defines the hosting scene
  24791. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24792. * @param samplingMode defines the sampling mode to use with spritesheet
  24793. * @param fromPacked set to false; do not alter
  24794. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  24795. */
  24796. constructor(
  24797. /** defines the manager's name */
  24798. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  24799. /**
  24800. * Returns the string "SpriteManager"
  24801. * @returns "SpriteManager"
  24802. */
  24803. getClassName(): string;
  24804. private _makePacked;
  24805. private _checkTextureAlpha;
  24806. /**
  24807. * Intersects the sprites with a ray
  24808. * @param ray defines the ray to intersect with
  24809. * @param camera defines the current active camera
  24810. * @param predicate defines a predicate used to select candidate sprites
  24811. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  24812. * @returns null if no hit or a PickingInfo
  24813. */
  24814. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24815. /**
  24816. * Intersects the sprites with a ray
  24817. * @param ray defines the ray to intersect with
  24818. * @param camera defines the current active camera
  24819. * @param predicate defines a predicate used to select candidate sprites
  24820. * @returns null if no hit or a PickingInfo array
  24821. */
  24822. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24823. /**
  24824. * Render all child sprites
  24825. */
  24826. render(): void;
  24827. private _customUpdate;
  24828. /**
  24829. * Release associated resources
  24830. */
  24831. dispose(): void;
  24832. /**
  24833. * Serializes the sprite manager to a JSON object
  24834. * @param serializeTexture defines if the texture must be serialized as well
  24835. * @returns the JSON object
  24836. */
  24837. serialize(serializeTexture?: boolean): any;
  24838. /**
  24839. * Parses a JSON object to create a new sprite manager.
  24840. * @param parsedManager The JSON object to parse
  24841. * @param scene The scene to create the sprite manager
  24842. * @param rootUrl The root url to use to load external dependencies like texture
  24843. * @returns the new sprite manager
  24844. */
  24845. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  24846. /**
  24847. * Creates a sprite manager from a snippet saved in a remote file
  24848. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  24849. * @param url defines the url to load from
  24850. * @param scene defines the hosting scene
  24851. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24852. * @returns a promise that will resolve to the new sprite manager
  24853. */
  24854. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24855. /**
  24856. * Creates a sprite manager from a snippet saved by the sprite editor
  24857. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  24858. * @param scene defines the hosting scene
  24859. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24860. * @returns a promise that will resolve to the new sprite manager
  24861. */
  24862. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24863. }
  24864. }
  24865. declare module BABYLON {
  24866. /**
  24867. * Class used to represent a sprite
  24868. * @see https://doc.babylonjs.com/babylon101/sprites
  24869. */
  24870. export class Sprite extends ThinSprite implements IAnimatable {
  24871. /** defines the name */
  24872. name: string;
  24873. /** Gets or sets the current world position */
  24874. position: Vector3;
  24875. /** Gets or sets the main color */
  24876. color: Color4;
  24877. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  24878. disposeWhenFinishedAnimating: boolean;
  24879. /** Gets the list of attached animations */
  24880. animations: Nullable<Array<Animation>>;
  24881. /** Gets or sets a boolean indicating if the sprite can be picked */
  24882. isPickable: boolean;
  24883. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  24884. useAlphaForPicking: boolean;
  24885. /**
  24886. * Gets or sets the associated action manager
  24887. */
  24888. actionManager: Nullable<ActionManager>;
  24889. /**
  24890. * An event triggered when the control has been disposed
  24891. */
  24892. onDisposeObservable: Observable<Sprite>;
  24893. private _manager;
  24894. private _onAnimationEnd;
  24895. /**
  24896. * Gets or sets the sprite size
  24897. */
  24898. get size(): number;
  24899. set size(value: number);
  24900. /**
  24901. * Gets or sets the unique id of the sprite
  24902. */
  24903. uniqueId: number;
  24904. /**
  24905. * Gets the manager of this sprite
  24906. */
  24907. get manager(): ISpriteManager;
  24908. /**
  24909. * Creates a new Sprite
  24910. * @param name defines the name
  24911. * @param manager defines the manager
  24912. */
  24913. constructor(
  24914. /** defines the name */
  24915. name: string, manager: ISpriteManager);
  24916. /**
  24917. * Returns the string "Sprite"
  24918. * @returns "Sprite"
  24919. */
  24920. getClassName(): string;
  24921. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  24922. get fromIndex(): number;
  24923. set fromIndex(value: number);
  24924. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24925. get toIndex(): number;
  24926. set toIndex(value: number);
  24927. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24928. get loopAnimation(): boolean;
  24929. set loopAnimation(value: boolean);
  24930. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24931. get delay(): number;
  24932. set delay(value: number);
  24933. /**
  24934. * Starts an animation
  24935. * @param from defines the initial key
  24936. * @param to defines the end key
  24937. * @param loop defines if the animation must loop
  24938. * @param delay defines the start delay (in ms)
  24939. * @param onAnimationEnd defines a callback to call when animation ends
  24940. */
  24941. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  24942. private _endAnimation;
  24943. /** Release associated resources */
  24944. dispose(): void;
  24945. /**
  24946. * Serializes the sprite to a JSON object
  24947. * @returns the JSON object
  24948. */
  24949. serialize(): any;
  24950. /**
  24951. * Parses a JSON object to create a new sprite
  24952. * @param parsedSprite The JSON object to parse
  24953. * @param manager defines the hosting manager
  24954. * @returns the new sprite
  24955. */
  24956. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  24957. }
  24958. }
  24959. declare module BABYLON {
  24960. /**
  24961. * Information about the result of picking within a scene
  24962. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  24963. */
  24964. export class PickingInfo {
  24965. /** @hidden */
  24966. _pickingUnavailable: boolean;
  24967. /**
  24968. * If the pick collided with an object
  24969. */
  24970. hit: boolean;
  24971. /**
  24972. * Distance away where the pick collided
  24973. */
  24974. distance: number;
  24975. /**
  24976. * The location of pick collision
  24977. */
  24978. pickedPoint: Nullable<Vector3>;
  24979. /**
  24980. * The mesh corresponding the the pick collision
  24981. */
  24982. pickedMesh: Nullable<AbstractMesh>;
  24983. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  24984. bu: number;
  24985. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  24986. bv: number;
  24987. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24988. faceId: number;
  24989. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24990. subMeshFaceId: number;
  24991. /** Id of the the submesh that was picked */
  24992. subMeshId: number;
  24993. /** If a sprite was picked, this will be the sprite the pick collided with */
  24994. pickedSprite: Nullable<Sprite>;
  24995. /** If we are picking a mesh with thin instance, this will give you the picked thin instance */
  24996. thinInstanceIndex: number;
  24997. /**
  24998. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  24999. */
  25000. originMesh: Nullable<AbstractMesh>;
  25001. /**
  25002. * The ray that was used to perform the picking.
  25003. */
  25004. ray: Nullable<Ray>;
  25005. /**
  25006. * Gets the normal corresponding to the face the pick collided with
  25007. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  25008. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  25009. * @returns The normal corresponding to the face the pick collided with
  25010. */
  25011. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  25012. /**
  25013. * Gets the texture coordinates of where the pick occurred
  25014. * @returns the vector containing the coordinates of the texture
  25015. */
  25016. getTextureCoordinates(): Nullable<Vector2>;
  25017. }
  25018. }
  25019. declare module BABYLON {
  25020. /**
  25021. * Gather the list of pointer event types as constants.
  25022. */
  25023. export class PointerEventTypes {
  25024. /**
  25025. * 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.
  25026. */
  25027. static readonly POINTERDOWN: number;
  25028. /**
  25029. * The pointerup event is fired when a pointer is no longer active.
  25030. */
  25031. static readonly POINTERUP: number;
  25032. /**
  25033. * The pointermove event is fired when a pointer changes coordinates.
  25034. */
  25035. static readonly POINTERMOVE: number;
  25036. /**
  25037. * The pointerwheel event is fired when a mouse wheel has been rotated.
  25038. */
  25039. static readonly POINTERWHEEL: number;
  25040. /**
  25041. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  25042. */
  25043. static readonly POINTERPICK: number;
  25044. /**
  25045. * The pointertap event is fired when a the object has been touched and released without drag.
  25046. */
  25047. static readonly POINTERTAP: number;
  25048. /**
  25049. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  25050. */
  25051. static readonly POINTERDOUBLETAP: number;
  25052. }
  25053. /**
  25054. * Base class of pointer info types.
  25055. */
  25056. export class PointerInfoBase {
  25057. /**
  25058. * Defines the type of event (PointerEventTypes)
  25059. */
  25060. type: number;
  25061. /**
  25062. * Defines the related dom event
  25063. */
  25064. event: IMouseEvent;
  25065. /**
  25066. * Instantiates the base class of pointers info.
  25067. * @param type Defines the type of event (PointerEventTypes)
  25068. * @param event Defines the related dom event
  25069. */
  25070. constructor(
  25071. /**
  25072. * Defines the type of event (PointerEventTypes)
  25073. */
  25074. type: number,
  25075. /**
  25076. * Defines the related dom event
  25077. */
  25078. event: IMouseEvent);
  25079. }
  25080. /**
  25081. * This class is used to store pointer related info for the onPrePointerObservable event.
  25082. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  25083. */
  25084. export class PointerInfoPre extends PointerInfoBase {
  25085. /**
  25086. * Ray from a pointer if availible (eg. 6dof controller)
  25087. */
  25088. ray: Nullable<Ray>;
  25089. /**
  25090. * Defines the local position of the pointer on the canvas.
  25091. */
  25092. localPosition: Vector2;
  25093. /**
  25094. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  25095. */
  25096. skipOnPointerObservable: boolean;
  25097. /**
  25098. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  25099. * @param type Defines the type of event (PointerEventTypes)
  25100. * @param event Defines the related dom event
  25101. * @param localX Defines the local x coordinates of the pointer when the event occured
  25102. * @param localY Defines the local y coordinates of the pointer when the event occured
  25103. */
  25104. constructor(type: number, event: IMouseEvent, localX: number, localY: number);
  25105. }
  25106. /**
  25107. * This type contains all the data related to a pointer event in Babylon.js.
  25108. * 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.
  25109. */
  25110. export class PointerInfo extends PointerInfoBase {
  25111. /**
  25112. * Defines the picking info associated to the info (if any)\
  25113. */
  25114. pickInfo: Nullable<PickingInfo>;
  25115. /**
  25116. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  25117. * @param type Defines the type of event (PointerEventTypes)
  25118. * @param event Defines the related dom event
  25119. * @param pickInfo Defines the picking info associated to the info (if any)\
  25120. */
  25121. constructor(type: number, event: IMouseEvent,
  25122. /**
  25123. * Defines the picking info associated to the info (if any)\
  25124. */
  25125. pickInfo: Nullable<PickingInfo>);
  25126. }
  25127. /**
  25128. * Data relating to a touch event on the screen.
  25129. */
  25130. export interface PointerTouch {
  25131. /**
  25132. * X coordinate of touch.
  25133. */
  25134. x: number;
  25135. /**
  25136. * Y coordinate of touch.
  25137. */
  25138. y: number;
  25139. /**
  25140. * Id of touch. Unique for each finger.
  25141. */
  25142. pointerId: number;
  25143. /**
  25144. * Event type passed from DOM.
  25145. */
  25146. type: any;
  25147. }
  25148. }
  25149. declare module BABYLON {
  25150. /**
  25151. * Manage the mouse inputs to control the movement of a free camera.
  25152. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25153. */
  25154. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  25155. /**
  25156. * Define if touch is enabled in the mouse input
  25157. */
  25158. touchEnabled: boolean;
  25159. /**
  25160. * Defines the camera the input is attached to.
  25161. */
  25162. camera: FreeCamera;
  25163. /**
  25164. * Defines the buttons associated with the input to handle camera move.
  25165. */
  25166. buttons: number[];
  25167. /**
  25168. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  25169. */
  25170. angularSensibility: number;
  25171. private _pointerInput;
  25172. private _onMouseMove;
  25173. private _observer;
  25174. private previousPosition;
  25175. /**
  25176. * Observable for when a pointer move event occurs containing the move offset
  25177. */
  25178. onPointerMovedObservable: Observable<{
  25179. offsetX: number;
  25180. offsetY: number;
  25181. }>;
  25182. /**
  25183. * @hidden
  25184. * If the camera should be rotated automatically based on pointer movement
  25185. */
  25186. _allowCameraRotation: boolean;
  25187. /**
  25188. * Manage the mouse inputs to control the movement of a free camera.
  25189. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25190. * @param touchEnabled Defines if touch is enabled or not
  25191. */
  25192. constructor(
  25193. /**
  25194. * Define if touch is enabled in the mouse input
  25195. */
  25196. touchEnabled?: boolean);
  25197. /**
  25198. * Attach the input controls to a specific dom element to get the input from.
  25199. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25200. */
  25201. attachControl(noPreventDefault?: boolean): void;
  25202. /**
  25203. * Called on JS contextmenu event.
  25204. * Override this method to provide functionality.
  25205. */
  25206. protected onContextMenu(evt: PointerEvent): void;
  25207. /**
  25208. * Detach the current controls from the specified dom element.
  25209. */
  25210. detachControl(): void;
  25211. /**
  25212. * Gets the class name of the current input.
  25213. * @returns the class name
  25214. */
  25215. getClassName(): string;
  25216. /**
  25217. * Get the friendly name associated with the input class.
  25218. * @returns the input friendly name
  25219. */
  25220. getSimpleName(): string;
  25221. }
  25222. }
  25223. declare module BABYLON {
  25224. /**
  25225. * Base class for mouse wheel input..
  25226. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  25227. * for example usage.
  25228. */
  25229. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  25230. /**
  25231. * Defines the camera the input is attached to.
  25232. */
  25233. abstract camera: Camera;
  25234. /**
  25235. * How fast is the camera moves in relation to X axis mouseWheel events.
  25236. * Use negative value to reverse direction.
  25237. */
  25238. wheelPrecisionX: number;
  25239. /**
  25240. * How fast is the camera moves in relation to Y axis mouseWheel events.
  25241. * Use negative value to reverse direction.
  25242. */
  25243. wheelPrecisionY: number;
  25244. /**
  25245. * How fast is the camera moves in relation to Z axis mouseWheel events.
  25246. * Use negative value to reverse direction.
  25247. */
  25248. wheelPrecisionZ: number;
  25249. /**
  25250. * Observable for when a mouse wheel move event occurs.
  25251. */
  25252. onChangedObservable: Observable<{
  25253. wheelDeltaX: number;
  25254. wheelDeltaY: number;
  25255. wheelDeltaZ: number;
  25256. }>;
  25257. private _wheel;
  25258. private _observer;
  25259. /**
  25260. * Attach the input controls to a specific dom element to get the input from.
  25261. * @param noPreventDefault Defines whether event caught by the controls
  25262. * should call preventdefault().
  25263. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25264. */
  25265. attachControl(noPreventDefault?: boolean): void;
  25266. /**
  25267. * Detach the current controls from the specified dom element.
  25268. */
  25269. detachControl(): void;
  25270. /**
  25271. * Called for each rendered frame.
  25272. */
  25273. checkInputs(): void;
  25274. /**
  25275. * Gets the class name of the current input.
  25276. * @returns the class name
  25277. */
  25278. getClassName(): string;
  25279. /**
  25280. * Get the friendly name associated with the input class.
  25281. * @returns the input friendly name
  25282. */
  25283. getSimpleName(): string;
  25284. /**
  25285. * Incremental value of multiple mouse wheel movements of the X axis.
  25286. * Should be zero-ed when read.
  25287. */
  25288. protected _wheelDeltaX: number;
  25289. /**
  25290. * Incremental value of multiple mouse wheel movements of the Y axis.
  25291. * Should be zero-ed when read.
  25292. */
  25293. protected _wheelDeltaY: number;
  25294. /**
  25295. * Incremental value of multiple mouse wheel movements of the Z axis.
  25296. * Should be zero-ed when read.
  25297. */
  25298. protected _wheelDeltaZ: number;
  25299. /**
  25300. * Firefox uses a different scheme to report scroll distances to other
  25301. * browsers. Rather than use complicated methods to calculate the exact
  25302. * multiple we need to apply, let's just cheat and use a constant.
  25303. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  25304. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  25305. */
  25306. private readonly _ffMultiplier;
  25307. /**
  25308. * Different event attributes for wheel data fall into a few set ranges.
  25309. * Some relevant but dated date here:
  25310. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  25311. */
  25312. private readonly _normalize;
  25313. }
  25314. }
  25315. declare module BABYLON {
  25316. /**
  25317. * Manage the mouse wheel inputs to control a free camera.
  25318. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25319. */
  25320. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  25321. /**
  25322. * Defines the camera the input is attached to.
  25323. */
  25324. camera: FreeCamera;
  25325. /**
  25326. * Gets the class name of the current input.
  25327. * @returns the class name
  25328. */
  25329. getClassName(): string;
  25330. /**
  25331. * Set which movement axis (relative to camera's orientation) the mouse
  25332. * wheel's X axis controls.
  25333. * @param axis The axis to be moved. Set null to clear.
  25334. */
  25335. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  25336. /**
  25337. * Get the configured movement axis (relative to camera's orientation) the
  25338. * mouse wheel's X axis controls.
  25339. * @returns The configured axis or null if none.
  25340. */
  25341. get wheelXMoveRelative(): Nullable<Coordinate>;
  25342. /**
  25343. * Set which movement axis (relative to camera's orientation) the mouse
  25344. * wheel's Y axis controls.
  25345. * @param axis The axis to be moved. Set null to clear.
  25346. */
  25347. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  25348. /**
  25349. * Get the configured movement axis (relative to camera's orientation) the
  25350. * mouse wheel's Y axis controls.
  25351. * @returns The configured axis or null if none.
  25352. */
  25353. get wheelYMoveRelative(): Nullable<Coordinate>;
  25354. /**
  25355. * Set which movement axis (relative to camera's orientation) the mouse
  25356. * wheel's Z axis controls.
  25357. * @param axis The axis to be moved. Set null to clear.
  25358. */
  25359. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  25360. /**
  25361. * Get the configured movement axis (relative to camera's orientation) the
  25362. * mouse wheel's Z axis controls.
  25363. * @returns The configured axis or null if none.
  25364. */
  25365. get wheelZMoveRelative(): Nullable<Coordinate>;
  25366. /**
  25367. * Set which rotation axis (relative to camera's orientation) the mouse
  25368. * wheel's X axis controls.
  25369. * @param axis The axis to be moved. Set null to clear.
  25370. */
  25371. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  25372. /**
  25373. * Get the configured rotation axis (relative to camera's orientation) the
  25374. * mouse wheel's X axis controls.
  25375. * @returns The configured axis or null if none.
  25376. */
  25377. get wheelXRotateRelative(): Nullable<Coordinate>;
  25378. /**
  25379. * Set which rotation axis (relative to camera's orientation) the mouse
  25380. * wheel's Y axis controls.
  25381. * @param axis The axis to be moved. Set null to clear.
  25382. */
  25383. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  25384. /**
  25385. * Get the configured rotation axis (relative to camera's orientation) the
  25386. * mouse wheel's Y axis controls.
  25387. * @returns The configured axis or null if none.
  25388. */
  25389. get wheelYRotateRelative(): Nullable<Coordinate>;
  25390. /**
  25391. * Set which rotation axis (relative to camera's orientation) the mouse
  25392. * wheel's Z axis controls.
  25393. * @param axis The axis to be moved. Set null to clear.
  25394. */
  25395. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  25396. /**
  25397. * Get the configured rotation axis (relative to camera's orientation) the
  25398. * mouse wheel's Z axis controls.
  25399. * @returns The configured axis or null if none.
  25400. */
  25401. get wheelZRotateRelative(): Nullable<Coordinate>;
  25402. /**
  25403. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  25404. * controls.
  25405. * @param axis The axis to be moved. Set null to clear.
  25406. */
  25407. set wheelXMoveScene(axis: Nullable<Coordinate>);
  25408. /**
  25409. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25410. * X axis controls.
  25411. * @returns The configured axis or null if none.
  25412. */
  25413. get wheelXMoveScene(): Nullable<Coordinate>;
  25414. /**
  25415. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  25416. * controls.
  25417. * @param axis The axis to be moved. Set null to clear.
  25418. */
  25419. set wheelYMoveScene(axis: Nullable<Coordinate>);
  25420. /**
  25421. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25422. * Y axis controls.
  25423. * @returns The configured axis or null if none.
  25424. */
  25425. get wheelYMoveScene(): Nullable<Coordinate>;
  25426. /**
  25427. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  25428. * controls.
  25429. * @param axis The axis to be moved. Set null to clear.
  25430. */
  25431. set wheelZMoveScene(axis: Nullable<Coordinate>);
  25432. /**
  25433. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25434. * Z axis controls.
  25435. * @returns The configured axis or null if none.
  25436. */
  25437. get wheelZMoveScene(): Nullable<Coordinate>;
  25438. /**
  25439. * Called for each rendered frame.
  25440. */
  25441. checkInputs(): void;
  25442. private _moveRelative;
  25443. private _rotateRelative;
  25444. private _moveScene;
  25445. /**
  25446. * These are set to the desired default behaviour.
  25447. */
  25448. private _wheelXAction;
  25449. private _wheelXActionCoordinate;
  25450. private _wheelYAction;
  25451. private _wheelYActionCoordinate;
  25452. private _wheelZAction;
  25453. private _wheelZActionCoordinate;
  25454. /**
  25455. * Update the camera according to any configured properties for the 3
  25456. * mouse-wheel axis.
  25457. */
  25458. private _updateCamera;
  25459. /**
  25460. * Update one property of the camera.
  25461. */
  25462. private _updateCameraProperty;
  25463. }
  25464. }
  25465. declare module BABYLON {
  25466. /**
  25467. * Manage the touch inputs to control the movement of a free camera.
  25468. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25469. */
  25470. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  25471. /**
  25472. * Define if mouse events can be treated as touch events
  25473. */
  25474. allowMouse: boolean;
  25475. /**
  25476. * Defines the camera the input is attached to.
  25477. */
  25478. camera: FreeCamera;
  25479. /**
  25480. * Defines the touch sensibility for rotation.
  25481. * The higher the faster.
  25482. */
  25483. touchAngularSensibility: number;
  25484. /**
  25485. * Defines the touch sensibility for move.
  25486. * The higher the faster.
  25487. */
  25488. touchMoveSensibility: number;
  25489. private _offsetX;
  25490. private _offsetY;
  25491. private _pointerPressed;
  25492. private _pointerInput?;
  25493. private _observer;
  25494. private _onLostFocus;
  25495. /**
  25496. * Manage the touch inputs to control the movement of a free camera.
  25497. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25498. * @param allowMouse Defines if mouse events can be treated as touch events
  25499. */
  25500. constructor(
  25501. /**
  25502. * Define if mouse events can be treated as touch events
  25503. */
  25504. allowMouse?: boolean);
  25505. /**
  25506. * Attach the input controls to a specific dom element to get the input from.
  25507. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25508. */
  25509. attachControl(noPreventDefault?: boolean): void;
  25510. /**
  25511. * Detach the current controls from the specified dom element.
  25512. */
  25513. detachControl(): void;
  25514. /**
  25515. * Update the current camera state depending on the inputs that have been used this frame.
  25516. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  25517. */
  25518. checkInputs(): void;
  25519. /**
  25520. * Gets the class name of the current input.
  25521. * @returns the class name
  25522. */
  25523. getClassName(): string;
  25524. /**
  25525. * Get the friendly name associated with the input class.
  25526. * @returns the input friendly name
  25527. */
  25528. getSimpleName(): string;
  25529. }
  25530. }
  25531. declare module BABYLON {
  25532. /**
  25533. * Default Inputs manager for the FreeCamera.
  25534. * It groups all the default supported inputs for ease of use.
  25535. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25536. */
  25537. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  25538. /**
  25539. * @hidden
  25540. */
  25541. _mouseInput: Nullable<FreeCameraMouseInput>;
  25542. /**
  25543. * @hidden
  25544. */
  25545. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  25546. /**
  25547. * Instantiates a new FreeCameraInputsManager.
  25548. * @param camera Defines the camera the inputs belong to
  25549. */
  25550. constructor(camera: FreeCamera);
  25551. /**
  25552. * Add keyboard input support to the input manager.
  25553. * @returns the current input manager
  25554. */
  25555. addKeyboard(): FreeCameraInputsManager;
  25556. /**
  25557. * Add mouse input support to the input manager.
  25558. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  25559. * @returns the current input manager
  25560. */
  25561. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  25562. /**
  25563. * Removes the mouse input support from the manager
  25564. * @returns the current input manager
  25565. */
  25566. removeMouse(): FreeCameraInputsManager;
  25567. /**
  25568. * Add mouse wheel input support to the input manager.
  25569. * @returns the current input manager
  25570. */
  25571. addMouseWheel(): FreeCameraInputsManager;
  25572. /**
  25573. * Removes the mouse wheel input support from the manager
  25574. * @returns the current input manager
  25575. */
  25576. removeMouseWheel(): FreeCameraInputsManager;
  25577. /**
  25578. * Add touch input support to the input manager.
  25579. * @returns the current input manager
  25580. */
  25581. addTouch(): FreeCameraInputsManager;
  25582. /**
  25583. * Remove all attached input methods from a camera
  25584. */
  25585. clear(): void;
  25586. }
  25587. }
  25588. declare module BABYLON {
  25589. /**
  25590. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25591. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  25592. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25593. */
  25594. export class FreeCamera extends TargetCamera {
  25595. /**
  25596. * Define the collision ellipsoid of the camera.
  25597. * This is helpful to simulate a camera body like the player body around the camera
  25598. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  25599. */
  25600. ellipsoid: Vector3;
  25601. /**
  25602. * Define an offset for the position of the ellipsoid around the camera.
  25603. * This can be helpful to determine the center of the body near the gravity center of the body
  25604. * instead of its head.
  25605. */
  25606. ellipsoidOffset: Vector3;
  25607. /**
  25608. * Enable or disable collisions of the camera with the rest of the scene objects.
  25609. */
  25610. checkCollisions: boolean;
  25611. /**
  25612. * Enable or disable gravity on the camera.
  25613. */
  25614. applyGravity: boolean;
  25615. /**
  25616. * Define the input manager associated to the camera.
  25617. */
  25618. inputs: FreeCameraInputsManager;
  25619. /**
  25620. * Gets the input sensibility for a mouse input. (default is 2000.0)
  25621. * Higher values reduce sensitivity.
  25622. */
  25623. get angularSensibility(): number;
  25624. /**
  25625. * Sets the input sensibility for a mouse input. (default is 2000.0)
  25626. * Higher values reduce sensitivity.
  25627. */
  25628. set angularSensibility(value: number);
  25629. /**
  25630. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  25631. */
  25632. get keysUp(): number[];
  25633. set keysUp(value: number[]);
  25634. /**
  25635. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  25636. */
  25637. get keysUpward(): number[];
  25638. set keysUpward(value: number[]);
  25639. /**
  25640. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  25641. */
  25642. get keysDown(): number[];
  25643. set keysDown(value: number[]);
  25644. /**
  25645. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  25646. */
  25647. get keysDownward(): number[];
  25648. set keysDownward(value: number[]);
  25649. /**
  25650. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  25651. */
  25652. get keysLeft(): number[];
  25653. set keysLeft(value: number[]);
  25654. /**
  25655. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  25656. */
  25657. get keysRight(): number[];
  25658. set keysRight(value: number[]);
  25659. /**
  25660. * Event raised when the camera collide with a mesh in the scene.
  25661. */
  25662. onCollide: (collidedMesh: AbstractMesh) => void;
  25663. private _collider;
  25664. private _needMoveForGravity;
  25665. private _oldPosition;
  25666. private _diffPosition;
  25667. private _newPosition;
  25668. /** @hidden */
  25669. _localDirection: Vector3;
  25670. /** @hidden */
  25671. _transformedDirection: Vector3;
  25672. /**
  25673. * Instantiates a Free Camera.
  25674. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25675. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  25676. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25677. * @param name Define the name of the camera in the scene
  25678. * @param position Define the start position of the camera in the scene
  25679. * @param scene Define the scene the camera belongs to
  25680. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active if not other active cameras have been defined
  25681. */
  25682. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25683. /**
  25684. * Attach the input controls to a specific dom element to get the input from.
  25685. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25686. */
  25687. attachControl(noPreventDefault?: boolean): void;
  25688. /**
  25689. * Attach the input controls to a specific dom element to get the input from.
  25690. * @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
  25691. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25692. * BACK COMPAT SIGNATURE ONLY.
  25693. */
  25694. attachControl(ignored: any, noPreventDefault?: boolean): void;
  25695. /**
  25696. * Detach the current controls from the specified dom element.
  25697. */
  25698. detachControl(): void;
  25699. /**
  25700. * Detach the current controls from the specified dom element.
  25701. * @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
  25702. */
  25703. detachControl(ignored: any): void;
  25704. private _collisionMask;
  25705. /**
  25706. * Define a collision mask to limit the list of object the camera can collide with
  25707. */
  25708. get collisionMask(): number;
  25709. set collisionMask(mask: number);
  25710. /** @hidden */
  25711. _collideWithWorld(displacement: Vector3): void;
  25712. private _onCollisionPositionChange;
  25713. /** @hidden */
  25714. _checkInputs(): void;
  25715. /** @hidden */
  25716. _decideIfNeedsToMove(): boolean;
  25717. /** @hidden */
  25718. _updatePosition(): void;
  25719. /**
  25720. * Destroy the camera and release the current resources hold by it.
  25721. */
  25722. dispose(): void;
  25723. /**
  25724. * Gets the current object class name.
  25725. * @return the class name
  25726. */
  25727. getClassName(): string;
  25728. }
  25729. }
  25730. declare module BABYLON {
  25731. /**
  25732. * Represents a gamepad control stick position
  25733. */
  25734. export class StickValues {
  25735. /**
  25736. * The x component of the control stick
  25737. */
  25738. x: number;
  25739. /**
  25740. * The y component of the control stick
  25741. */
  25742. y: number;
  25743. /**
  25744. * Initializes the gamepad x and y control stick values
  25745. * @param x The x component of the gamepad control stick value
  25746. * @param y The y component of the gamepad control stick value
  25747. */
  25748. constructor(
  25749. /**
  25750. * The x component of the control stick
  25751. */
  25752. x: number,
  25753. /**
  25754. * The y component of the control stick
  25755. */
  25756. y: number);
  25757. }
  25758. /**
  25759. * An interface which manages callbacks for gamepad button changes
  25760. */
  25761. export interface GamepadButtonChanges {
  25762. /**
  25763. * Called when a gamepad has been changed
  25764. */
  25765. changed: boolean;
  25766. /**
  25767. * Called when a gamepad press event has been triggered
  25768. */
  25769. pressChanged: boolean;
  25770. /**
  25771. * Called when a touch event has been triggered
  25772. */
  25773. touchChanged: boolean;
  25774. /**
  25775. * Called when a value has changed
  25776. */
  25777. valueChanged: boolean;
  25778. }
  25779. /**
  25780. * Represents a gamepad
  25781. */
  25782. export class Gamepad {
  25783. /**
  25784. * The id of the gamepad
  25785. */
  25786. id: string;
  25787. /**
  25788. * The index of the gamepad
  25789. */
  25790. index: number;
  25791. /**
  25792. * The browser gamepad
  25793. */
  25794. browserGamepad: any;
  25795. /**
  25796. * Specifies what type of gamepad this represents
  25797. */
  25798. type: number;
  25799. private _leftStick;
  25800. private _rightStick;
  25801. /** @hidden */
  25802. _isConnected: boolean;
  25803. private _leftStickAxisX;
  25804. private _leftStickAxisY;
  25805. private _rightStickAxisX;
  25806. private _rightStickAxisY;
  25807. /**
  25808. * Triggered when the left control stick has been changed
  25809. */
  25810. private _onleftstickchanged;
  25811. /**
  25812. * Triggered when the right control stick has been changed
  25813. */
  25814. private _onrightstickchanged;
  25815. /**
  25816. * Represents a gamepad controller
  25817. */
  25818. static GAMEPAD: number;
  25819. /**
  25820. * Represents a generic controller
  25821. */
  25822. static GENERIC: number;
  25823. /**
  25824. * Represents an XBox controller
  25825. */
  25826. static XBOX: number;
  25827. /**
  25828. * Represents a pose-enabled controller
  25829. */
  25830. static POSE_ENABLED: number;
  25831. /**
  25832. * Represents an Dual Shock controller
  25833. */
  25834. static DUALSHOCK: number;
  25835. /**
  25836. * Specifies whether the left control stick should be Y-inverted
  25837. */
  25838. protected _invertLeftStickY: boolean;
  25839. /**
  25840. * Specifies if the gamepad has been connected
  25841. */
  25842. get isConnected(): boolean;
  25843. /**
  25844. * Initializes the gamepad
  25845. * @param id The id of the gamepad
  25846. * @param index The index of the gamepad
  25847. * @param browserGamepad The browser gamepad
  25848. * @param leftStickX The x component of the left joystick
  25849. * @param leftStickY The y component of the left joystick
  25850. * @param rightStickX The x component of the right joystick
  25851. * @param rightStickY The y component of the right joystick
  25852. */
  25853. constructor(
  25854. /**
  25855. * The id of the gamepad
  25856. */
  25857. id: string,
  25858. /**
  25859. * The index of the gamepad
  25860. */
  25861. index: number,
  25862. /**
  25863. * The browser gamepad
  25864. */
  25865. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  25866. /**
  25867. * Callback triggered when the left joystick has changed
  25868. * @param callback
  25869. */
  25870. onleftstickchanged(callback: (values: StickValues) => void): void;
  25871. /**
  25872. * Callback triggered when the right joystick has changed
  25873. * @param callback
  25874. */
  25875. onrightstickchanged(callback: (values: StickValues) => void): void;
  25876. /**
  25877. * Gets the left joystick
  25878. */
  25879. get leftStick(): StickValues;
  25880. /**
  25881. * Sets the left joystick values
  25882. */
  25883. set leftStick(newValues: StickValues);
  25884. /**
  25885. * Gets the right joystick
  25886. */
  25887. get rightStick(): StickValues;
  25888. /**
  25889. * Sets the right joystick value
  25890. */
  25891. set rightStick(newValues: StickValues);
  25892. /**
  25893. * Updates the gamepad joystick positions
  25894. */
  25895. update(): void;
  25896. /**
  25897. * Disposes the gamepad
  25898. */
  25899. dispose(): void;
  25900. }
  25901. /**
  25902. * Represents a generic gamepad
  25903. */
  25904. export class GenericPad extends Gamepad {
  25905. private _buttons;
  25906. private _onbuttondown;
  25907. private _onbuttonup;
  25908. /**
  25909. * Observable triggered when a button has been pressed
  25910. */
  25911. onButtonDownObservable: Observable<number>;
  25912. /**
  25913. * Observable triggered when a button has been released
  25914. */
  25915. onButtonUpObservable: Observable<number>;
  25916. /**
  25917. * Callback triggered when a button has been pressed
  25918. * @param callback Called when a button has been pressed
  25919. */
  25920. onbuttondown(callback: (buttonPressed: number) => void): void;
  25921. /**
  25922. * Callback triggered when a button has been released
  25923. * @param callback Called when a button has been released
  25924. */
  25925. onbuttonup(callback: (buttonReleased: number) => void): void;
  25926. /**
  25927. * Initializes the generic gamepad
  25928. * @param id The id of the generic gamepad
  25929. * @param index The index of the generic gamepad
  25930. * @param browserGamepad The browser gamepad
  25931. */
  25932. constructor(id: string, index: number, browserGamepad: any);
  25933. private _setButtonValue;
  25934. /**
  25935. * Updates the generic gamepad
  25936. */
  25937. update(): void;
  25938. /**
  25939. * Disposes the generic gamepad
  25940. */
  25941. dispose(): void;
  25942. }
  25943. }
  25944. declare module BABYLON {
  25945. /**
  25946. * Defines a runtime animation
  25947. */
  25948. export class RuntimeAnimation {
  25949. private _events;
  25950. /**
  25951. * The current frame of the runtime animation
  25952. */
  25953. private _currentFrame;
  25954. /**
  25955. * The animation used by the runtime animation
  25956. */
  25957. private _animation;
  25958. /**
  25959. * The target of the runtime animation
  25960. */
  25961. private _target;
  25962. /**
  25963. * The initiating animatable
  25964. */
  25965. private _host;
  25966. /**
  25967. * The original value of the runtime animation
  25968. */
  25969. private _originalValue;
  25970. /**
  25971. * The original blend value of the runtime animation
  25972. */
  25973. private _originalBlendValue;
  25974. /**
  25975. * The offsets cache of the runtime animation
  25976. */
  25977. private _offsetsCache;
  25978. /**
  25979. * The high limits cache of the runtime animation
  25980. */
  25981. private _highLimitsCache;
  25982. /**
  25983. * Specifies if the runtime animation has been stopped
  25984. */
  25985. private _stopped;
  25986. /**
  25987. * The blending factor of the runtime animation
  25988. */
  25989. private _blendingFactor;
  25990. /**
  25991. * The BabylonJS scene
  25992. */
  25993. private _scene;
  25994. /**
  25995. * The current value of the runtime animation
  25996. */
  25997. private _currentValue;
  25998. /** @hidden */
  25999. _animationState: _IAnimationState;
  26000. /**
  26001. * The active target of the runtime animation
  26002. */
  26003. private _activeTargets;
  26004. private _currentActiveTarget;
  26005. private _directTarget;
  26006. /**
  26007. * The target path of the runtime animation
  26008. */
  26009. private _targetPath;
  26010. /**
  26011. * The weight of the runtime animation
  26012. */
  26013. private _weight;
  26014. /**
  26015. * The ratio offset of the runtime animation
  26016. */
  26017. private _ratioOffset;
  26018. /**
  26019. * The previous delay of the runtime animation
  26020. */
  26021. private _previousDelay;
  26022. /**
  26023. * The previous ratio of the runtime animation
  26024. */
  26025. private _previousRatio;
  26026. private _enableBlending;
  26027. private _keys;
  26028. private _minFrame;
  26029. private _maxFrame;
  26030. private _minValue;
  26031. private _maxValue;
  26032. private _targetIsArray;
  26033. /**
  26034. * Gets the current frame of the runtime animation
  26035. */
  26036. get currentFrame(): number;
  26037. /**
  26038. * Gets the weight of the runtime animation
  26039. */
  26040. get weight(): number;
  26041. /**
  26042. * Gets the current value of the runtime animation
  26043. */
  26044. get currentValue(): any;
  26045. /**
  26046. * Gets the target path of the runtime animation
  26047. */
  26048. get targetPath(): string;
  26049. /**
  26050. * Gets the actual target of the runtime animation
  26051. */
  26052. get target(): any;
  26053. /**
  26054. * Gets the additive state of the runtime animation
  26055. */
  26056. get isAdditive(): boolean;
  26057. /** @hidden */
  26058. _onLoop: () => void;
  26059. /**
  26060. * Create a new RuntimeAnimation object
  26061. * @param target defines the target of the animation
  26062. * @param animation defines the source animation object
  26063. * @param scene defines the hosting scene
  26064. * @param host defines the initiating Animatable
  26065. */
  26066. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  26067. private _preparePath;
  26068. /**
  26069. * Gets the animation from the runtime animation
  26070. */
  26071. get animation(): Animation;
  26072. /**
  26073. * Resets the runtime animation to the beginning
  26074. * @param restoreOriginal defines whether to restore the target property to the original value
  26075. */
  26076. reset(restoreOriginal?: boolean): void;
  26077. /**
  26078. * Specifies if the runtime animation is stopped
  26079. * @returns Boolean specifying if the runtime animation is stopped
  26080. */
  26081. isStopped(): boolean;
  26082. /**
  26083. * Disposes of the runtime animation
  26084. */
  26085. dispose(): void;
  26086. /**
  26087. * Apply the interpolated value to the target
  26088. * @param currentValue defines the value computed by the animation
  26089. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  26090. */
  26091. setValue(currentValue: any, weight: number): void;
  26092. private _getOriginalValues;
  26093. private _setValue;
  26094. /**
  26095. * Gets the loop pmode of the runtime animation
  26096. * @returns Loop Mode
  26097. */
  26098. private _getCorrectLoopMode;
  26099. /**
  26100. * Move the current animation to a given frame
  26101. * @param frame defines the frame to move to
  26102. */
  26103. goToFrame(frame: number): void;
  26104. /**
  26105. * @hidden Internal use only
  26106. */
  26107. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  26108. /**
  26109. * Execute the current animation
  26110. * @param delay defines the delay to add to the current frame
  26111. * @param from defines the lower bound of the animation range
  26112. * @param to defines the upper bound of the animation range
  26113. * @param loop defines if the current animation must loop
  26114. * @param speedRatio defines the current speed ratio
  26115. * @param weight defines the weight of the animation (default is -1 so no weight)
  26116. * @param onLoop optional callback called when animation loops
  26117. * @returns a boolean indicating if the animation is running
  26118. */
  26119. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  26120. }
  26121. }
  26122. declare module BABYLON {
  26123. /**
  26124. * Class used to store an actual running animation
  26125. */
  26126. export class Animatable {
  26127. /** defines the target object */
  26128. target: any;
  26129. /** defines the starting frame number (default is 0) */
  26130. fromFrame: number;
  26131. /** defines the ending frame number (default is 100) */
  26132. toFrame: number;
  26133. /** defines if the animation must loop (default is false) */
  26134. loopAnimation: boolean;
  26135. /** defines a callback to call when animation ends if it is not looping */
  26136. onAnimationEnd?: (() => void) | null | undefined;
  26137. /** defines a callback to call when animation loops */
  26138. onAnimationLoop?: (() => void) | null | undefined;
  26139. /** defines whether the animation should be evaluated additively */
  26140. isAdditive: boolean;
  26141. private _localDelayOffset;
  26142. private _pausedDelay;
  26143. private _runtimeAnimations;
  26144. private _paused;
  26145. private _scene;
  26146. private _speedRatio;
  26147. private _weight;
  26148. private _syncRoot;
  26149. /**
  26150. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  26151. * This will only apply for non looping animation (default is true)
  26152. */
  26153. disposeOnEnd: boolean;
  26154. /**
  26155. * Gets a boolean indicating if the animation has started
  26156. */
  26157. animationStarted: boolean;
  26158. /**
  26159. * Observer raised when the animation ends
  26160. */
  26161. onAnimationEndObservable: Observable<Animatable>;
  26162. /**
  26163. * Observer raised when the animation loops
  26164. */
  26165. onAnimationLoopObservable: Observable<Animatable>;
  26166. /**
  26167. * Gets the root Animatable used to synchronize and normalize animations
  26168. */
  26169. get syncRoot(): Nullable<Animatable>;
  26170. /**
  26171. * Gets the current frame of the first RuntimeAnimation
  26172. * Used to synchronize Animatables
  26173. */
  26174. get masterFrame(): number;
  26175. /**
  26176. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  26177. */
  26178. get weight(): number;
  26179. set weight(value: number);
  26180. /**
  26181. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  26182. */
  26183. get speedRatio(): number;
  26184. set speedRatio(value: number);
  26185. /**
  26186. * Creates a new Animatable
  26187. * @param scene defines the hosting scene
  26188. * @param target defines the target object
  26189. * @param fromFrame defines the starting frame number (default is 0)
  26190. * @param toFrame defines the ending frame number (default is 100)
  26191. * @param loopAnimation defines if the animation must loop (default is false)
  26192. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  26193. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  26194. * @param animations defines a group of animation to add to the new Animatable
  26195. * @param onAnimationLoop defines a callback to call when animation loops
  26196. * @param isAdditive defines whether the animation should be evaluated additively
  26197. */
  26198. constructor(scene: Scene,
  26199. /** defines the target object */
  26200. target: any,
  26201. /** defines the starting frame number (default is 0) */
  26202. fromFrame?: number,
  26203. /** defines the ending frame number (default is 100) */
  26204. toFrame?: number,
  26205. /** defines if the animation must loop (default is false) */
  26206. loopAnimation?: boolean, speedRatio?: number,
  26207. /** defines a callback to call when animation ends if it is not looping */
  26208. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  26209. /** defines a callback to call when animation loops */
  26210. onAnimationLoop?: (() => void) | null | undefined,
  26211. /** defines whether the animation should be evaluated additively */
  26212. isAdditive?: boolean);
  26213. /**
  26214. * Synchronize and normalize current Animatable with a source Animatable
  26215. * This is useful when using animation weights and when animations are not of the same length
  26216. * @param root defines the root Animatable to synchronize with
  26217. * @returns the current Animatable
  26218. */
  26219. syncWith(root: Animatable): Animatable;
  26220. /**
  26221. * Gets the list of runtime animations
  26222. * @returns an array of RuntimeAnimation
  26223. */
  26224. getAnimations(): RuntimeAnimation[];
  26225. /**
  26226. * Adds more animations to the current animatable
  26227. * @param target defines the target of the animations
  26228. * @param animations defines the new animations to add
  26229. */
  26230. appendAnimations(target: any, animations: Animation[]): void;
  26231. /**
  26232. * Gets the source animation for a specific property
  26233. * @param property defines the property to look for
  26234. * @returns null or the source animation for the given property
  26235. */
  26236. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  26237. /**
  26238. * Gets the runtime animation for a specific property
  26239. * @param property defines the property to look for
  26240. * @returns null or the runtime animation for the given property
  26241. */
  26242. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  26243. /**
  26244. * Resets the animatable to its original state
  26245. */
  26246. reset(): void;
  26247. /**
  26248. * Allows the animatable to blend with current running animations
  26249. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  26250. * @param blendingSpeed defines the blending speed to use
  26251. */
  26252. enableBlending(blendingSpeed: number): void;
  26253. /**
  26254. * Disable animation blending
  26255. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  26256. */
  26257. disableBlending(): void;
  26258. /**
  26259. * Jump directly to a given frame
  26260. * @param frame defines the frame to jump to
  26261. */
  26262. goToFrame(frame: number): void;
  26263. /**
  26264. * Pause the animation
  26265. */
  26266. pause(): void;
  26267. /**
  26268. * Restart the animation
  26269. */
  26270. restart(): void;
  26271. private _raiseOnAnimationEnd;
  26272. /**
  26273. * Stop and delete the current animation
  26274. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  26275. * @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)
  26276. */
  26277. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  26278. /**
  26279. * Wait asynchronously for the animation to end
  26280. * @returns a promise which will be fulfilled when the animation ends
  26281. */
  26282. waitAsync(): Promise<Animatable>;
  26283. /** @hidden */
  26284. _animate(delay: number): boolean;
  26285. }
  26286. interface Scene {
  26287. /** @hidden */
  26288. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  26289. /** @hidden */
  26290. _processLateAnimationBindingsForMatrices(holder: {
  26291. totalWeight: number;
  26292. totalAdditiveWeight: number;
  26293. animations: RuntimeAnimation[];
  26294. additiveAnimations: RuntimeAnimation[];
  26295. originalValue: Matrix;
  26296. }): any;
  26297. /** @hidden */
  26298. _processLateAnimationBindingsForQuaternions(holder: {
  26299. totalWeight: number;
  26300. totalAdditiveWeight: number;
  26301. animations: RuntimeAnimation[];
  26302. additiveAnimations: RuntimeAnimation[];
  26303. originalValue: Quaternion;
  26304. }, refQuaternion: Quaternion): Quaternion;
  26305. /** @hidden */
  26306. _processLateAnimationBindings(): void;
  26307. /**
  26308. * Will start the animation sequence of a given target
  26309. * @param target defines the target
  26310. * @param from defines from which frame should animation start
  26311. * @param to defines until which frame should animation run.
  26312. * @param weight defines the weight to apply to the animation (1.0 by default)
  26313. * @param loop defines if the animation loops
  26314. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26315. * @param onAnimationEnd defines the function to be executed when the animation ends
  26316. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26317. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  26318. * @param onAnimationLoop defines the callback to call when an animation loops
  26319. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26320. * @returns the animatable object created for this animation
  26321. */
  26322. 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;
  26323. /**
  26324. * Will start the animation sequence of a given target
  26325. * @param target defines the target
  26326. * @param from defines from which frame should animation start
  26327. * @param to defines until which frame should animation run.
  26328. * @param loop defines if the animation loops
  26329. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26330. * @param onAnimationEnd defines the function to be executed when the animation ends
  26331. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26332. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  26333. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  26334. * @param onAnimationLoop defines the callback to call when an animation loops
  26335. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26336. * @returns the animatable object created for this animation
  26337. */
  26338. 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;
  26339. /**
  26340. * Will start the animation sequence of a given target and its hierarchy
  26341. * @param target defines the target
  26342. * @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.
  26343. * @param from defines from which frame should animation start
  26344. * @param to defines until which frame should animation run.
  26345. * @param loop defines if the animation loops
  26346. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26347. * @param onAnimationEnd defines the function to be executed when the animation ends
  26348. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26349. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  26350. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  26351. * @param onAnimationLoop defines the callback to call when an animation loops
  26352. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26353. * @returns the list of created animatables
  26354. */
  26355. 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[];
  26356. /**
  26357. * Begin a new animation on a given node
  26358. * @param target defines the target where the animation will take place
  26359. * @param animations defines the list of animations to start
  26360. * @param from defines the initial value
  26361. * @param to defines the final value
  26362. * @param loop defines if you want animation to loop (off by default)
  26363. * @param speedRatio defines the speed ratio to apply to all animations
  26364. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26365. * @param onAnimationLoop defines the callback to call when an animation loops
  26366. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26367. * @returns the list of created animatables
  26368. */
  26369. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  26370. /**
  26371. * Begin a new animation on a given node and its hierarchy
  26372. * @param target defines the root node where the animation will take place
  26373. * @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.
  26374. * @param animations defines the list of animations to start
  26375. * @param from defines the initial value
  26376. * @param to defines the final value
  26377. * @param loop defines if you want animation to loop (off by default)
  26378. * @param speedRatio defines the speed ratio to apply to all animations
  26379. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26380. * @param onAnimationLoop defines the callback to call when an animation loops
  26381. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26382. * @returns the list of animatables created for all nodes
  26383. */
  26384. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  26385. /**
  26386. * Gets the animatable associated with a specific target
  26387. * @param target defines the target of the animatable
  26388. * @returns the required animatable if found
  26389. */
  26390. getAnimatableByTarget(target: any): Nullable<Animatable>;
  26391. /**
  26392. * Gets all animatables associated with a given target
  26393. * @param target defines the target to look animatables for
  26394. * @returns an array of Animatables
  26395. */
  26396. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  26397. /**
  26398. * Stops and removes all animations that have been applied to the scene
  26399. */
  26400. stopAllAnimations(): void;
  26401. /**
  26402. * Gets the current delta time used by animation engine
  26403. */
  26404. deltaTime: number;
  26405. }
  26406. interface Bone {
  26407. /**
  26408. * Copy an animation range from another bone
  26409. * @param source defines the source bone
  26410. * @param rangeName defines the range name to copy
  26411. * @param frameOffset defines the frame offset
  26412. * @param rescaleAsRequired defines if rescaling must be applied if required
  26413. * @param skelDimensionsRatio defines the scaling ratio
  26414. * @returns true if operation was successful
  26415. */
  26416. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  26417. }
  26418. }
  26419. declare module BABYLON {
  26420. /**
  26421. * Class used to override all child animations of a given target
  26422. */
  26423. export class AnimationPropertiesOverride {
  26424. /**
  26425. * Gets or sets a value indicating if animation blending must be used
  26426. */
  26427. enableBlending: boolean;
  26428. /**
  26429. * Gets or sets the blending speed to use when enableBlending is true
  26430. */
  26431. blendingSpeed: number;
  26432. /**
  26433. * Gets or sets the default loop mode to use
  26434. */
  26435. loopMode: number;
  26436. }
  26437. }
  26438. declare module BABYLON {
  26439. /**
  26440. * Class used to handle skinning animations
  26441. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26442. */
  26443. export class Skeleton implements IAnimatable {
  26444. /** defines the skeleton name */
  26445. name: string;
  26446. /** defines the skeleton Id */
  26447. id: string;
  26448. /**
  26449. * Defines the list of child bones
  26450. */
  26451. bones: Bone[];
  26452. /**
  26453. * Defines an estimate of the dimension of the skeleton at rest
  26454. */
  26455. dimensionsAtRest: Vector3;
  26456. /**
  26457. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  26458. */
  26459. needInitialSkinMatrix: boolean;
  26460. /**
  26461. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  26462. */
  26463. overrideMesh: Nullable<AbstractMesh>;
  26464. /**
  26465. * Gets the list of animations attached to this skeleton
  26466. */
  26467. animations: Array<Animation>;
  26468. private _scene;
  26469. private _isDirty;
  26470. private _transformMatrices;
  26471. private _transformMatrixTexture;
  26472. private _meshesWithPoseMatrix;
  26473. private _animatables;
  26474. private _identity;
  26475. private _synchronizedWithMesh;
  26476. private _ranges;
  26477. private _lastAbsoluteTransformsUpdateId;
  26478. private _canUseTextureForBones;
  26479. private _uniqueId;
  26480. /** @hidden */
  26481. _numBonesWithLinkedTransformNode: number;
  26482. /** @hidden */
  26483. _hasWaitingData: Nullable<boolean>;
  26484. /** @hidden */
  26485. _waitingOverrideMeshId: Nullable<string>;
  26486. /**
  26487. * Specifies if the skeleton should be serialized
  26488. */
  26489. doNotSerialize: boolean;
  26490. private _useTextureToStoreBoneMatrices;
  26491. /**
  26492. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  26493. * Please note that this option is not available if the hardware does not support it
  26494. */
  26495. get useTextureToStoreBoneMatrices(): boolean;
  26496. set useTextureToStoreBoneMatrices(value: boolean);
  26497. private _animationPropertiesOverride;
  26498. /**
  26499. * Gets or sets the animation properties override
  26500. */
  26501. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26502. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26503. /**
  26504. * List of inspectable custom properties (used by the Inspector)
  26505. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26506. */
  26507. inspectableCustomProperties: IInspectable[];
  26508. /**
  26509. * An observable triggered before computing the skeleton's matrices
  26510. */
  26511. onBeforeComputeObservable: Observable<Skeleton>;
  26512. /**
  26513. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  26514. */
  26515. get isUsingTextureForMatrices(): boolean;
  26516. /**
  26517. * Gets the unique ID of this skeleton
  26518. */
  26519. get uniqueId(): number;
  26520. /**
  26521. * Creates a new skeleton
  26522. * @param name defines the skeleton name
  26523. * @param id defines the skeleton Id
  26524. * @param scene defines the hosting scene
  26525. */
  26526. constructor(
  26527. /** defines the skeleton name */
  26528. name: string,
  26529. /** defines the skeleton Id */
  26530. id: string, scene: Scene);
  26531. /**
  26532. * Gets the current object class name.
  26533. * @return the class name
  26534. */
  26535. getClassName(): string;
  26536. /**
  26537. * Returns an array containing the root bones
  26538. * @returns an array containing the root bones
  26539. */
  26540. getChildren(): Array<Bone>;
  26541. /**
  26542. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  26543. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26544. * @returns a Float32Array containing matrices data
  26545. */
  26546. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  26547. /**
  26548. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  26549. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26550. * @returns a raw texture containing the data
  26551. */
  26552. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  26553. /**
  26554. * Gets the current hosting scene
  26555. * @returns a scene object
  26556. */
  26557. getScene(): Scene;
  26558. /**
  26559. * Gets a string representing the current skeleton data
  26560. * @param fullDetails defines a boolean indicating if we want a verbose version
  26561. * @returns a string representing the current skeleton data
  26562. */
  26563. toString(fullDetails?: boolean): string;
  26564. /**
  26565. * Get bone's index searching by name
  26566. * @param name defines bone's name to search for
  26567. * @return the indice of the bone. Returns -1 if not found
  26568. */
  26569. getBoneIndexByName(name: string): number;
  26570. /**
  26571. * Create a new animation range
  26572. * @param name defines the name of the range
  26573. * @param from defines the start key
  26574. * @param to defines the end key
  26575. */
  26576. createAnimationRange(name: string, from: number, to: number): void;
  26577. /**
  26578. * Delete a specific animation range
  26579. * @param name defines the name of the range
  26580. * @param deleteFrames defines if frames must be removed as well
  26581. */
  26582. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26583. /**
  26584. * Gets a specific animation range
  26585. * @param name defines the name of the range to look for
  26586. * @returns the requested animation range or null if not found
  26587. */
  26588. getAnimationRange(name: string): Nullable<AnimationRange>;
  26589. /**
  26590. * Gets the list of all animation ranges defined on this skeleton
  26591. * @returns an array
  26592. */
  26593. getAnimationRanges(): Nullable<AnimationRange>[];
  26594. /**
  26595. * Copy animation range from a source skeleton.
  26596. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  26597. * @param source defines the source skeleton
  26598. * @param name defines the name of the range to copy
  26599. * @param rescaleAsRequired defines if rescaling must be applied if required
  26600. * @returns true if operation was successful
  26601. */
  26602. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  26603. /**
  26604. * Forces the skeleton to go to rest pose
  26605. */
  26606. returnToRest(): void;
  26607. private _getHighestAnimationFrame;
  26608. /**
  26609. * Begin a specific animation range
  26610. * @param name defines the name of the range to start
  26611. * @param loop defines if looping must be turned on (false by default)
  26612. * @param speedRatio defines the speed ratio to apply (1 by default)
  26613. * @param onAnimationEnd defines a callback which will be called when animation will end
  26614. * @returns a new animatable
  26615. */
  26616. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26617. /**
  26618. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  26619. * @param skeleton defines the Skeleton containing the animation range to convert
  26620. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  26621. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  26622. * @returns the original skeleton
  26623. */
  26624. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  26625. /** @hidden */
  26626. _markAsDirty(): void;
  26627. /** @hidden */
  26628. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26629. /** @hidden */
  26630. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26631. private _computeTransformMatrices;
  26632. /**
  26633. * Build all resources required to render a skeleton
  26634. */
  26635. prepare(): void;
  26636. /**
  26637. * Gets the list of animatables currently running for this skeleton
  26638. * @returns an array of animatables
  26639. */
  26640. getAnimatables(): IAnimatable[];
  26641. /**
  26642. * Clone the current skeleton
  26643. * @param name defines the name of the new skeleton
  26644. * @param id defines the id of the new skeleton
  26645. * @returns the new skeleton
  26646. */
  26647. clone(name: string, id?: string): Skeleton;
  26648. /**
  26649. * Enable animation blending for this skeleton
  26650. * @param blendingSpeed defines the blending speed to apply
  26651. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  26652. */
  26653. enableBlending(blendingSpeed?: number): void;
  26654. /**
  26655. * Releases all resources associated with the current skeleton
  26656. */
  26657. dispose(): void;
  26658. /**
  26659. * Serialize the skeleton in a JSON object
  26660. * @returns a JSON object
  26661. */
  26662. serialize(): any;
  26663. /**
  26664. * Creates a new skeleton from serialized data
  26665. * @param parsedSkeleton defines the serialized data
  26666. * @param scene defines the hosting scene
  26667. * @returns a new skeleton
  26668. */
  26669. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  26670. /**
  26671. * Compute all node absolute transforms
  26672. * @param forceUpdate defines if computation must be done even if cache is up to date
  26673. */
  26674. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  26675. /**
  26676. * Gets the root pose matrix
  26677. * @returns a matrix
  26678. */
  26679. getPoseMatrix(): Nullable<Matrix>;
  26680. /**
  26681. * Sorts bones per internal index
  26682. */
  26683. sortBones(): void;
  26684. private _sortBones;
  26685. /**
  26686. * Set the current local matrix as the restPose for all bones in the skeleton.
  26687. */
  26688. setCurrentPoseAsRest(): void;
  26689. }
  26690. }
  26691. declare module BABYLON {
  26692. /**
  26693. * Class used to store bone information
  26694. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26695. */
  26696. export class Bone extends Node {
  26697. /**
  26698. * defines the bone name
  26699. */
  26700. name: string;
  26701. private static _tmpVecs;
  26702. private static _tmpQuat;
  26703. private static _tmpMats;
  26704. /**
  26705. * Gets the list of child bones
  26706. */
  26707. children: Bone[];
  26708. /** Gets the animations associated with this bone */
  26709. animations: Animation[];
  26710. /**
  26711. * Gets or sets bone length
  26712. */
  26713. length: number;
  26714. /**
  26715. * @hidden Internal only
  26716. * Set this value to map this bone to a different index in the transform matrices
  26717. * Set this value to -1 to exclude the bone from the transform matrices
  26718. */
  26719. _index: Nullable<number>;
  26720. private _skeleton;
  26721. private _localMatrix;
  26722. private _restPose;
  26723. private _bindPose;
  26724. private _baseMatrix;
  26725. private _absoluteTransform;
  26726. private _invertedAbsoluteTransform;
  26727. private _parent;
  26728. private _scalingDeterminant;
  26729. private _worldTransform;
  26730. private _localScaling;
  26731. private _localRotation;
  26732. private _localPosition;
  26733. private _needToDecompose;
  26734. private _needToCompose;
  26735. /** @hidden */
  26736. _linkedTransformNode: Nullable<TransformNode>;
  26737. /** @hidden */
  26738. _waitingTransformNodeId: Nullable<string>;
  26739. /** @hidden */
  26740. get _matrix(): Matrix;
  26741. /** @hidden */
  26742. set _matrix(value: Matrix);
  26743. /**
  26744. * Create a new bone
  26745. * @param name defines the bone name
  26746. * @param skeleton defines the parent skeleton
  26747. * @param parentBone defines the parent (can be null if the bone is the root)
  26748. * @param localMatrix defines the local matrix
  26749. * @param restPose defines the rest pose matrix
  26750. * @param baseMatrix defines the base matrix
  26751. * @param index defines index of the bone in the hierarchy
  26752. */
  26753. constructor(
  26754. /**
  26755. * defines the bone name
  26756. */
  26757. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  26758. /**
  26759. * Gets the current object class name.
  26760. * @return the class name
  26761. */
  26762. getClassName(): string;
  26763. /**
  26764. * Gets the parent skeleton
  26765. * @returns a skeleton
  26766. */
  26767. getSkeleton(): Skeleton;
  26768. /**
  26769. * Gets parent bone
  26770. * @returns a bone or null if the bone is the root of the bone hierarchy
  26771. */
  26772. getParent(): Nullable<Bone>;
  26773. /**
  26774. * Returns an array containing the root bones
  26775. * @returns an array containing the root bones
  26776. */
  26777. getChildren(): Array<Bone>;
  26778. /**
  26779. * Gets the node index in matrix array generated for rendering
  26780. * @returns the node index
  26781. */
  26782. getIndex(): number;
  26783. /**
  26784. * Sets the parent bone
  26785. * @param parent defines the parent (can be null if the bone is the root)
  26786. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26787. */
  26788. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  26789. /**
  26790. * Gets the local matrix
  26791. * @returns a matrix
  26792. */
  26793. getLocalMatrix(): Matrix;
  26794. /**
  26795. * Gets the base matrix (initial matrix which remains unchanged)
  26796. * @returns a matrix
  26797. */
  26798. getBaseMatrix(): Matrix;
  26799. /**
  26800. * Gets the rest pose matrix
  26801. * @returns a matrix
  26802. */
  26803. getRestPose(): Matrix;
  26804. /**
  26805. * Sets the rest pose matrix
  26806. * @param matrix the local-space rest pose to set for this bone
  26807. */
  26808. setRestPose(matrix: Matrix): void;
  26809. /**
  26810. * Gets the bind pose matrix
  26811. * @returns the bind pose matrix
  26812. */
  26813. getBindPose(): Matrix;
  26814. /**
  26815. * Sets the bind pose matrix
  26816. * @param matrix the local-space bind pose to set for this bone
  26817. */
  26818. setBindPose(matrix: Matrix): void;
  26819. /**
  26820. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  26821. */
  26822. getWorldMatrix(): Matrix;
  26823. /**
  26824. * Sets the local matrix to rest pose matrix
  26825. */
  26826. returnToRest(): void;
  26827. /**
  26828. * Gets the inverse of the absolute transform matrix.
  26829. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  26830. * @returns a matrix
  26831. */
  26832. getInvertedAbsoluteTransform(): Matrix;
  26833. /**
  26834. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  26835. * @returns a matrix
  26836. */
  26837. getAbsoluteTransform(): Matrix;
  26838. /**
  26839. * Links with the given transform node.
  26840. * The local matrix of this bone is copied from the transform node every frame.
  26841. * @param transformNode defines the transform node to link to
  26842. */
  26843. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  26844. /**
  26845. * Gets the node used to drive the bone's transformation
  26846. * @returns a transform node or null
  26847. */
  26848. getTransformNode(): Nullable<TransformNode>;
  26849. /** Gets or sets current position (in local space) */
  26850. get position(): Vector3;
  26851. set position(newPosition: Vector3);
  26852. /** Gets or sets current rotation (in local space) */
  26853. get rotation(): Vector3;
  26854. set rotation(newRotation: Vector3);
  26855. /** Gets or sets current rotation quaternion (in local space) */
  26856. get rotationQuaternion(): Quaternion;
  26857. set rotationQuaternion(newRotation: Quaternion);
  26858. /** Gets or sets current scaling (in local space) */
  26859. get scaling(): Vector3;
  26860. set scaling(newScaling: Vector3);
  26861. /**
  26862. * Gets the animation properties override
  26863. */
  26864. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26865. private _decompose;
  26866. private _compose;
  26867. /**
  26868. * Update the base and local matrices
  26869. * @param matrix defines the new base or local matrix
  26870. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26871. * @param updateLocalMatrix defines if the local matrix should be updated
  26872. */
  26873. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  26874. /** @hidden */
  26875. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  26876. /**
  26877. * Flag the bone as dirty (Forcing it to update everything)
  26878. */
  26879. markAsDirty(): void;
  26880. /** @hidden */
  26881. _markAsDirtyAndCompose(): void;
  26882. private _markAsDirtyAndDecompose;
  26883. /**
  26884. * Translate the bone in local or world space
  26885. * @param vec The amount to translate the bone
  26886. * @param space The space that the translation is in
  26887. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26888. */
  26889. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26890. /**
  26891. * Set the position of the bone in local or world space
  26892. * @param position The position to set the bone
  26893. * @param space The space that the position is in
  26894. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26895. */
  26896. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26897. /**
  26898. * Set the absolute position of the bone (world space)
  26899. * @param position The position to set the bone
  26900. * @param mesh The mesh that this bone is attached to
  26901. */
  26902. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  26903. /**
  26904. * Scale the bone on the x, y and z axes (in local space)
  26905. * @param x The amount to scale the bone on the x axis
  26906. * @param y The amount to scale the bone on the y axis
  26907. * @param z The amount to scale the bone on the z axis
  26908. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  26909. */
  26910. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  26911. /**
  26912. * Set the bone scaling in local space
  26913. * @param scale defines the scaling vector
  26914. */
  26915. setScale(scale: Vector3): void;
  26916. /**
  26917. * Gets the current scaling in local space
  26918. * @returns the current scaling vector
  26919. */
  26920. getScale(): Vector3;
  26921. /**
  26922. * Gets the current scaling in local space and stores it in a target vector
  26923. * @param result defines the target vector
  26924. */
  26925. getScaleToRef(result: Vector3): void;
  26926. /**
  26927. * Set the yaw, pitch, and roll of the bone in local or world space
  26928. * @param yaw The rotation of the bone on the y axis
  26929. * @param pitch The rotation of the bone on the x axis
  26930. * @param roll The rotation of the bone on the z axis
  26931. * @param space The space that the axes of rotation are in
  26932. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26933. */
  26934. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  26935. /**
  26936. * Add a rotation to the bone on an axis in local or world space
  26937. * @param axis The axis to rotate the bone on
  26938. * @param amount The amount to rotate the bone
  26939. * @param space The space that the axis is in
  26940. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26941. */
  26942. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  26943. /**
  26944. * Set the rotation of the bone to a particular axis angle in local or world space
  26945. * @param axis The axis to rotate the bone on
  26946. * @param angle The angle that the bone should be rotated to
  26947. * @param space The space that the axis is in
  26948. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26949. */
  26950. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  26951. /**
  26952. * Set the euler rotation of the bone in local or world space
  26953. * @param rotation The euler rotation that the bone should be set to
  26954. * @param space The space that the rotation is in
  26955. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26956. */
  26957. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26958. /**
  26959. * Set the quaternion rotation of the bone in local or world space
  26960. * @param quat The quaternion rotation that the bone should be set to
  26961. * @param space The space that the rotation is in
  26962. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26963. */
  26964. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  26965. /**
  26966. * Set the rotation matrix of the bone in local or world space
  26967. * @param rotMat The rotation matrix that the bone should be set to
  26968. * @param space The space that the rotation is in
  26969. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26970. */
  26971. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  26972. private _rotateWithMatrix;
  26973. private _getNegativeRotationToRef;
  26974. /**
  26975. * Get the position of the bone in local or world space
  26976. * @param space The space that the returned position is in
  26977. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26978. * @returns The position of the bone
  26979. */
  26980. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26981. /**
  26982. * Copy the position of the bone to a vector3 in local or world space
  26983. * @param space The space that the returned position is in
  26984. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26985. * @param result The vector3 to copy the position to
  26986. */
  26987. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  26988. /**
  26989. * Get the absolute position of the bone (world space)
  26990. * @param mesh The mesh that this bone is attached to
  26991. * @returns The absolute position of the bone
  26992. */
  26993. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  26994. /**
  26995. * Copy the absolute position of the bone (world space) to the result param
  26996. * @param mesh The mesh that this bone is attached to
  26997. * @param result The vector3 to copy the absolute position to
  26998. */
  26999. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  27000. /**
  27001. * Compute the absolute transforms of this bone and its children
  27002. */
  27003. computeAbsoluteTransforms(): void;
  27004. /**
  27005. * Get the world direction from an axis that is in the local space of the bone
  27006. * @param localAxis The local direction that is used to compute the world direction
  27007. * @param mesh The mesh that this bone is attached to
  27008. * @returns The world direction
  27009. */
  27010. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  27011. /**
  27012. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  27013. * @param localAxis The local direction that is used to compute the world direction
  27014. * @param mesh The mesh that this bone is attached to
  27015. * @param result The vector3 that the world direction will be copied to
  27016. */
  27017. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  27018. /**
  27019. * Get the euler rotation of the bone in local or world space
  27020. * @param space The space that the rotation should be in
  27021. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27022. * @returns The euler rotation
  27023. */
  27024. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  27025. /**
  27026. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  27027. * @param space The space that the rotation should be in
  27028. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27029. * @param result The vector3 that the rotation should be copied to
  27030. */
  27031. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  27032. /**
  27033. * Get the quaternion rotation of the bone in either local or world space
  27034. * @param space The space that the rotation should be in
  27035. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27036. * @returns The quaternion rotation
  27037. */
  27038. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  27039. /**
  27040. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  27041. * @param space The space that the rotation should be in
  27042. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27043. * @param result The quaternion that the rotation should be copied to
  27044. */
  27045. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  27046. /**
  27047. * Get the rotation matrix of the bone in local or world space
  27048. * @param space The space that the rotation should be in
  27049. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27050. * @returns The rotation matrix
  27051. */
  27052. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  27053. /**
  27054. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  27055. * @param space The space that the rotation should be in
  27056. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27057. * @param result The quaternion that the rotation should be copied to
  27058. */
  27059. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  27060. /**
  27061. * Get the world position of a point that is in the local space of the bone
  27062. * @param position The local position
  27063. * @param mesh The mesh that this bone is attached to
  27064. * @returns The world position
  27065. */
  27066. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  27067. /**
  27068. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  27069. * @param position The local position
  27070. * @param mesh The mesh that this bone is attached to
  27071. * @param result The vector3 that the world position should be copied to
  27072. */
  27073. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  27074. /**
  27075. * Get the local position of a point that is in world space
  27076. * @param position The world position
  27077. * @param mesh The mesh that this bone is attached to
  27078. * @returns The local position
  27079. */
  27080. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  27081. /**
  27082. * Get the local position of a point that is in world space and copy it to the result param
  27083. * @param position The world position
  27084. * @param mesh The mesh that this bone is attached to
  27085. * @param result The vector3 that the local position should be copied to
  27086. */
  27087. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  27088. /**
  27089. * Set the current local matrix as the restPose for this bone.
  27090. */
  27091. setCurrentPoseAsRest(): void;
  27092. }
  27093. }
  27094. declare module BABYLON {
  27095. /**
  27096. * 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.
  27097. * @see https://doc.babylonjs.com/how_to/transformnode
  27098. */
  27099. export class TransformNode extends Node {
  27100. /**
  27101. * Object will not rotate to face the camera
  27102. */
  27103. static BILLBOARDMODE_NONE: number;
  27104. /**
  27105. * Object will rotate to face the camera but only on the x axis
  27106. */
  27107. static BILLBOARDMODE_X: number;
  27108. /**
  27109. * Object will rotate to face the camera but only on the y axis
  27110. */
  27111. static BILLBOARDMODE_Y: number;
  27112. /**
  27113. * Object will rotate to face the camera but only on the z axis
  27114. */
  27115. static BILLBOARDMODE_Z: number;
  27116. /**
  27117. * Object will rotate to face the camera
  27118. */
  27119. static BILLBOARDMODE_ALL: number;
  27120. /**
  27121. * Object will rotate to face the camera's position instead of orientation
  27122. */
  27123. static BILLBOARDMODE_USE_POSITION: number;
  27124. private static _TmpRotation;
  27125. private static _TmpScaling;
  27126. private static _TmpTranslation;
  27127. private _forward;
  27128. private _forwardInverted;
  27129. private _up;
  27130. private _right;
  27131. private _rightInverted;
  27132. private _position;
  27133. private _rotation;
  27134. private _rotationQuaternion;
  27135. protected _scaling: Vector3;
  27136. protected _isDirty: boolean;
  27137. private _transformToBoneReferal;
  27138. private _isAbsoluteSynced;
  27139. private _billboardMode;
  27140. /**
  27141. * Gets or sets the billboard mode. Default is 0.
  27142. *
  27143. * | Value | Type | Description |
  27144. * | --- | --- | --- |
  27145. * | 0 | BILLBOARDMODE_NONE | |
  27146. * | 1 | BILLBOARDMODE_X | |
  27147. * | 2 | BILLBOARDMODE_Y | |
  27148. * | 4 | BILLBOARDMODE_Z | |
  27149. * | 7 | BILLBOARDMODE_ALL | |
  27150. *
  27151. */
  27152. get billboardMode(): number;
  27153. set billboardMode(value: number);
  27154. private _preserveParentRotationForBillboard;
  27155. /**
  27156. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  27157. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  27158. */
  27159. get preserveParentRotationForBillboard(): boolean;
  27160. set preserveParentRotationForBillboard(value: boolean);
  27161. /**
  27162. * 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
  27163. */
  27164. scalingDeterminant: number;
  27165. private _infiniteDistance;
  27166. /**
  27167. * Gets or sets the distance of the object to max, often used by skybox
  27168. */
  27169. get infiniteDistance(): boolean;
  27170. set infiniteDistance(value: boolean);
  27171. /**
  27172. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  27173. * By default the system will update normals to compensate
  27174. */
  27175. ignoreNonUniformScaling: boolean;
  27176. /**
  27177. * 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
  27178. */
  27179. reIntegrateRotationIntoRotationQuaternion: boolean;
  27180. /** @hidden */
  27181. _poseMatrix: Nullable<Matrix>;
  27182. /** @hidden */
  27183. _localMatrix: Matrix;
  27184. private _usePivotMatrix;
  27185. private _absolutePosition;
  27186. private _absoluteScaling;
  27187. private _absoluteRotationQuaternion;
  27188. private _pivotMatrix;
  27189. private _pivotMatrixInverse;
  27190. /** @hidden */
  27191. _postMultiplyPivotMatrix: boolean;
  27192. protected _isWorldMatrixFrozen: boolean;
  27193. /** @hidden */
  27194. _indexInSceneTransformNodesArray: number;
  27195. /**
  27196. * An event triggered after the world matrix is updated
  27197. */
  27198. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  27199. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  27200. /**
  27201. * Gets a string identifying the name of the class
  27202. * @returns "TransformNode" string
  27203. */
  27204. getClassName(): string;
  27205. /**
  27206. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  27207. */
  27208. get position(): Vector3;
  27209. set position(newPosition: Vector3);
  27210. /**
  27211. * 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)).
  27212. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  27213. */
  27214. get rotation(): Vector3;
  27215. set rotation(newRotation: Vector3);
  27216. /**
  27217. * 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)).
  27218. */
  27219. get scaling(): Vector3;
  27220. set scaling(newScaling: Vector3);
  27221. /**
  27222. * 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).
  27223. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  27224. */
  27225. get rotationQuaternion(): Nullable<Quaternion>;
  27226. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  27227. /**
  27228. * The forward direction of that transform in world space.
  27229. */
  27230. get forward(): Vector3;
  27231. /**
  27232. * The up direction of that transform in world space.
  27233. */
  27234. get up(): Vector3;
  27235. /**
  27236. * The right direction of that transform in world space.
  27237. */
  27238. get right(): Vector3;
  27239. /**
  27240. * Copies the parameter passed Matrix into the mesh Pose matrix.
  27241. * @param matrix the matrix to copy the pose from
  27242. * @returns this TransformNode.
  27243. */
  27244. updatePoseMatrix(matrix: Matrix): TransformNode;
  27245. /**
  27246. * Returns the mesh Pose matrix.
  27247. * @returns the pose matrix
  27248. */
  27249. getPoseMatrix(): Matrix;
  27250. /** @hidden */
  27251. _isSynchronized(): boolean;
  27252. /** @hidden */
  27253. _initCache(): void;
  27254. /**
  27255. * Flag the transform node as dirty (Forcing it to update everything)
  27256. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  27257. * @returns this transform node
  27258. */
  27259. markAsDirty(property: string): TransformNode;
  27260. /**
  27261. * Returns the current mesh absolute position.
  27262. * Returns a Vector3.
  27263. */
  27264. get absolutePosition(): Vector3;
  27265. /**
  27266. * Returns the current mesh absolute scaling.
  27267. * Returns a Vector3.
  27268. */
  27269. get absoluteScaling(): Vector3;
  27270. /**
  27271. * Returns the current mesh absolute rotation.
  27272. * Returns a Quaternion.
  27273. */
  27274. get absoluteRotationQuaternion(): Quaternion;
  27275. /**
  27276. * Sets a new matrix to apply before all other transformation
  27277. * @param matrix defines the transform matrix
  27278. * @returns the current TransformNode
  27279. */
  27280. setPreTransformMatrix(matrix: Matrix): TransformNode;
  27281. /**
  27282. * Sets a new pivot matrix to the current node
  27283. * @param matrix defines the new pivot matrix to use
  27284. * @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
  27285. * @returns the current TransformNode
  27286. */
  27287. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  27288. /**
  27289. * Returns the mesh pivot matrix.
  27290. * Default : Identity.
  27291. * @returns the matrix
  27292. */
  27293. getPivotMatrix(): Matrix;
  27294. /**
  27295. * Instantiate (when possible) or clone that node with its hierarchy
  27296. * @param newParent defines the new parent to use for the instance (or clone)
  27297. * @param options defines options to configure how copy is done
  27298. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  27299. * @returns an instance (or a clone) of the current node with its hiearchy
  27300. */
  27301. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  27302. doNotInstantiate: boolean;
  27303. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  27304. /**
  27305. * Prevents the World matrix to be computed any longer
  27306. * @param newWorldMatrix defines an optional matrix to use as world matrix
  27307. * @returns the TransformNode.
  27308. */
  27309. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  27310. /**
  27311. * Allows back the World matrix computation.
  27312. * @returns the TransformNode.
  27313. */
  27314. unfreezeWorldMatrix(): this;
  27315. /**
  27316. * True if the World matrix has been frozen.
  27317. */
  27318. get isWorldMatrixFrozen(): boolean;
  27319. /**
  27320. * Returns the mesh absolute position in the World.
  27321. * @returns a Vector3.
  27322. */
  27323. getAbsolutePosition(): Vector3;
  27324. /**
  27325. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  27326. * @param absolutePosition the absolute position to set
  27327. * @returns the TransformNode.
  27328. */
  27329. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27330. /**
  27331. * Sets the mesh position in its local space.
  27332. * @param vector3 the position to set in localspace
  27333. * @returns the TransformNode.
  27334. */
  27335. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  27336. /**
  27337. * Returns the mesh position in the local space from the current World matrix values.
  27338. * @returns a new Vector3.
  27339. */
  27340. getPositionExpressedInLocalSpace(): Vector3;
  27341. /**
  27342. * Translates the mesh along the passed Vector3 in its local space.
  27343. * @param vector3 the distance to translate in localspace
  27344. * @returns the TransformNode.
  27345. */
  27346. locallyTranslate(vector3: Vector3): TransformNode;
  27347. private static _lookAtVectorCache;
  27348. /**
  27349. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  27350. * @param targetPoint the position (must be in same space as current mesh) to look at
  27351. * @param yawCor optional yaw (y-axis) correction in radians
  27352. * @param pitchCor optional pitch (x-axis) correction in radians
  27353. * @param rollCor optional roll (z-axis) correction in radians
  27354. * @param space the chosen space of the target
  27355. * @returns the TransformNode.
  27356. */
  27357. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  27358. /**
  27359. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  27360. * This Vector3 is expressed in the World space.
  27361. * @param localAxis axis to rotate
  27362. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  27363. */
  27364. getDirection(localAxis: Vector3): Vector3;
  27365. /**
  27366. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  27367. * localAxis is expressed in the mesh local space.
  27368. * result is computed in the Wordl space from the mesh World matrix.
  27369. * @param localAxis axis to rotate
  27370. * @param result the resulting transformnode
  27371. * @returns this TransformNode.
  27372. */
  27373. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  27374. /**
  27375. * Sets this transform node rotation to the given local axis.
  27376. * @param localAxis the axis in local space
  27377. * @param yawCor optional yaw (y-axis) correction in radians
  27378. * @param pitchCor optional pitch (x-axis) correction in radians
  27379. * @param rollCor optional roll (z-axis) correction in radians
  27380. * @returns this TransformNode
  27381. */
  27382. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  27383. /**
  27384. * Sets a new pivot point to the current node
  27385. * @param point defines the new pivot point to use
  27386. * @param space defines if the point is in world or local space (local by default)
  27387. * @returns the current TransformNode
  27388. */
  27389. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  27390. /**
  27391. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  27392. * @returns the pivot point
  27393. */
  27394. getPivotPoint(): Vector3;
  27395. /**
  27396. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  27397. * @param result the vector3 to store the result
  27398. * @returns this TransformNode.
  27399. */
  27400. getPivotPointToRef(result: Vector3): TransformNode;
  27401. /**
  27402. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  27403. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  27404. */
  27405. getAbsolutePivotPoint(): Vector3;
  27406. /**
  27407. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  27408. * @param result vector3 to store the result
  27409. * @returns this TransformNode.
  27410. */
  27411. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  27412. /**
  27413. * Defines the passed node as the parent of the current node.
  27414. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  27415. * @see https://doc.babylonjs.com/how_to/parenting
  27416. * @param node the node ot set as the parent
  27417. * @returns this TransformNode.
  27418. */
  27419. setParent(node: Nullable<Node>): TransformNode;
  27420. private _nonUniformScaling;
  27421. /**
  27422. * True if the scaling property of this object is non uniform eg. (1,2,1)
  27423. */
  27424. get nonUniformScaling(): boolean;
  27425. /** @hidden */
  27426. _updateNonUniformScalingState(value: boolean): boolean;
  27427. /**
  27428. * Attach the current TransformNode to another TransformNode associated with a bone
  27429. * @param bone Bone affecting the TransformNode
  27430. * @param affectedTransformNode TransformNode associated with the bone
  27431. * @returns this object
  27432. */
  27433. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  27434. /**
  27435. * Detach the transform node if its associated with a bone
  27436. * @returns this object
  27437. */
  27438. detachFromBone(): TransformNode;
  27439. private static _rotationAxisCache;
  27440. /**
  27441. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  27442. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  27443. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  27444. * The passed axis is also normalized.
  27445. * @param axis the axis to rotate around
  27446. * @param amount the amount to rotate in radians
  27447. * @param space Space to rotate in (Default: local)
  27448. * @returns the TransformNode.
  27449. */
  27450. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27451. /**
  27452. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  27453. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  27454. * The passed axis is also normalized. .
  27455. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  27456. * @param point the point to rotate around
  27457. * @param axis the axis to rotate around
  27458. * @param amount the amount to rotate in radians
  27459. * @returns the TransformNode
  27460. */
  27461. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  27462. /**
  27463. * Translates the mesh along the axis vector for the passed distance in the given space.
  27464. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  27465. * @param axis the axis to translate in
  27466. * @param distance the distance to translate
  27467. * @param space Space to rotate in (Default: local)
  27468. * @returns the TransformNode.
  27469. */
  27470. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27471. /**
  27472. * Adds a rotation step to the mesh current rotation.
  27473. * x, y, z are Euler angles expressed in radians.
  27474. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  27475. * This means this rotation is made in the mesh local space only.
  27476. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  27477. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  27478. * ```javascript
  27479. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  27480. * ```
  27481. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  27482. * 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.
  27483. * @param x Rotation to add
  27484. * @param y Rotation to add
  27485. * @param z Rotation to add
  27486. * @returns the TransformNode.
  27487. */
  27488. addRotation(x: number, y: number, z: number): TransformNode;
  27489. /**
  27490. * @hidden
  27491. */
  27492. protected _getEffectiveParent(): Nullable<Node>;
  27493. /**
  27494. * Computes the world matrix of the node
  27495. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27496. * @returns the world matrix
  27497. */
  27498. computeWorldMatrix(force?: boolean): Matrix;
  27499. /**
  27500. * Resets this nodeTransform's local matrix to Matrix.Identity().
  27501. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  27502. */
  27503. resetLocalMatrix(independentOfChildren?: boolean): void;
  27504. protected _afterComputeWorldMatrix(): void;
  27505. /**
  27506. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  27507. * @param func callback function to add
  27508. *
  27509. * @returns the TransformNode.
  27510. */
  27511. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  27512. /**
  27513. * Removes a registered callback function.
  27514. * @param func callback function to remove
  27515. * @returns the TransformNode.
  27516. */
  27517. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  27518. /**
  27519. * Gets the position of the current mesh in camera space
  27520. * @param camera defines the camera to use
  27521. * @returns a position
  27522. */
  27523. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  27524. /**
  27525. * Returns the distance from the mesh to the active camera
  27526. * @param camera defines the camera to use
  27527. * @returns the distance
  27528. */
  27529. getDistanceToCamera(camera?: Nullable<Camera>): number;
  27530. /**
  27531. * Clone the current transform node
  27532. * @param name Name of the new clone
  27533. * @param newParent New parent for the clone
  27534. * @param doNotCloneChildren Do not clone children hierarchy
  27535. * @returns the new transform node
  27536. */
  27537. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  27538. /**
  27539. * Serializes the objects information.
  27540. * @param currentSerializationObject defines the object to serialize in
  27541. * @returns the serialized object
  27542. */
  27543. serialize(currentSerializationObject?: any): any;
  27544. /**
  27545. * Returns a new TransformNode object parsed from the source provided.
  27546. * @param parsedTransformNode is the source.
  27547. * @param scene the scene the object belongs to
  27548. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  27549. * @returns a new TransformNode object parsed from the source provided.
  27550. */
  27551. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  27552. /**
  27553. * Get all child-transformNodes of this node
  27554. * @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
  27555. * @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
  27556. * @returns an array of TransformNode
  27557. */
  27558. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  27559. /**
  27560. * Releases resources associated with this transform node.
  27561. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27562. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27563. */
  27564. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27565. /**
  27566. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27567. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27568. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27569. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27570. * @returns the current mesh
  27571. */
  27572. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  27573. private _syncAbsoluteScalingAndRotation;
  27574. }
  27575. }
  27576. declare module BABYLON {
  27577. /**
  27578. * Defines the types of pose enabled controllers that are supported
  27579. */
  27580. export enum PoseEnabledControllerType {
  27581. /**
  27582. * HTC Vive
  27583. */
  27584. VIVE = 0,
  27585. /**
  27586. * Oculus Rift
  27587. */
  27588. OCULUS = 1,
  27589. /**
  27590. * Windows mixed reality
  27591. */
  27592. WINDOWS = 2,
  27593. /**
  27594. * Samsung gear VR
  27595. */
  27596. GEAR_VR = 3,
  27597. /**
  27598. * Google Daydream
  27599. */
  27600. DAYDREAM = 4,
  27601. /**
  27602. * Generic
  27603. */
  27604. GENERIC = 5
  27605. }
  27606. /**
  27607. * Defines the MutableGamepadButton interface for the state of a gamepad button
  27608. */
  27609. export interface MutableGamepadButton {
  27610. /**
  27611. * Value of the button/trigger
  27612. */
  27613. value: number;
  27614. /**
  27615. * If the button/trigger is currently touched
  27616. */
  27617. touched: boolean;
  27618. /**
  27619. * If the button/trigger is currently pressed
  27620. */
  27621. pressed: boolean;
  27622. }
  27623. /**
  27624. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  27625. * @hidden
  27626. */
  27627. export interface ExtendedGamepadButton extends GamepadButton {
  27628. /**
  27629. * If the button/trigger is currently pressed
  27630. */
  27631. readonly pressed: boolean;
  27632. /**
  27633. * If the button/trigger is currently touched
  27634. */
  27635. readonly touched: boolean;
  27636. /**
  27637. * Value of the button/trigger
  27638. */
  27639. readonly value: number;
  27640. }
  27641. /** @hidden */
  27642. export interface _GamePadFactory {
  27643. /**
  27644. * Returns whether or not the current gamepad can be created for this type of controller.
  27645. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27646. * @returns true if it can be created, otherwise false
  27647. */
  27648. canCreate(gamepadInfo: any): boolean;
  27649. /**
  27650. * Creates a new instance of the Gamepad.
  27651. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27652. * @returns the new gamepad instance
  27653. */
  27654. create(gamepadInfo: any): Gamepad;
  27655. }
  27656. /**
  27657. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27658. */
  27659. export class PoseEnabledControllerHelper {
  27660. /** @hidden */
  27661. static _ControllerFactories: _GamePadFactory[];
  27662. /** @hidden */
  27663. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  27664. /**
  27665. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27666. * @param vrGamepad the gamepad to initialized
  27667. * @returns a vr controller of the type the gamepad identified as
  27668. */
  27669. static InitiateController(vrGamepad: any): Gamepad;
  27670. }
  27671. /**
  27672. * Defines the PoseEnabledController object that contains state of a vr capable controller
  27673. */
  27674. export class PoseEnabledController extends Gamepad implements PoseControlled {
  27675. /**
  27676. * If the controller is used in a webXR session
  27677. */
  27678. isXR: boolean;
  27679. private _deviceRoomPosition;
  27680. private _deviceRoomRotationQuaternion;
  27681. /**
  27682. * The device position in babylon space
  27683. */
  27684. devicePosition: Vector3;
  27685. /**
  27686. * The device rotation in babylon space
  27687. */
  27688. deviceRotationQuaternion: Quaternion;
  27689. /**
  27690. * The scale factor of the device in babylon space
  27691. */
  27692. deviceScaleFactor: number;
  27693. /**
  27694. * (Likely devicePosition should be used instead) The device position in its room space
  27695. */
  27696. position: Vector3;
  27697. /**
  27698. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  27699. */
  27700. rotationQuaternion: Quaternion;
  27701. /**
  27702. * The type of controller (Eg. Windows mixed reality)
  27703. */
  27704. controllerType: PoseEnabledControllerType;
  27705. protected _calculatedPosition: Vector3;
  27706. private _calculatedRotation;
  27707. /**
  27708. * The raw pose from the device
  27709. */
  27710. rawPose: DevicePose;
  27711. private _trackPosition;
  27712. private _maxRotationDistFromHeadset;
  27713. private _draggedRoomRotation;
  27714. /**
  27715. * @hidden
  27716. */
  27717. _disableTrackPosition(fixedPosition: Vector3): void;
  27718. /**
  27719. * Internal, the mesh attached to the controller
  27720. * @hidden
  27721. */
  27722. _mesh: Nullable<AbstractMesh>;
  27723. private _poseControlledCamera;
  27724. private _leftHandSystemQuaternion;
  27725. /**
  27726. * Internal, matrix used to convert room space to babylon space
  27727. * @hidden
  27728. */
  27729. _deviceToWorld: Matrix;
  27730. /**
  27731. * Node to be used when casting a ray from the controller
  27732. * @hidden
  27733. */
  27734. _pointingPoseNode: Nullable<TransformNode>;
  27735. /**
  27736. * Name of the child mesh that can be used to cast a ray from the controller
  27737. */
  27738. static readonly POINTING_POSE: string;
  27739. /**
  27740. * Creates a new PoseEnabledController from a gamepad
  27741. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  27742. */
  27743. constructor(browserGamepad: any);
  27744. private _workingMatrix;
  27745. /**
  27746. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  27747. */
  27748. update(): void;
  27749. /**
  27750. * Updates only the pose device and mesh without doing any button event checking
  27751. */
  27752. protected _updatePoseAndMesh(): void;
  27753. /**
  27754. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  27755. * @param poseData raw pose fromthe device
  27756. */
  27757. updateFromDevice(poseData: DevicePose): void;
  27758. /**
  27759. * @hidden
  27760. */
  27761. _meshAttachedObservable: Observable<AbstractMesh>;
  27762. /**
  27763. * Attaches a mesh to the controller
  27764. * @param mesh the mesh to be attached
  27765. */
  27766. attachToMesh(mesh: AbstractMesh): void;
  27767. /**
  27768. * Attaches the controllers mesh to a camera
  27769. * @param camera the camera the mesh should be attached to
  27770. */
  27771. attachToPoseControlledCamera(camera: TargetCamera): void;
  27772. /**
  27773. * Disposes of the controller
  27774. */
  27775. dispose(): void;
  27776. /**
  27777. * The mesh that is attached to the controller
  27778. */
  27779. get mesh(): Nullable<AbstractMesh>;
  27780. /**
  27781. * Gets the ray of the controller in the direction the controller is pointing
  27782. * @param length the length the resulting ray should be
  27783. * @returns a ray in the direction the controller is pointing
  27784. */
  27785. getForwardRay(length?: number): Ray;
  27786. }
  27787. }
  27788. declare module BABYLON {
  27789. /**
  27790. * Defines the WebVRController object that represents controllers tracked in 3D space
  27791. */
  27792. export abstract class WebVRController extends PoseEnabledController {
  27793. /**
  27794. * Internal, the default controller model for the controller
  27795. */
  27796. protected _defaultModel: Nullable<AbstractMesh>;
  27797. /**
  27798. * Fired when the trigger state has changed
  27799. */
  27800. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  27801. /**
  27802. * Fired when the main button state has changed
  27803. */
  27804. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27805. /**
  27806. * Fired when the secondary button state has changed
  27807. */
  27808. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27809. /**
  27810. * Fired when the pad state has changed
  27811. */
  27812. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  27813. /**
  27814. * Fired when controllers stick values have changed
  27815. */
  27816. onPadValuesChangedObservable: Observable<StickValues>;
  27817. /**
  27818. * Array of button availible on the controller
  27819. */
  27820. protected _buttons: Array<MutableGamepadButton>;
  27821. private _onButtonStateChange;
  27822. /**
  27823. * Fired when a controller button's state has changed
  27824. * @param callback the callback containing the button that was modified
  27825. */
  27826. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  27827. /**
  27828. * X and Y axis corresponding to the controllers joystick
  27829. */
  27830. pad: StickValues;
  27831. /**
  27832. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  27833. */
  27834. hand: string;
  27835. /**
  27836. * The default controller model for the controller
  27837. */
  27838. get defaultModel(): Nullable<AbstractMesh>;
  27839. /**
  27840. * Creates a new WebVRController from a gamepad
  27841. * @param vrGamepad the gamepad that the WebVRController should be created from
  27842. */
  27843. constructor(vrGamepad: any);
  27844. /**
  27845. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  27846. */
  27847. update(): void;
  27848. /**
  27849. * Function to be called when a button is modified
  27850. */
  27851. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  27852. /**
  27853. * Loads a mesh and attaches it to the controller
  27854. * @param scene the scene the mesh should be added to
  27855. * @param meshLoaded callback for when the mesh has been loaded
  27856. */
  27857. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  27858. private _setButtonValue;
  27859. private _changes;
  27860. private _checkChanges;
  27861. /**
  27862. * Disposes of th webVRCOntroller
  27863. */
  27864. dispose(): void;
  27865. }
  27866. }
  27867. declare module BABYLON {
  27868. /**
  27869. * The HemisphericLight simulates the ambient environment light,
  27870. * so the passed direction is the light reflection direction, not the incoming direction.
  27871. */
  27872. export class HemisphericLight extends Light {
  27873. /**
  27874. * The groundColor is the light in the opposite direction to the one specified during creation.
  27875. * 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.
  27876. */
  27877. groundColor: Color3;
  27878. /**
  27879. * The light reflection direction, not the incoming direction.
  27880. */
  27881. direction: Vector3;
  27882. /**
  27883. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  27884. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  27885. * The HemisphericLight can't cast shadows.
  27886. * Documentation : https://doc.babylonjs.com/babylon101/lights
  27887. * @param name The friendly name of the light
  27888. * @param direction The direction of the light reflection
  27889. * @param scene The scene the light belongs to
  27890. */
  27891. constructor(name: string, direction: Vector3, scene: Scene);
  27892. protected _buildUniformLayout(): void;
  27893. /**
  27894. * Returns the string "HemisphericLight".
  27895. * @return The class name
  27896. */
  27897. getClassName(): string;
  27898. /**
  27899. * Sets the HemisphericLight direction towards the passed target (Vector3).
  27900. * Returns the updated direction.
  27901. * @param target The target the direction should point to
  27902. * @return The computed direction
  27903. */
  27904. setDirectionToTarget(target: Vector3): Vector3;
  27905. /**
  27906. * Returns the shadow generator associated to the light.
  27907. * @returns Always null for hemispheric lights because it does not support shadows.
  27908. */
  27909. getShadowGenerator(): Nullable<IShadowGenerator>;
  27910. /**
  27911. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  27912. * @param effect The effect to update
  27913. * @param lightIndex The index of the light in the effect to update
  27914. * @returns The hemispheric light
  27915. */
  27916. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  27917. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  27918. /**
  27919. * Computes the world matrix of the node
  27920. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27921. * @param useWasUpdatedFlag defines a reserved property
  27922. * @returns the world matrix
  27923. */
  27924. computeWorldMatrix(): Matrix;
  27925. /**
  27926. * Returns the integer 3.
  27927. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  27928. */
  27929. getTypeID(): number;
  27930. /**
  27931. * Prepares the list of defines specific to the light type.
  27932. * @param defines the list of defines
  27933. * @param lightIndex defines the index of the light for the effect
  27934. */
  27935. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  27936. }
  27937. }
  27938. declare module BABYLON {
  27939. /** @hidden */
  27940. export var vrMultiviewToSingleviewPixelShader: {
  27941. name: string;
  27942. shader: string;
  27943. };
  27944. }
  27945. declare module BABYLON {
  27946. /**
  27947. * Renders to multiple views with a single draw call
  27948. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  27949. */
  27950. export class MultiviewRenderTarget extends RenderTargetTexture {
  27951. /**
  27952. * Creates a multiview render target
  27953. * @param scene scene used with the render target
  27954. * @param size the size of the render target (used for each view)
  27955. */
  27956. constructor(scene: Scene, size?: number | {
  27957. width: number;
  27958. height: number;
  27959. } | {
  27960. ratio: number;
  27961. });
  27962. /**
  27963. * @hidden
  27964. * @param faceIndex the face index, if its a cube texture
  27965. */
  27966. _bindFrameBuffer(faceIndex?: number): void;
  27967. /**
  27968. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  27969. * @returns the view count
  27970. */
  27971. getViewCount(): number;
  27972. }
  27973. }
  27974. declare module BABYLON {
  27975. interface Engine {
  27976. /**
  27977. * Creates a new multiview render target
  27978. * @param width defines the width of the texture
  27979. * @param height defines the height of the texture
  27980. * @returns the created multiview texture
  27981. */
  27982. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  27983. /**
  27984. * Binds a multiview framebuffer to be drawn to
  27985. * @param multiviewTexture texture to bind
  27986. */
  27987. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  27988. }
  27989. interface Camera {
  27990. /**
  27991. * @hidden
  27992. * 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)
  27993. */
  27994. _useMultiviewToSingleView: boolean;
  27995. /**
  27996. * @hidden
  27997. * 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)
  27998. */
  27999. _multiviewTexture: Nullable<RenderTargetTexture>;
  28000. /**
  28001. * @hidden
  28002. * ensures the multiview texture of the camera exists and has the specified width/height
  28003. * @param width height to set on the multiview texture
  28004. * @param height width to set on the multiview texture
  28005. */
  28006. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  28007. }
  28008. interface Scene {
  28009. /** @hidden */
  28010. _transformMatrixR: Matrix;
  28011. /** @hidden */
  28012. _multiviewSceneUbo: Nullable<UniformBuffer>;
  28013. /** @hidden */
  28014. _createMultiviewUbo(): void;
  28015. /** @hidden */
  28016. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  28017. /** @hidden */
  28018. _renderMultiviewToSingleView(camera: Camera): void;
  28019. }
  28020. }
  28021. declare module BABYLON {
  28022. /**
  28023. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  28024. * This will not be used for webXR as it supports displaying texture arrays directly
  28025. */
  28026. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  28027. /**
  28028. * Gets a string identifying the name of the class
  28029. * @returns "VRMultiviewToSingleviewPostProcess" string
  28030. */
  28031. getClassName(): string;
  28032. /**
  28033. * Initializes a VRMultiviewToSingleview
  28034. * @param name name of the post process
  28035. * @param camera camera to be applied to
  28036. * @param scaleFactor scaling factor to the size of the output texture
  28037. */
  28038. constructor(name: string, camera: Camera, scaleFactor: number);
  28039. }
  28040. }
  28041. declare module BABYLON {
  28042. /**
  28043. * Interface used to define additional presentation attributes
  28044. */
  28045. export interface IVRPresentationAttributes {
  28046. /**
  28047. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  28048. */
  28049. highRefreshRate: boolean;
  28050. /**
  28051. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  28052. */
  28053. foveationLevel: number;
  28054. }
  28055. interface Engine {
  28056. /** @hidden */
  28057. _vrDisplay: any;
  28058. /** @hidden */
  28059. _vrSupported: boolean;
  28060. /** @hidden */
  28061. _oldSize: Size;
  28062. /** @hidden */
  28063. _oldHardwareScaleFactor: number;
  28064. /** @hidden */
  28065. _vrExclusivePointerMode: boolean;
  28066. /** @hidden */
  28067. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  28068. /** @hidden */
  28069. _onVRDisplayPointerRestricted: () => void;
  28070. /** @hidden */
  28071. _onVRDisplayPointerUnrestricted: () => void;
  28072. /** @hidden */
  28073. _onVrDisplayConnect: Nullable<(display: any) => void>;
  28074. /** @hidden */
  28075. _onVrDisplayDisconnect: Nullable<() => void>;
  28076. /** @hidden */
  28077. _onVrDisplayPresentChange: Nullable<() => void>;
  28078. /**
  28079. * Observable signaled when VR display mode changes
  28080. */
  28081. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  28082. /**
  28083. * Observable signaled when VR request present is complete
  28084. */
  28085. onVRRequestPresentComplete: Observable<boolean>;
  28086. /**
  28087. * Observable signaled when VR request present starts
  28088. */
  28089. onVRRequestPresentStart: Observable<Engine>;
  28090. /**
  28091. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  28092. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  28093. */
  28094. isInVRExclusivePointerMode: boolean;
  28095. /**
  28096. * Gets a boolean indicating if a webVR device was detected
  28097. * @returns true if a webVR device was detected
  28098. */
  28099. isVRDevicePresent(): boolean;
  28100. /**
  28101. * Gets the current webVR device
  28102. * @returns the current webVR device (or null)
  28103. */
  28104. getVRDevice(): any;
  28105. /**
  28106. * Initializes a webVR display and starts listening to display change events
  28107. * The onVRDisplayChangedObservable will be notified upon these changes
  28108. * @returns A promise containing a VRDisplay and if vr is supported
  28109. */
  28110. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  28111. /** @hidden */
  28112. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  28113. /**
  28114. * Gets or sets the presentation attributes used to configure VR rendering
  28115. */
  28116. vrPresentationAttributes?: IVRPresentationAttributes;
  28117. /**
  28118. * Call this function to switch to webVR mode
  28119. * Will do nothing if webVR is not supported or if there is no webVR device
  28120. * @param options the webvr options provided to the camera. mainly used for multiview
  28121. * @see https://doc.babylonjs.com/how_to/webvr_camera
  28122. */
  28123. enableVR(options: WebVROptions): void;
  28124. /** @hidden */
  28125. _onVRFullScreenTriggered(): void;
  28126. }
  28127. }
  28128. declare module BABYLON {
  28129. /**
  28130. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  28131. * IMPORTANT!! The data is right-hand data.
  28132. * @export
  28133. * @interface DevicePose
  28134. */
  28135. export interface DevicePose {
  28136. /**
  28137. * The position of the device, values in array are [x,y,z].
  28138. */
  28139. readonly position: Nullable<Float32Array>;
  28140. /**
  28141. * The linearVelocity of the device, values in array are [x,y,z].
  28142. */
  28143. readonly linearVelocity: Nullable<Float32Array>;
  28144. /**
  28145. * The linearAcceleration of the device, values in array are [x,y,z].
  28146. */
  28147. readonly linearAcceleration: Nullable<Float32Array>;
  28148. /**
  28149. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  28150. */
  28151. readonly orientation: Nullable<Float32Array>;
  28152. /**
  28153. * The angularVelocity of the device, values in array are [x,y,z].
  28154. */
  28155. readonly angularVelocity: Nullable<Float32Array>;
  28156. /**
  28157. * The angularAcceleration of the device, values in array are [x,y,z].
  28158. */
  28159. readonly angularAcceleration: Nullable<Float32Array>;
  28160. }
  28161. /**
  28162. * Interface representing a pose controlled object in Babylon.
  28163. * A pose controlled object has both regular pose values as well as pose values
  28164. * from an external device such as a VR head mounted display
  28165. */
  28166. export interface PoseControlled {
  28167. /**
  28168. * The position of the object in babylon space.
  28169. */
  28170. position: Vector3;
  28171. /**
  28172. * The rotation quaternion of the object in babylon space.
  28173. */
  28174. rotationQuaternion: Quaternion;
  28175. /**
  28176. * The position of the device in babylon space.
  28177. */
  28178. devicePosition?: Vector3;
  28179. /**
  28180. * The rotation quaternion of the device in babylon space.
  28181. */
  28182. deviceRotationQuaternion: Quaternion;
  28183. /**
  28184. * The raw pose coming from the device.
  28185. */
  28186. rawPose: Nullable<DevicePose>;
  28187. /**
  28188. * The scale of the device to be used when translating from device space to babylon space.
  28189. */
  28190. deviceScaleFactor: number;
  28191. /**
  28192. * Updates the poseControlled values based on the input device pose.
  28193. * @param poseData the pose data to update the object with
  28194. */
  28195. updateFromDevice(poseData: DevicePose): void;
  28196. }
  28197. /**
  28198. * Set of options to customize the webVRCamera
  28199. */
  28200. export interface WebVROptions {
  28201. /**
  28202. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  28203. */
  28204. trackPosition?: boolean;
  28205. /**
  28206. * Sets the scale of the vrDevice in babylon space. (default: 1)
  28207. */
  28208. positionScale?: number;
  28209. /**
  28210. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  28211. */
  28212. displayName?: string;
  28213. /**
  28214. * Should the native controller meshes be initialized. (default: true)
  28215. */
  28216. controllerMeshes?: boolean;
  28217. /**
  28218. * Creating a default HemiLight only on controllers. (default: true)
  28219. */
  28220. defaultLightingOnControllers?: boolean;
  28221. /**
  28222. * If you don't want to use the default VR button of the helper. (default: false)
  28223. */
  28224. useCustomVRButton?: boolean;
  28225. /**
  28226. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  28227. */
  28228. customVRButton?: HTMLButtonElement;
  28229. /**
  28230. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  28231. */
  28232. rayLength?: number;
  28233. /**
  28234. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  28235. */
  28236. defaultHeight?: number;
  28237. /**
  28238. * If multiview should be used if available (default: false)
  28239. */
  28240. useMultiview?: boolean;
  28241. }
  28242. /**
  28243. * This represents a WebVR camera.
  28244. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  28245. * @example https://doc.babylonjs.com/how_to/webvr_camera
  28246. */
  28247. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  28248. private webVROptions;
  28249. /**
  28250. * @hidden
  28251. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  28252. */
  28253. _vrDevice: any;
  28254. /**
  28255. * The rawPose of the vrDevice.
  28256. */
  28257. rawPose: Nullable<DevicePose>;
  28258. private _onVREnabled;
  28259. private _specsVersion;
  28260. private _attached;
  28261. private _frameData;
  28262. protected _descendants: Array<Node>;
  28263. private _deviceRoomPosition;
  28264. /** @hidden */
  28265. _deviceRoomRotationQuaternion: Quaternion;
  28266. private _standingMatrix;
  28267. /**
  28268. * Represents device position in babylon space.
  28269. */
  28270. devicePosition: Vector3;
  28271. /**
  28272. * Represents device rotation in babylon space.
  28273. */
  28274. deviceRotationQuaternion: Quaternion;
  28275. /**
  28276. * The scale of the device to be used when translating from device space to babylon space.
  28277. */
  28278. deviceScaleFactor: number;
  28279. private _deviceToWorld;
  28280. private _worldToDevice;
  28281. /**
  28282. * References to the webVR controllers for the vrDevice.
  28283. */
  28284. controllers: Array<WebVRController>;
  28285. /**
  28286. * Emits an event when a controller is attached.
  28287. */
  28288. onControllersAttachedObservable: Observable<WebVRController[]>;
  28289. /**
  28290. * Emits an event when a controller's mesh has been loaded;
  28291. */
  28292. onControllerMeshLoadedObservable: Observable<WebVRController>;
  28293. /**
  28294. * Emits an event when the HMD's pose has been updated.
  28295. */
  28296. onPoseUpdatedFromDeviceObservable: Observable<any>;
  28297. private _poseSet;
  28298. /**
  28299. * If the rig cameras be used as parent instead of this camera.
  28300. */
  28301. rigParenting: boolean;
  28302. private _lightOnControllers;
  28303. private _defaultHeight?;
  28304. /**
  28305. * Instantiates a WebVRFreeCamera.
  28306. * @param name The name of the WebVRFreeCamera
  28307. * @param position The starting anchor position for the camera
  28308. * @param scene The scene the camera belongs to
  28309. * @param webVROptions a set of customizable options for the webVRCamera
  28310. */
  28311. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  28312. /**
  28313. * Gets the device distance from the ground in meters.
  28314. * @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.
  28315. */
  28316. deviceDistanceToRoomGround(): number;
  28317. /**
  28318. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28319. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  28320. */
  28321. useStandingMatrix(callback?: (bool: boolean) => void): void;
  28322. /**
  28323. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28324. * @returns A promise with a boolean set to if the standing matrix is supported.
  28325. */
  28326. useStandingMatrixAsync(): Promise<boolean>;
  28327. /**
  28328. * Disposes the camera
  28329. */
  28330. dispose(): void;
  28331. /**
  28332. * Gets a vrController by name.
  28333. * @param name The name of the controller to retreive
  28334. * @returns the controller matching the name specified or null if not found
  28335. */
  28336. getControllerByName(name: string): Nullable<WebVRController>;
  28337. private _leftController;
  28338. /**
  28339. * The controller corresponding to the users left hand.
  28340. */
  28341. get leftController(): Nullable<WebVRController>;
  28342. private _rightController;
  28343. /**
  28344. * The controller corresponding to the users right hand.
  28345. */
  28346. get rightController(): Nullable<WebVRController>;
  28347. /**
  28348. * Casts a ray forward from the vrCamera's gaze.
  28349. * @param length Length of the ray (default: 100)
  28350. * @returns the ray corresponding to the gaze
  28351. */
  28352. getForwardRay(length?: number): Ray;
  28353. /**
  28354. * @hidden
  28355. * Updates the camera based on device's frame data
  28356. */
  28357. _checkInputs(): void;
  28358. /**
  28359. * Updates the poseControlled values based on the input device pose.
  28360. * @param poseData Pose coming from the device
  28361. */
  28362. updateFromDevice(poseData: DevicePose): void;
  28363. private _detachIfAttached;
  28364. /**
  28365. * WebVR's attach control will start broadcasting frames to the device.
  28366. * Note that in certain browsers (chrome for example) this function must be called
  28367. * within a user-interaction callback. Example:
  28368. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  28369. *
  28370. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  28371. */
  28372. attachControl(noPreventDefault?: boolean): void;
  28373. /**
  28374. * Detach the current controls from the specified dom element.
  28375. */
  28376. detachControl(): void;
  28377. /**
  28378. * @returns the name of this class
  28379. */
  28380. getClassName(): string;
  28381. /**
  28382. * Calls resetPose on the vrDisplay
  28383. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  28384. */
  28385. resetToCurrentRotation(): void;
  28386. /**
  28387. * @hidden
  28388. * Updates the rig cameras (left and right eye)
  28389. */
  28390. _updateRigCameras(): void;
  28391. private _workingVector;
  28392. private _oneVector;
  28393. private _workingMatrix;
  28394. private updateCacheCalled;
  28395. private _correctPositionIfNotTrackPosition;
  28396. /**
  28397. * @hidden
  28398. * Updates the cached values of the camera
  28399. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  28400. */
  28401. _updateCache(ignoreParentClass?: boolean): void;
  28402. /**
  28403. * @hidden
  28404. * Get current device position in babylon world
  28405. */
  28406. _computeDevicePosition(): void;
  28407. /**
  28408. * Updates the current device position and rotation in the babylon world
  28409. */
  28410. update(): void;
  28411. /**
  28412. * @hidden
  28413. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  28414. * @returns an identity matrix
  28415. */
  28416. _getViewMatrix(): Matrix;
  28417. private _tmpMatrix;
  28418. /**
  28419. * This function is called by the two RIG cameras.
  28420. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  28421. * @hidden
  28422. */
  28423. _getWebVRViewMatrix(): Matrix;
  28424. /** @hidden */
  28425. _getWebVRProjectionMatrix(): Matrix;
  28426. private _onGamepadConnectedObserver;
  28427. private _onGamepadDisconnectedObserver;
  28428. private _updateCacheWhenTrackingDisabledObserver;
  28429. /**
  28430. * Initializes the controllers and their meshes
  28431. */
  28432. initControllers(): void;
  28433. }
  28434. }
  28435. declare module BABYLON {
  28436. /**
  28437. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  28438. *
  28439. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  28440. *
  28441. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  28442. */
  28443. export class MaterialHelper {
  28444. /**
  28445. * Bind the current view position to an effect.
  28446. * @param effect The effect to be bound
  28447. * @param scene The scene the eyes position is used from
  28448. * @param variableName name of the shader variable that will hold the eye position
  28449. * @param isVector3 true to indicates that variableName is a Vector3 and not a Vector4
  28450. * @return the computed eye position
  28451. */
  28452. static BindEyePosition(effect: Nullable<Effect>, scene: Scene, variableName?: string, isVector3?: boolean): Vector4;
  28453. /**
  28454. * Update the scene ubo before it can be used in rendering processing
  28455. * @param scene the scene to retrieve the ubo from
  28456. * @returns the scene UniformBuffer
  28457. */
  28458. static FinalizeSceneUbo(scene: Scene): UniformBuffer;
  28459. /**
  28460. * Binds the scene's uniform buffer to the effect.
  28461. * @param effect defines the effect to bind to the scene uniform buffer
  28462. * @param sceneUbo defines the uniform buffer storing scene data
  28463. */
  28464. static BindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  28465. /**
  28466. * Helps preparing the defines values about the UVs in used in the effect.
  28467. * UVs are shared as much as we can across channels in the shaders.
  28468. * @param texture The texture we are preparing the UVs for
  28469. * @param defines The defines to update
  28470. * @param key The channel key "diffuse", "specular"... used in the shader
  28471. */
  28472. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  28473. /**
  28474. * Binds a texture matrix value to its corresponding uniform
  28475. * @param texture The texture to bind the matrix for
  28476. * @param uniformBuffer The uniform buffer receiving the data
  28477. * @param key The channel key "diffuse", "specular"... used in the shader
  28478. */
  28479. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  28480. /**
  28481. * Gets the current status of the fog (should it be enabled?)
  28482. * @param mesh defines the mesh to evaluate for fog support
  28483. * @param scene defines the hosting scene
  28484. * @returns true if fog must be enabled
  28485. */
  28486. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  28487. /**
  28488. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  28489. * @param mesh defines the current mesh
  28490. * @param scene defines the current scene
  28491. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  28492. * @param pointsCloud defines if point cloud rendering has to be turned on
  28493. * @param fogEnabled defines if fog has to be turned on
  28494. * @param alphaTest defines if alpha testing has to be turned on
  28495. * @param defines defines the current list of defines
  28496. */
  28497. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  28498. /**
  28499. * Helper used to prepare the list of defines associated with frame values for shader compilation
  28500. * @param scene defines the current scene
  28501. * @param engine defines the current engine
  28502. * @param defines specifies the list of active defines
  28503. * @param useInstances defines if instances have to be turned on
  28504. * @param useClipPlane defines if clip plane have to be turned on
  28505. * @param useInstances defines if instances have to be turned on
  28506. * @param useThinInstances defines if thin instances have to be turned on
  28507. */
  28508. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  28509. /**
  28510. * Prepares the defines for bones
  28511. * @param mesh The mesh containing the geometry data we will draw
  28512. * @param defines The defines to update
  28513. */
  28514. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  28515. /**
  28516. * Prepares the defines for morph targets
  28517. * @param mesh The mesh containing the geometry data we will draw
  28518. * @param defines The defines to update
  28519. */
  28520. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  28521. /**
  28522. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  28523. * @param mesh The mesh containing the geometry data we will draw
  28524. * @param defines The defines to update
  28525. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  28526. * @param useBones Precise whether bones should be used or not (override mesh info)
  28527. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  28528. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  28529. * @returns false if defines are considered not dirty and have not been checked
  28530. */
  28531. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  28532. /**
  28533. * Prepares the defines related to multiview
  28534. * @param scene The scene we are intending to draw
  28535. * @param defines The defines to update
  28536. */
  28537. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  28538. /**
  28539. * Prepares the defines related to the prepass
  28540. * @param scene The scene we are intending to draw
  28541. * @param defines The defines to update
  28542. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  28543. */
  28544. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  28545. /**
  28546. * Prepares the defines related to the light information passed in parameter
  28547. * @param scene The scene we are intending to draw
  28548. * @param mesh The mesh the effect is compiling for
  28549. * @param light The light the effect is compiling for
  28550. * @param lightIndex The index of the light
  28551. * @param defines The defines to update
  28552. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  28553. * @param state Defines the current state regarding what is needed (normals, etc...)
  28554. */
  28555. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  28556. needNormals: boolean;
  28557. needRebuild: boolean;
  28558. shadowEnabled: boolean;
  28559. specularEnabled: boolean;
  28560. lightmapMode: boolean;
  28561. }): void;
  28562. /**
  28563. * Prepares the defines related to the light information passed in parameter
  28564. * @param scene The scene we are intending to draw
  28565. * @param mesh The mesh the effect is compiling for
  28566. * @param defines The defines to update
  28567. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  28568. * @param maxSimultaneousLights Specifies how manuy lights can be added to the effect at max
  28569. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  28570. * @returns true if normals will be required for the rest of the effect
  28571. */
  28572. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  28573. /**
  28574. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  28575. * @param lightIndex defines the light index
  28576. * @param uniformsList The uniform list
  28577. * @param samplersList The sampler list
  28578. * @param projectedLightTexture defines if projected texture must be used
  28579. * @param uniformBuffersList defines an optional list of uniform buffers
  28580. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  28581. */
  28582. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  28583. /**
  28584. * Prepares the uniforms and samplers list to be used in the effect
  28585. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the list and extra information
  28586. * @param samplersList The sampler list
  28587. * @param defines The defines helping in the list generation
  28588. * @param maxSimultaneousLights The maximum number of simultaneous light allowed in the effect
  28589. */
  28590. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  28591. /**
  28592. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  28593. * @param defines The defines to update while falling back
  28594. * @param fallbacks The authorized effect fallbacks
  28595. * @param maxSimultaneousLights The maximum number of lights allowed
  28596. * @param rank the current rank of the Effect
  28597. * @returns The newly affected rank
  28598. */
  28599. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  28600. private static _TmpMorphInfluencers;
  28601. /**
  28602. * Prepares the list of attributes required for morph targets according to the effect defines.
  28603. * @param attribs The current list of supported attribs
  28604. * @param mesh The mesh to prepare the morph targets attributes for
  28605. * @param influencers The number of influencers
  28606. */
  28607. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  28608. /**
  28609. * Prepares the list of attributes required for morph targets according to the effect defines.
  28610. * @param attribs The current list of supported attribs
  28611. * @param mesh The mesh to prepare the morph targets attributes for
  28612. * @param defines The current Defines of the effect
  28613. */
  28614. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  28615. /**
  28616. * Prepares the list of attributes required for bones according to the effect defines.
  28617. * @param attribs The current list of supported attribs
  28618. * @param mesh The mesh to prepare the bones attributes for
  28619. * @param defines The current Defines of the effect
  28620. * @param fallbacks The current effect fallback strategy
  28621. */
  28622. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  28623. /**
  28624. * Check and prepare the list of attributes required for instances according to the effect defines.
  28625. * @param attribs The current list of supported attribs
  28626. * @param defines The current MaterialDefines of the effect
  28627. */
  28628. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  28629. /**
  28630. * Add the list of attributes required for instances to the attribs array.
  28631. * @param attribs The current list of supported attribs
  28632. */
  28633. static PushAttributesForInstances(attribs: string[]): void;
  28634. /**
  28635. * Binds the light information to the effect.
  28636. * @param light The light containing the generator
  28637. * @param effect The effect we are binding the data to
  28638. * @param lightIndex The light index in the effect used to render
  28639. */
  28640. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  28641. /**
  28642. * Binds the lights information from the scene to the effect for the given mesh.
  28643. * @param light Light to bind
  28644. * @param lightIndex Light index
  28645. * @param scene The scene where the light belongs to
  28646. * @param effect The effect we are binding the data to
  28647. * @param useSpecular Defines if specular is supported
  28648. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28649. */
  28650. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  28651. /**
  28652. * Binds the lights information from the scene to the effect for the given mesh.
  28653. * @param scene The scene the lights belongs to
  28654. * @param mesh The mesh we are binding the information to render
  28655. * @param effect The effect we are binding the data to
  28656. * @param defines The generated defines for the effect
  28657. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  28658. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28659. */
  28660. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  28661. private static _tempFogColor;
  28662. /**
  28663. * Binds the fog information from the scene to the effect for the given mesh.
  28664. * @param scene The scene the lights belongs to
  28665. * @param mesh The mesh we are binding the information to render
  28666. * @param effect The effect we are binding the data to
  28667. * @param linearSpace Defines if the fog effect is applied in linear space
  28668. */
  28669. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  28670. /**
  28671. * Binds the bones information from the mesh to the effect.
  28672. * @param mesh The mesh we are binding the information to render
  28673. * @param effect The effect we are binding the data to
  28674. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  28675. */
  28676. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  28677. private static _CopyBonesTransformationMatrices;
  28678. /**
  28679. * Binds the morph targets information from the mesh to the effect.
  28680. * @param abstractMesh The mesh we are binding the information to render
  28681. * @param effect The effect we are binding the data to
  28682. */
  28683. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  28684. /**
  28685. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  28686. * @param defines The generated defines used in the effect
  28687. * @param effect The effect we are binding the data to
  28688. * @param scene The scene we are willing to render with logarithmic scale for
  28689. */
  28690. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  28691. /**
  28692. * Binds the clip plane information from the scene to the effect.
  28693. * @param scene The scene the clip plane information are extracted from
  28694. * @param effect The effect we are binding the data to
  28695. */
  28696. static BindClipPlane(effect: Effect, scene: Scene): void;
  28697. }
  28698. }
  28699. declare module BABYLON {
  28700. /** @hidden */
  28701. export var bayerDitherFunctions: {
  28702. name: string;
  28703. shader: string;
  28704. };
  28705. }
  28706. declare module BABYLON {
  28707. /** @hidden */
  28708. export var shadowMapFragmentDeclaration: {
  28709. name: string;
  28710. shader: string;
  28711. };
  28712. }
  28713. declare module BABYLON {
  28714. /** @hidden */
  28715. export var shadowMapFragment: {
  28716. name: string;
  28717. shader: string;
  28718. };
  28719. }
  28720. declare module BABYLON {
  28721. /** @hidden */
  28722. export var shadowMapPixelShader: {
  28723. name: string;
  28724. shader: string;
  28725. };
  28726. }
  28727. declare module BABYLON {
  28728. /** @hidden */
  28729. export var shadowMapVertexDeclaration: {
  28730. name: string;
  28731. shader: string;
  28732. };
  28733. }
  28734. declare module BABYLON {
  28735. /** @hidden */
  28736. export var shadowMapVertexNormalBias: {
  28737. name: string;
  28738. shader: string;
  28739. };
  28740. }
  28741. declare module BABYLON {
  28742. /** @hidden */
  28743. export var shadowMapVertexMetric: {
  28744. name: string;
  28745. shader: string;
  28746. };
  28747. }
  28748. declare module BABYLON {
  28749. /** @hidden */
  28750. export var shadowMapVertexShader: {
  28751. name: string;
  28752. shader: string;
  28753. };
  28754. }
  28755. declare module BABYLON {
  28756. /** @hidden */
  28757. export var depthBoxBlurPixelShader: {
  28758. name: string;
  28759. shader: string;
  28760. };
  28761. }
  28762. declare module BABYLON {
  28763. /** @hidden */
  28764. export var shadowMapFragmentSoftTransparentShadow: {
  28765. name: string;
  28766. shader: string;
  28767. };
  28768. }
  28769. declare module BABYLON {
  28770. /**
  28771. * Creates an instance based on a source mesh.
  28772. */
  28773. export class InstancedMesh extends AbstractMesh {
  28774. private _sourceMesh;
  28775. private _currentLOD;
  28776. /** @hidden */
  28777. _indexInSourceMeshInstanceArray: number;
  28778. constructor(name: string, source: Mesh);
  28779. /**
  28780. * Returns the string "InstancedMesh".
  28781. */
  28782. getClassName(): string;
  28783. /** Gets the list of lights affecting that mesh */
  28784. get lightSources(): Light[];
  28785. _resyncLightSources(): void;
  28786. _resyncLightSource(light: Light): void;
  28787. _removeLightSource(light: Light, dispose: boolean): void;
  28788. /**
  28789. * If the source mesh receives shadows
  28790. */
  28791. get receiveShadows(): boolean;
  28792. /**
  28793. * The material of the source mesh
  28794. */
  28795. get material(): Nullable<Material>;
  28796. /**
  28797. * Visibility of the source mesh
  28798. */
  28799. get visibility(): number;
  28800. /**
  28801. * Skeleton of the source mesh
  28802. */
  28803. get skeleton(): Nullable<Skeleton>;
  28804. /**
  28805. * Rendering ground id of the source mesh
  28806. */
  28807. get renderingGroupId(): number;
  28808. set renderingGroupId(value: number);
  28809. /**
  28810. * Returns the total number of vertices (integer).
  28811. */
  28812. getTotalVertices(): number;
  28813. /**
  28814. * Returns a positive integer : the total number of indices in this mesh geometry.
  28815. * @returns the numner of indices or zero if the mesh has no geometry.
  28816. */
  28817. getTotalIndices(): number;
  28818. /**
  28819. * The source mesh of the instance
  28820. */
  28821. get sourceMesh(): Mesh;
  28822. /**
  28823. * Creates a new InstancedMesh object from the mesh model.
  28824. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28825. * @param name defines the name of the new instance
  28826. * @returns a new InstancedMesh
  28827. */
  28828. createInstance(name: string): InstancedMesh;
  28829. /**
  28830. * Is this node ready to be used/rendered
  28831. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28832. * @return {boolean} is it ready
  28833. */
  28834. isReady(completeCheck?: boolean): boolean;
  28835. /**
  28836. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28837. * @param kind kind of verticies to retrieve (eg. positions, normals, uvs, etc.)
  28838. * @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.
  28839. * @returns a float array or a Float32Array of the requested kind of data : positions, normals, uvs, etc.
  28840. */
  28841. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  28842. /**
  28843. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28844. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28845. * The `data` are either a numeric array either a Float32Array.
  28846. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initially none) or updater.
  28847. * 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).
  28848. * Note that a new underlying VertexBuffer object is created each call.
  28849. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28850. *
  28851. * Possible `kind` values :
  28852. * - VertexBuffer.PositionKind
  28853. * - VertexBuffer.UVKind
  28854. * - VertexBuffer.UV2Kind
  28855. * - VertexBuffer.UV3Kind
  28856. * - VertexBuffer.UV4Kind
  28857. * - VertexBuffer.UV5Kind
  28858. * - VertexBuffer.UV6Kind
  28859. * - VertexBuffer.ColorKind
  28860. * - VertexBuffer.MatricesIndicesKind
  28861. * - VertexBuffer.MatricesIndicesExtraKind
  28862. * - VertexBuffer.MatricesWeightsKind
  28863. * - VertexBuffer.MatricesWeightsExtraKind
  28864. *
  28865. * Returns the Mesh.
  28866. */
  28867. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28868. /**
  28869. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28870. * If the mesh has no geometry, it is simply returned as it is.
  28871. * The `data` are either a numeric array either a Float32Array.
  28872. * No new underlying VertexBuffer object is created.
  28873. * 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.
  28874. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  28875. *
  28876. * Possible `kind` values :
  28877. * - VertexBuffer.PositionKind
  28878. * - VertexBuffer.UVKind
  28879. * - VertexBuffer.UV2Kind
  28880. * - VertexBuffer.UV3Kind
  28881. * - VertexBuffer.UV4Kind
  28882. * - VertexBuffer.UV5Kind
  28883. * - VertexBuffer.UV6Kind
  28884. * - VertexBuffer.ColorKind
  28885. * - VertexBuffer.MatricesIndicesKind
  28886. * - VertexBuffer.MatricesIndicesExtraKind
  28887. * - VertexBuffer.MatricesWeightsKind
  28888. * - VertexBuffer.MatricesWeightsExtraKind
  28889. *
  28890. * Returns the Mesh.
  28891. */
  28892. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  28893. /**
  28894. * Sets the mesh indices.
  28895. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  28896. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28897. * This method creates a new index buffer each call.
  28898. * Returns the Mesh.
  28899. */
  28900. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  28901. /**
  28902. * Boolean : True if the mesh owns the requested kind of data.
  28903. */
  28904. isVerticesDataPresent(kind: string): boolean;
  28905. /**
  28906. * Returns an array of indices (IndicesArray).
  28907. */
  28908. getIndices(): Nullable<IndicesArray>;
  28909. get _positions(): Nullable<Vector3[]>;
  28910. /**
  28911. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28912. * This means the mesh underlying bounding box and sphere are recomputed.
  28913. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28914. * @returns the current mesh
  28915. */
  28916. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  28917. /** @hidden */
  28918. _preActivate(): InstancedMesh;
  28919. /** @hidden */
  28920. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28921. /** @hidden */
  28922. _postActivate(): void;
  28923. getWorldMatrix(): Matrix;
  28924. get isAnInstance(): boolean;
  28925. /**
  28926. * Returns the current associated LOD AbstractMesh.
  28927. */
  28928. getLOD(camera: Camera): AbstractMesh;
  28929. /** @hidden */
  28930. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28931. /** @hidden */
  28932. _syncSubMeshes(): InstancedMesh;
  28933. /** @hidden */
  28934. _generatePointsArray(): boolean;
  28935. /** @hidden */
  28936. _updateBoundingInfo(): AbstractMesh;
  28937. /**
  28938. * Creates a new InstancedMesh from the current mesh.
  28939. * - name (string) : the cloned mesh name
  28940. * - newParent (optional Node) : the optional Node to parent the clone to.
  28941. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  28942. *
  28943. * Returns the clone.
  28944. */
  28945. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  28946. /**
  28947. * Disposes the InstancedMesh.
  28948. * Returns nothing.
  28949. */
  28950. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28951. }
  28952. interface Mesh {
  28953. /**
  28954. * Register a custom buffer that will be instanced
  28955. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28956. * @param kind defines the buffer kind
  28957. * @param stride defines the stride in floats
  28958. */
  28959. registerInstancedBuffer(kind: string, stride: number): void;
  28960. /**
  28961. * Invalidate VertexArrayObjects belonging to the mesh (but not to the Geometry of the mesh).
  28962. */
  28963. _invalidateInstanceVertexArrayObject(): void;
  28964. /**
  28965. * true to use the edge renderer for all instances of this mesh
  28966. */
  28967. edgesShareWithInstances: boolean;
  28968. /** @hidden */
  28969. _userInstancedBuffersStorage: {
  28970. data: {
  28971. [key: string]: Float32Array;
  28972. };
  28973. sizes: {
  28974. [key: string]: number;
  28975. };
  28976. vertexBuffers: {
  28977. [key: string]: Nullable<VertexBuffer>;
  28978. };
  28979. strides: {
  28980. [key: string]: number;
  28981. };
  28982. vertexArrayObjects?: {
  28983. [key: string]: WebGLVertexArrayObject;
  28984. };
  28985. };
  28986. }
  28987. interface AbstractMesh {
  28988. /**
  28989. * Object used to store instanced buffers defined by user
  28990. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28991. */
  28992. instancedBuffers: {
  28993. [key: string]: any;
  28994. };
  28995. }
  28996. }
  28997. declare module BABYLON {
  28998. /**
  28999. * Defines the options associated with the creation of a shader material.
  29000. */
  29001. export interface IShaderMaterialOptions {
  29002. /**
  29003. * Does the material work in alpha blend mode
  29004. */
  29005. needAlphaBlending: boolean;
  29006. /**
  29007. * Does the material work in alpha test mode
  29008. */
  29009. needAlphaTesting: boolean;
  29010. /**
  29011. * The list of attribute names used in the shader
  29012. */
  29013. attributes: string[];
  29014. /**
  29015. * The list of uniform names used in the shader
  29016. */
  29017. uniforms: string[];
  29018. /**
  29019. * The list of UBO names used in the shader
  29020. */
  29021. uniformBuffers: string[];
  29022. /**
  29023. * The list of sampler names used in the shader
  29024. */
  29025. samplers: string[];
  29026. /**
  29027. * The list of defines used in the shader
  29028. */
  29029. defines: string[];
  29030. }
  29031. /**
  29032. * 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.
  29033. *
  29034. * This returned material effects how the mesh will look based on the code in the shaders.
  29035. *
  29036. * @see https://doc.babylonjs.com/how_to/shader_material
  29037. */
  29038. export class ShaderMaterial extends Material {
  29039. private _shaderPath;
  29040. private _options;
  29041. private _textures;
  29042. private _textureArrays;
  29043. private _floats;
  29044. private _ints;
  29045. private _floatsArrays;
  29046. private _colors3;
  29047. private _colors3Arrays;
  29048. private _colors4;
  29049. private _colors4Arrays;
  29050. private _vectors2;
  29051. private _vectors3;
  29052. private _vectors4;
  29053. private _matrices;
  29054. private _matrixArrays;
  29055. private _matrices3x3;
  29056. private _matrices2x2;
  29057. private _vectors2Arrays;
  29058. private _vectors3Arrays;
  29059. private _vectors4Arrays;
  29060. private _cachedWorldViewMatrix;
  29061. private _cachedWorldViewProjectionMatrix;
  29062. private _renderId;
  29063. private _multiview;
  29064. private _cachedDefines;
  29065. /** Define the Url to load snippets */
  29066. static SnippetUrl: string;
  29067. /** Snippet ID if the material was created from the snippet server */
  29068. snippetId: string;
  29069. /**
  29070. * Instantiate a new shader material.
  29071. * 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.
  29072. * This returned material effects how the mesh will look based on the code in the shaders.
  29073. * @see https://doc.babylonjs.com/how_to/shader_material
  29074. * @param name Define the name of the material in the scene
  29075. * @param scene Define the scene the material belongs to
  29076. * @param shaderPath Defines the route to the shader code in one of three ways:
  29077. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  29078. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  29079. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  29080. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  29081. * @param options Define the options used to create the shader
  29082. */
  29083. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  29084. /**
  29085. * Gets the shader path used to define the shader code
  29086. * It can be modified to trigger a new compilation
  29087. */
  29088. get shaderPath(): any;
  29089. /**
  29090. * Sets the shader path used to define the shader code
  29091. * It can be modified to trigger a new compilation
  29092. */
  29093. set shaderPath(shaderPath: any);
  29094. /**
  29095. * Gets the options used to compile the shader.
  29096. * They can be modified to trigger a new compilation
  29097. */
  29098. get options(): IShaderMaterialOptions;
  29099. /**
  29100. * Gets the current class name of the material e.g. "ShaderMaterial"
  29101. * Mainly use in serialization.
  29102. * @returns the class name
  29103. */
  29104. getClassName(): string;
  29105. /**
  29106. * Specifies if the material will require alpha blending
  29107. * @returns a boolean specifying if alpha blending is needed
  29108. */
  29109. needAlphaBlending(): boolean;
  29110. /**
  29111. * Specifies if this material should be rendered in alpha test mode
  29112. * @returns a boolean specifying if an alpha test is needed.
  29113. */
  29114. needAlphaTesting(): boolean;
  29115. private _checkUniform;
  29116. /**
  29117. * Set a texture in the shader.
  29118. * @param name Define the name of the uniform samplers as defined in the shader
  29119. * @param texture Define the texture to bind to this sampler
  29120. * @return the material itself allowing "fluent" like uniform updates
  29121. */
  29122. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  29123. /**
  29124. * Set a texture array in the shader.
  29125. * @param name Define the name of the uniform sampler array as defined in the shader
  29126. * @param textures Define the list of textures to bind to this sampler
  29127. * @return the material itself allowing "fluent" like uniform updates
  29128. */
  29129. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  29130. /**
  29131. * Set a float in the shader.
  29132. * @param name Define the name of the uniform as defined in the shader
  29133. * @param value Define the value to give to the uniform
  29134. * @return the material itself allowing "fluent" like uniform updates
  29135. */
  29136. setFloat(name: string, value: number): ShaderMaterial;
  29137. /**
  29138. * Set a int in the shader.
  29139. * @param name Define the name of the uniform as defined in the shader
  29140. * @param value Define the value to give to the uniform
  29141. * @return the material itself allowing "fluent" like uniform updates
  29142. */
  29143. setInt(name: string, value: number): ShaderMaterial;
  29144. /**
  29145. * Set an array of floats in the shader.
  29146. * @param name Define the name of the uniform as defined in the shader
  29147. * @param value Define the value to give to the uniform
  29148. * @return the material itself allowing "fluent" like uniform updates
  29149. */
  29150. setFloats(name: string, value: number[]): ShaderMaterial;
  29151. /**
  29152. * Set a vec3 in the shader from a Color3.
  29153. * @param name Define the name of the uniform as defined in the shader
  29154. * @param value Define the value to give to the uniform
  29155. * @return the material itself allowing "fluent" like uniform updates
  29156. */
  29157. setColor3(name: string, value: Color3): ShaderMaterial;
  29158. /**
  29159. * Set a vec3 array in the shader from a Color3 array.
  29160. * @param name Define the name of the uniform as defined in the shader
  29161. * @param value Define the value to give to the uniform
  29162. * @return the material itself allowing "fluent" like uniform updates
  29163. */
  29164. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  29165. /**
  29166. * Set a vec4 in the shader from a Color4.
  29167. * @param name Define the name of the uniform as defined in the shader
  29168. * @param value Define the value to give to the uniform
  29169. * @return the material itself allowing "fluent" like uniform updates
  29170. */
  29171. setColor4(name: string, value: Color4): ShaderMaterial;
  29172. /**
  29173. * Set a vec4 array in the shader from a Color4 array.
  29174. * @param name Define the name of the uniform as defined in the shader
  29175. * @param value Define the value to give to the uniform
  29176. * @return the material itself allowing "fluent" like uniform updates
  29177. */
  29178. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  29179. /**
  29180. * Set a vec2 in the shader from a Vector2.
  29181. * @param name Define the name of the uniform as defined in the shader
  29182. * @param value Define the value to give to the uniform
  29183. * @return the material itself allowing "fluent" like uniform updates
  29184. */
  29185. setVector2(name: string, value: Vector2): ShaderMaterial;
  29186. /**
  29187. * Set a vec3 in the shader from a Vector3.
  29188. * @param name Define the name of the uniform as defined in the shader
  29189. * @param value Define the value to give to the uniform
  29190. * @return the material itself allowing "fluent" like uniform updates
  29191. */
  29192. setVector3(name: string, value: Vector3): ShaderMaterial;
  29193. /**
  29194. * Set a vec4 in the shader from a Vector4.
  29195. * @param name Define the name of the uniform as defined in the shader
  29196. * @param value Define the value to give to the uniform
  29197. * @return the material itself allowing "fluent" like uniform updates
  29198. */
  29199. setVector4(name: string, value: Vector4): ShaderMaterial;
  29200. /**
  29201. * Set a mat4 in the shader from a Matrix.
  29202. * @param name Define the name of the uniform as defined in the shader
  29203. * @param value Define the value to give to the uniform
  29204. * @return the material itself allowing "fluent" like uniform updates
  29205. */
  29206. setMatrix(name: string, value: Matrix): ShaderMaterial;
  29207. /**
  29208. * Set a float32Array in the shader from a matrix array.
  29209. * @param name Define the name of the uniform as defined in the shader
  29210. * @param value Define the value to give to the uniform
  29211. * @return the material itself allowing "fluent" like uniform updates
  29212. */
  29213. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  29214. /**
  29215. * Set a mat3 in the shader from a Float32Array.
  29216. * @param name Define the name of the uniform as defined in the shader
  29217. * @param value Define the value to give to the uniform
  29218. * @return the material itself allowing "fluent" like uniform updates
  29219. */
  29220. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  29221. /**
  29222. * Set a mat2 in the shader from a Float32Array.
  29223. * @param name Define the name of the uniform as defined in the shader
  29224. * @param value Define the value to give to the uniform
  29225. * @return the material itself allowing "fluent" like uniform updates
  29226. */
  29227. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  29228. /**
  29229. * Set a vec2 array in the shader from a number array.
  29230. * @param name Define the name of the uniform as defined in the shader
  29231. * @param value Define the value to give to the uniform
  29232. * @return the material itself allowing "fluent" like uniform updates
  29233. */
  29234. setArray2(name: string, value: number[]): ShaderMaterial;
  29235. /**
  29236. * Set a vec3 array in the shader from a number array.
  29237. * @param name Define the name of the uniform as defined in the shader
  29238. * @param value Define the value to give to the uniform
  29239. * @return the material itself allowing "fluent" like uniform updates
  29240. */
  29241. setArray3(name: string, value: number[]): ShaderMaterial;
  29242. /**
  29243. * Set a vec4 array in the shader from a number array.
  29244. * @param name Define the name of the uniform as defined in the shader
  29245. * @param value Define the value to give to the uniform
  29246. * @return the material itself allowing "fluent" like uniform updates
  29247. */
  29248. setArray4(name: string, value: number[]): ShaderMaterial;
  29249. private _checkCache;
  29250. /**
  29251. * Specifies that the submesh is ready to be used
  29252. * @param mesh defines the mesh to check
  29253. * @param subMesh defines which submesh to check
  29254. * @param useInstances specifies that instances should be used
  29255. * @returns a boolean indicating that the submesh is ready or not
  29256. */
  29257. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29258. /**
  29259. * Checks if the material is ready to render the requested mesh
  29260. * @param mesh Define the mesh to render
  29261. * @param useInstances Define whether or not the material is used with instances
  29262. * @returns true if ready, otherwise false
  29263. */
  29264. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29265. /**
  29266. * Binds the world matrix to the material
  29267. * @param world defines the world transformation matrix
  29268. * @param effectOverride - If provided, use this effect instead of internal effect
  29269. */
  29270. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  29271. /**
  29272. * Binds the submesh to this material by preparing the effect and shader to draw
  29273. * @param world defines the world transformation matrix
  29274. * @param mesh defines the mesh containing the submesh
  29275. * @param subMesh defines the submesh to bind the material to
  29276. */
  29277. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29278. /**
  29279. * Binds the material to the mesh
  29280. * @param world defines the world transformation matrix
  29281. * @param mesh defines the mesh to bind the material to
  29282. * @param effectOverride - If provided, use this effect instead of internal effect
  29283. */
  29284. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  29285. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  29286. /**
  29287. * Gets the active textures from the material
  29288. * @returns an array of textures
  29289. */
  29290. getActiveTextures(): BaseTexture[];
  29291. /**
  29292. * Specifies if the material uses a texture
  29293. * @param texture defines the texture to check against the material
  29294. * @returns a boolean specifying if the material uses the texture
  29295. */
  29296. hasTexture(texture: BaseTexture): boolean;
  29297. /**
  29298. * Makes a duplicate of the material, and gives it a new name
  29299. * @param name defines the new name for the duplicated material
  29300. * @returns the cloned material
  29301. */
  29302. clone(name: string): ShaderMaterial;
  29303. /**
  29304. * Disposes the material
  29305. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29306. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29307. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29308. */
  29309. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29310. /**
  29311. * Serializes this material in a JSON representation
  29312. * @returns the serialized material object
  29313. */
  29314. serialize(): any;
  29315. /**
  29316. * Creates a shader material from parsed shader material data
  29317. * @param source defines the JSON representation of the material
  29318. * @param scene defines the hosting scene
  29319. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29320. * @returns a new material
  29321. */
  29322. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  29323. /**
  29324. * Creates a new ShaderMaterial from a snippet saved in a remote file
  29325. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  29326. * @param url defines the url to load from
  29327. * @param scene defines the hosting scene
  29328. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29329. * @returns a promise that will resolve to the new ShaderMaterial
  29330. */
  29331. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  29332. /**
  29333. * Creates a ShaderMaterial from a snippet saved by the Inspector
  29334. * @param snippetId defines the snippet to load
  29335. * @param scene defines the hosting scene
  29336. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29337. * @returns a promise that will resolve to the new ShaderMaterial
  29338. */
  29339. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  29340. }
  29341. }
  29342. declare module BABYLON {
  29343. /** @hidden */
  29344. export var colorPixelShader: {
  29345. name: string;
  29346. shader: string;
  29347. };
  29348. }
  29349. declare module BABYLON {
  29350. /** @hidden */
  29351. export var colorVertexShader: {
  29352. name: string;
  29353. shader: string;
  29354. };
  29355. }
  29356. declare module BABYLON {
  29357. /**
  29358. * Line mesh
  29359. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  29360. */
  29361. export class LinesMesh extends Mesh {
  29362. /**
  29363. * If vertex color should be applied to the mesh
  29364. */
  29365. readonly useVertexColor?: boolean | undefined;
  29366. /**
  29367. * If vertex alpha should be applied to the mesh
  29368. */
  29369. readonly useVertexAlpha?: boolean | undefined;
  29370. /**
  29371. * Color of the line (Default: White)
  29372. */
  29373. color: Color3;
  29374. /**
  29375. * Alpha of the line (Default: 1)
  29376. */
  29377. alpha: number;
  29378. /**
  29379. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  29380. * This margin is expressed in world space coordinates, so its value may vary.
  29381. * Default value is 0.1
  29382. */
  29383. intersectionThreshold: number;
  29384. private _colorShader;
  29385. private color4;
  29386. /**
  29387. * Creates a new LinesMesh
  29388. * @param name defines the name
  29389. * @param scene defines the hosting scene
  29390. * @param parent defines the parent mesh if any
  29391. * @param source defines the optional source LinesMesh used to clone data from
  29392. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29393. * When false, achieved by calling a clone(), also passing False.
  29394. * This will make creation of children, recursive.
  29395. * @param useVertexColor defines if this LinesMesh supports vertex color
  29396. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  29397. */
  29398. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  29399. /**
  29400. * If vertex color should be applied to the mesh
  29401. */
  29402. useVertexColor?: boolean | undefined,
  29403. /**
  29404. * If vertex alpha should be applied to the mesh
  29405. */
  29406. useVertexAlpha?: boolean | undefined);
  29407. private _addClipPlaneDefine;
  29408. private _removeClipPlaneDefine;
  29409. isReady(): boolean;
  29410. /**
  29411. * Returns the string "LineMesh"
  29412. */
  29413. getClassName(): string;
  29414. /**
  29415. * @hidden
  29416. */
  29417. get material(): Material;
  29418. /**
  29419. * @hidden
  29420. */
  29421. set material(value: Material);
  29422. /**
  29423. * @hidden
  29424. */
  29425. get checkCollisions(): boolean;
  29426. set checkCollisions(value: boolean);
  29427. /** @hidden */
  29428. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29429. /** @hidden */
  29430. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29431. /**
  29432. * Disposes of the line mesh
  29433. * @param doNotRecurse If children should be disposed
  29434. */
  29435. dispose(doNotRecurse?: boolean): void;
  29436. /**
  29437. * Returns a new LineMesh object cloned from the current one.
  29438. */
  29439. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  29440. /**
  29441. * Creates a new InstancedLinesMesh object from the mesh model.
  29442. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29443. * @param name defines the name of the new instance
  29444. * @returns a new InstancedLinesMesh
  29445. */
  29446. createInstance(name: string): InstancedLinesMesh;
  29447. }
  29448. /**
  29449. * Creates an instance based on a source LinesMesh
  29450. */
  29451. export class InstancedLinesMesh extends InstancedMesh {
  29452. /**
  29453. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  29454. * This margin is expressed in world space coordinates, so its value may vary.
  29455. * Initialized with the intersectionThreshold value of the source LinesMesh
  29456. */
  29457. intersectionThreshold: number;
  29458. constructor(name: string, source: LinesMesh);
  29459. /**
  29460. * Returns the string "InstancedLinesMesh".
  29461. */
  29462. getClassName(): string;
  29463. }
  29464. }
  29465. declare module BABYLON {
  29466. /** @hidden */
  29467. export var linePixelShader: {
  29468. name: string;
  29469. shader: string;
  29470. };
  29471. }
  29472. declare module BABYLON {
  29473. /** @hidden */
  29474. export var lineVertexShader: {
  29475. name: string;
  29476. shader: string;
  29477. };
  29478. }
  29479. declare module BABYLON {
  29480. interface Scene {
  29481. /** @hidden */
  29482. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  29483. }
  29484. interface AbstractMesh {
  29485. /**
  29486. * Gets the edgesRenderer associated with the mesh
  29487. */
  29488. edgesRenderer: Nullable<EdgesRenderer>;
  29489. }
  29490. interface LinesMesh {
  29491. /**
  29492. * Enables the edge rendering mode on the mesh.
  29493. * This mode makes the mesh edges visible
  29494. * @param epsilon defines the maximal distance between two angles to detect a face
  29495. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29496. * @returns the currentAbstractMesh
  29497. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29498. */
  29499. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29500. }
  29501. interface InstancedLinesMesh {
  29502. /**
  29503. * Enables the edge rendering mode on the mesh.
  29504. * This mode makes the mesh edges visible
  29505. * @param epsilon defines the maximal distance between two angles to detect a face
  29506. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29507. * @returns the current InstancedLinesMesh
  29508. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29509. */
  29510. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  29511. }
  29512. /**
  29513. * Defines the minimum contract an Edges renderer should follow.
  29514. */
  29515. export interface IEdgesRenderer extends IDisposable {
  29516. /**
  29517. * Gets or sets a boolean indicating if the edgesRenderer is active
  29518. */
  29519. isEnabled: boolean;
  29520. /**
  29521. * Renders the edges of the attached mesh,
  29522. */
  29523. render(): void;
  29524. /**
  29525. * Checks whether or not the edges renderer is ready to render.
  29526. * @return true if ready, otherwise false.
  29527. */
  29528. isReady(): boolean;
  29529. /**
  29530. * List of instances to render in case the source mesh has instances
  29531. */
  29532. customInstances: SmartArray<Matrix>;
  29533. }
  29534. /**
  29535. * Defines the additional options of the edges renderer
  29536. */
  29537. export interface IEdgesRendererOptions {
  29538. /**
  29539. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  29540. * If not defined, the default value is true
  29541. */
  29542. useAlternateEdgeFinder?: boolean;
  29543. /**
  29544. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  29545. * If not defined, the default value is true.
  29546. * 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)
  29547. * This option is used only if useAlternateEdgeFinder = true
  29548. */
  29549. useFastVertexMerger?: boolean;
  29550. /**
  29551. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit within which vertices are considered to be equal.
  29552. * The default value is 1e-6
  29553. * This option is used only if useAlternateEdgeFinder = true
  29554. */
  29555. epsilonVertexMerge?: number;
  29556. /**
  29557. * 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
  29558. * 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.
  29559. * This option is used only if useAlternateEdgeFinder = true
  29560. */
  29561. applyTessellation?: boolean;
  29562. /**
  29563. * 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
  29564. * The default value is 1e-6
  29565. * This option is used only if useAlternateEdgeFinder = true
  29566. */
  29567. epsilonVertexAligned?: number;
  29568. }
  29569. /**
  29570. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  29571. */
  29572. export class EdgesRenderer implements IEdgesRenderer {
  29573. /**
  29574. * Define the size of the edges with an orthographic camera
  29575. */
  29576. edgesWidthScalerForOrthographic: number;
  29577. /**
  29578. * Define the size of the edges with a perspective camera
  29579. */
  29580. edgesWidthScalerForPerspective: number;
  29581. protected _source: AbstractMesh;
  29582. protected _linesPositions: number[];
  29583. protected _linesNormals: number[];
  29584. protected _linesIndices: number[];
  29585. protected _epsilon: number;
  29586. protected _indicesCount: number;
  29587. protected _lineShader: ShaderMaterial;
  29588. protected _ib: DataBuffer;
  29589. protected _buffers: {
  29590. [key: string]: Nullable<VertexBuffer>;
  29591. };
  29592. protected _buffersForInstances: {
  29593. [key: string]: Nullable<VertexBuffer>;
  29594. };
  29595. protected _checkVerticesInsteadOfIndices: boolean;
  29596. protected _options: Nullable<IEdgesRendererOptions>;
  29597. private _meshRebuildObserver;
  29598. private _meshDisposeObserver;
  29599. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  29600. isEnabled: boolean;
  29601. /** Gets the vertices generated by the edge renderer */
  29602. get linesPositions(): Immutable<Array<number>>;
  29603. /** Gets the normals generated by the edge renderer */
  29604. get linesNormals(): Immutable<Array<number>>;
  29605. /** Gets the indices generated by the edge renderer */
  29606. get linesIndices(): Immutable<Array<number>>;
  29607. /**
  29608. * List of instances to render in case the source mesh has instances
  29609. */
  29610. customInstances: SmartArray<Matrix>;
  29611. private static GetShader;
  29612. /**
  29613. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  29614. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  29615. * @param source Mesh used to create edges
  29616. * @param epsilon sum of angles in adjacency to check for edge
  29617. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  29618. * @param generateEdgesLines - should generate Lines or only prepare resources.
  29619. * @param options The options to apply when generating the edges
  29620. */
  29621. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  29622. protected _prepareRessources(): void;
  29623. /** @hidden */
  29624. _rebuild(): void;
  29625. /**
  29626. * Releases the required resources for the edges renderer
  29627. */
  29628. dispose(): void;
  29629. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  29630. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  29631. /**
  29632. * Checks if the pair of p0 and p1 is en edge
  29633. * @param faceIndex
  29634. * @param edge
  29635. * @param faceNormals
  29636. * @param p0
  29637. * @param p1
  29638. * @private
  29639. */
  29640. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  29641. /**
  29642. * push line into the position, normal and index buffer
  29643. * @protected
  29644. */
  29645. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  29646. /**
  29647. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  29648. */
  29649. private _tessellateTriangle;
  29650. private _generateEdgesLinesAlternate;
  29651. /**
  29652. * Generates lines edges from adjacencjes
  29653. * @private
  29654. */
  29655. _generateEdgesLines(): void;
  29656. /**
  29657. * Checks whether or not the edges renderer is ready to render.
  29658. * @return true if ready, otherwise false.
  29659. */
  29660. isReady(): boolean;
  29661. /**
  29662. * Renders the edges of the attached mesh,
  29663. */
  29664. render(): void;
  29665. }
  29666. /**
  29667. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  29668. */
  29669. export class LineEdgesRenderer extends EdgesRenderer {
  29670. /**
  29671. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  29672. * @param source LineMesh used to generate edges
  29673. * @param epsilon not important (specified angle for edge detection)
  29674. * @param checkVerticesInsteadOfIndices not important for LineMesh
  29675. */
  29676. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  29677. /**
  29678. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  29679. */
  29680. _generateEdgesLines(): void;
  29681. }
  29682. }
  29683. declare module BABYLON {
  29684. /**
  29685. * This represents the object necessary to create a rendering group.
  29686. * This is exclusively used and created by the rendering manager.
  29687. * To modify the behavior, you use the available helpers in your scene or meshes.
  29688. * @hidden
  29689. */
  29690. export class RenderingGroup {
  29691. index: number;
  29692. private static _zeroVector;
  29693. private _scene;
  29694. private _opaqueSubMeshes;
  29695. private _transparentSubMeshes;
  29696. private _alphaTestSubMeshes;
  29697. private _depthOnlySubMeshes;
  29698. private _particleSystems;
  29699. private _spriteManagers;
  29700. private _opaqueSortCompareFn;
  29701. private _alphaTestSortCompareFn;
  29702. private _transparentSortCompareFn;
  29703. private _renderOpaque;
  29704. private _renderAlphaTest;
  29705. private _renderTransparent;
  29706. /** @hidden */
  29707. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  29708. onBeforeTransparentRendering: () => void;
  29709. /**
  29710. * Set the opaque sort comparison function.
  29711. * If null the sub meshes will be render in the order they were created
  29712. */
  29713. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29714. /**
  29715. * Set the alpha test sort comparison function.
  29716. * If null the sub meshes will be render in the order they were created
  29717. */
  29718. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29719. /**
  29720. * Set the transparent sort comparison function.
  29721. * If null the sub meshes will be render in the order they were created
  29722. */
  29723. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29724. /**
  29725. * Creates a new rendering group.
  29726. * @param index The rendering group index
  29727. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  29728. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  29729. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  29730. */
  29731. 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>);
  29732. /**
  29733. * Render all the sub meshes contained in the group.
  29734. * @param customRenderFunction Used to override the default render behaviour of the group.
  29735. * @returns true if rendered some submeshes.
  29736. */
  29737. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  29738. /**
  29739. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  29740. * @param subMeshes The submeshes to render
  29741. */
  29742. private renderOpaqueSorted;
  29743. /**
  29744. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  29745. * @param subMeshes The submeshes to render
  29746. */
  29747. private renderAlphaTestSorted;
  29748. /**
  29749. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  29750. * @param subMeshes The submeshes to render
  29751. */
  29752. private renderTransparentSorted;
  29753. /**
  29754. * Renders the submeshes in a specified order.
  29755. * @param subMeshes The submeshes to sort before render
  29756. * @param sortCompareFn The comparison function use to sort
  29757. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  29758. * @param transparent Specifies to activate blending if true
  29759. */
  29760. private static renderSorted;
  29761. /**
  29762. * Renders the submeshes in the order they were dispatched (no sort applied).
  29763. * @param subMeshes The submeshes to render
  29764. */
  29765. private static renderUnsorted;
  29766. /**
  29767. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29768. * are rendered back to front if in the same alpha index.
  29769. *
  29770. * @param a The first submesh
  29771. * @param b The second submesh
  29772. * @returns The result of the comparison
  29773. */
  29774. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  29775. /**
  29776. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29777. * are rendered back to front.
  29778. *
  29779. * @param a The first submesh
  29780. * @param b The second submesh
  29781. * @returns The result of the comparison
  29782. */
  29783. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  29784. /**
  29785. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29786. * are rendered front to back (prevent overdraw).
  29787. *
  29788. * @param a The first submesh
  29789. * @param b The second submesh
  29790. * @returns The result of the comparison
  29791. */
  29792. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  29793. /**
  29794. * Resets the different lists of submeshes to prepare a new frame.
  29795. */
  29796. prepare(): void;
  29797. dispose(): void;
  29798. /**
  29799. * Inserts the submesh in its correct queue depending on its material.
  29800. * @param subMesh The submesh to dispatch
  29801. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29802. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29803. */
  29804. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29805. dispatchSprites(spriteManager: ISpriteManager): void;
  29806. dispatchParticles(particleSystem: IParticleSystem): void;
  29807. private _renderParticles;
  29808. private _renderSprites;
  29809. }
  29810. }
  29811. declare module BABYLON {
  29812. /**
  29813. * Interface describing the different options available in the rendering manager
  29814. * regarding Auto Clear between groups.
  29815. */
  29816. export interface IRenderingManagerAutoClearSetup {
  29817. /**
  29818. * Defines whether or not autoclear is enable.
  29819. */
  29820. autoClear: boolean;
  29821. /**
  29822. * Defines whether or not to autoclear the depth buffer.
  29823. */
  29824. depth: boolean;
  29825. /**
  29826. * Defines whether or not to autoclear the stencil buffer.
  29827. */
  29828. stencil: boolean;
  29829. }
  29830. /**
  29831. * This class is used by the onRenderingGroupObservable
  29832. */
  29833. export class RenderingGroupInfo {
  29834. /**
  29835. * The Scene that being rendered
  29836. */
  29837. scene: Scene;
  29838. /**
  29839. * The camera currently used for the rendering pass
  29840. */
  29841. camera: Nullable<Camera>;
  29842. /**
  29843. * The ID of the renderingGroup being processed
  29844. */
  29845. renderingGroupId: number;
  29846. }
  29847. /**
  29848. * This is the manager responsible of all the rendering for meshes sprites and particles.
  29849. * It is enable to manage the different groups as well as the different necessary sort functions.
  29850. * This should not be used directly aside of the few static configurations
  29851. */
  29852. export class RenderingManager {
  29853. /**
  29854. * The max id used for rendering groups (not included)
  29855. */
  29856. static MAX_RENDERINGGROUPS: number;
  29857. /**
  29858. * The min id used for rendering groups (included)
  29859. */
  29860. static MIN_RENDERINGGROUPS: number;
  29861. /**
  29862. * Used to globally prevent autoclearing scenes.
  29863. */
  29864. static AUTOCLEAR: boolean;
  29865. /**
  29866. * @hidden
  29867. */
  29868. _useSceneAutoClearSetup: boolean;
  29869. private _scene;
  29870. private _renderingGroups;
  29871. private _depthStencilBufferAlreadyCleaned;
  29872. private _autoClearDepthStencil;
  29873. private _customOpaqueSortCompareFn;
  29874. private _customAlphaTestSortCompareFn;
  29875. private _customTransparentSortCompareFn;
  29876. private _renderingGroupInfo;
  29877. /**
  29878. * Instantiates a new rendering group for a particular scene
  29879. * @param scene Defines the scene the groups belongs to
  29880. */
  29881. constructor(scene: Scene);
  29882. private _clearDepthStencilBuffer;
  29883. /**
  29884. * Renders the entire managed groups. This is used by the scene or the different render targets.
  29885. * @hidden
  29886. */
  29887. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  29888. /**
  29889. * Resets the different information of the group to prepare a new frame
  29890. * @hidden
  29891. */
  29892. reset(): void;
  29893. /**
  29894. * Dispose and release the group and its associated resources.
  29895. * @hidden
  29896. */
  29897. dispose(): void;
  29898. /**
  29899. * Clear the info related to rendering groups preventing retention points during dispose.
  29900. */
  29901. freeRenderingGroups(): void;
  29902. private _prepareRenderingGroup;
  29903. /**
  29904. * Add a sprite manager to the rendering manager in order to render it this frame.
  29905. * @param spriteManager Define the sprite manager to render
  29906. */
  29907. dispatchSprites(spriteManager: ISpriteManager): void;
  29908. /**
  29909. * Add a particle system to the rendering manager in order to render it this frame.
  29910. * @param particleSystem Define the particle system to render
  29911. */
  29912. dispatchParticles(particleSystem: IParticleSystem): void;
  29913. /**
  29914. * Add a submesh to the manager in order to render it this frame
  29915. * @param subMesh The submesh to dispatch
  29916. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29917. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29918. */
  29919. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29920. /**
  29921. * Overrides the default sort function applied in the rendering group to prepare the meshes.
  29922. * This allowed control for front to back rendering or reversely depending of the special needs.
  29923. *
  29924. * @param renderingGroupId The rendering group id corresponding to its index
  29925. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29926. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29927. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29928. */
  29929. 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;
  29930. /**
  29931. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29932. *
  29933. * @param renderingGroupId The rendering group id corresponding to its index
  29934. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29935. * @param depth Automatically clears depth between groups if true and autoClear is true.
  29936. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  29937. */
  29938. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  29939. /**
  29940. * Gets the current auto clear configuration for one rendering group of the rendering
  29941. * manager.
  29942. * @param index the rendering group index to get the information for
  29943. * @returns The auto clear setup for the requested rendering group
  29944. */
  29945. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  29946. }
  29947. }
  29948. declare module BABYLON {
  29949. /**
  29950. * Defines the options associated with the creation of a custom shader for a shadow generator.
  29951. */
  29952. export interface ICustomShaderOptions {
  29953. /**
  29954. * Gets or sets the custom shader name to use
  29955. */
  29956. shaderName: string;
  29957. /**
  29958. * The list of attribute names used in the shader
  29959. */
  29960. attributes?: string[];
  29961. /**
  29962. * The list of uniform names used in the shader
  29963. */
  29964. uniforms?: string[];
  29965. /**
  29966. * The list of sampler names used in the shader
  29967. */
  29968. samplers?: string[];
  29969. /**
  29970. * The list of defines used in the shader
  29971. */
  29972. defines?: string[];
  29973. }
  29974. /**
  29975. * Interface to implement to create a shadow generator compatible with BJS.
  29976. */
  29977. export interface IShadowGenerator {
  29978. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29979. id: string;
  29980. /**
  29981. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29982. * @returns The render target texture if present otherwise, null
  29983. */
  29984. getShadowMap(): Nullable<RenderTargetTexture>;
  29985. /**
  29986. * Determine whether the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29987. * @param subMesh The submesh we want to render in the shadow map
  29988. * @param useInstances Defines whether will draw in the map using instances
  29989. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29990. * @returns true if ready otherwise, false
  29991. */
  29992. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29993. /**
  29994. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29995. * @param defines Defines of the material we want to update
  29996. * @param lightIndex Index of the light in the enabled light list of the material
  29997. */
  29998. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  29999. /**
  30000. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  30001. * defined in the generator but impacting the effect).
  30002. * It implies the uniforms available on the materials are the standard BJS ones.
  30003. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  30004. * @param effect The effect we are binding the information for
  30005. */
  30006. bindShadowLight(lightIndex: string, effect: Effect): void;
  30007. /**
  30008. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  30009. * (eq to shadow projection matrix * light transform matrix)
  30010. * @returns The transform matrix used to create the shadow map
  30011. */
  30012. getTransformMatrix(): Matrix;
  30013. /**
  30014. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  30015. * Cube and 2D textures for instance.
  30016. */
  30017. recreateShadowMap(): void;
  30018. /**
  30019. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  30020. * @param onCompiled Callback triggered at the and of the effects compilation
  30021. * @param options Sets of optional options forcing the compilation with different modes
  30022. */
  30023. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  30024. useInstances: boolean;
  30025. }>): void;
  30026. /**
  30027. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  30028. * @param options Sets of optional options forcing the compilation with different modes
  30029. * @returns A promise that resolves when the compilation completes
  30030. */
  30031. forceCompilationAsync(options?: Partial<{
  30032. useInstances: boolean;
  30033. }>): Promise<void>;
  30034. /**
  30035. * Serializes the shadow generator setup to a json object.
  30036. * @returns The serialized JSON object
  30037. */
  30038. serialize(): any;
  30039. /**
  30040. * Disposes the Shadow map and related Textures and effects.
  30041. */
  30042. dispose(): void;
  30043. }
  30044. /**
  30045. * Default implementation IShadowGenerator.
  30046. * This is the main object responsible of generating shadows in the framework.
  30047. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  30048. */
  30049. export class ShadowGenerator implements IShadowGenerator {
  30050. private static _Counter;
  30051. /**
  30052. * Name of the shadow generator class
  30053. */
  30054. static CLASSNAME: string;
  30055. /**
  30056. * Shadow generator mode None: no filtering applied.
  30057. */
  30058. static readonly FILTER_NONE: number;
  30059. /**
  30060. * Shadow generator mode ESM: Exponential Shadow Mapping.
  30061. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30062. */
  30063. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  30064. /**
  30065. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  30066. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  30067. */
  30068. static readonly FILTER_POISSONSAMPLING: number;
  30069. /**
  30070. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  30071. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30072. */
  30073. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  30074. /**
  30075. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  30076. * edge artifacts on steep falloff.
  30077. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30078. */
  30079. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  30080. /**
  30081. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  30082. * edge artifacts on steep falloff.
  30083. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30084. */
  30085. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  30086. /**
  30087. * Shadow generator mode PCF: Percentage Closer Filtering
  30088. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  30089. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  30090. */
  30091. static readonly FILTER_PCF: number;
  30092. /**
  30093. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  30094. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  30095. * Contact Hardening
  30096. */
  30097. static readonly FILTER_PCSS: number;
  30098. /**
  30099. * Reserved for PCF and PCSS
  30100. * Highest Quality.
  30101. *
  30102. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  30103. *
  30104. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  30105. */
  30106. static readonly QUALITY_HIGH: number;
  30107. /**
  30108. * Reserved for PCF and PCSS
  30109. * Good tradeoff for quality/perf cross devices
  30110. *
  30111. * Execute PCF on a 3*3 kernel.
  30112. *
  30113. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  30114. */
  30115. static readonly QUALITY_MEDIUM: number;
  30116. /**
  30117. * Reserved for PCF and PCSS
  30118. * The lowest quality but the fastest.
  30119. *
  30120. * Execute PCF on a 1*1 kernel.
  30121. *
  30122. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  30123. */
  30124. static readonly QUALITY_LOW: number;
  30125. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  30126. id: string;
  30127. /** Gets or sets the custom shader name to use */
  30128. customShaderOptions: ICustomShaderOptions;
  30129. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  30130. customAllowRendering: (subMesh: SubMesh) => boolean;
  30131. /**
  30132. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  30133. */
  30134. onBeforeShadowMapRenderObservable: Observable<Effect>;
  30135. /**
  30136. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  30137. */
  30138. onAfterShadowMapRenderObservable: Observable<Effect>;
  30139. /**
  30140. * Observable triggered before a mesh is rendered in the shadow map.
  30141. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  30142. */
  30143. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  30144. /**
  30145. * Observable triggered after a mesh is rendered in the shadow map.
  30146. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  30147. */
  30148. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  30149. protected _bias: number;
  30150. /**
  30151. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  30152. */
  30153. get bias(): number;
  30154. /**
  30155. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  30156. */
  30157. set bias(bias: number);
  30158. protected _normalBias: number;
  30159. /**
  30160. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportional to the light/normal angle).
  30161. */
  30162. get normalBias(): number;
  30163. /**
  30164. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportional to the light/normal angle).
  30165. */
  30166. set normalBias(normalBias: number);
  30167. protected _blurBoxOffset: number;
  30168. /**
  30169. * Gets the blur box offset: offset applied during the blur pass.
  30170. * Only useful if useKernelBlur = false
  30171. */
  30172. get blurBoxOffset(): number;
  30173. /**
  30174. * Sets the blur box offset: offset applied during the blur pass.
  30175. * Only useful if useKernelBlur = false
  30176. */
  30177. set blurBoxOffset(value: number);
  30178. protected _blurScale: number;
  30179. /**
  30180. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  30181. * 2 means half of the size.
  30182. */
  30183. get blurScale(): number;
  30184. /**
  30185. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  30186. * 2 means half of the size.
  30187. */
  30188. set blurScale(value: number);
  30189. protected _blurKernel: number;
  30190. /**
  30191. * Gets the blur kernel: kernel size of the blur pass.
  30192. * Only useful if useKernelBlur = true
  30193. */
  30194. get blurKernel(): number;
  30195. /**
  30196. * Sets the blur kernel: kernel size of the blur pass.
  30197. * Only useful if useKernelBlur = true
  30198. */
  30199. set blurKernel(value: number);
  30200. protected _useKernelBlur: boolean;
  30201. /**
  30202. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  30203. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  30204. */
  30205. get useKernelBlur(): boolean;
  30206. /**
  30207. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  30208. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  30209. */
  30210. set useKernelBlur(value: boolean);
  30211. protected _depthScale: number;
  30212. /**
  30213. * Gets the depth scale used in ESM mode.
  30214. */
  30215. get depthScale(): number;
  30216. /**
  30217. * Sets the depth scale used in ESM mode.
  30218. * This can override the scale stored on the light.
  30219. */
  30220. set depthScale(value: number);
  30221. protected _validateFilter(filter: number): number;
  30222. protected _filter: number;
  30223. /**
  30224. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  30225. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  30226. */
  30227. get filter(): number;
  30228. /**
  30229. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  30230. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  30231. */
  30232. set filter(value: number);
  30233. /**
  30234. * Gets if the current filter is set to Poisson Sampling.
  30235. */
  30236. get usePoissonSampling(): boolean;
  30237. /**
  30238. * Sets the current filter to Poisson Sampling.
  30239. */
  30240. set usePoissonSampling(value: boolean);
  30241. /**
  30242. * Gets if the current filter is set to ESM.
  30243. */
  30244. get useExponentialShadowMap(): boolean;
  30245. /**
  30246. * Sets the current filter is to ESM.
  30247. */
  30248. set useExponentialShadowMap(value: boolean);
  30249. /**
  30250. * Gets if the current filter is set to filtered ESM.
  30251. */
  30252. get useBlurExponentialShadowMap(): boolean;
  30253. /**
  30254. * Gets if the current filter is set to filtered ESM.
  30255. */
  30256. set useBlurExponentialShadowMap(value: boolean);
  30257. /**
  30258. * Gets if the current filter is set to "close ESM" (using the inverse of the
  30259. * exponential to prevent steep falloff artifacts).
  30260. */
  30261. get useCloseExponentialShadowMap(): boolean;
  30262. /**
  30263. * Sets the current filter to "close ESM" (using the inverse of the
  30264. * exponential to prevent steep falloff artifacts).
  30265. */
  30266. set useCloseExponentialShadowMap(value: boolean);
  30267. /**
  30268. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  30269. * exponential to prevent steep falloff artifacts).
  30270. */
  30271. get useBlurCloseExponentialShadowMap(): boolean;
  30272. /**
  30273. * Sets the current filter to filtered "close ESM" (using the inverse of the
  30274. * exponential to prevent steep falloff artifacts).
  30275. */
  30276. set useBlurCloseExponentialShadowMap(value: boolean);
  30277. /**
  30278. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  30279. */
  30280. get usePercentageCloserFiltering(): boolean;
  30281. /**
  30282. * Sets the current filter to "PCF" (percentage closer filtering).
  30283. */
  30284. set usePercentageCloserFiltering(value: boolean);
  30285. protected _filteringQuality: number;
  30286. /**
  30287. * Gets the PCF or PCSS Quality.
  30288. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30289. */
  30290. get filteringQuality(): number;
  30291. /**
  30292. * Sets the PCF or PCSS Quality.
  30293. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30294. */
  30295. set filteringQuality(filteringQuality: number);
  30296. /**
  30297. * Gets if the current filter is set to "PCSS" (contact hardening).
  30298. */
  30299. get useContactHardeningShadow(): boolean;
  30300. /**
  30301. * Sets the current filter to "PCSS" (contact hardening).
  30302. */
  30303. set useContactHardeningShadow(value: boolean);
  30304. protected _contactHardeningLightSizeUVRatio: number;
  30305. /**
  30306. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30307. * Using a ratio helps keeping shape stability independently of the map size.
  30308. *
  30309. * It does not account for the light projection as it was having too much
  30310. * instability during the light setup or during light position changes.
  30311. *
  30312. * Only valid if useContactHardeningShadow is true.
  30313. */
  30314. get contactHardeningLightSizeUVRatio(): number;
  30315. /**
  30316. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30317. * Using a ratio helps keeping shape stability independently of the map size.
  30318. *
  30319. * It does not account for the light projection as it was having too much
  30320. * instability during the light setup or during light position changes.
  30321. *
  30322. * Only valid if useContactHardeningShadow is true.
  30323. */
  30324. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  30325. protected _darkness: number;
  30326. /** Gets or sets the actual darkness of a shadow */
  30327. get darkness(): number;
  30328. set darkness(value: number);
  30329. /**
  30330. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  30331. * 0 means strongest and 1 would means no shadow.
  30332. * @returns the darkness.
  30333. */
  30334. getDarkness(): number;
  30335. /**
  30336. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  30337. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  30338. * @returns the shadow generator allowing fluent coding.
  30339. */
  30340. setDarkness(darkness: number): ShadowGenerator;
  30341. protected _transparencyShadow: boolean;
  30342. /** Gets or sets the ability to have transparent shadow */
  30343. get transparencyShadow(): boolean;
  30344. set transparencyShadow(value: boolean);
  30345. /**
  30346. * Sets the ability to have transparent shadow (boolean).
  30347. * @param transparent True if transparent else False
  30348. * @returns the shadow generator allowing fluent coding
  30349. */
  30350. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  30351. /**
  30352. * Enables or disables shadows with varying strength based on the transparency
  30353. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  30354. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  30355. * mesh.visibility * alphaTexture.a
  30356. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  30357. */
  30358. enableSoftTransparentShadow: boolean;
  30359. protected _shadowMap: Nullable<RenderTargetTexture>;
  30360. protected _shadowMap2: Nullable<RenderTargetTexture>;
  30361. /**
  30362. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  30363. * @returns The render target texture if present otherwise, null
  30364. */
  30365. getShadowMap(): Nullable<RenderTargetTexture>;
  30366. /**
  30367. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  30368. * @returns The render target texture if the shadow map is present otherwise, null
  30369. */
  30370. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  30371. /**
  30372. * Gets the class name of that object
  30373. * @returns "ShadowGenerator"
  30374. */
  30375. getClassName(): string;
  30376. /**
  30377. * Helper function to add a mesh and its descendants to the list of shadow casters.
  30378. * @param mesh Mesh to add
  30379. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  30380. * @returns the Shadow Generator itself
  30381. */
  30382. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30383. /**
  30384. * Helper function to remove a mesh and its descendants from the list of shadow casters
  30385. * @param mesh Mesh to remove
  30386. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  30387. * @returns the Shadow Generator itself
  30388. */
  30389. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30390. /**
  30391. * Controls the extent to which the shadows fade out at the edge of the frustum
  30392. */
  30393. frustumEdgeFalloff: number;
  30394. protected _light: IShadowLight;
  30395. /**
  30396. * Returns the associated light object.
  30397. * @returns the light generating the shadow
  30398. */
  30399. getLight(): IShadowLight;
  30400. /**
  30401. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  30402. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  30403. * It might on the other hand introduce peter panning.
  30404. */
  30405. forceBackFacesOnly: boolean;
  30406. protected _scene: Scene;
  30407. protected _lightDirection: Vector3;
  30408. protected _viewMatrix: Matrix;
  30409. protected _projectionMatrix: Matrix;
  30410. protected _transformMatrix: Matrix;
  30411. protected _cachedPosition: Vector3;
  30412. protected _cachedDirection: Vector3;
  30413. protected _cachedDefines: string;
  30414. protected _currentRenderID: number;
  30415. protected _boxBlurPostprocess: Nullable<PostProcess>;
  30416. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  30417. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  30418. protected _blurPostProcesses: PostProcess[];
  30419. protected _mapSize: number;
  30420. protected _currentFaceIndex: number;
  30421. protected _currentFaceIndexCache: number;
  30422. protected _textureType: number;
  30423. protected _defaultTextureMatrix: Matrix;
  30424. protected _storedUniqueId: Nullable<number>;
  30425. protected _nameForCustomEffect: string;
  30426. /** @hidden */
  30427. static _SceneComponentInitialization: (scene: Scene) => void;
  30428. /**
  30429. * Gets or sets the size of the texture what stores the shadows
  30430. */
  30431. get mapSize(): number;
  30432. set mapSize(size: number);
  30433. /**
  30434. * Creates a ShadowGenerator object.
  30435. * A ShadowGenerator is the required tool to use the shadows.
  30436. * Each light casting shadows needs to use its own ShadowGenerator.
  30437. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  30438. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  30439. * @param light The light object generating the shadows.
  30440. * @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.
  30441. */
  30442. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  30443. protected _initializeGenerator(): void;
  30444. protected _createTargetRenderTexture(): void;
  30445. protected _initializeShadowMap(): void;
  30446. protected _initializeBlurRTTAndPostProcesses(): void;
  30447. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  30448. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  30449. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  30450. protected _applyFilterValues(): void;
  30451. /**
  30452. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  30453. * @param onCompiled Callback triggered at the and of the effects compilation
  30454. * @param options Sets of optional options forcing the compilation with different modes
  30455. */
  30456. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  30457. useInstances: boolean;
  30458. }>): void;
  30459. /**
  30460. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  30461. * @param options Sets of optional options forcing the compilation with different modes
  30462. * @returns A promise that resolves when the compilation completes
  30463. */
  30464. forceCompilationAsync(options?: Partial<{
  30465. useInstances: boolean;
  30466. }>): Promise<void>;
  30467. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  30468. private _prepareShadowDefines;
  30469. /**
  30470. * Determine whether the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  30471. * @param subMesh The submesh we want to render in the shadow map
  30472. * @param useInstances Defines whether will draw in the map using instances
  30473. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  30474. * @returns true if ready otherwise, false
  30475. */
  30476. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  30477. /**
  30478. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  30479. * @param defines Defines of the material we want to update
  30480. * @param lightIndex Index of the light in the enabled light list of the material
  30481. */
  30482. prepareDefines(defines: any, lightIndex: number): void;
  30483. /**
  30484. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  30485. * defined in the generator but impacting the effect).
  30486. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  30487. * @param effect The effect we are binding the information for
  30488. */
  30489. bindShadowLight(lightIndex: string, effect: Effect): void;
  30490. /**
  30491. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  30492. * (eq to shadow projection matrix * light transform matrix)
  30493. * @returns The transform matrix used to create the shadow map
  30494. */
  30495. getTransformMatrix(): Matrix;
  30496. /**
  30497. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  30498. * Cube and 2D textures for instance.
  30499. */
  30500. recreateShadowMap(): void;
  30501. protected _disposeBlurPostProcesses(): void;
  30502. protected _disposeRTTandPostProcesses(): void;
  30503. /**
  30504. * Disposes the ShadowGenerator.
  30505. * Returns nothing.
  30506. */
  30507. dispose(): void;
  30508. /**
  30509. * Serializes the shadow generator setup to a json object.
  30510. * @returns The serialized JSON object
  30511. */
  30512. serialize(): any;
  30513. /**
  30514. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  30515. * @param parsedShadowGenerator The JSON object to parse
  30516. * @param scene The scene to create the shadow map for
  30517. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  30518. * @returns The parsed shadow generator
  30519. */
  30520. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  30521. }
  30522. }
  30523. declare module BABYLON {
  30524. /**
  30525. * Options to be used when creating a shadow depth material
  30526. */
  30527. export interface IIOptionShadowDepthMaterial {
  30528. /** Variables in the vertex shader code that need to have their names remapped.
  30529. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  30530. * "var_name" should be either: worldPos or vNormalW
  30531. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  30532. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  30533. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  30534. */
  30535. remappedVariables?: string[];
  30536. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  30537. standalone?: boolean;
  30538. }
  30539. /**
  30540. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  30541. */
  30542. export class ShadowDepthWrapper {
  30543. private _scene;
  30544. private _options?;
  30545. private _baseMaterial;
  30546. private _onEffectCreatedObserver;
  30547. private _subMeshToEffect;
  30548. private _subMeshToDepthEffect;
  30549. private _meshes;
  30550. /** @hidden */
  30551. _matriceNames: any;
  30552. /** Gets the standalone status of the wrapper */
  30553. get standalone(): boolean;
  30554. /** Gets the base material the wrapper is built upon */
  30555. get baseMaterial(): Material;
  30556. /**
  30557. * Instantiate a new shadow depth wrapper.
  30558. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  30559. * generate the shadow depth map. For more information, please refer to the documentation:
  30560. * https://doc.babylonjs.com/babylon101/shadows
  30561. * @param baseMaterial Material to wrap
  30562. * @param scene Define the scene the material belongs to
  30563. * @param options Options used to create the wrapper
  30564. */
  30565. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  30566. /**
  30567. * Gets the effect to use to generate the depth map
  30568. * @param subMesh subMesh to get the effect for
  30569. * @param shadowGenerator shadow generator to get the effect for
  30570. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  30571. */
  30572. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  30573. /**
  30574. * Specifies that the submesh is ready to be used for depth rendering
  30575. * @param subMesh submesh to check
  30576. * @param defines the list of defines to take into account when checking the effect
  30577. * @param shadowGenerator combined with subMesh, it defines the effect to check
  30578. * @param useInstances specifies that instances should be used
  30579. * @returns a boolean indicating that the submesh is ready or not
  30580. */
  30581. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  30582. /**
  30583. * Disposes the resources
  30584. */
  30585. dispose(): void;
  30586. private _makeEffect;
  30587. }
  30588. }
  30589. declare module BABYLON {
  30590. /**
  30591. * Options for compiling materials.
  30592. */
  30593. export interface IMaterialCompilationOptions {
  30594. /**
  30595. * Defines whether clip planes are enabled.
  30596. */
  30597. clipPlane: boolean;
  30598. /**
  30599. * Defines whether instances are enabled.
  30600. */
  30601. useInstances: boolean;
  30602. }
  30603. /**
  30604. * Options passed when calling customShaderNameResolve
  30605. */
  30606. export interface ICustomShaderNameResolveOptions {
  30607. /**
  30608. * 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
  30609. */
  30610. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  30611. }
  30612. /**
  30613. * Base class for the main features of a material in Babylon.js
  30614. */
  30615. export class Material implements IAnimatable {
  30616. /**
  30617. * Returns the triangle fill mode
  30618. */
  30619. static readonly TriangleFillMode: number;
  30620. /**
  30621. * Returns the wireframe mode
  30622. */
  30623. static readonly WireFrameFillMode: number;
  30624. /**
  30625. * Returns the point fill mode
  30626. */
  30627. static readonly PointFillMode: number;
  30628. /**
  30629. * Returns the point list draw mode
  30630. */
  30631. static readonly PointListDrawMode: number;
  30632. /**
  30633. * Returns the line list draw mode
  30634. */
  30635. static readonly LineListDrawMode: number;
  30636. /**
  30637. * Returns the line loop draw mode
  30638. */
  30639. static readonly LineLoopDrawMode: number;
  30640. /**
  30641. * Returns the line strip draw mode
  30642. */
  30643. static readonly LineStripDrawMode: number;
  30644. /**
  30645. * Returns the triangle strip draw mode
  30646. */
  30647. static readonly TriangleStripDrawMode: number;
  30648. /**
  30649. * Returns the triangle fan draw mode
  30650. */
  30651. static readonly TriangleFanDrawMode: number;
  30652. /**
  30653. * Stores the clock-wise side orientation
  30654. */
  30655. static readonly ClockWiseSideOrientation: number;
  30656. /**
  30657. * Stores the counter clock-wise side orientation
  30658. */
  30659. static readonly CounterClockWiseSideOrientation: number;
  30660. /**
  30661. * The dirty texture flag value
  30662. */
  30663. static readonly TextureDirtyFlag: number;
  30664. /**
  30665. * The dirty light flag value
  30666. */
  30667. static readonly LightDirtyFlag: number;
  30668. /**
  30669. * The dirty fresnel flag value
  30670. */
  30671. static readonly FresnelDirtyFlag: number;
  30672. /**
  30673. * The dirty attribute flag value
  30674. */
  30675. static readonly AttributesDirtyFlag: number;
  30676. /**
  30677. * The dirty misc flag value
  30678. */
  30679. static readonly MiscDirtyFlag: number;
  30680. /**
  30681. * The dirty prepass flag value
  30682. */
  30683. static readonly PrePassDirtyFlag: number;
  30684. /**
  30685. * The all dirty flag value
  30686. */
  30687. static readonly AllDirtyFlag: number;
  30688. /**
  30689. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30690. */
  30691. static readonly MATERIAL_OPAQUE: number;
  30692. /**
  30693. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30694. */
  30695. static readonly MATERIAL_ALPHATEST: number;
  30696. /**
  30697. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30698. */
  30699. static readonly MATERIAL_ALPHABLEND: number;
  30700. /**
  30701. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30702. * They are also discarded below the alpha cutoff threshold to improve performances.
  30703. */
  30704. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  30705. /**
  30706. * The Whiteout method is used to blend normals.
  30707. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30708. */
  30709. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  30710. /**
  30711. * The Reoriented Normal Mapping method is used to blend normals.
  30712. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30713. */
  30714. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  30715. /**
  30716. * Custom callback helping to override the default shader used in the material.
  30717. */
  30718. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  30719. /**
  30720. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  30721. */
  30722. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  30723. /**
  30724. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  30725. * This means that the material can keep using a previous shader while a new one is being compiled.
  30726. * This is mostly used when shader parallel compilation is supported (true by default)
  30727. */
  30728. allowShaderHotSwapping: boolean;
  30729. /**
  30730. * The ID of the material
  30731. */
  30732. id: string;
  30733. /**
  30734. * Gets or sets the unique id of the material
  30735. */
  30736. uniqueId: number;
  30737. /**
  30738. * The name of the material
  30739. */
  30740. name: string;
  30741. /**
  30742. * Gets or sets user defined metadata
  30743. */
  30744. metadata: any;
  30745. /**
  30746. * For internal use only. Please do not use.
  30747. */
  30748. reservedDataStore: any;
  30749. /**
  30750. * Specifies if the ready state should be checked on each call
  30751. */
  30752. checkReadyOnEveryCall: boolean;
  30753. /**
  30754. * Specifies if the ready state should be checked once
  30755. */
  30756. checkReadyOnlyOnce: boolean;
  30757. /**
  30758. * The state of the material
  30759. */
  30760. state: string;
  30761. /**
  30762. * If the material can be rendered to several textures with MRT extension
  30763. */
  30764. get canRenderToMRT(): boolean;
  30765. /**
  30766. * The alpha value of the material
  30767. */
  30768. protected _alpha: number;
  30769. /**
  30770. * List of inspectable custom properties (used by the Inspector)
  30771. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30772. */
  30773. inspectableCustomProperties: IInspectable[];
  30774. /**
  30775. * Sets the alpha value of the material
  30776. */
  30777. set alpha(value: number);
  30778. /**
  30779. * Gets the alpha value of the material
  30780. */
  30781. get alpha(): number;
  30782. /**
  30783. * Specifies if back face culling is enabled
  30784. */
  30785. protected _backFaceCulling: boolean;
  30786. /**
  30787. * Sets the back-face culling state
  30788. */
  30789. set backFaceCulling(value: boolean);
  30790. /**
  30791. * Gets the back-face culling state
  30792. */
  30793. get backFaceCulling(): boolean;
  30794. /**
  30795. * Stores the value for side orientation
  30796. */
  30797. sideOrientation: number;
  30798. /**
  30799. * Callback triggered when the material is compiled
  30800. */
  30801. onCompiled: Nullable<(effect: Effect) => void>;
  30802. /**
  30803. * Callback triggered when an error occurs
  30804. */
  30805. onError: Nullable<(effect: Effect, errors: string) => void>;
  30806. /**
  30807. * Callback triggered to get the render target textures
  30808. */
  30809. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  30810. /**
  30811. * Gets a boolean indicating that current material needs to register RTT
  30812. */
  30813. get hasRenderTargetTextures(): boolean;
  30814. /**
  30815. * Specifies if the material should be serialized
  30816. */
  30817. doNotSerialize: boolean;
  30818. /**
  30819. * @hidden
  30820. */
  30821. _storeEffectOnSubMeshes: boolean;
  30822. /**
  30823. * Stores the animations for the material
  30824. */
  30825. animations: Nullable<Array<Animation>>;
  30826. /**
  30827. * An event triggered when the material is disposed
  30828. */
  30829. onDisposeObservable: Observable<Material>;
  30830. /**
  30831. * An observer which watches for dispose events
  30832. */
  30833. private _onDisposeObserver;
  30834. private _onUnBindObservable;
  30835. /**
  30836. * Called during a dispose event
  30837. */
  30838. set onDispose(callback: () => void);
  30839. private _onBindObservable;
  30840. /**
  30841. * An event triggered when the material is bound
  30842. */
  30843. get onBindObservable(): Observable<AbstractMesh>;
  30844. /**
  30845. * An observer which watches for bind events
  30846. */
  30847. private _onBindObserver;
  30848. /**
  30849. * Called during a bind event
  30850. */
  30851. set onBind(callback: (Mesh: AbstractMesh) => void);
  30852. /**
  30853. * An event triggered when the material is unbound
  30854. */
  30855. get onUnBindObservable(): Observable<Material>;
  30856. protected _onEffectCreatedObservable: Nullable<Observable<{
  30857. effect: Effect;
  30858. subMesh: Nullable<SubMesh>;
  30859. }>>;
  30860. /**
  30861. * An event triggered when the effect is (re)created
  30862. */
  30863. get onEffectCreatedObservable(): Observable<{
  30864. effect: Effect;
  30865. subMesh: Nullable<SubMesh>;
  30866. }>;
  30867. /**
  30868. * Stores the value of the alpha mode
  30869. */
  30870. private _alphaMode;
  30871. /**
  30872. * Sets the value of the alpha mode.
  30873. *
  30874. * | Value | Type | Description |
  30875. * | --- | --- | --- |
  30876. * | 0 | ALPHA_DISABLE | |
  30877. * | 1 | ALPHA_ADD | |
  30878. * | 2 | ALPHA_COMBINE | |
  30879. * | 3 | ALPHA_SUBTRACT | |
  30880. * | 4 | ALPHA_MULTIPLY | |
  30881. * | 5 | ALPHA_MAXIMIZED | |
  30882. * | 6 | ALPHA_ONEONE | |
  30883. * | 7 | ALPHA_PREMULTIPLIED | |
  30884. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  30885. * | 9 | ALPHA_INTERPOLATE | |
  30886. * | 10 | ALPHA_SCREENMODE | |
  30887. *
  30888. */
  30889. set alphaMode(value: number);
  30890. /**
  30891. * Gets the value of the alpha mode
  30892. */
  30893. get alphaMode(): number;
  30894. /**
  30895. * Stores the state of the need depth pre-pass value
  30896. */
  30897. private _needDepthPrePass;
  30898. /**
  30899. * Sets the need depth pre-pass value
  30900. */
  30901. set needDepthPrePass(value: boolean);
  30902. /**
  30903. * Gets the depth pre-pass value
  30904. */
  30905. get needDepthPrePass(): boolean;
  30906. /**
  30907. * Can this material render to prepass
  30908. */
  30909. get isPrePassCapable(): boolean;
  30910. /**
  30911. * Specifies if depth writing should be disabled
  30912. */
  30913. disableDepthWrite: boolean;
  30914. /**
  30915. * Specifies if color writing should be disabled
  30916. */
  30917. disableColorWrite: boolean;
  30918. /**
  30919. * Specifies if depth writing should be forced
  30920. */
  30921. forceDepthWrite: boolean;
  30922. /**
  30923. * Specifies the depth function that should be used. 0 means the default engine function
  30924. */
  30925. depthFunction: number;
  30926. /**
  30927. * Specifies if there should be a separate pass for culling
  30928. */
  30929. separateCullingPass: boolean;
  30930. /**
  30931. * Stores the state specifying if fog should be enabled
  30932. */
  30933. private _fogEnabled;
  30934. /**
  30935. * Sets the state for enabling fog
  30936. */
  30937. set fogEnabled(value: boolean);
  30938. /**
  30939. * Gets the value of the fog enabled state
  30940. */
  30941. get fogEnabled(): boolean;
  30942. /**
  30943. * Stores the size of points
  30944. */
  30945. pointSize: number;
  30946. /**
  30947. * Stores the z offset value
  30948. */
  30949. zOffset: number;
  30950. get wireframe(): boolean;
  30951. /**
  30952. * Sets the state of wireframe mode
  30953. */
  30954. set wireframe(value: boolean);
  30955. /**
  30956. * Gets the value specifying if point clouds are enabled
  30957. */
  30958. get pointsCloud(): boolean;
  30959. /**
  30960. * Sets the state of point cloud mode
  30961. */
  30962. set pointsCloud(value: boolean);
  30963. /**
  30964. * Gets the material fill mode
  30965. */
  30966. get fillMode(): number;
  30967. /**
  30968. * Sets the material fill mode
  30969. */
  30970. set fillMode(value: number);
  30971. /**
  30972. * @hidden
  30973. * Stores the effects for the material
  30974. */
  30975. _effect: Nullable<Effect>;
  30976. /**
  30977. * Specifies if uniform buffers should be used
  30978. */
  30979. private _useUBO;
  30980. /**
  30981. * Stores a reference to the scene
  30982. */
  30983. private _scene;
  30984. private _needToBindSceneUbo;
  30985. /**
  30986. * Stores the fill mode state
  30987. */
  30988. private _fillMode;
  30989. /**
  30990. * Specifies if the depth write state should be cached
  30991. */
  30992. private _cachedDepthWriteState;
  30993. /**
  30994. * Specifies if the color write state should be cached
  30995. */
  30996. private _cachedColorWriteState;
  30997. /**
  30998. * Specifies if the depth function state should be cached
  30999. */
  31000. private _cachedDepthFunctionState;
  31001. /**
  31002. * Stores the uniform buffer
  31003. */
  31004. protected _uniformBuffer: UniformBuffer;
  31005. /** @hidden */
  31006. _indexInSceneMaterialArray: number;
  31007. /** @hidden */
  31008. meshMap: Nullable<{
  31009. [id: string]: AbstractMesh | undefined;
  31010. }>;
  31011. /**
  31012. * Creates a material instance
  31013. * @param name defines the name of the material
  31014. * @param scene defines the scene to reference
  31015. * @param doNotAdd specifies if the material should be added to the scene
  31016. */
  31017. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  31018. /**
  31019. * Returns a string representation of the current material
  31020. * @param fullDetails defines a boolean indicating which levels of logging is desired
  31021. * @returns a string with material information
  31022. */
  31023. toString(fullDetails?: boolean): string;
  31024. /**
  31025. * Gets the class name of the material
  31026. * @returns a string with the class name of the material
  31027. */
  31028. getClassName(): string;
  31029. /**
  31030. * Specifies if updates for the material been locked
  31031. */
  31032. get isFrozen(): boolean;
  31033. /**
  31034. * Locks updates for the material
  31035. */
  31036. freeze(): void;
  31037. /**
  31038. * Unlocks updates for the material
  31039. */
  31040. unfreeze(): void;
  31041. /**
  31042. * Specifies if the material is ready to be used
  31043. * @param mesh defines the mesh to check
  31044. * @param useInstances specifies if instances should be used
  31045. * @returns a boolean indicating if the material is ready to be used
  31046. */
  31047. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  31048. /**
  31049. * Specifies that the submesh is ready to be used
  31050. * @param mesh defines the mesh to check
  31051. * @param subMesh defines which submesh to check
  31052. * @param useInstances specifies that instances should be used
  31053. * @returns a boolean indicating that the submesh is ready or not
  31054. */
  31055. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31056. /**
  31057. * Returns the material effect
  31058. * @returns the effect associated with the material
  31059. */
  31060. getEffect(): Nullable<Effect>;
  31061. /**
  31062. * Returns the current scene
  31063. * @returns a Scene
  31064. */
  31065. getScene(): Scene;
  31066. /**
  31067. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  31068. */
  31069. protected _forceAlphaTest: boolean;
  31070. /**
  31071. * The transparency mode of the material.
  31072. */
  31073. protected _transparencyMode: Nullable<number>;
  31074. /**
  31075. * Gets the current transparency mode.
  31076. */
  31077. get transparencyMode(): Nullable<number>;
  31078. /**
  31079. * Sets the transparency mode of the material.
  31080. *
  31081. * | Value | Type | Description |
  31082. * | ----- | ----------------------------------- | ----------- |
  31083. * | 0 | OPAQUE | |
  31084. * | 1 | ALPHATEST | |
  31085. * | 2 | ALPHABLEND | |
  31086. * | 3 | ALPHATESTANDBLEND | |
  31087. *
  31088. */
  31089. set transparencyMode(value: Nullable<number>);
  31090. /**
  31091. * Returns true if alpha blending should be disabled.
  31092. */
  31093. protected get _disableAlphaBlending(): boolean;
  31094. /**
  31095. * Specifies whether or not this material should be rendered in alpha blend mode.
  31096. * @returns a boolean specifying if alpha blending is needed
  31097. */
  31098. needAlphaBlending(): boolean;
  31099. /**
  31100. * Specifies if the mesh will require alpha blending
  31101. * @param mesh defines the mesh to check
  31102. * @returns a boolean specifying if alpha blending is needed for the mesh
  31103. */
  31104. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  31105. /**
  31106. * Specifies whether or not this material should be rendered in alpha test mode.
  31107. * @returns a boolean specifying if an alpha test is needed.
  31108. */
  31109. needAlphaTesting(): boolean;
  31110. /**
  31111. * Specifies if material alpha testing should be turned on for the mesh
  31112. * @param mesh defines the mesh to check
  31113. */
  31114. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  31115. /**
  31116. * Gets the texture used for the alpha test
  31117. * @returns the texture to use for alpha testing
  31118. */
  31119. getAlphaTestTexture(): Nullable<BaseTexture>;
  31120. /**
  31121. * Marks the material to indicate that it needs to be re-calculated
  31122. */
  31123. markDirty(): void;
  31124. /** @hidden */
  31125. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  31126. /**
  31127. * Binds the material to the mesh
  31128. * @param world defines the world transformation matrix
  31129. * @param mesh defines the mesh to bind the material to
  31130. */
  31131. bind(world: Matrix, mesh?: Mesh): void;
  31132. /**
  31133. * Binds the submesh to the material
  31134. * @param world defines the world transformation matrix
  31135. * @param mesh defines the mesh containing the submesh
  31136. * @param subMesh defines the submesh to bind the material to
  31137. */
  31138. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31139. /**
  31140. * Binds the world matrix to the material
  31141. * @param world defines the world transformation matrix
  31142. */
  31143. bindOnlyWorldMatrix(world: Matrix): void;
  31144. /**
  31145. * Binds the view matrix to the effect
  31146. * @param effect defines the effect to bind the view matrix to
  31147. */
  31148. bindView(effect: Effect): void;
  31149. /**
  31150. * Binds the view projection and projection matrices to the effect
  31151. * @param effect defines the effect to bind the view projection and projection matrices to
  31152. */
  31153. bindViewProjection(effect: Effect): void;
  31154. /**
  31155. * Binds the view matrix to the effect
  31156. * @param effect defines the effect to bind the view matrix to
  31157. * @param variableName name of the shader variable that will hold the eye position
  31158. */
  31159. bindEyePosition(effect: Effect, variableName?: string): void;
  31160. /**
  31161. * Processes to execute after binding the material to a mesh
  31162. * @param mesh defines the rendered mesh
  31163. */
  31164. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  31165. /**
  31166. * Unbinds the material from the mesh
  31167. */
  31168. unbind(): void;
  31169. /**
  31170. * Gets the active textures from the material
  31171. * @returns an array of textures
  31172. */
  31173. getActiveTextures(): BaseTexture[];
  31174. /**
  31175. * Specifies if the material uses a texture
  31176. * @param texture defines the texture to check against the material
  31177. * @returns a boolean specifying if the material uses the texture
  31178. */
  31179. hasTexture(texture: BaseTexture): boolean;
  31180. /**
  31181. * Makes a duplicate of the material, and gives it a new name
  31182. * @param name defines the new name for the duplicated material
  31183. * @returns the cloned material
  31184. */
  31185. clone(name: string): Nullable<Material>;
  31186. /**
  31187. * Gets the meshes bound to the material
  31188. * @returns an array of meshes bound to the material
  31189. */
  31190. getBindedMeshes(): AbstractMesh[];
  31191. /**
  31192. * Force shader compilation
  31193. * @param mesh defines the mesh associated with this material
  31194. * @param onCompiled defines a function to execute once the material is compiled
  31195. * @param options defines the options to configure the compilation
  31196. * @param onError defines a function to execute if the material fails compiling
  31197. */
  31198. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  31199. /**
  31200. * Force shader compilation
  31201. * @param mesh defines the mesh that will use this material
  31202. * @param options defines additional options for compiling the shaders
  31203. * @returns a promise that resolves when the compilation completes
  31204. */
  31205. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  31206. private static readonly _AllDirtyCallBack;
  31207. private static readonly _ImageProcessingDirtyCallBack;
  31208. private static readonly _TextureDirtyCallBack;
  31209. private static readonly _FresnelDirtyCallBack;
  31210. private static readonly _MiscDirtyCallBack;
  31211. private static readonly _PrePassDirtyCallBack;
  31212. private static readonly _LightsDirtyCallBack;
  31213. private static readonly _AttributeDirtyCallBack;
  31214. private static _FresnelAndMiscDirtyCallBack;
  31215. private static _TextureAndMiscDirtyCallBack;
  31216. private static readonly _DirtyCallbackArray;
  31217. private static readonly _RunDirtyCallBacks;
  31218. /**
  31219. * Marks a define in the material to indicate that it needs to be re-computed
  31220. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  31221. */
  31222. markAsDirty(flag: number): void;
  31223. /**
  31224. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  31225. * @param func defines a function which checks material defines against the submeshes
  31226. */
  31227. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  31228. /**
  31229. * Indicates that the scene should check if the rendering now needs a prepass
  31230. */
  31231. protected _markScenePrePassDirty(): void;
  31232. /**
  31233. * Indicates that we need to re-calculated for all submeshes
  31234. */
  31235. protected _markAllSubMeshesAsAllDirty(): void;
  31236. /**
  31237. * Indicates that image processing needs to be re-calculated for all submeshes
  31238. */
  31239. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  31240. /**
  31241. * Indicates that textures need to be re-calculated for all submeshes
  31242. */
  31243. protected _markAllSubMeshesAsTexturesDirty(): void;
  31244. /**
  31245. * Indicates that fresnel needs to be re-calculated for all submeshes
  31246. */
  31247. protected _markAllSubMeshesAsFresnelDirty(): void;
  31248. /**
  31249. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  31250. */
  31251. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  31252. /**
  31253. * Indicates that lights need to be re-calculated for all submeshes
  31254. */
  31255. protected _markAllSubMeshesAsLightsDirty(): void;
  31256. /**
  31257. * Indicates that attributes need to be re-calculated for all submeshes
  31258. */
  31259. protected _markAllSubMeshesAsAttributesDirty(): void;
  31260. /**
  31261. * Indicates that misc needs to be re-calculated for all submeshes
  31262. */
  31263. protected _markAllSubMeshesAsMiscDirty(): void;
  31264. /**
  31265. * Indicates that prepass needs to be re-calculated for all submeshes
  31266. */
  31267. protected _markAllSubMeshesAsPrePassDirty(): void;
  31268. /**
  31269. * Indicates that textures and misc need to be re-calculated for all submeshes
  31270. */
  31271. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  31272. /**
  31273. * Sets the required values to the prepass renderer.
  31274. * @param prePassRenderer defines the prepass renderer to setup.
  31275. * @returns true if the pre pass is needed.
  31276. */
  31277. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  31278. /**
  31279. * Disposes the material
  31280. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  31281. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  31282. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  31283. */
  31284. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  31285. /** @hidden */
  31286. private releaseVertexArrayObject;
  31287. /**
  31288. * Serializes this material
  31289. * @returns the serialized material object
  31290. */
  31291. serialize(): any;
  31292. /**
  31293. * Creates a material from parsed material data
  31294. * @param parsedMaterial defines parsed material data
  31295. * @param scene defines the hosting scene
  31296. * @param rootUrl defines the root URL to use to load textures
  31297. * @returns a new material
  31298. */
  31299. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  31300. }
  31301. }
  31302. declare module BABYLON {
  31303. /**
  31304. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31305. * separate meshes. This can be use to improve performances.
  31306. * @see https://doc.babylonjs.com/how_to/multi_materials
  31307. */
  31308. export class MultiMaterial extends Material {
  31309. private _subMaterials;
  31310. /**
  31311. * Gets or Sets the list of Materials used within the multi material.
  31312. * They need to be ordered according to the submeshes order in the associated mesh
  31313. */
  31314. get subMaterials(): Nullable<Material>[];
  31315. set subMaterials(value: Nullable<Material>[]);
  31316. /**
  31317. * Function used to align with Node.getChildren()
  31318. * @returns the list of Materials used within the multi material
  31319. */
  31320. getChildren(): Nullable<Material>[];
  31321. /**
  31322. * Instantiates a new Multi Material
  31323. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31324. * separate meshes. This can be use to improve performances.
  31325. * @see https://doc.babylonjs.com/how_to/multi_materials
  31326. * @param name Define the name in the scene
  31327. * @param scene Define the scene the material belongs to
  31328. */
  31329. constructor(name: string, scene: Scene);
  31330. private _hookArray;
  31331. /**
  31332. * Get one of the submaterial by its index in the submaterials array
  31333. * @param index The index to look the sub material at
  31334. * @returns The Material if the index has been defined
  31335. */
  31336. getSubMaterial(index: number): Nullable<Material>;
  31337. /**
  31338. * Get the list of active textures for the whole sub materials list.
  31339. * @returns All the textures that will be used during the rendering
  31340. */
  31341. getActiveTextures(): BaseTexture[];
  31342. /**
  31343. * Specifies if any sub-materials of this multi-material use a given texture.
  31344. * @param texture Defines the texture to check against this multi-material's sub-materials.
  31345. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  31346. */
  31347. hasTexture(texture: BaseTexture): boolean;
  31348. /**
  31349. * Gets the current class name of the material e.g. "MultiMaterial"
  31350. * Mainly use in serialization.
  31351. * @returns the class name
  31352. */
  31353. getClassName(): string;
  31354. /**
  31355. * Checks if the material is ready to render the requested sub mesh
  31356. * @param mesh Define the mesh the submesh belongs to
  31357. * @param subMesh Define the sub mesh to look readiness for
  31358. * @param useInstances Define whether or not the material is used with instances
  31359. * @returns true if ready, otherwise false
  31360. */
  31361. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31362. /**
  31363. * Clones the current material and its related sub materials
  31364. * @param name Define the name of the newly cloned material
  31365. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  31366. * @returns the cloned material
  31367. */
  31368. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  31369. /**
  31370. * Serializes the materials into a JSON representation.
  31371. * @returns the JSON representation
  31372. */
  31373. serialize(): any;
  31374. /**
  31375. * Dispose the material and release its associated resources
  31376. * @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)
  31377. * @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)
  31378. * @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)
  31379. */
  31380. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  31381. /**
  31382. * Creates a MultiMaterial from parsed MultiMaterial data.
  31383. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  31384. * @param scene defines the hosting scene
  31385. * @returns a new MultiMaterial
  31386. */
  31387. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  31388. }
  31389. }
  31390. declare module BABYLON {
  31391. /** @hidden */
  31392. export interface ICustomEffect {
  31393. effect: Effect;
  31394. defines: string;
  31395. }
  31396. /**
  31397. * Defines a subdivision inside a mesh
  31398. */
  31399. export class SubMesh implements ICullable {
  31400. /** the material index to use */
  31401. materialIndex: number;
  31402. /** vertex index start */
  31403. verticesStart: number;
  31404. /** vertices count */
  31405. verticesCount: number;
  31406. /** index start */
  31407. indexStart: number;
  31408. /** indices count */
  31409. indexCount: number;
  31410. /** @hidden */
  31411. _materialDefines: Nullable<MaterialDefines>;
  31412. /** @hidden */
  31413. _materialEffect: Nullable<Effect>;
  31414. /** @hidden */
  31415. _effectOverride: Nullable<Effect>;
  31416. private _customEffects;
  31417. /**
  31418. * Gets material defines used by the effect associated to the sub mesh
  31419. */
  31420. get materialDefines(): Nullable<MaterialDefines>;
  31421. /**
  31422. * Sets material defines used by the effect associated to the sub mesh
  31423. */
  31424. set materialDefines(defines: Nullable<MaterialDefines>);
  31425. /** @hidden */
  31426. _getCustomEffect(name: string, createIfNotExisting?: boolean): Nullable<ICustomEffect>;
  31427. /** @hidden */
  31428. _removeCustomEffect(name: string): void;
  31429. /**
  31430. * Gets associated effect
  31431. */
  31432. get effect(): Nullable<Effect>;
  31433. /**
  31434. * Sets associated effect (effect used to render this submesh)
  31435. * @param effect defines the effect to associate with
  31436. * @param defines defines the set of defines used to compile this effect
  31437. */
  31438. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  31439. /** @hidden */
  31440. _linesIndexCount: number;
  31441. private _mesh;
  31442. private _renderingMesh;
  31443. private _boundingInfo;
  31444. private _linesIndexBuffer;
  31445. /** @hidden */
  31446. _lastColliderWorldVertices: Nullable<Vector3[]>;
  31447. /** @hidden */
  31448. _trianglePlanes: Plane[];
  31449. /** @hidden */
  31450. _lastColliderTransformMatrix: Nullable<Matrix>;
  31451. /** @hidden */
  31452. _renderId: number;
  31453. /** @hidden */
  31454. _alphaIndex: number;
  31455. /** @hidden */
  31456. _distanceToCamera: number;
  31457. /** @hidden */
  31458. _id: number;
  31459. private _currentMaterial;
  31460. /**
  31461. * Add a new submesh to a mesh
  31462. * @param materialIndex defines the material index to use
  31463. * @param verticesStart defines vertex index start
  31464. * @param verticesCount defines vertices count
  31465. * @param indexStart defines index start
  31466. * @param indexCount defines indices count
  31467. * @param mesh defines the parent mesh
  31468. * @param renderingMesh defines an optional rendering mesh
  31469. * @param createBoundingBox defines if bounding box should be created for this submesh
  31470. * @returns the new submesh
  31471. */
  31472. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  31473. /**
  31474. * Creates a new submesh
  31475. * @param materialIndex defines the material index to use
  31476. * @param verticesStart defines vertex index start
  31477. * @param verticesCount defines vertices count
  31478. * @param indexStart defines index start
  31479. * @param indexCount defines indices count
  31480. * @param mesh defines the parent mesh
  31481. * @param renderingMesh defines an optional rendering mesh
  31482. * @param createBoundingBox defines if bounding box should be created for this submesh
  31483. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  31484. */
  31485. constructor(
  31486. /** the material index to use */
  31487. materialIndex: number,
  31488. /** vertex index start */
  31489. verticesStart: number,
  31490. /** vertices count */
  31491. verticesCount: number,
  31492. /** index start */
  31493. indexStart: number,
  31494. /** indices count */
  31495. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  31496. /**
  31497. * Returns true if this submesh covers the entire parent mesh
  31498. * @ignorenaming
  31499. */
  31500. get IsGlobal(): boolean;
  31501. /**
  31502. * Returns the submesh BoundingInfo object
  31503. * @returns current bounding info (or mesh's one if the submesh is global)
  31504. */
  31505. getBoundingInfo(): BoundingInfo;
  31506. /**
  31507. * Sets the submesh BoundingInfo
  31508. * @param boundingInfo defines the new bounding info to use
  31509. * @returns the SubMesh
  31510. */
  31511. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  31512. /**
  31513. * Returns the mesh of the current submesh
  31514. * @return the parent mesh
  31515. */
  31516. getMesh(): AbstractMesh;
  31517. /**
  31518. * Returns the rendering mesh of the submesh
  31519. * @returns the rendering mesh (could be different from parent mesh)
  31520. */
  31521. getRenderingMesh(): Mesh;
  31522. /**
  31523. * Returns the replacement mesh of the submesh
  31524. * @returns the replacement mesh (could be different from parent mesh)
  31525. */
  31526. getReplacementMesh(): Nullable<AbstractMesh>;
  31527. /**
  31528. * Returns the effective mesh of the submesh
  31529. * @returns the effective mesh (could be different from parent mesh)
  31530. */
  31531. getEffectiveMesh(): AbstractMesh;
  31532. /**
  31533. * Returns the submesh material
  31534. * @returns null or the current material
  31535. */
  31536. getMaterial(): Nullable<Material>;
  31537. private _IsMultiMaterial;
  31538. /**
  31539. * Sets a new updated BoundingInfo object to the submesh
  31540. * @param data defines an optional position array to use to determine the bounding info
  31541. * @returns the SubMesh
  31542. */
  31543. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  31544. /** @hidden */
  31545. _checkCollision(collider: Collider): boolean;
  31546. /**
  31547. * Updates the submesh BoundingInfo
  31548. * @param world defines the world matrix to use to update the bounding info
  31549. * @returns the submesh
  31550. */
  31551. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  31552. /**
  31553. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  31554. * @param frustumPlanes defines the frustum planes
  31555. * @returns true if the submesh is intersecting with the frustum
  31556. */
  31557. isInFrustum(frustumPlanes: Plane[]): boolean;
  31558. /**
  31559. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  31560. * @param frustumPlanes defines the frustum planes
  31561. * @returns true if the submesh is inside the frustum
  31562. */
  31563. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31564. /**
  31565. * Renders the submesh
  31566. * @param enableAlphaMode defines if alpha needs to be used
  31567. * @returns the submesh
  31568. */
  31569. render(enableAlphaMode: boolean): SubMesh;
  31570. /**
  31571. * @hidden
  31572. */
  31573. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  31574. /**
  31575. * Checks if the submesh intersects with a ray
  31576. * @param ray defines the ray to test
  31577. * @returns true is the passed ray intersects the submesh bounding box
  31578. */
  31579. canIntersects(ray: Ray): boolean;
  31580. /**
  31581. * Intersects current submesh with a ray
  31582. * @param ray defines the ray to test
  31583. * @param positions defines mesh's positions array
  31584. * @param indices defines mesh's indices array
  31585. * @param fastCheck defines if the first intersection will be used (and not the closest)
  31586. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31587. * @returns intersection info or null if no intersection
  31588. */
  31589. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  31590. /** @hidden */
  31591. private _intersectLines;
  31592. /** @hidden */
  31593. private _intersectUnIndexedLines;
  31594. /** @hidden */
  31595. private _intersectTriangles;
  31596. /** @hidden */
  31597. private _intersectUnIndexedTriangles;
  31598. /** @hidden */
  31599. _rebuild(): void;
  31600. /**
  31601. * Creates a new submesh from the passed mesh
  31602. * @param newMesh defines the new hosting mesh
  31603. * @param newRenderingMesh defines an optional rendering mesh
  31604. * @returns the new submesh
  31605. */
  31606. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  31607. /**
  31608. * Release associated resources
  31609. */
  31610. dispose(): void;
  31611. /**
  31612. * Gets the class name
  31613. * @returns the string "SubMesh".
  31614. */
  31615. getClassName(): string;
  31616. /**
  31617. * Creates a new submesh from indices data
  31618. * @param materialIndex the index of the main mesh material
  31619. * @param startIndex the index where to start the copy in the mesh indices array
  31620. * @param indexCount the number of indices to copy then from the startIndex
  31621. * @param mesh the main mesh to create the submesh from
  31622. * @param renderingMesh the optional rendering mesh
  31623. * @returns a new submesh
  31624. */
  31625. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  31626. }
  31627. }
  31628. declare module BABYLON {
  31629. /**
  31630. * Class used to represent data loading progression
  31631. */
  31632. export class SceneLoaderFlags {
  31633. private static _ForceFullSceneLoadingForIncremental;
  31634. private static _ShowLoadingScreen;
  31635. private static _CleanBoneMatrixWeights;
  31636. private static _loggingLevel;
  31637. /**
  31638. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  31639. */
  31640. static get ForceFullSceneLoadingForIncremental(): boolean;
  31641. static set ForceFullSceneLoadingForIncremental(value: boolean);
  31642. /**
  31643. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  31644. */
  31645. static get ShowLoadingScreen(): boolean;
  31646. static set ShowLoadingScreen(value: boolean);
  31647. /**
  31648. * Defines the current logging level (while loading the scene)
  31649. * @ignorenaming
  31650. */
  31651. static get loggingLevel(): number;
  31652. static set loggingLevel(value: number);
  31653. /**
  31654. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  31655. */
  31656. static get CleanBoneMatrixWeights(): boolean;
  31657. static set CleanBoneMatrixWeights(value: boolean);
  31658. }
  31659. }
  31660. declare module BABYLON {
  31661. /**
  31662. * Class used to store geometry data (vertex buffers + index buffer)
  31663. */
  31664. export class Geometry implements IGetSetVerticesData {
  31665. /**
  31666. * Gets or sets the ID of the geometry
  31667. */
  31668. id: string;
  31669. /**
  31670. * Gets or sets the unique ID of the geometry
  31671. */
  31672. uniqueId: number;
  31673. /**
  31674. * Gets the delay loading state of the geometry (none by default which means not delayed)
  31675. */
  31676. delayLoadState: number;
  31677. /**
  31678. * Gets the file containing the data to load when running in delay load state
  31679. */
  31680. delayLoadingFile: Nullable<string>;
  31681. /**
  31682. * Callback called when the geometry is updated
  31683. */
  31684. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  31685. private _scene;
  31686. private _engine;
  31687. private _meshes;
  31688. private _totalVertices;
  31689. /** @hidden */
  31690. _indices: IndicesArray;
  31691. /** @hidden */
  31692. _vertexBuffers: {
  31693. [key: string]: VertexBuffer;
  31694. };
  31695. private _isDisposed;
  31696. private _extend;
  31697. private _boundingBias;
  31698. /** @hidden */
  31699. _delayInfo: Array<string>;
  31700. private _indexBuffer;
  31701. private _indexBufferIsUpdatable;
  31702. /** @hidden */
  31703. _boundingInfo: Nullable<BoundingInfo>;
  31704. /** @hidden */
  31705. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  31706. /** @hidden */
  31707. _softwareSkinningFrameId: number;
  31708. private _vertexArrayObjects;
  31709. private _updatable;
  31710. /** @hidden */
  31711. _positions: Nullable<Vector3[]>;
  31712. private _positionsCache;
  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. get boundingBias(): Vector2;
  31717. /**
  31718. * 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
  31719. */
  31720. set boundingBias(value: Vector2);
  31721. /**
  31722. * Static function used to attach a new empty geometry to a mesh
  31723. * @param mesh defines the mesh to attach the geometry to
  31724. * @returns the new Geometry
  31725. */
  31726. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  31727. /** Get the list of meshes using this geometry */
  31728. get meshes(): Mesh[];
  31729. /**
  31730. * 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
  31731. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  31732. */
  31733. useBoundingInfoFromGeometry: boolean;
  31734. /**
  31735. * Creates a new geometry
  31736. * @param id defines the unique ID
  31737. * @param scene defines the hosting scene
  31738. * @param vertexData defines the VertexData used to get geometry data
  31739. * @param updatable defines if geometry must be updatable (false by default)
  31740. * @param mesh defines the mesh that will be associated with the geometry
  31741. */
  31742. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  31743. /**
  31744. * Gets the current extend of the geometry
  31745. */
  31746. get extend(): {
  31747. minimum: Vector3;
  31748. maximum: Vector3;
  31749. };
  31750. /**
  31751. * Gets the hosting scene
  31752. * @returns the hosting Scene
  31753. */
  31754. getScene(): Scene;
  31755. /**
  31756. * Gets the hosting engine
  31757. * @returns the hosting Engine
  31758. */
  31759. getEngine(): Engine;
  31760. /**
  31761. * Defines if the geometry is ready to use
  31762. * @returns true if the geometry is ready to be used
  31763. */
  31764. isReady(): boolean;
  31765. /**
  31766. * Gets a value indicating that the geometry should not be serialized
  31767. */
  31768. get doNotSerialize(): boolean;
  31769. /** @hidden */
  31770. _rebuild(): void;
  31771. /**
  31772. * Affects all geometry data in one call
  31773. * @param vertexData defines the geometry data
  31774. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  31775. */
  31776. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  31777. /**
  31778. * Set specific vertex data
  31779. * @param kind defines the data kind (Position, normal, etc...)
  31780. * @param data defines the vertex data to use
  31781. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31782. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31783. */
  31784. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  31785. /**
  31786. * Removes a specific vertex data
  31787. * @param kind defines the data kind (Position, normal, etc...)
  31788. */
  31789. removeVerticesData(kind: string): void;
  31790. /**
  31791. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  31792. * @param buffer defines the vertex buffer to use
  31793. * @param totalVertices defines the total number of vertices for position kind (could be null)
  31794. */
  31795. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  31796. /**
  31797. * Update a specific vertex buffer
  31798. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  31799. * It will do nothing if the buffer is not updatable
  31800. * @param kind defines the data kind (Position, normal, etc...)
  31801. * @param data defines the data to use
  31802. * @param offset defines the offset in the target buffer where to store the data
  31803. * @param useBytes set to true if the offset is in bytes
  31804. */
  31805. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  31806. /**
  31807. * Update a specific vertex buffer
  31808. * This function will create a new buffer if the current one is not updatable
  31809. * @param kind defines the data kind (Position, normal, etc...)
  31810. * @param data defines the data to use
  31811. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  31812. */
  31813. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  31814. private _updateBoundingInfo;
  31815. /** @hidden */
  31816. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>, overrideVertexBuffers?: {
  31817. [kind: string]: Nullable<VertexBuffer>;
  31818. }, overrideVertexArrayObjects?: {
  31819. [key: string]: WebGLVertexArrayObject;
  31820. }): void;
  31821. /**
  31822. * Gets total number of vertices
  31823. * @returns the total number of vertices
  31824. */
  31825. getTotalVertices(): number;
  31826. /**
  31827. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31828. * @param kind defines the data kind (Position, normal, etc...)
  31829. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31830. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31831. * @returns a float array containing vertex data
  31832. */
  31833. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31834. /**
  31835. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  31836. * @param kind defines the data kind (Position, normal, etc...)
  31837. * @returns true if the vertex buffer with the specified kind is updatable
  31838. */
  31839. isVertexBufferUpdatable(kind: string): boolean;
  31840. /**
  31841. * Gets a specific vertex buffer
  31842. * @param kind defines the data kind (Position, normal, etc...)
  31843. * @returns a VertexBuffer
  31844. */
  31845. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  31846. /**
  31847. * Returns all vertex buffers
  31848. * @return an object holding all vertex buffers indexed by kind
  31849. */
  31850. getVertexBuffers(): Nullable<{
  31851. [key: string]: VertexBuffer;
  31852. }>;
  31853. /**
  31854. * Gets a boolean indicating if specific vertex buffer is present
  31855. * @param kind defines the data kind (Position, normal, etc...)
  31856. * @returns true if data is present
  31857. */
  31858. isVerticesDataPresent(kind: string): boolean;
  31859. /**
  31860. * Gets a list of all attached data kinds (Position, normal, etc...)
  31861. * @returns a list of string containing all kinds
  31862. */
  31863. getVerticesDataKinds(): string[];
  31864. /**
  31865. * Update index buffer
  31866. * @param indices defines the indices to store in the index buffer
  31867. * @param offset defines the offset in the target buffer where to store the data
  31868. * @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)
  31869. */
  31870. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  31871. /**
  31872. * Creates a new index buffer
  31873. * @param indices defines the indices to store in the index buffer
  31874. * @param totalVertices defines the total number of vertices (could be null)
  31875. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31876. */
  31877. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  31878. /**
  31879. * Return the total number of indices
  31880. * @returns the total number of indices
  31881. */
  31882. getTotalIndices(): number;
  31883. /**
  31884. * Gets the index buffer array
  31885. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31886. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31887. * @returns the index buffer array
  31888. */
  31889. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31890. /**
  31891. * Gets the index buffer
  31892. * @return the index buffer
  31893. */
  31894. getIndexBuffer(): Nullable<DataBuffer>;
  31895. /** @hidden */
  31896. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  31897. /**
  31898. * Release the associated resources for a specific mesh
  31899. * @param mesh defines the source mesh
  31900. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  31901. */
  31902. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  31903. /**
  31904. * Apply current geometry to a given mesh
  31905. * @param mesh defines the mesh to apply geometry to
  31906. */
  31907. applyToMesh(mesh: Mesh): void;
  31908. private _updateExtend;
  31909. private _applyToMesh;
  31910. private notifyUpdate;
  31911. /**
  31912. * Load the geometry if it was flagged as delay loaded
  31913. * @param scene defines the hosting scene
  31914. * @param onLoaded defines a callback called when the geometry is loaded
  31915. */
  31916. load(scene: Scene, onLoaded?: () => void): void;
  31917. private _queueLoad;
  31918. /**
  31919. * Invert the geometry to move from a right handed system to a left handed one.
  31920. */
  31921. toLeftHanded(): void;
  31922. /** @hidden */
  31923. _resetPointsArrayCache(): void;
  31924. /** @hidden */
  31925. _generatePointsArray(): boolean;
  31926. /**
  31927. * Gets a value indicating if the geometry is disposed
  31928. * @returns true if the geometry was disposed
  31929. */
  31930. isDisposed(): boolean;
  31931. private _disposeVertexArrayObjects;
  31932. /**
  31933. * Free all associated resources
  31934. */
  31935. dispose(): void;
  31936. /**
  31937. * Clone the current geometry into a new geometry
  31938. * @param id defines the unique ID of the new geometry
  31939. * @returns a new geometry object
  31940. */
  31941. copy(id: string): Geometry;
  31942. /**
  31943. * Serialize the current geometry info (and not the vertices data) into a JSON object
  31944. * @return a JSON representation of the current geometry data (without the vertices data)
  31945. */
  31946. serialize(): any;
  31947. private toNumberArray;
  31948. /**
  31949. * Serialize all vertices data into a JSON object
  31950. * @returns a JSON representation of the current geometry data
  31951. */
  31952. serializeVerticeData(): any;
  31953. /**
  31954. * Extracts a clone of a mesh geometry
  31955. * @param mesh defines the source mesh
  31956. * @param id defines the unique ID of the new geometry object
  31957. * @returns the new geometry object
  31958. */
  31959. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  31960. /**
  31961. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  31962. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31963. * Be aware Math.random() could cause collisions, but:
  31964. * "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"
  31965. * @returns a string containing a new GUID
  31966. */
  31967. static RandomId(): string;
  31968. /** @hidden */
  31969. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  31970. private static _CleanMatricesWeights;
  31971. /**
  31972. * Create a new geometry from persisted data (Using .babylon file format)
  31973. * @param parsedVertexData defines the persisted data
  31974. * @param scene defines the hosting scene
  31975. * @param rootUrl defines the root url to use to load assets (like delayed data)
  31976. * @returns the new geometry object
  31977. */
  31978. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  31979. }
  31980. }
  31981. declare module BABYLON {
  31982. /**
  31983. * Defines a target to use with MorphTargetManager
  31984. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31985. */
  31986. export class MorphTarget implements IAnimatable {
  31987. /** defines the name of the target */
  31988. name: string;
  31989. /**
  31990. * Gets or sets the list of animations
  31991. */
  31992. animations: Animation[];
  31993. private _scene;
  31994. private _positions;
  31995. private _normals;
  31996. private _tangents;
  31997. private _uvs;
  31998. private _influence;
  31999. private _uniqueId;
  32000. /**
  32001. * Observable raised when the influence changes
  32002. */
  32003. onInfluenceChanged: Observable<boolean>;
  32004. /** @hidden */
  32005. _onDataLayoutChanged: Observable<void>;
  32006. /**
  32007. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  32008. */
  32009. get influence(): number;
  32010. set influence(influence: number);
  32011. /**
  32012. * Gets or sets the id of the morph Target
  32013. */
  32014. id: string;
  32015. private _animationPropertiesOverride;
  32016. /**
  32017. * Gets or sets the animation properties override
  32018. */
  32019. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32020. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32021. /**
  32022. * Creates a new MorphTarget
  32023. * @param name defines the name of the target
  32024. * @param influence defines the influence to use
  32025. * @param scene defines the scene the morphtarget belongs to
  32026. */
  32027. constructor(
  32028. /** defines the name of the target */
  32029. name: string, influence?: number, scene?: Nullable<Scene>);
  32030. /**
  32031. * Gets the unique ID of this manager
  32032. */
  32033. get uniqueId(): number;
  32034. /**
  32035. * Gets a boolean defining if the target contains position data
  32036. */
  32037. get hasPositions(): boolean;
  32038. /**
  32039. * Gets a boolean defining if the target contains normal data
  32040. */
  32041. get hasNormals(): boolean;
  32042. /**
  32043. * Gets a boolean defining if the target contains tangent data
  32044. */
  32045. get hasTangents(): boolean;
  32046. /**
  32047. * Gets a boolean defining if the target contains texture coordinates data
  32048. */
  32049. get hasUVs(): boolean;
  32050. /**
  32051. * Affects position data to this target
  32052. * @param data defines the position data to use
  32053. */
  32054. setPositions(data: Nullable<FloatArray>): void;
  32055. /**
  32056. * Gets the position data stored in this target
  32057. * @returns a FloatArray containing the position data (or null if not present)
  32058. */
  32059. getPositions(): Nullable<FloatArray>;
  32060. /**
  32061. * Affects normal data to this target
  32062. * @param data defines the normal data to use
  32063. */
  32064. setNormals(data: Nullable<FloatArray>): void;
  32065. /**
  32066. * Gets the normal data stored in this target
  32067. * @returns a FloatArray containing the normal data (or null if not present)
  32068. */
  32069. getNormals(): Nullable<FloatArray>;
  32070. /**
  32071. * Affects tangent data to this target
  32072. * @param data defines the tangent data to use
  32073. */
  32074. setTangents(data: Nullable<FloatArray>): void;
  32075. /**
  32076. * Gets the tangent data stored in this target
  32077. * @returns a FloatArray containing the tangent data (or null if not present)
  32078. */
  32079. getTangents(): Nullable<FloatArray>;
  32080. /**
  32081. * Affects texture coordinates data to this target
  32082. * @param data defines the texture coordinates data to use
  32083. */
  32084. setUVs(data: Nullable<FloatArray>): void;
  32085. /**
  32086. * Gets the texture coordinates data stored in this target
  32087. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  32088. */
  32089. getUVs(): Nullable<FloatArray>;
  32090. /**
  32091. * Clone the current target
  32092. * @returns a new MorphTarget
  32093. */
  32094. clone(): MorphTarget;
  32095. /**
  32096. * Serializes the current target into a Serialization object
  32097. * @returns the serialized object
  32098. */
  32099. serialize(): any;
  32100. /**
  32101. * Returns the string "MorphTarget"
  32102. * @returns "MorphTarget"
  32103. */
  32104. getClassName(): string;
  32105. /**
  32106. * Creates a new target from serialized data
  32107. * @param serializationObject defines the serialized data to use
  32108. * @returns a new MorphTarget
  32109. */
  32110. static Parse(serializationObject: any): MorphTarget;
  32111. /**
  32112. * Creates a MorphTarget from mesh data
  32113. * @param mesh defines the source mesh
  32114. * @param name defines the name to use for the new target
  32115. * @param influence defines the influence to attach to the target
  32116. * @returns a new MorphTarget
  32117. */
  32118. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  32119. }
  32120. }
  32121. declare module BABYLON {
  32122. /**
  32123. * Class used to store 2D array textures containing user data
  32124. */
  32125. export class RawTexture2DArray extends Texture {
  32126. /** Gets or sets the texture format to use */
  32127. format: number;
  32128. private _depth;
  32129. /**
  32130. * Gets the number of layers of the texture
  32131. */
  32132. get depth(): number;
  32133. /**
  32134. * Create a new RawTexture2DArray
  32135. * @param data defines the data of the texture
  32136. * @param width defines the width of the texture
  32137. * @param height defines the height of the texture
  32138. * @param depth defines the number of layers of the texture
  32139. * @param format defines the texture format to use
  32140. * @param scene defines the hosting scene
  32141. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  32142. * @param invertY defines if texture must be stored with Y axis inverted
  32143. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  32144. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  32145. */
  32146. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  32147. /** Gets or sets the texture format to use */
  32148. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  32149. /**
  32150. * Update the texture with new data
  32151. * @param data defines the data to store in the texture
  32152. */
  32153. update(data: ArrayBufferView): void;
  32154. /**
  32155. * Creates a RGBA texture from some data.
  32156. * @param data Define the texture data
  32157. * @param width Define the width of the texture
  32158. * @param height Define the height of the texture
  32159. * @param depth defines the number of layers of the texture
  32160. * @param scene defines the scene the texture will belong to
  32161. * @param generateMipMaps Define whether or not to create mip maps for the texture
  32162. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  32163. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  32164. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  32165. * @returns the RGBA texture
  32166. */
  32167. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, depth: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture2DArray;
  32168. }
  32169. }
  32170. declare module BABYLON {
  32171. /**
  32172. * This class is used to deform meshes using morphing between different targets
  32173. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32174. */
  32175. export class MorphTargetManager implements IDisposable {
  32176. private _targets;
  32177. private _targetInfluenceChangedObservers;
  32178. private _targetDataLayoutChangedObservers;
  32179. private _activeTargets;
  32180. private _scene;
  32181. private _influences;
  32182. private _supportsNormals;
  32183. private _supportsTangents;
  32184. private _supportsUVs;
  32185. private _vertexCount;
  32186. private _textureVertexStride;
  32187. private _textureWidth;
  32188. private _textureHeight;
  32189. private _uniqueId;
  32190. private _tempInfluences;
  32191. private _canUseTextureForTargets;
  32192. /** @hidden */
  32193. _targetStoreTexture: Nullable<RawTexture2DArray>;
  32194. /**
  32195. * Gets or sets a boolean indicating if normals must be morphed
  32196. */
  32197. enableNormalMorphing: boolean;
  32198. /**
  32199. * Gets or sets a boolean indicating if tangents must be morphed
  32200. */
  32201. enableTangentMorphing: boolean;
  32202. /**
  32203. * Gets or sets a boolean indicating if UV must be morphed
  32204. */
  32205. enableUVMorphing: boolean;
  32206. /**
  32207. * Creates a new MorphTargetManager
  32208. * @param scene defines the current scene
  32209. */
  32210. constructor(scene?: Nullable<Scene>);
  32211. /**
  32212. * Gets the unique ID of this manager
  32213. */
  32214. get uniqueId(): number;
  32215. /**
  32216. * Gets the number of vertices handled by this manager
  32217. */
  32218. get vertexCount(): number;
  32219. /**
  32220. * Gets a boolean indicating if this manager supports morphing of normals
  32221. */
  32222. get supportsNormals(): boolean;
  32223. /**
  32224. * Gets a boolean indicating if this manager supports morphing of tangents
  32225. */
  32226. get supportsTangents(): boolean;
  32227. /**
  32228. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  32229. */
  32230. get supportsUVs(): boolean;
  32231. /**
  32232. * Gets the number of targets stored in this manager
  32233. */
  32234. get numTargets(): number;
  32235. /**
  32236. * Gets the number of influencers (ie. the number of targets with influences > 0)
  32237. */
  32238. get numInfluencers(): number;
  32239. /**
  32240. * Gets the list of influences (one per target)
  32241. */
  32242. get influences(): Float32Array;
  32243. private _useTextureToStoreTargets;
  32244. /**
  32245. * Gets or sets a boolean indicating that targets should be stored as a texture instead of using vertex attributes (default is true).
  32246. * Please note that this option is not available if the hardware does not support it
  32247. */
  32248. get useTextureToStoreTargets(): boolean;
  32249. set useTextureToStoreTargets(value: boolean);
  32250. /**
  32251. * Gets a boolean indicating that the targets are stored into a texture (instead of as attributes)
  32252. */
  32253. get isUsingTextureForTargets(): boolean;
  32254. /**
  32255. * Gets the active target at specified index. An active target is a target with an influence > 0
  32256. * @param index defines the index to check
  32257. * @returns the requested target
  32258. */
  32259. getActiveTarget(index: number): MorphTarget;
  32260. /**
  32261. * Gets the target at specified index
  32262. * @param index defines the index to check
  32263. * @returns the requested target
  32264. */
  32265. getTarget(index: number): MorphTarget;
  32266. /**
  32267. * Add a new target to this manager
  32268. * @param target defines the target to add
  32269. */
  32270. addTarget(target: MorphTarget): void;
  32271. /**
  32272. * Removes a target from the manager
  32273. * @param target defines the target to remove
  32274. */
  32275. removeTarget(target: MorphTarget): void;
  32276. /** @hidden */
  32277. _bind(effect: Effect): void;
  32278. /**
  32279. * Clone the current manager
  32280. * @returns a new MorphTargetManager
  32281. */
  32282. clone(): MorphTargetManager;
  32283. /**
  32284. * Serializes the current manager into a Serialization object
  32285. * @returns the serialized object
  32286. */
  32287. serialize(): any;
  32288. private _syncActiveTargets;
  32289. /**
  32290. * Synchronize the targets with all the meshes using this morph target manager
  32291. */
  32292. synchronize(): void;
  32293. /**
  32294. * Release all resources
  32295. */
  32296. dispose(): void;
  32297. /**
  32298. * Creates a new MorphTargetManager from serialized data
  32299. * @param serializationObject defines the serialized data
  32300. * @param scene defines the hosting scene
  32301. * @returns the new MorphTargetManager
  32302. */
  32303. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  32304. }
  32305. }
  32306. declare module BABYLON {
  32307. /**
  32308. * Class used to represent a specific level of detail of a mesh
  32309. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32310. */
  32311. export class MeshLODLevel {
  32312. /** Defines the distance where this level should start being displayed */
  32313. distance: number;
  32314. /** Defines the mesh to use to render this level */
  32315. mesh: Nullable<Mesh>;
  32316. /**
  32317. * Creates a new LOD level
  32318. * @param distance defines the distance where this level should star being displayed
  32319. * @param mesh defines the mesh to use to render this level
  32320. */
  32321. constructor(
  32322. /** Defines the distance where this level should start being displayed */
  32323. distance: number,
  32324. /** Defines the mesh to use to render this level */
  32325. mesh: Nullable<Mesh>);
  32326. }
  32327. }
  32328. declare module BABYLON {
  32329. /**
  32330. * Helper class used to generate a canvas to manipulate images
  32331. */
  32332. export class CanvasGenerator {
  32333. /**
  32334. * Create a new canvas (or offscreen canvas depending on the context)
  32335. * @param width defines the expected width
  32336. * @param height defines the expected height
  32337. * @return a new canvas or offscreen canvas
  32338. */
  32339. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  32340. }
  32341. }
  32342. declare module BABYLON {
  32343. /**
  32344. * Mesh representing the ground
  32345. */
  32346. export class GroundMesh extends Mesh {
  32347. /** If octree should be generated */
  32348. generateOctree: boolean;
  32349. private _heightQuads;
  32350. /** @hidden */
  32351. _subdivisionsX: number;
  32352. /** @hidden */
  32353. _subdivisionsY: number;
  32354. /** @hidden */
  32355. _width: number;
  32356. /** @hidden */
  32357. _height: number;
  32358. /** @hidden */
  32359. _minX: number;
  32360. /** @hidden */
  32361. _maxX: number;
  32362. /** @hidden */
  32363. _minZ: number;
  32364. /** @hidden */
  32365. _maxZ: number;
  32366. constructor(name: string, scene: Scene);
  32367. /**
  32368. * "GroundMesh"
  32369. * @returns "GroundMesh"
  32370. */
  32371. getClassName(): string;
  32372. /**
  32373. * The minimum of x and y subdivisions
  32374. */
  32375. get subdivisions(): number;
  32376. /**
  32377. * X subdivisions
  32378. */
  32379. get subdivisionsX(): number;
  32380. /**
  32381. * Y subdivisions
  32382. */
  32383. get subdivisionsY(): number;
  32384. /**
  32385. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  32386. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  32387. * @param chunksCount the number of subdivisions for x and y
  32388. * @param octreeBlocksSize (Default: 32)
  32389. */
  32390. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  32391. /**
  32392. * Returns a height (y) value in the World system :
  32393. * the ground altitude at the coordinates (x, z) expressed in the World system.
  32394. * @param x x coordinate
  32395. * @param z z coordinate
  32396. * @returns the ground y position if (x, z) are outside the ground surface.
  32397. */
  32398. getHeightAtCoordinates(x: number, z: number): number;
  32399. /**
  32400. * Returns a normalized vector (Vector3) orthogonal to the ground
  32401. * at the ground coordinates (x, z) expressed in the World system.
  32402. * @param x x coordinate
  32403. * @param z z coordinate
  32404. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  32405. */
  32406. getNormalAtCoordinates(x: number, z: number): Vector3;
  32407. /**
  32408. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  32409. * at the ground coordinates (x, z) expressed in the World system.
  32410. * Doesn't update the reference Vector3 if (x, z) are outside the ground surface.
  32411. * @param x x coordinate
  32412. * @param z z coordinate
  32413. * @param ref vector to store the result
  32414. * @returns the GroundMesh.
  32415. */
  32416. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  32417. /**
  32418. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  32419. * if the ground has been updated.
  32420. * This can be used in the render loop.
  32421. * @returns the GroundMesh.
  32422. */
  32423. updateCoordinateHeights(): GroundMesh;
  32424. private _getFacetAt;
  32425. private _initHeightQuads;
  32426. private _computeHeightQuads;
  32427. /**
  32428. * Serializes this ground mesh
  32429. * @param serializationObject object to write serialization to
  32430. */
  32431. serialize(serializationObject: any): void;
  32432. /**
  32433. * Parses a serialized ground mesh
  32434. * @param parsedMesh the serialized mesh
  32435. * @param scene the scene to create the ground mesh in
  32436. * @returns the created ground mesh
  32437. */
  32438. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  32439. }
  32440. }
  32441. declare module BABYLON {
  32442. /**
  32443. * Interface for Physics-Joint data
  32444. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32445. */
  32446. export interface PhysicsJointData {
  32447. /**
  32448. * The main pivot of the joint
  32449. */
  32450. mainPivot?: Vector3;
  32451. /**
  32452. * The connected pivot of the joint
  32453. */
  32454. connectedPivot?: Vector3;
  32455. /**
  32456. * The main axis of the joint
  32457. */
  32458. mainAxis?: Vector3;
  32459. /**
  32460. * The connected axis of the joint
  32461. */
  32462. connectedAxis?: Vector3;
  32463. /**
  32464. * The collision of the joint
  32465. */
  32466. collision?: boolean;
  32467. /**
  32468. * Native Oimo/Cannon/Energy data
  32469. */
  32470. nativeParams?: any;
  32471. }
  32472. /**
  32473. * This is a holder class for the physics joint created by the physics plugin
  32474. * It holds a set of functions to control the underlying joint
  32475. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32476. */
  32477. export class PhysicsJoint {
  32478. /**
  32479. * The type of the physics joint
  32480. */
  32481. type: number;
  32482. /**
  32483. * The data for the physics joint
  32484. */
  32485. jointData: PhysicsJointData;
  32486. private _physicsJoint;
  32487. protected _physicsPlugin: IPhysicsEnginePlugin;
  32488. /**
  32489. * Initializes the physics joint
  32490. * @param type The type of the physics joint
  32491. * @param jointData The data for the physics joint
  32492. */
  32493. constructor(
  32494. /**
  32495. * The type of the physics joint
  32496. */
  32497. type: number,
  32498. /**
  32499. * The data for the physics joint
  32500. */
  32501. jointData: PhysicsJointData);
  32502. /**
  32503. * Gets the physics joint
  32504. */
  32505. get physicsJoint(): any;
  32506. /**
  32507. * Sets the physics joint
  32508. */
  32509. set physicsJoint(newJoint: any);
  32510. /**
  32511. * Sets the physics plugin
  32512. */
  32513. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  32514. /**
  32515. * Execute a function that is physics-plugin specific.
  32516. * @param {Function} func the function that will be executed.
  32517. * It accepts two parameters: the physics world and the physics joint
  32518. */
  32519. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  32520. /**
  32521. * Distance-Joint type
  32522. */
  32523. static DistanceJoint: number;
  32524. /**
  32525. * Hinge-Joint type
  32526. */
  32527. static HingeJoint: number;
  32528. /**
  32529. * Ball-and-Socket joint type
  32530. */
  32531. static BallAndSocketJoint: number;
  32532. /**
  32533. * Wheel-Joint type
  32534. */
  32535. static WheelJoint: number;
  32536. /**
  32537. * Slider-Joint type
  32538. */
  32539. static SliderJoint: number;
  32540. /**
  32541. * Prismatic-Joint type
  32542. */
  32543. static PrismaticJoint: number;
  32544. /**
  32545. * Universal-Joint type
  32546. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  32547. */
  32548. static UniversalJoint: number;
  32549. /**
  32550. * Hinge-Joint 2 type
  32551. */
  32552. static Hinge2Joint: number;
  32553. /**
  32554. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  32555. */
  32556. static PointToPointJoint: number;
  32557. /**
  32558. * Spring-Joint type
  32559. */
  32560. static SpringJoint: number;
  32561. /**
  32562. * Lock-Joint type
  32563. */
  32564. static LockJoint: number;
  32565. }
  32566. /**
  32567. * A class representing a physics distance joint
  32568. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32569. */
  32570. export class DistanceJoint extends PhysicsJoint {
  32571. /**
  32572. *
  32573. * @param jointData The data for the Distance-Joint
  32574. */
  32575. constructor(jointData: DistanceJointData);
  32576. /**
  32577. * Update the predefined distance.
  32578. * @param maxDistance The maximum preferred distance
  32579. * @param minDistance The minimum preferred distance
  32580. */
  32581. updateDistance(maxDistance: number, minDistance?: number): void;
  32582. }
  32583. /**
  32584. * Represents a Motor-Enabled Joint
  32585. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32586. */
  32587. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  32588. /**
  32589. * Initializes the Motor-Enabled Joint
  32590. * @param type The type of the joint
  32591. * @param jointData The physical joint data for the joint
  32592. */
  32593. constructor(type: number, jointData: PhysicsJointData);
  32594. /**
  32595. * Set the motor values.
  32596. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32597. * @param force the force to apply
  32598. * @param maxForce max force for this motor.
  32599. */
  32600. setMotor(force?: number, maxForce?: number): void;
  32601. /**
  32602. * Set the motor's limits.
  32603. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32604. * @param upperLimit The upper limit of the motor
  32605. * @param lowerLimit The lower limit of the motor
  32606. */
  32607. setLimit(upperLimit: number, lowerLimit?: number): void;
  32608. }
  32609. /**
  32610. * This class represents a single physics Hinge-Joint
  32611. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32612. */
  32613. export class HingeJoint extends MotorEnabledJoint {
  32614. /**
  32615. * Initializes the Hinge-Joint
  32616. * @param jointData The joint data for the Hinge-Joint
  32617. */
  32618. constructor(jointData: PhysicsJointData);
  32619. /**
  32620. * Set the motor values.
  32621. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32622. * @param {number} force the force to apply
  32623. * @param {number} maxForce max force for this motor.
  32624. */
  32625. setMotor(force?: number, maxForce?: number): void;
  32626. /**
  32627. * Set the motor's limits.
  32628. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32629. * @param upperLimit The upper limit of the motor
  32630. * @param lowerLimit The lower limit of the motor
  32631. */
  32632. setLimit(upperLimit: number, lowerLimit?: number): void;
  32633. }
  32634. /**
  32635. * This class represents a dual hinge physics joint (same as wheel joint)
  32636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32637. */
  32638. export class Hinge2Joint extends MotorEnabledJoint {
  32639. /**
  32640. * Initializes the Hinge2-Joint
  32641. * @param jointData The joint data for the Hinge2-Joint
  32642. */
  32643. constructor(jointData: PhysicsJointData);
  32644. /**
  32645. * Set the motor values.
  32646. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32647. * @param {number} targetSpeed the speed the motor is to reach
  32648. * @param {number} maxForce max force for this motor.
  32649. * @param {motorIndex} the motor's index, 0 or 1.
  32650. */
  32651. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  32652. /**
  32653. * Set the motor limits.
  32654. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32655. * @param {number} upperLimit the upper limit
  32656. * @param {number} lowerLimit lower limit
  32657. * @param {motorIndex} the motor's index, 0 or 1.
  32658. */
  32659. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32660. }
  32661. /**
  32662. * Interface for a motor enabled joint
  32663. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32664. */
  32665. export interface IMotorEnabledJoint {
  32666. /**
  32667. * Physics joint
  32668. */
  32669. physicsJoint: any;
  32670. /**
  32671. * Sets the motor of the motor-enabled joint
  32672. * @param force The force of the motor
  32673. * @param maxForce The maximum force of the motor
  32674. * @param motorIndex The index of the motor
  32675. */
  32676. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32677. /**
  32678. * Sets the limit of the motor
  32679. * @param upperLimit The upper limit of the motor
  32680. * @param lowerLimit The lower limit of the motor
  32681. * @param motorIndex The index of the motor
  32682. */
  32683. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32684. }
  32685. /**
  32686. * Joint data for a Distance-Joint
  32687. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32688. */
  32689. export interface DistanceJointData extends PhysicsJointData {
  32690. /**
  32691. * Max distance the 2 joint objects can be apart
  32692. */
  32693. maxDistance: number;
  32694. }
  32695. /**
  32696. * Joint data from a spring joint
  32697. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32698. */
  32699. export interface SpringJointData extends PhysicsJointData {
  32700. /**
  32701. * Length of the spring
  32702. */
  32703. length: number;
  32704. /**
  32705. * Stiffness of the spring
  32706. */
  32707. stiffness: number;
  32708. /**
  32709. * Damping of the spring
  32710. */
  32711. damping: number;
  32712. /** this callback will be called when applying the force to the impostors. */
  32713. forceApplicationCallback: () => void;
  32714. }
  32715. }
  32716. declare module BABYLON {
  32717. /**
  32718. * Holds the data for the raycast result
  32719. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32720. */
  32721. export class PhysicsRaycastResult {
  32722. private _hasHit;
  32723. private _hitDistance;
  32724. private _hitNormalWorld;
  32725. private _hitPointWorld;
  32726. private _rayFromWorld;
  32727. private _rayToWorld;
  32728. /**
  32729. * Gets if there was a hit
  32730. */
  32731. get hasHit(): boolean;
  32732. /**
  32733. * Gets the distance from the hit
  32734. */
  32735. get hitDistance(): number;
  32736. /**
  32737. * Gets the hit normal/direction in the world
  32738. */
  32739. get hitNormalWorld(): Vector3;
  32740. /**
  32741. * Gets the hit point in the world
  32742. */
  32743. get hitPointWorld(): Vector3;
  32744. /**
  32745. * Gets the ray "start point" of the ray in the world
  32746. */
  32747. get rayFromWorld(): Vector3;
  32748. /**
  32749. * Gets the ray "end point" of the ray in the world
  32750. */
  32751. get rayToWorld(): Vector3;
  32752. /**
  32753. * Sets the hit data (normal & point in world space)
  32754. * @param hitNormalWorld defines the normal in world space
  32755. * @param hitPointWorld defines the point in world space
  32756. */
  32757. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  32758. /**
  32759. * Sets the distance from the start point to the hit point
  32760. * @param distance
  32761. */
  32762. setHitDistance(distance: number): void;
  32763. /**
  32764. * Calculates the distance manually
  32765. */
  32766. calculateHitDistance(): void;
  32767. /**
  32768. * Resets all the values to default
  32769. * @param from The from point on world space
  32770. * @param to The to point on world space
  32771. */
  32772. reset(from?: Vector3, to?: Vector3): void;
  32773. }
  32774. /**
  32775. * Interface for the size containing width and height
  32776. */
  32777. interface IXYZ {
  32778. /**
  32779. * X
  32780. */
  32781. x: number;
  32782. /**
  32783. * Y
  32784. */
  32785. y: number;
  32786. /**
  32787. * Z
  32788. */
  32789. z: number;
  32790. }
  32791. }
  32792. declare module BABYLON {
  32793. /**
  32794. * Interface used to describe a physics joint
  32795. */
  32796. export interface PhysicsImpostorJoint {
  32797. /** Defines the main impostor to which the joint is linked */
  32798. mainImpostor: PhysicsImpostor;
  32799. /** Defines the impostor that is connected to the main impostor using this joint */
  32800. connectedImpostor: PhysicsImpostor;
  32801. /** Defines the joint itself */
  32802. joint: PhysicsJoint;
  32803. }
  32804. /** @hidden */
  32805. export interface IPhysicsEnginePlugin {
  32806. world: any;
  32807. name: string;
  32808. setGravity(gravity: Vector3): void;
  32809. setTimeStep(timeStep: number): void;
  32810. getTimeStep(): number;
  32811. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32812. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32813. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32814. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32815. removePhysicsBody(impostor: PhysicsImpostor): void;
  32816. generateJoint(joint: PhysicsImpostorJoint): void;
  32817. removeJoint(joint: PhysicsImpostorJoint): void;
  32818. isSupported(): boolean;
  32819. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32820. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32821. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32822. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32823. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32824. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32825. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32826. getBodyMass(impostor: PhysicsImpostor): number;
  32827. getBodyFriction(impostor: PhysicsImpostor): number;
  32828. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32829. getBodyRestitution(impostor: PhysicsImpostor): number;
  32830. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32831. getBodyPressure?(impostor: PhysicsImpostor): number;
  32832. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  32833. getBodyStiffness?(impostor: PhysicsImpostor): number;
  32834. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  32835. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  32836. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  32837. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  32838. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  32839. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32840. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32841. sleepBody(impostor: PhysicsImpostor): void;
  32842. wakeUpBody(impostor: PhysicsImpostor): void;
  32843. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32844. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32845. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32846. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32847. getRadius(impostor: PhysicsImpostor): number;
  32848. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32849. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32850. dispose(): void;
  32851. }
  32852. /**
  32853. * Interface used to define a physics engine
  32854. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32855. */
  32856. export interface IPhysicsEngine {
  32857. /**
  32858. * Gets the gravity vector used by the simulation
  32859. */
  32860. gravity: Vector3;
  32861. /**
  32862. * Sets the gravity vector used by the simulation
  32863. * @param gravity defines the gravity vector to use
  32864. */
  32865. setGravity(gravity: Vector3): void;
  32866. /**
  32867. * Set the time step of the physics engine.
  32868. * Default is 1/60.
  32869. * To slow it down, enter 1/600 for example.
  32870. * To speed it up, 1/30
  32871. * @param newTimeStep the new timestep to apply to this world.
  32872. */
  32873. setTimeStep(newTimeStep: number): void;
  32874. /**
  32875. * Get the time step of the physics engine.
  32876. * @returns the current time step
  32877. */
  32878. getTimeStep(): number;
  32879. /**
  32880. * Set the sub time step of the physics engine.
  32881. * Default is 0 meaning there is no sub steps
  32882. * To increase physics resolution precision, set a small value (like 1 ms)
  32883. * @param subTimeStep defines the new sub timestep used for physics resolution.
  32884. */
  32885. setSubTimeStep(subTimeStep: number): void;
  32886. /**
  32887. * Get the sub time step of the physics engine.
  32888. * @returns the current sub time step
  32889. */
  32890. getSubTimeStep(): number;
  32891. /**
  32892. * Release all resources
  32893. */
  32894. dispose(): void;
  32895. /**
  32896. * Gets the name of the current physics plugin
  32897. * @returns the name of the plugin
  32898. */
  32899. getPhysicsPluginName(): string;
  32900. /**
  32901. * Adding a new impostor for the impostor tracking.
  32902. * This will be done by the impostor itself.
  32903. * @param impostor the impostor to add
  32904. */
  32905. addImpostor(impostor: PhysicsImpostor): void;
  32906. /**
  32907. * Remove an impostor from the engine.
  32908. * This impostor and its mesh will not longer be updated by the physics engine.
  32909. * @param impostor the impostor to remove
  32910. */
  32911. removeImpostor(impostor: PhysicsImpostor): void;
  32912. /**
  32913. * Add a joint to the physics engine
  32914. * @param mainImpostor defines the main impostor to which the joint is added.
  32915. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32916. * @param joint defines the joint that will connect both impostors.
  32917. */
  32918. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32919. /**
  32920. * Removes a joint from the simulation
  32921. * @param mainImpostor defines the impostor used with the joint
  32922. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32923. * @param joint defines the joint to remove
  32924. */
  32925. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32926. /**
  32927. * Gets the current plugin used to run the simulation
  32928. * @returns current plugin
  32929. */
  32930. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32931. /**
  32932. * Gets the list of physic impostors
  32933. * @returns an array of PhysicsImpostor
  32934. */
  32935. getImpostors(): Array<PhysicsImpostor>;
  32936. /**
  32937. * Gets the impostor for a physics enabled object
  32938. * @param object defines the object impersonated by the impostor
  32939. * @returns the PhysicsImpostor or null if not found
  32940. */
  32941. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32942. /**
  32943. * Gets the impostor for a physics body object
  32944. * @param body defines physics body used by the impostor
  32945. * @returns the PhysicsImpostor or null if not found
  32946. */
  32947. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32948. /**
  32949. * Does a raycast in the physics world
  32950. * @param from when should the ray start?
  32951. * @param to when should the ray end?
  32952. * @returns PhysicsRaycastResult
  32953. */
  32954. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32955. /**
  32956. * Called by the scene. No need to call it.
  32957. * @param delta defines the timespan between frames
  32958. */
  32959. _step(delta: number): void;
  32960. }
  32961. }
  32962. declare module BABYLON {
  32963. /**
  32964. * The interface for the physics imposter parameters
  32965. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32966. */
  32967. export interface PhysicsImpostorParameters {
  32968. /**
  32969. * The mass of the physics imposter
  32970. */
  32971. mass: number;
  32972. /**
  32973. * The friction of the physics imposter
  32974. */
  32975. friction?: number;
  32976. /**
  32977. * The coefficient of restitution of the physics imposter
  32978. */
  32979. restitution?: number;
  32980. /**
  32981. * The native options of the physics imposter
  32982. */
  32983. nativeOptions?: any;
  32984. /**
  32985. * Specifies if the parent should be ignored
  32986. */
  32987. ignoreParent?: boolean;
  32988. /**
  32989. * Specifies if bi-directional transformations should be disabled
  32990. */
  32991. disableBidirectionalTransformation?: boolean;
  32992. /**
  32993. * The pressure inside the physics imposter, soft object only
  32994. */
  32995. pressure?: number;
  32996. /**
  32997. * The stiffness the physics imposter, soft object only
  32998. */
  32999. stiffness?: number;
  33000. /**
  33001. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  33002. */
  33003. velocityIterations?: number;
  33004. /**
  33005. * The number of iterations used in maintaining consistent vertex positions, soft object only
  33006. */
  33007. positionIterations?: number;
  33008. /**
  33009. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  33010. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  33011. * Add to fix multiple points
  33012. */
  33013. fixedPoints?: number;
  33014. /**
  33015. * The collision margin around a soft object
  33016. */
  33017. margin?: number;
  33018. /**
  33019. * The collision margin around a soft object
  33020. */
  33021. damping?: number;
  33022. /**
  33023. * The path for a rope based on an extrusion
  33024. */
  33025. path?: any;
  33026. /**
  33027. * The shape of an extrusion used for a rope based on an extrusion
  33028. */
  33029. shape?: any;
  33030. }
  33031. /**
  33032. * Interface for a physics-enabled object
  33033. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33034. */
  33035. export interface IPhysicsEnabledObject {
  33036. /**
  33037. * The position of the physics-enabled object
  33038. */
  33039. position: Vector3;
  33040. /**
  33041. * The rotation of the physics-enabled object
  33042. */
  33043. rotationQuaternion: Nullable<Quaternion>;
  33044. /**
  33045. * The scale of the physics-enabled object
  33046. */
  33047. scaling: Vector3;
  33048. /**
  33049. * The rotation of the physics-enabled object
  33050. */
  33051. rotation?: Vector3;
  33052. /**
  33053. * The parent of the physics-enabled object
  33054. */
  33055. parent?: any;
  33056. /**
  33057. * The bounding info of the physics-enabled object
  33058. * @returns The bounding info of the physics-enabled object
  33059. */
  33060. getBoundingInfo(): BoundingInfo;
  33061. /**
  33062. * Computes the world matrix
  33063. * @param force Specifies if the world matrix should be computed by force
  33064. * @returns A world matrix
  33065. */
  33066. computeWorldMatrix(force: boolean): Matrix;
  33067. /**
  33068. * Gets the world matrix
  33069. * @returns A world matrix
  33070. */
  33071. getWorldMatrix?(): Matrix;
  33072. /**
  33073. * Gets the child meshes
  33074. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  33075. * @returns An array of abstract meshes
  33076. */
  33077. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  33078. /**
  33079. * Gets the vertex data
  33080. * @param kind The type of vertex data
  33081. * @returns A nullable array of numbers, or a float32 array
  33082. */
  33083. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  33084. /**
  33085. * Gets the indices from the mesh
  33086. * @returns A nullable array of index arrays
  33087. */
  33088. getIndices?(): Nullable<IndicesArray>;
  33089. /**
  33090. * Gets the scene from the mesh
  33091. * @returns the indices array or null
  33092. */
  33093. getScene?(): Scene;
  33094. /**
  33095. * Gets the absolute position from the mesh
  33096. * @returns the absolute position
  33097. */
  33098. getAbsolutePosition(): Vector3;
  33099. /**
  33100. * Gets the absolute pivot point from the mesh
  33101. * @returns the absolute pivot point
  33102. */
  33103. getAbsolutePivotPoint(): Vector3;
  33104. /**
  33105. * Rotates the mesh
  33106. * @param axis The axis of rotation
  33107. * @param amount The amount of rotation
  33108. * @param space The space of the rotation
  33109. * @returns The rotation transform node
  33110. */
  33111. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  33112. /**
  33113. * Translates the mesh
  33114. * @param axis The axis of translation
  33115. * @param distance The distance of translation
  33116. * @param space The space of the translation
  33117. * @returns The transform node
  33118. */
  33119. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  33120. /**
  33121. * Sets the absolute position of the mesh
  33122. * @param absolutePosition The absolute position of the mesh
  33123. * @returns The transform node
  33124. */
  33125. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33126. /**
  33127. * Gets the class name of the mesh
  33128. * @returns The class name
  33129. */
  33130. getClassName(): string;
  33131. }
  33132. /**
  33133. * Represents a physics imposter
  33134. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33135. */
  33136. export class PhysicsImpostor {
  33137. /**
  33138. * The physics-enabled object used as the physics imposter
  33139. */
  33140. object: IPhysicsEnabledObject;
  33141. /**
  33142. * The type of the physics imposter
  33143. */
  33144. type: number;
  33145. private _options;
  33146. private _scene?;
  33147. /**
  33148. * The default object size of the imposter
  33149. */
  33150. static DEFAULT_OBJECT_SIZE: Vector3;
  33151. /**
  33152. * The identity quaternion of the imposter
  33153. */
  33154. static IDENTITY_QUATERNION: Quaternion;
  33155. /** @hidden */
  33156. _pluginData: any;
  33157. private _physicsEngine;
  33158. private _physicsBody;
  33159. private _bodyUpdateRequired;
  33160. private _onBeforePhysicsStepCallbacks;
  33161. private _onAfterPhysicsStepCallbacks;
  33162. /** @hidden */
  33163. _onPhysicsCollideCallbacks: Array<{
  33164. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  33165. otherImpostors: Array<PhysicsImpostor>;
  33166. }>;
  33167. private _deltaPosition;
  33168. private _deltaRotation;
  33169. private _deltaRotationConjugated;
  33170. /** @hidden */
  33171. _isFromLine: boolean;
  33172. private _parent;
  33173. private _isDisposed;
  33174. private static _tmpVecs;
  33175. private static _tmpQuat;
  33176. /**
  33177. * Specifies if the physics imposter is disposed
  33178. */
  33179. get isDisposed(): boolean;
  33180. /**
  33181. * Gets the mass of the physics imposter
  33182. */
  33183. get mass(): number;
  33184. set mass(value: number);
  33185. /**
  33186. * Gets the coefficient of friction
  33187. */
  33188. get friction(): number;
  33189. /**
  33190. * Sets the coefficient of friction
  33191. */
  33192. set friction(value: number);
  33193. /**
  33194. * Gets the coefficient of restitution
  33195. */
  33196. get restitution(): number;
  33197. /**
  33198. * Sets the coefficient of restitution
  33199. */
  33200. set restitution(value: number);
  33201. /**
  33202. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  33203. */
  33204. get pressure(): number;
  33205. /**
  33206. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  33207. */
  33208. set pressure(value: number);
  33209. /**
  33210. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33211. */
  33212. get stiffness(): number;
  33213. /**
  33214. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33215. */
  33216. set stiffness(value: number);
  33217. /**
  33218. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33219. */
  33220. get velocityIterations(): number;
  33221. /**
  33222. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33223. */
  33224. set velocityIterations(value: number);
  33225. /**
  33226. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33227. */
  33228. get positionIterations(): number;
  33229. /**
  33230. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33231. */
  33232. set positionIterations(value: number);
  33233. /**
  33234. * The unique id of the physics imposter
  33235. * set by the physics engine when adding this impostor to the array
  33236. */
  33237. uniqueId: number;
  33238. /**
  33239. * @hidden
  33240. */
  33241. soft: boolean;
  33242. /**
  33243. * @hidden
  33244. */
  33245. segments: number;
  33246. private _joints;
  33247. /**
  33248. * Initializes the physics imposter
  33249. * @param object The physics-enabled object used as the physics imposter
  33250. * @param type The type of the physics imposter
  33251. * @param _options The options for the physics imposter
  33252. * @param _scene The Babylon scene
  33253. */
  33254. constructor(
  33255. /**
  33256. * The physics-enabled object used as the physics imposter
  33257. */
  33258. object: IPhysicsEnabledObject,
  33259. /**
  33260. * The type of the physics imposter
  33261. */
  33262. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33263. /**
  33264. * This function will completely initialize this impostor.
  33265. * It will create a new body - but only if this mesh has no parent.
  33266. * If it has, this impostor will not be used other than to define the impostor
  33267. * of the child mesh.
  33268. * @hidden
  33269. */
  33270. _init(): void;
  33271. private _getPhysicsParent;
  33272. /**
  33273. * Should a new body be generated.
  33274. * @returns boolean specifying if body initialization is required
  33275. */
  33276. isBodyInitRequired(): boolean;
  33277. /**
  33278. * Sets the updated scaling
  33279. * @param updated Specifies if the scaling is updated
  33280. */
  33281. setScalingUpdated(): void;
  33282. /**
  33283. * Force a regeneration of this or the parent's impostor's body.
  33284. * Use under cautious - This will remove all joints already implemented.
  33285. */
  33286. forceUpdate(): void;
  33287. /**
  33288. * Gets the body that holds this impostor. Either its own, or its parent.
  33289. */
  33290. get physicsBody(): any;
  33291. /**
  33292. * Get the parent of the physics imposter
  33293. * @returns Physics imposter or null
  33294. */
  33295. get parent(): Nullable<PhysicsImpostor>;
  33296. /**
  33297. * Sets the parent of the physics imposter
  33298. */
  33299. set parent(value: Nullable<PhysicsImpostor>);
  33300. /**
  33301. * Set the physics body. Used mainly by the physics engine/plugin
  33302. */
  33303. set physicsBody(physicsBody: any);
  33304. /**
  33305. * Resets the update flags
  33306. */
  33307. resetUpdateFlags(): void;
  33308. /**
  33309. * Gets the object extend size
  33310. * @returns the object extend size
  33311. */
  33312. getObjectExtendSize(): Vector3;
  33313. /**
  33314. * Gets the object center
  33315. * @returns The object center
  33316. */
  33317. getObjectCenter(): Vector3;
  33318. /**
  33319. * Get a specific parameter from the options parameters
  33320. * @param paramName The object parameter name
  33321. * @returns The object parameter
  33322. */
  33323. getParam(paramName: string): any;
  33324. /**
  33325. * Sets a specific parameter in the options given to the physics plugin
  33326. * @param paramName The parameter name
  33327. * @param value The value of the parameter
  33328. */
  33329. setParam(paramName: string, value: number): void;
  33330. /**
  33331. * Specifically change the body's mass option. Won't recreate the physics body object
  33332. * @param mass The mass of the physics imposter
  33333. */
  33334. setMass(mass: number): void;
  33335. /**
  33336. * Gets the linear velocity
  33337. * @returns linear velocity or null
  33338. */
  33339. getLinearVelocity(): Nullable<Vector3>;
  33340. /**
  33341. * Sets the linear velocity
  33342. * @param velocity linear velocity or null
  33343. */
  33344. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33345. /**
  33346. * Gets the angular velocity
  33347. * @returns angular velocity or null
  33348. */
  33349. getAngularVelocity(): Nullable<Vector3>;
  33350. /**
  33351. * Sets the angular velocity
  33352. * @param velocity The velocity or null
  33353. */
  33354. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33355. /**
  33356. * Execute a function with the physics plugin native code
  33357. * Provide a function the will have two variables - the world object and the physics body object
  33358. * @param func The function to execute with the physics plugin native code
  33359. */
  33360. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33361. /**
  33362. * Register a function that will be executed before the physics world is stepping forward
  33363. * @param func The function to execute before the physics world is stepped forward
  33364. */
  33365. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33366. /**
  33367. * Unregister a function that will be executed before the physics world is stepping forward
  33368. * @param func The function to execute before the physics world is stepped forward
  33369. */
  33370. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33371. /**
  33372. * Register a function that will be executed after the physics step
  33373. * @param func The function to execute after physics step
  33374. */
  33375. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33376. /**
  33377. * Unregisters a function that will be executed after the physics step
  33378. * @param func The function to execute after physics step
  33379. */
  33380. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33381. /**
  33382. * register a function that will be executed when this impostor collides against a different body
  33383. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33384. * @param func Callback that is executed on collision
  33385. */
  33386. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33387. /**
  33388. * Unregisters the physics imposter on contact
  33389. * @param collideAgainst The physics object to collide against
  33390. * @param func Callback to execute on collision
  33391. */
  33392. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33393. private _tmpQuat;
  33394. private _tmpQuat2;
  33395. /**
  33396. * Get the parent rotation
  33397. * @returns The parent rotation
  33398. */
  33399. getParentsRotation(): Quaternion;
  33400. /**
  33401. * this function is executed by the physics engine.
  33402. */
  33403. beforeStep: () => void;
  33404. /**
  33405. * this function is executed by the physics engine
  33406. */
  33407. afterStep: () => void;
  33408. /**
  33409. * Legacy collision detection event support
  33410. */
  33411. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33412. /**
  33413. * event and body object due to cannon's event-based architecture.
  33414. */
  33415. onCollide: (e: {
  33416. body: any;
  33417. point: Nullable<Vector3>;
  33418. }) => void;
  33419. /**
  33420. * Apply a force
  33421. * @param force The force to apply
  33422. * @param contactPoint The contact point for the force
  33423. * @returns The physics imposter
  33424. */
  33425. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33426. /**
  33427. * Apply an impulse
  33428. * @param force The impulse force
  33429. * @param contactPoint The contact point for the impulse force
  33430. * @returns The physics imposter
  33431. */
  33432. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33433. /**
  33434. * A help function to create a joint
  33435. * @param otherImpostor A physics imposter used to create a joint
  33436. * @param jointType The type of joint
  33437. * @param jointData The data for the joint
  33438. * @returns The physics imposter
  33439. */
  33440. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33441. /**
  33442. * Add a joint to this impostor with a different impostor
  33443. * @param otherImpostor A physics imposter used to add a joint
  33444. * @param joint The joint to add
  33445. * @returns The physics imposter
  33446. */
  33447. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33448. /**
  33449. * Add an anchor to a cloth impostor
  33450. * @param otherImpostor rigid impostor to anchor to
  33451. * @param width ratio across width from 0 to 1
  33452. * @param height ratio up height from 0 to 1
  33453. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little stretch
  33454. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  33455. * @returns impostor the soft imposter
  33456. */
  33457. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33458. /**
  33459. * Add a hook to a rope impostor
  33460. * @param otherImpostor rigid impostor to anchor to
  33461. * @param length ratio across rope from 0 to 1
  33462. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little stretch
  33463. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  33464. * @returns impostor the rope imposter
  33465. */
  33466. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33467. /**
  33468. * Will keep this body still, in a sleep mode.
  33469. * @returns the physics imposter
  33470. */
  33471. sleep(): PhysicsImpostor;
  33472. /**
  33473. * Wake the body up.
  33474. * @returns The physics imposter
  33475. */
  33476. wakeUp(): PhysicsImpostor;
  33477. /**
  33478. * Clones the physics imposter
  33479. * @param newObject The physics imposter clones to this physics-enabled object
  33480. * @returns A nullable physics imposter
  33481. */
  33482. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33483. /**
  33484. * Disposes the physics imposter
  33485. */
  33486. dispose(): void;
  33487. /**
  33488. * Sets the delta position
  33489. * @param position The delta position amount
  33490. */
  33491. setDeltaPosition(position: Vector3): void;
  33492. /**
  33493. * Sets the delta rotation
  33494. * @param rotation The delta rotation amount
  33495. */
  33496. setDeltaRotation(rotation: Quaternion): void;
  33497. /**
  33498. * Gets the box size of the physics imposter and stores the result in the input parameter
  33499. * @param result Stores the box size
  33500. * @returns The physics imposter
  33501. */
  33502. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33503. /**
  33504. * Gets the radius of the physics imposter
  33505. * @returns Radius of the physics imposter
  33506. */
  33507. getRadius(): number;
  33508. /**
  33509. * Sync a bone with this impostor
  33510. * @param bone The bone to sync to the impostor.
  33511. * @param boneMesh The mesh that the bone is influencing.
  33512. * @param jointPivot The pivot of the joint / bone in local space.
  33513. * @param distToJoint Optional distance from the impostor to the joint.
  33514. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33515. */
  33516. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33517. /**
  33518. * Sync impostor to a bone
  33519. * @param bone The bone that the impostor will be synced to.
  33520. * @param boneMesh The mesh that the bone is influencing.
  33521. * @param jointPivot The pivot of the joint / bone in local space.
  33522. * @param distToJoint Optional distance from the impostor to the joint.
  33523. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33524. * @param boneAxis Optional vector3 axis the bone is aligned with
  33525. */
  33526. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33527. /**
  33528. * No-Imposter type
  33529. */
  33530. static NoImpostor: number;
  33531. /**
  33532. * Sphere-Imposter type
  33533. */
  33534. static SphereImpostor: number;
  33535. /**
  33536. * Box-Imposter type
  33537. */
  33538. static BoxImpostor: number;
  33539. /**
  33540. * Plane-Imposter type
  33541. */
  33542. static PlaneImpostor: number;
  33543. /**
  33544. * Mesh-imposter type
  33545. */
  33546. static MeshImpostor: number;
  33547. /**
  33548. * Capsule-Impostor type (Ammo.js plugin only)
  33549. */
  33550. static CapsuleImpostor: number;
  33551. /**
  33552. * Cylinder-Imposter type
  33553. */
  33554. static CylinderImpostor: number;
  33555. /**
  33556. * Particle-Imposter type
  33557. */
  33558. static ParticleImpostor: number;
  33559. /**
  33560. * Heightmap-Imposter type
  33561. */
  33562. static HeightmapImpostor: number;
  33563. /**
  33564. * ConvexHull-Impostor type (Ammo.js plugin only)
  33565. */
  33566. static ConvexHullImpostor: number;
  33567. /**
  33568. * Custom-Imposter type (Ammo.js plugin only)
  33569. */
  33570. static CustomImpostor: number;
  33571. /**
  33572. * Rope-Imposter type
  33573. */
  33574. static RopeImpostor: number;
  33575. /**
  33576. * Cloth-Imposter type
  33577. */
  33578. static ClothImpostor: number;
  33579. /**
  33580. * Softbody-Imposter type
  33581. */
  33582. static SoftbodyImpostor: number;
  33583. }
  33584. }
  33585. declare module BABYLON {
  33586. /**
  33587. * @hidden
  33588. **/
  33589. export class _CreationDataStorage {
  33590. closePath?: boolean;
  33591. closeArray?: boolean;
  33592. idx: number[];
  33593. dashSize: number;
  33594. gapSize: number;
  33595. path3D: Path3D;
  33596. pathArray: Vector3[][];
  33597. arc: number;
  33598. radius: number;
  33599. cap: number;
  33600. tessellation: number;
  33601. }
  33602. /**
  33603. * @hidden
  33604. **/
  33605. class _InstanceDataStorage {
  33606. visibleInstances: any;
  33607. batchCache: _InstancesBatch;
  33608. instancesBufferSize: number;
  33609. instancesBuffer: Nullable<Buffer>;
  33610. instancesData: Float32Array;
  33611. overridenInstanceCount: number;
  33612. isFrozen: boolean;
  33613. previousBatch: Nullable<_InstancesBatch>;
  33614. hardwareInstancedRendering: boolean;
  33615. sideOrientation: number;
  33616. manualUpdate: boolean;
  33617. previousRenderId: number;
  33618. }
  33619. /**
  33620. * @hidden
  33621. **/
  33622. export class _InstancesBatch {
  33623. mustReturn: boolean;
  33624. visibleInstances: Nullable<InstancedMesh[]>[];
  33625. renderSelf: boolean[];
  33626. hardwareInstancedRendering: boolean[];
  33627. }
  33628. /**
  33629. * @hidden
  33630. **/
  33631. class _ThinInstanceDataStorage {
  33632. instancesCount: number;
  33633. matrixBuffer: Nullable<Buffer>;
  33634. matrixBufferSize: number;
  33635. matrixData: Nullable<Float32Array>;
  33636. boundingVectors: Array<Vector3>;
  33637. worldMatrices: Nullable<Matrix[]>;
  33638. }
  33639. /**
  33640. * Class used to represent renderable models
  33641. */
  33642. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  33643. /**
  33644. * Mesh side orientation : usually the external or front surface
  33645. */
  33646. static readonly FRONTSIDE: number;
  33647. /**
  33648. * Mesh side orientation : usually the internal or back surface
  33649. */
  33650. static readonly BACKSIDE: number;
  33651. /**
  33652. * Mesh side orientation : both internal and external or front and back surfaces
  33653. */
  33654. static readonly DOUBLESIDE: number;
  33655. /**
  33656. * Mesh side orientation : by default, `FRONTSIDE`
  33657. */
  33658. static readonly DEFAULTSIDE: number;
  33659. /**
  33660. * Mesh cap setting : no cap
  33661. */
  33662. static readonly NO_CAP: number;
  33663. /**
  33664. * Mesh cap setting : one cap at the beginning of the mesh
  33665. */
  33666. static readonly CAP_START: number;
  33667. /**
  33668. * Mesh cap setting : one cap at the end of the mesh
  33669. */
  33670. static readonly CAP_END: number;
  33671. /**
  33672. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  33673. */
  33674. static readonly CAP_ALL: number;
  33675. /**
  33676. * Mesh pattern setting : no flip or rotate
  33677. */
  33678. static readonly NO_FLIP: number;
  33679. /**
  33680. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  33681. */
  33682. static readonly FLIP_TILE: number;
  33683. /**
  33684. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  33685. */
  33686. static readonly ROTATE_TILE: number;
  33687. /**
  33688. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  33689. */
  33690. static readonly FLIP_ROW: number;
  33691. /**
  33692. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  33693. */
  33694. static readonly ROTATE_ROW: number;
  33695. /**
  33696. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  33697. */
  33698. static readonly FLIP_N_ROTATE_TILE: number;
  33699. /**
  33700. * Mesh pattern setting : rotate pattern and rotate
  33701. */
  33702. static readonly FLIP_N_ROTATE_ROW: number;
  33703. /**
  33704. * Mesh tile positioning : part tiles same on left/right or top/bottom
  33705. */
  33706. static readonly CENTER: number;
  33707. /**
  33708. * Mesh tile positioning : part tiles on left
  33709. */
  33710. static readonly LEFT: number;
  33711. /**
  33712. * Mesh tile positioning : part tiles on right
  33713. */
  33714. static readonly RIGHT: number;
  33715. /**
  33716. * Mesh tile positioning : part tiles on top
  33717. */
  33718. static readonly TOP: number;
  33719. /**
  33720. * Mesh tile positioning : part tiles on bottom
  33721. */
  33722. static readonly BOTTOM: number;
  33723. /**
  33724. * Gets the default side orientation.
  33725. * @param orientation the orientation to value to attempt to get
  33726. * @returns the default orientation
  33727. * @hidden
  33728. */
  33729. static _GetDefaultSideOrientation(orientation?: number): number;
  33730. private _internalMeshDataInfo;
  33731. get computeBonesUsingShaders(): boolean;
  33732. set computeBonesUsingShaders(value: boolean);
  33733. /**
  33734. * An event triggered before rendering the mesh
  33735. */
  33736. get onBeforeRenderObservable(): Observable<Mesh>;
  33737. /**
  33738. * An event triggered before binding the mesh
  33739. */
  33740. get onBeforeBindObservable(): Observable<Mesh>;
  33741. /**
  33742. * An event triggered after rendering the mesh
  33743. */
  33744. get onAfterRenderObservable(): Observable<Mesh>;
  33745. /**
  33746. * An event triggeredbetween rendering pass wneh using separateCullingPass = true
  33747. */
  33748. get onBetweenPassObservable(): Observable<Mesh>;
  33749. /**
  33750. * An event triggered before drawing the mesh
  33751. */
  33752. get onBeforeDrawObservable(): Observable<Mesh>;
  33753. private _onBeforeDrawObserver;
  33754. /**
  33755. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  33756. */
  33757. set onBeforeDraw(callback: () => void);
  33758. get hasInstances(): boolean;
  33759. get hasThinInstances(): boolean;
  33760. /**
  33761. * Gets the delay loading state of the mesh (when delay loading is turned on)
  33762. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  33763. */
  33764. delayLoadState: number;
  33765. /**
  33766. * Gets the list of instances created from this mesh
  33767. * it is not supposed to be modified manually.
  33768. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  33769. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33770. */
  33771. instances: InstancedMesh[];
  33772. /**
  33773. * Gets the file containing delay loading data for this mesh
  33774. */
  33775. delayLoadingFile: string;
  33776. /** @hidden */
  33777. _binaryInfo: any;
  33778. /**
  33779. * User defined function used to change how LOD level selection is done
  33780. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33781. */
  33782. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  33783. /**
  33784. * Gets or sets the morph target manager
  33785. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  33786. */
  33787. get morphTargetManager(): Nullable<MorphTargetManager>;
  33788. set morphTargetManager(value: Nullable<MorphTargetManager>);
  33789. /** @hidden */
  33790. _creationDataStorage: Nullable<_CreationDataStorage>;
  33791. /** @hidden */
  33792. _geometry: Nullable<Geometry>;
  33793. /** @hidden */
  33794. _delayInfo: Array<string>;
  33795. /** @hidden */
  33796. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  33797. /** @hidden */
  33798. _instanceDataStorage: _InstanceDataStorage;
  33799. /** @hidden */
  33800. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  33801. private _effectiveMaterial;
  33802. /** @hidden */
  33803. _shouldGenerateFlatShading: boolean;
  33804. /** @hidden */
  33805. _originalBuilderSideOrientation: number;
  33806. /**
  33807. * Use this property to change the original side orientation defined at construction time
  33808. */
  33809. overrideMaterialSideOrientation: Nullable<number>;
  33810. /**
  33811. * Gets or sets a boolean indicating whether to render ignoring the active camera's max z setting. (false by default)
  33812. * Note this will reduce performance when set to true.
  33813. */
  33814. ignoreCameraMaxZ: boolean;
  33815. /**
  33816. * Gets the source mesh (the one used to clone this one from)
  33817. */
  33818. get source(): Nullable<Mesh>;
  33819. /**
  33820. * Gets the list of clones of this mesh
  33821. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  33822. * Note that useClonedMeshMap=true is the default setting
  33823. */
  33824. get cloneMeshMap(): Nullable<{
  33825. [id: string]: Mesh | undefined;
  33826. }>;
  33827. /**
  33828. * Gets or sets a boolean indicating that this mesh does not use index buffer
  33829. */
  33830. get isUnIndexed(): boolean;
  33831. set isUnIndexed(value: boolean);
  33832. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  33833. get worldMatrixInstancedBuffer(): Float32Array;
  33834. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  33835. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  33836. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  33837. /**
  33838. * @constructor
  33839. * @param name The value used by scene.getMeshByName() to do a lookup.
  33840. * @param scene The scene to add this mesh to.
  33841. * @param parent The parent of this mesh, if it has one
  33842. * @param source An optional Mesh from which geometry is shared, cloned.
  33843. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  33844. * When false, achieved by calling a clone(), also passing False.
  33845. * This will make creation of children, recursive.
  33846. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  33847. */
  33848. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  33849. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  33850. doNotInstantiate: boolean;
  33851. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  33852. /**
  33853. * Gets the class name
  33854. * @returns the string "Mesh".
  33855. */
  33856. getClassName(): string;
  33857. /** @hidden */
  33858. get _isMesh(): boolean;
  33859. /**
  33860. * Returns a description of this mesh
  33861. * @param fullDetails define if full details about this mesh must be used
  33862. * @returns a descriptive string representing this mesh
  33863. */
  33864. toString(fullDetails?: boolean): string;
  33865. /** @hidden */
  33866. _unBindEffect(): void;
  33867. /**
  33868. * Gets a boolean indicating if this mesh has LOD
  33869. */
  33870. get hasLODLevels(): boolean;
  33871. /**
  33872. * Gets the list of MeshLODLevel associated with the current mesh
  33873. * @returns an array of MeshLODLevel
  33874. */
  33875. getLODLevels(): MeshLODLevel[];
  33876. private _sortLODLevels;
  33877. /**
  33878. * Add a mesh as LOD level triggered at the given distance.
  33879. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33880. * @param distance The distance from the center of the object to show this level
  33881. * @param mesh The mesh to be added as LOD level (can be null)
  33882. * @return This mesh (for chaining)
  33883. */
  33884. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  33885. /**
  33886. * Returns the LOD level mesh at the passed distance or null if not found.
  33887. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33888. * @param distance The distance from the center of the object to show this level
  33889. * @returns a Mesh or `null`
  33890. */
  33891. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  33892. /**
  33893. * Remove a mesh from the LOD array
  33894. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33895. * @param mesh defines the mesh to be removed
  33896. * @return This mesh (for chaining)
  33897. */
  33898. removeLODLevel(mesh: Mesh): Mesh;
  33899. /**
  33900. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  33901. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33902. * @param camera defines the camera to use to compute distance
  33903. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  33904. * @return This mesh (for chaining)
  33905. */
  33906. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  33907. /**
  33908. * Gets the mesh internal Geometry object
  33909. */
  33910. get geometry(): Nullable<Geometry>;
  33911. /**
  33912. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  33913. * @returns the total number of vertices
  33914. */
  33915. getTotalVertices(): number;
  33916. /**
  33917. * Returns the content of an associated vertex buffer
  33918. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33919. * - VertexBuffer.PositionKind
  33920. * - VertexBuffer.UVKind
  33921. * - VertexBuffer.UV2Kind
  33922. * - VertexBuffer.UV3Kind
  33923. * - VertexBuffer.UV4Kind
  33924. * - VertexBuffer.UV5Kind
  33925. * - VertexBuffer.UV6Kind
  33926. * - VertexBuffer.ColorKind
  33927. * - VertexBuffer.MatricesIndicesKind
  33928. * - VertexBuffer.MatricesIndicesExtraKind
  33929. * - VertexBuffer.MatricesWeightsKind
  33930. * - VertexBuffer.MatricesWeightsExtraKind
  33931. * @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
  33932. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  33933. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  33934. */
  33935. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33936. /**
  33937. * Returns the mesh VertexBuffer object from the requested `kind`
  33938. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33939. * - VertexBuffer.PositionKind
  33940. * - VertexBuffer.NormalKind
  33941. * - VertexBuffer.UVKind
  33942. * - VertexBuffer.UV2Kind
  33943. * - VertexBuffer.UV3Kind
  33944. * - VertexBuffer.UV4Kind
  33945. * - VertexBuffer.UV5Kind
  33946. * - VertexBuffer.UV6Kind
  33947. * - VertexBuffer.ColorKind
  33948. * - VertexBuffer.MatricesIndicesKind
  33949. * - VertexBuffer.MatricesIndicesExtraKind
  33950. * - VertexBuffer.MatricesWeightsKind
  33951. * - VertexBuffer.MatricesWeightsExtraKind
  33952. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  33953. */
  33954. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  33955. /**
  33956. * Tests if a specific vertex buffer is associated with this mesh
  33957. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33958. * - VertexBuffer.PositionKind
  33959. * - VertexBuffer.NormalKind
  33960. * - VertexBuffer.UVKind
  33961. * - VertexBuffer.UV2Kind
  33962. * - VertexBuffer.UV3Kind
  33963. * - VertexBuffer.UV4Kind
  33964. * - VertexBuffer.UV5Kind
  33965. * - VertexBuffer.UV6Kind
  33966. * - VertexBuffer.ColorKind
  33967. * - VertexBuffer.MatricesIndicesKind
  33968. * - VertexBuffer.MatricesIndicesExtraKind
  33969. * - VertexBuffer.MatricesWeightsKind
  33970. * - VertexBuffer.MatricesWeightsExtraKind
  33971. * @returns a boolean
  33972. */
  33973. isVerticesDataPresent(kind: string): boolean;
  33974. /**
  33975. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  33976. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33977. * - VertexBuffer.PositionKind
  33978. * - VertexBuffer.UVKind
  33979. * - VertexBuffer.UV2Kind
  33980. * - VertexBuffer.UV3Kind
  33981. * - VertexBuffer.UV4Kind
  33982. * - VertexBuffer.UV5Kind
  33983. * - VertexBuffer.UV6Kind
  33984. * - VertexBuffer.ColorKind
  33985. * - VertexBuffer.MatricesIndicesKind
  33986. * - VertexBuffer.MatricesIndicesExtraKind
  33987. * - VertexBuffer.MatricesWeightsKind
  33988. * - VertexBuffer.MatricesWeightsExtraKind
  33989. * @returns a boolean
  33990. */
  33991. isVertexBufferUpdatable(kind: string): boolean;
  33992. /**
  33993. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  33994. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33995. * - VertexBuffer.PositionKind
  33996. * - VertexBuffer.NormalKind
  33997. * - VertexBuffer.UVKind
  33998. * - VertexBuffer.UV2Kind
  33999. * - VertexBuffer.UV3Kind
  34000. * - VertexBuffer.UV4Kind
  34001. * - VertexBuffer.UV5Kind
  34002. * - VertexBuffer.UV6Kind
  34003. * - VertexBuffer.ColorKind
  34004. * - VertexBuffer.MatricesIndicesKind
  34005. * - VertexBuffer.MatricesIndicesExtraKind
  34006. * - VertexBuffer.MatricesWeightsKind
  34007. * - VertexBuffer.MatricesWeightsExtraKind
  34008. * @returns an array of strings
  34009. */
  34010. getVerticesDataKinds(): string[];
  34011. /**
  34012. * Returns a positive integer : the total number of indices in this mesh geometry.
  34013. * @returns the numner of indices or zero if the mesh has no geometry.
  34014. */
  34015. getTotalIndices(): number;
  34016. /**
  34017. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34018. * @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.
  34019. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34020. * @returns the indices array or an empty array if the mesh has no geometry
  34021. */
  34022. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34023. get isBlocked(): boolean;
  34024. /**
  34025. * Determine if the current mesh is ready to be rendered
  34026. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34027. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  34028. * @returns true if all associated assets are ready (material, textures, shaders)
  34029. */
  34030. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  34031. /**
  34032. * 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.
  34033. */
  34034. get areNormalsFrozen(): boolean;
  34035. /**
  34036. * 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.
  34037. * @returns the current mesh
  34038. */
  34039. freezeNormals(): Mesh;
  34040. /**
  34041. * 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
  34042. * @returns the current mesh
  34043. */
  34044. unfreezeNormals(): Mesh;
  34045. /**
  34046. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  34047. */
  34048. set overridenInstanceCount(count: number);
  34049. /** @hidden */
  34050. _preActivate(): Mesh;
  34051. /** @hidden */
  34052. _preActivateForIntermediateRendering(renderId: number): Mesh;
  34053. /** @hidden */
  34054. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  34055. protected _afterComputeWorldMatrix(): void;
  34056. /** @hidden */
  34057. _postActivate(): void;
  34058. /**
  34059. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  34060. * This means the mesh underlying bounding box and sphere are recomputed.
  34061. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  34062. * @returns the current mesh
  34063. */
  34064. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  34065. /** @hidden */
  34066. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  34067. /**
  34068. * This function will subdivide the mesh into multiple submeshes
  34069. * @param count defines the expected number of submeshes
  34070. */
  34071. subdivide(count: number): void;
  34072. /**
  34073. * Copy a FloatArray into a specific associated vertex buffer
  34074. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34075. * - VertexBuffer.PositionKind
  34076. * - VertexBuffer.UVKind
  34077. * - VertexBuffer.UV2Kind
  34078. * - VertexBuffer.UV3Kind
  34079. * - VertexBuffer.UV4Kind
  34080. * - VertexBuffer.UV5Kind
  34081. * - VertexBuffer.UV6Kind
  34082. * - VertexBuffer.ColorKind
  34083. * - VertexBuffer.MatricesIndicesKind
  34084. * - VertexBuffer.MatricesIndicesExtraKind
  34085. * - VertexBuffer.MatricesWeightsKind
  34086. * - VertexBuffer.MatricesWeightsExtraKind
  34087. * @param data defines the data source
  34088. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34089. * @param stride defines the data stride size (can be null)
  34090. * @returns the current mesh
  34091. */
  34092. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  34093. /**
  34094. * Delete a vertex buffer associated with this mesh
  34095. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  34096. * - VertexBuffer.PositionKind
  34097. * - VertexBuffer.UVKind
  34098. * - VertexBuffer.UV2Kind
  34099. * - VertexBuffer.UV3Kind
  34100. * - VertexBuffer.UV4Kind
  34101. * - VertexBuffer.UV5Kind
  34102. * - VertexBuffer.UV6Kind
  34103. * - VertexBuffer.ColorKind
  34104. * - VertexBuffer.MatricesIndicesKind
  34105. * - VertexBuffer.MatricesIndicesExtraKind
  34106. * - VertexBuffer.MatricesWeightsKind
  34107. * - VertexBuffer.MatricesWeightsExtraKind
  34108. */
  34109. removeVerticesData(kind: string): void;
  34110. /**
  34111. * Flags an associated vertex buffer as updatable
  34112. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  34113. * - VertexBuffer.PositionKind
  34114. * - VertexBuffer.UVKind
  34115. * - VertexBuffer.UV2Kind
  34116. * - VertexBuffer.UV3Kind
  34117. * - VertexBuffer.UV4Kind
  34118. * - VertexBuffer.UV5Kind
  34119. * - VertexBuffer.UV6Kind
  34120. * - VertexBuffer.ColorKind
  34121. * - VertexBuffer.MatricesIndicesKind
  34122. * - VertexBuffer.MatricesIndicesExtraKind
  34123. * - VertexBuffer.MatricesWeightsKind
  34124. * - VertexBuffer.MatricesWeightsExtraKind
  34125. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34126. */
  34127. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  34128. /**
  34129. * Sets the mesh global Vertex Buffer
  34130. * @param buffer defines the buffer to use
  34131. * @returns the current mesh
  34132. */
  34133. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  34134. /**
  34135. * Update a specific associated vertex buffer
  34136. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34137. * - VertexBuffer.PositionKind
  34138. * - VertexBuffer.UVKind
  34139. * - VertexBuffer.UV2Kind
  34140. * - VertexBuffer.UV3Kind
  34141. * - VertexBuffer.UV4Kind
  34142. * - VertexBuffer.UV5Kind
  34143. * - VertexBuffer.UV6Kind
  34144. * - VertexBuffer.ColorKind
  34145. * - VertexBuffer.MatricesIndicesKind
  34146. * - VertexBuffer.MatricesIndicesExtraKind
  34147. * - VertexBuffer.MatricesWeightsKind
  34148. * - VertexBuffer.MatricesWeightsExtraKind
  34149. * @param data defines the data source
  34150. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34151. * @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)
  34152. * @returns the current mesh
  34153. */
  34154. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  34155. /**
  34156. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  34157. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  34158. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  34159. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  34160. * @returns the current mesh
  34161. */
  34162. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  34163. /**
  34164. * Creates a un-shared specific occurence of the geometry for the mesh.
  34165. * @returns the current mesh
  34166. */
  34167. makeGeometryUnique(): Mesh;
  34168. /**
  34169. * Set the index buffer of this mesh
  34170. * @param indices defines the source data
  34171. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  34172. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  34173. * @returns the current mesh
  34174. */
  34175. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  34176. /**
  34177. * Update the current index buffer
  34178. * @param indices defines the source data
  34179. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  34180. * @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)
  34181. * @returns the current mesh
  34182. */
  34183. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  34184. /**
  34185. * Invert the geometry to move from a right handed system to a left handed one.
  34186. * @returns the current mesh
  34187. */
  34188. toLeftHanded(): Mesh;
  34189. /** @hidden */
  34190. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  34191. /** @hidden */
  34192. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  34193. /**
  34194. * Registers for this mesh a javascript function called just before the rendering process
  34195. * @param func defines the function to call before rendering this mesh
  34196. * @returns the current mesh
  34197. */
  34198. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34199. /**
  34200. * Disposes a previously registered javascript function called before the rendering
  34201. * @param func defines the function to remove
  34202. * @returns the current mesh
  34203. */
  34204. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34205. /**
  34206. * Registers for this mesh a javascript function called just after the rendering is complete
  34207. * @param func defines the function to call after rendering this mesh
  34208. * @returns the current mesh
  34209. */
  34210. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34211. /**
  34212. * Disposes a previously registered javascript function called after the rendering.
  34213. * @param func defines the function to remove
  34214. * @returns the current mesh
  34215. */
  34216. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34217. /** @hidden */
  34218. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  34219. /** @hidden */
  34220. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  34221. /** @hidden */
  34222. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  34223. /** @hidden */
  34224. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  34225. /** @hidden */
  34226. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  34227. /** @hidden */
  34228. _rebuild(): void;
  34229. /** @hidden */
  34230. _freeze(): void;
  34231. /** @hidden */
  34232. _unFreeze(): void;
  34233. /**
  34234. * 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
  34235. * @param subMesh defines the subMesh to render
  34236. * @param enableAlphaMode defines if alpha mode can be changed
  34237. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  34238. * @returns the current mesh
  34239. */
  34240. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  34241. private _onBeforeDraw;
  34242. /**
  34243. * Renormalize the mesh and patch it up if there are no weights
  34244. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  34245. * However in the case of zero weights then we set just a single influence to 1.
  34246. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  34247. */
  34248. cleanMatrixWeights(): void;
  34249. private normalizeSkinFourWeights;
  34250. private normalizeSkinWeightsAndExtra;
  34251. /**
  34252. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  34253. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  34254. * the user know there was an issue with importing the mesh
  34255. * @returns a validation object with skinned, valid and report string
  34256. */
  34257. validateSkinning(): {
  34258. skinned: boolean;
  34259. valid: boolean;
  34260. report: string;
  34261. };
  34262. /** @hidden */
  34263. _checkDelayState(): Mesh;
  34264. private _queueLoad;
  34265. /**
  34266. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  34267. * A mesh is in the frustum if its bounding box intersects the frustum
  34268. * @param frustumPlanes defines the frustum to test
  34269. * @returns true if the mesh is in the frustum planes
  34270. */
  34271. isInFrustum(frustumPlanes: Plane[]): boolean;
  34272. /**
  34273. * Sets the mesh material by the material or multiMaterial `id` property
  34274. * @param id is a string identifying the material or the multiMaterial
  34275. * @returns the current mesh
  34276. */
  34277. setMaterialByID(id: string): Mesh;
  34278. /**
  34279. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  34280. * @returns an array of IAnimatable
  34281. */
  34282. getAnimatables(): IAnimatable[];
  34283. /**
  34284. * Modifies the mesh geometry according to the passed transformation matrix.
  34285. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  34286. * The mesh normals are modified using the same transformation.
  34287. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34288. * @param transform defines the transform matrix to use
  34289. * @see https://doc.babylonjs.com/resources/baking_transformations
  34290. * @returns the current mesh
  34291. */
  34292. bakeTransformIntoVertices(transform: Matrix): Mesh;
  34293. /**
  34294. * Modifies the mesh geometry according to its own current World Matrix.
  34295. * The mesh World Matrix is then reset.
  34296. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  34297. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34298. * @see https://doc.babylonjs.com/resources/baking_transformations
  34299. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  34300. * @returns the current mesh
  34301. */
  34302. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  34303. /** @hidden */
  34304. get _positions(): Nullable<Vector3[]>;
  34305. /** @hidden */
  34306. _resetPointsArrayCache(): Mesh;
  34307. /** @hidden */
  34308. _generatePointsArray(): boolean;
  34309. /**
  34310. * Returns a new Mesh object generated from the current mesh properties.
  34311. * This method must not get confused with createInstance()
  34312. * @param name is a string, the name given to the new mesh
  34313. * @param newParent can be any Node object (default `null`)
  34314. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  34315. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  34316. * @returns a new mesh
  34317. */
  34318. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  34319. /**
  34320. * Releases resources associated with this mesh.
  34321. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34322. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34323. */
  34324. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34325. /** @hidden */
  34326. _disposeInstanceSpecificData(): void;
  34327. /** @hidden */
  34328. _disposeThinInstanceSpecificData(): void;
  34329. /**
  34330. * Modifies the mesh geometry according to a displacement map.
  34331. * 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.
  34332. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34333. * @param url is a string, the URL from the image file is to be downloaded.
  34334. * @param minHeight is the lower limit of the displacement.
  34335. * @param maxHeight is the upper limit of the displacement.
  34336. * @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.
  34337. * @param uvOffset is an optional vector2 used to offset UV.
  34338. * @param uvScale is an optional vector2 used to scale UV.
  34339. * @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.
  34340. * @returns the Mesh.
  34341. */
  34342. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34343. /**
  34344. * Modifies the mesh geometry according to a displacementMap buffer.
  34345. * 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.
  34346. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34347. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  34348. * @param heightMapWidth is the width of the buffer image.
  34349. * @param heightMapHeight is the height of the buffer image.
  34350. * @param minHeight is the lower limit of the displacement.
  34351. * @param maxHeight is the upper limit of the displacement.
  34352. * @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.
  34353. * @param uvOffset is an optional vector2 used to offset UV.
  34354. * @param uvScale is an optional vector2 used to scale UV.
  34355. * @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.
  34356. * @returns the Mesh.
  34357. */
  34358. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34359. /**
  34360. * Modify the mesh to get a flat shading rendering.
  34361. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  34362. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  34363. * @returns current mesh
  34364. */
  34365. convertToFlatShadedMesh(): Mesh;
  34366. /**
  34367. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  34368. * In other words, more vertices, no more indices and a single bigger VBO.
  34369. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  34370. * @returns current mesh
  34371. */
  34372. convertToUnIndexedMesh(): Mesh;
  34373. /**
  34374. * Inverses facet orientations.
  34375. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34376. * @param flipNormals will also inverts the normals
  34377. * @returns current mesh
  34378. */
  34379. flipFaces(flipNormals?: boolean): Mesh;
  34380. /**
  34381. * Increase the number of facets and hence vertices in a mesh
  34382. * Vertex normals are interpolated from existing vertex normals
  34383. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34384. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  34385. */
  34386. increaseVertices(numberPerEdge: number): void;
  34387. /**
  34388. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  34389. * This will undo any application of covertToFlatShadedMesh
  34390. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34391. */
  34392. forceSharedVertices(): void;
  34393. /** @hidden */
  34394. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  34395. /** @hidden */
  34396. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  34397. /**
  34398. * Creates a new InstancedMesh object from the mesh model.
  34399. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  34400. * @param name defines the name of the new instance
  34401. * @returns a new InstancedMesh
  34402. */
  34403. createInstance(name: string): InstancedMesh;
  34404. /**
  34405. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  34406. * After this call, all the mesh instances have the same submeshes than the current mesh.
  34407. * @returns the current mesh
  34408. */
  34409. synchronizeInstances(): Mesh;
  34410. /**
  34411. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  34412. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  34413. * This should be used together with the simplification to avoid disappearing triangles.
  34414. * @param successCallback an optional success callback to be called after the optimization finished.
  34415. * @returns the current mesh
  34416. */
  34417. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  34418. /**
  34419. * Serialize current mesh
  34420. * @param serializationObject defines the object which will receive the serialization data
  34421. */
  34422. serialize(serializationObject: any): void;
  34423. /** @hidden */
  34424. _syncGeometryWithMorphTargetManager(): void;
  34425. /** @hidden */
  34426. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  34427. /**
  34428. * Returns a new Mesh object parsed from the source provided.
  34429. * @param parsedMesh is the source
  34430. * @param scene defines the hosting scene
  34431. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  34432. * @returns a new Mesh
  34433. */
  34434. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  34435. /**
  34436. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  34437. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34438. * @param name defines the name of the mesh to create
  34439. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  34440. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  34441. * @param closePath creates a seam between the first and the last points of each path of the path array
  34442. * @param offset is taken in account only if the `pathArray` is containing a single path
  34443. * @param scene defines the hosting scene
  34444. * @param updatable defines if the mesh must be flagged as updatable
  34445. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34446. * @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)
  34447. * @returns a new Mesh
  34448. */
  34449. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34450. /**
  34451. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  34452. * @param name defines the name of the mesh to create
  34453. * @param radius sets the radius size (float) of the polygon (default 0.5)
  34454. * @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
  34455. * @param scene defines the hosting scene
  34456. * @param updatable defines if the mesh must be flagged as updatable
  34457. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34458. * @returns a new Mesh
  34459. */
  34460. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34461. /**
  34462. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  34463. * @param name defines the name of the mesh to create
  34464. * @param size sets the size (float) of each box side (default 1)
  34465. * @param scene defines the hosting scene
  34466. * @param updatable defines if the mesh must be flagged as updatable
  34467. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34468. * @returns a new Mesh
  34469. */
  34470. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34471. /**
  34472. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  34473. * @param name defines the name of the mesh to create
  34474. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34475. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34476. * @param scene defines the hosting scene
  34477. * @param updatable defines if the mesh must be flagged as updatable
  34478. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34479. * @returns a new Mesh
  34480. */
  34481. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34482. /**
  34483. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  34484. * @param name defines the name of the mesh to create
  34485. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34486. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34487. * @param scene defines the hosting scene
  34488. * @returns a new Mesh
  34489. */
  34490. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  34491. /**
  34492. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  34493. * @param name defines the name of the mesh to create
  34494. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  34495. * @param diameterTop set the top cap diameter (floats, default 1)
  34496. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  34497. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  34498. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  34499. * @param scene defines the hosting scene
  34500. * @param updatable defines if the mesh must be flagged as updatable
  34501. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34502. * @returns a new Mesh
  34503. */
  34504. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  34505. /**
  34506. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  34507. * @param name defines the name of the mesh to create
  34508. * @param diameter sets the diameter size (float) of the torus (default 1)
  34509. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  34510. * @param tessellation sets the number of torus sides (positive integer, default 16)
  34511. * @param scene defines the hosting scene
  34512. * @param updatable defines if the mesh must be flagged as updatable
  34513. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34514. * @returns a new Mesh
  34515. */
  34516. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34517. /**
  34518. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  34519. * @param name defines the name of the mesh to create
  34520. * @param radius sets the global radius size (float) of the torus knot (default 2)
  34521. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  34522. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  34523. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  34524. * @param p the number of windings on X axis (positive integers, default 2)
  34525. * @param q the number of windings on Y axis (positive integers, default 3)
  34526. * @param scene defines the hosting scene
  34527. * @param updatable defines if the mesh must be flagged as updatable
  34528. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34529. * @returns a new Mesh
  34530. */
  34531. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34532. /**
  34533. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  34534. * @param name defines the name of the mesh to create
  34535. * @param points is an array successive Vector3
  34536. * @param scene defines the hosting scene
  34537. * @param updatable defines if the mesh must be flagged as updatable
  34538. * @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).
  34539. * @returns a new Mesh
  34540. */
  34541. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  34542. /**
  34543. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  34544. * @param name defines the name of the mesh to create
  34545. * @param points is an array successive Vector3
  34546. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  34547. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  34548. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  34549. * @param scene defines the hosting scene
  34550. * @param updatable defines if the mesh must be flagged as updatable
  34551. * @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)
  34552. * @returns a new Mesh
  34553. */
  34554. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  34555. /**
  34556. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  34557. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  34558. * 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.
  34559. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34560. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  34561. * Remember you can only change the shape positions, not their number when updating a polygon.
  34562. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  34563. * @param name defines the name of the mesh to create
  34564. * @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
  34565. * @param scene defines the hosting scene
  34566. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34567. * @param updatable defines if the mesh must be flagged as updatable
  34568. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34569. * @param earcutInjection can be used to inject your own earcut reference
  34570. * @returns a new Mesh
  34571. */
  34572. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34573. /**
  34574. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  34575. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  34576. * @param name defines the name of the mesh to create
  34577. * @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
  34578. * @param depth defines the height of extrusion
  34579. * @param scene defines the hosting scene
  34580. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34581. * @param updatable defines if the mesh must be flagged as updatable
  34582. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34583. * @param earcutInjection can be used to inject your own earcut reference
  34584. * @returns a new Mesh
  34585. */
  34586. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34587. /**
  34588. * Creates an extruded shape mesh.
  34589. * 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
  34590. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34591. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34592. * @param name defines the name of the mesh to create
  34593. * @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
  34594. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34595. * @param scale is the value to scale the shape
  34596. * @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
  34597. * @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
  34598. * @param scene defines the hosting scene
  34599. * @param updatable defines if the mesh must be flagged as updatable
  34600. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34601. * @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)
  34602. * @returns a new Mesh
  34603. */
  34604. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34605. /**
  34606. * Creates an custom extruded shape mesh.
  34607. * The custom extrusion is a parametric shape.
  34608. * It has no predefined shape. Its final shape will depend on the input parameters.
  34609. * Please consider using the same method from the MeshBuilder class instead
  34610. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34611. * @param name defines the name of the mesh to create
  34612. * @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
  34613. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34614. * @param scaleFunction is a custom Javascript function called on each path point
  34615. * @param rotationFunction is a custom Javascript function called on each path point
  34616. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  34617. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  34618. * @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
  34619. * @param scene defines the hosting scene
  34620. * @param updatable defines if the mesh must be flagged as updatable
  34621. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34622. * @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)
  34623. * @returns a new Mesh
  34624. */
  34625. 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;
  34626. /**
  34627. * Creates lathe mesh.
  34628. * The lathe is a shape with a symmetry axis : a 2D model shape is rotated around this axis to design the lathe.
  34629. * Please consider using the same method from the MeshBuilder class instead
  34630. * @param name defines the name of the mesh to create
  34631. * @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
  34632. * @param radius is the radius value of the lathe
  34633. * @param tessellation is the side number of the lathe.
  34634. * @param scene defines the hosting scene
  34635. * @param updatable defines if the mesh must be flagged as updatable
  34636. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34637. * @returns a new Mesh
  34638. */
  34639. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34640. /**
  34641. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  34642. * @param name defines the name of the mesh to create
  34643. * @param size sets the size (float) of both sides of the plane at once (default 1)
  34644. * @param scene defines the hosting scene
  34645. * @param updatable defines if the mesh must be flagged as updatable
  34646. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34647. * @returns a new Mesh
  34648. */
  34649. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34650. /**
  34651. * Creates a ground mesh.
  34652. * Please consider using the same method from the MeshBuilder class instead
  34653. * @param name defines the name of the mesh to create
  34654. * @param width set the width of the ground
  34655. * @param height set the height of the ground
  34656. * @param subdivisions sets the number of subdivisions per side
  34657. * @param scene defines the hosting scene
  34658. * @param updatable defines if the mesh must be flagged as updatable
  34659. * @returns a new Mesh
  34660. */
  34661. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  34662. /**
  34663. * Creates a tiled ground mesh.
  34664. * Please consider using the same method from the MeshBuilder class instead
  34665. * @param name defines the name of the mesh to create
  34666. * @param xmin set the ground minimum X coordinate
  34667. * @param zmin set the ground minimum Y coordinate
  34668. * @param xmax set the ground maximum X coordinate
  34669. * @param zmax set the ground maximum Z coordinate
  34670. * @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
  34671. * @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
  34672. * @param scene defines the hosting scene
  34673. * @param updatable defines if the mesh must be flagged as updatable
  34674. * @returns a new Mesh
  34675. */
  34676. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  34677. w: number;
  34678. h: number;
  34679. }, precision: {
  34680. w: number;
  34681. h: number;
  34682. }, scene: Scene, updatable?: boolean): Mesh;
  34683. /**
  34684. * Creates a ground mesh from a height map.
  34685. * Please consider using the same method from the MeshBuilder class instead
  34686. * @see https://doc.babylonjs.com/babylon101/height_map
  34687. * @param name defines the name of the mesh to create
  34688. * @param url sets the URL of the height map image resource
  34689. * @param width set the ground width size
  34690. * @param height set the ground height size
  34691. * @param subdivisions sets the number of subdivision per side
  34692. * @param minHeight is the minimum altitude on the ground
  34693. * @param maxHeight is the maximum altitude on the ground
  34694. * @param scene defines the hosting scene
  34695. * @param updatable defines if the mesh must be flagged as updatable
  34696. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  34697. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  34698. * @returns a new Mesh
  34699. */
  34700. 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;
  34701. /**
  34702. * Creates a tube mesh.
  34703. * The tube is a parametric shape.
  34704. * It has no predefined shape. Its final shape will depend on the input parameters.
  34705. * Please consider using the same method from the MeshBuilder class instead
  34706. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34707. * @param name defines the name of the mesh to create
  34708. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  34709. * @param radius sets the tube radius size
  34710. * @param tessellation is the number of sides on the tubular surface
  34711. * @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
  34712. * @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
  34713. * @param scene defines the hosting scene
  34714. * @param updatable defines if the mesh must be flagged as updatable
  34715. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34716. * @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)
  34717. * @returns a new Mesh
  34718. */
  34719. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  34720. (i: number, distance: number): number;
  34721. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34722. /**
  34723. * Creates a polyhedron mesh.
  34724. * Please consider using the same method from the MeshBuilder class instead.
  34725. * * 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
  34726. * * The parameter `size` (positive float, default 1) sets the polygon size
  34727. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  34728. * * 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`
  34729. * * 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
  34730. * * 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)`)
  34731. * * 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
  34732. * * 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
  34733. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34734. * * 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
  34735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34736. * @param name defines the name of the mesh to create
  34737. * @param options defines the options used to create the mesh
  34738. * @param scene defines the hosting scene
  34739. * @returns a new Mesh
  34740. */
  34741. static CreatePolyhedron(name: string, options: {
  34742. type?: number;
  34743. size?: number;
  34744. sizeX?: number;
  34745. sizeY?: number;
  34746. sizeZ?: number;
  34747. custom?: any;
  34748. faceUV?: Vector4[];
  34749. faceColors?: Color4[];
  34750. updatable?: boolean;
  34751. sideOrientation?: number;
  34752. }, scene: Scene): Mesh;
  34753. /**
  34754. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  34755. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  34756. * * 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`)
  34757. * * The parameter `subdivisions` sets the number of subdivisions (positive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  34758. * * 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
  34759. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34760. * * 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
  34761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34762. * @param name defines the name of the mesh
  34763. * @param options defines the options used to create the mesh
  34764. * @param scene defines the hosting scene
  34765. * @returns a new Mesh
  34766. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  34767. */
  34768. static CreateIcoSphere(name: string, options: {
  34769. radius?: number;
  34770. flat?: boolean;
  34771. subdivisions?: number;
  34772. sideOrientation?: number;
  34773. updatable?: boolean;
  34774. }, scene: Scene): Mesh;
  34775. /**
  34776. * Creates a decal mesh.
  34777. * Please consider using the same method from the MeshBuilder class instead.
  34778. * A decal is a mesh usually applied as a model onto the surface of another mesh
  34779. * @param name defines the name of the mesh
  34780. * @param sourceMesh defines the mesh receiving the decal
  34781. * @param position sets the position of the decal in world coordinates
  34782. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  34783. * @param size sets the decal scaling
  34784. * @param angle sets the angle to rotate the decal
  34785. * @returns a new Mesh
  34786. */
  34787. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  34788. /** Creates a Capsule Mesh
  34789. * @param name defines the name of the mesh.
  34790. * @param options the constructors options used to shape the mesh.
  34791. * @param scene defines the scene the mesh is scoped to.
  34792. * @returns the capsule mesh
  34793. * @see https://doc.babylonjs.com/how_to/capsule_shape
  34794. */
  34795. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  34796. /**
  34797. * Prepare internal position array for software CPU skinning
  34798. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  34799. */
  34800. setPositionsForCPUSkinning(): Float32Array;
  34801. /**
  34802. * Prepare internal normal array for software CPU skinning
  34803. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  34804. */
  34805. setNormalsForCPUSkinning(): Float32Array;
  34806. /**
  34807. * Updates the vertex buffer by applying transformation from the bones
  34808. * @param skeleton defines the skeleton to apply to current mesh
  34809. * @returns the current mesh
  34810. */
  34811. applySkeleton(skeleton: Skeleton): Mesh;
  34812. /**
  34813. * 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
  34814. * @param meshes defines the list of meshes to scan
  34815. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  34816. */
  34817. static MinMax(meshes: AbstractMesh[]): {
  34818. min: Vector3;
  34819. max: Vector3;
  34820. };
  34821. /**
  34822. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  34823. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  34824. * @returns a vector3
  34825. */
  34826. static Center(meshesOrMinMaxVector: {
  34827. min: Vector3;
  34828. max: Vector3;
  34829. } | AbstractMesh[]): Vector3;
  34830. /**
  34831. * Merge the array of meshes into a single mesh for performance reasons.
  34832. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  34833. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  34834. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  34835. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  34836. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  34837. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  34838. * @returns a new mesh
  34839. */
  34840. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  34841. /** @hidden */
  34842. addInstance(instance: InstancedMesh): void;
  34843. /** @hidden */
  34844. removeInstance(instance: InstancedMesh): void;
  34845. }
  34846. }
  34847. declare module BABYLON {
  34848. /**
  34849. * The options Interface for creating a Capsule Mesh
  34850. */
  34851. export interface ICreateCapsuleOptions {
  34852. /** The Orientation of the capsule. Default : Vector3.Up() */
  34853. orientation?: Vector3;
  34854. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  34855. subdivisions: number;
  34856. /** Number of cylindrical segments on the capsule. */
  34857. tessellation: number;
  34858. /** Height or Length of the capsule. */
  34859. height: number;
  34860. /** Radius of the capsule. */
  34861. radius: number;
  34862. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  34863. capSubdivisions: number;
  34864. /** Overwrite for the top radius. */
  34865. radiusTop?: number;
  34866. /** Overwrite for the bottom radius. */
  34867. radiusBottom?: number;
  34868. /** Overwrite for the top capSubdivisions. */
  34869. topCapSubdivisions?: number;
  34870. /** Overwrite for the bottom capSubdivisions. */
  34871. bottomCapSubdivisions?: number;
  34872. /** Internal geometry is supposed to change once created. */
  34873. updatable?: boolean;
  34874. }
  34875. /**
  34876. * Class containing static functions to help procedurally build meshes
  34877. */
  34878. export class CapsuleBuilder {
  34879. /**
  34880. * Creates a capsule or a pill mesh
  34881. * @param name defines the name of the mesh
  34882. * @param options The constructors options.
  34883. * @param scene The scene the mesh is scoped to.
  34884. * @returns Capsule Mesh
  34885. */
  34886. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  34887. }
  34888. }
  34889. declare module BABYLON {
  34890. /**
  34891. * Define an interface for all classes that will get and set the data on vertices
  34892. */
  34893. export interface IGetSetVerticesData {
  34894. /**
  34895. * Gets a boolean indicating if specific vertex data is present
  34896. * @param kind defines the vertex data kind to use
  34897. * @returns true is data kind is present
  34898. */
  34899. isVerticesDataPresent(kind: string): boolean;
  34900. /**
  34901. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  34902. * @param kind defines the data kind (Position, normal, etc...)
  34903. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  34904. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34905. * @returns a float array containing vertex data
  34906. */
  34907. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  34908. /**
  34909. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34910. * @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.
  34911. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34912. * @returns the indices array or an empty array if the mesh has no geometry
  34913. */
  34914. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34915. /**
  34916. * Set specific vertex data
  34917. * @param kind defines the data kind (Position, normal, etc...)
  34918. * @param data defines the vertex data to use
  34919. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  34920. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  34921. */
  34922. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  34923. /**
  34924. * Update a specific associated vertex buffer
  34925. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34926. * - VertexBuffer.PositionKind
  34927. * - VertexBuffer.UVKind
  34928. * - VertexBuffer.UV2Kind
  34929. * - VertexBuffer.UV3Kind
  34930. * - VertexBuffer.UV4Kind
  34931. * - VertexBuffer.UV5Kind
  34932. * - VertexBuffer.UV6Kind
  34933. * - VertexBuffer.ColorKind
  34934. * - VertexBuffer.MatricesIndicesKind
  34935. * - VertexBuffer.MatricesIndicesExtraKind
  34936. * - VertexBuffer.MatricesWeightsKind
  34937. * - VertexBuffer.MatricesWeightsExtraKind
  34938. * @param data defines the data source
  34939. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34940. * @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)
  34941. */
  34942. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  34943. /**
  34944. * Creates a new index buffer
  34945. * @param indices defines the indices to store in the index buffer
  34946. * @param totalVertices defines the total number of vertices (could be null)
  34947. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  34948. */
  34949. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  34950. }
  34951. /**
  34952. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  34953. */
  34954. export class VertexData {
  34955. /**
  34956. * Mesh side orientation : usually the external or front surface
  34957. */
  34958. static readonly FRONTSIDE: number;
  34959. /**
  34960. * Mesh side orientation : usually the internal or back surface
  34961. */
  34962. static readonly BACKSIDE: number;
  34963. /**
  34964. * Mesh side orientation : both internal and external or front and back surfaces
  34965. */
  34966. static readonly DOUBLESIDE: number;
  34967. /**
  34968. * Mesh side orientation : by default, `FRONTSIDE`
  34969. */
  34970. static readonly DEFAULTSIDE: number;
  34971. /**
  34972. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  34973. */
  34974. positions: Nullable<FloatArray>;
  34975. /**
  34976. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  34977. */
  34978. normals: Nullable<FloatArray>;
  34979. /**
  34980. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  34981. */
  34982. tangents: Nullable<FloatArray>;
  34983. /**
  34984. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34985. */
  34986. uvs: Nullable<FloatArray>;
  34987. /**
  34988. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34989. */
  34990. uvs2: Nullable<FloatArray>;
  34991. /**
  34992. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34993. */
  34994. uvs3: Nullable<FloatArray>;
  34995. /**
  34996. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34997. */
  34998. uvs4: Nullable<FloatArray>;
  34999. /**
  35000. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  35001. */
  35002. uvs5: Nullable<FloatArray>;
  35003. /**
  35004. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  35005. */
  35006. uvs6: Nullable<FloatArray>;
  35007. /**
  35008. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  35009. */
  35010. colors: Nullable<FloatArray>;
  35011. /**
  35012. * 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).
  35013. */
  35014. matricesIndices: Nullable<FloatArray>;
  35015. /**
  35016. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  35017. */
  35018. matricesWeights: Nullable<FloatArray>;
  35019. /**
  35020. * An array extending the number of possible indices
  35021. */
  35022. matricesIndicesExtra: Nullable<FloatArray>;
  35023. /**
  35024. * An array extending the number of possible weights when the number of indices is extended
  35025. */
  35026. matricesWeightsExtra: Nullable<FloatArray>;
  35027. /**
  35028. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  35029. */
  35030. indices: Nullable<IndicesArray>;
  35031. /**
  35032. * Uses the passed data array to set the set the values for the specified kind of data
  35033. * @param data a linear array of floating numbers
  35034. * @param kind the type of data that is being set, eg positions, colors etc
  35035. */
  35036. set(data: FloatArray, kind: string): void;
  35037. /**
  35038. * Associates the vertexData to the passed Mesh.
  35039. * Sets it as updatable or not (default `false`)
  35040. * @param mesh the mesh the vertexData is applied to
  35041. * @param updatable when used and having the value true allows new data to update the vertexData
  35042. * @returns the VertexData
  35043. */
  35044. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  35045. /**
  35046. * Associates the vertexData to the passed Geometry.
  35047. * Sets it as updatable or not (default `false`)
  35048. * @param geometry the geometry the vertexData is applied to
  35049. * @param updatable when used and having the value true allows new data to update the vertexData
  35050. * @returns VertexData
  35051. */
  35052. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  35053. /**
  35054. * Updates the associated mesh
  35055. * @param mesh the mesh to be updated
  35056. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  35057. * @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
  35058. * @returns VertexData
  35059. */
  35060. updateMesh(mesh: Mesh): VertexData;
  35061. /**
  35062. * Updates the associated geometry
  35063. * @param geometry the geometry to be updated
  35064. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  35065. * @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
  35066. * @returns VertexData.
  35067. */
  35068. updateGeometry(geometry: Geometry): VertexData;
  35069. private _applyTo;
  35070. private _update;
  35071. /**
  35072. * Transforms each position and each normal of the vertexData according to the passed Matrix
  35073. * @param matrix the transforming matrix
  35074. * @returns the VertexData
  35075. */
  35076. transform(matrix: Matrix): VertexData;
  35077. /**
  35078. * Merges the passed VertexData into the current one
  35079. * @param other the VertexData to be merged into the current one
  35080. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  35081. * @returns the modified VertexData
  35082. */
  35083. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  35084. private _mergeElement;
  35085. private _validate;
  35086. /**
  35087. * Serializes the VertexData
  35088. * @returns a serialized object
  35089. */
  35090. serialize(): any;
  35091. /**
  35092. * Extracts the vertexData from a mesh
  35093. * @param mesh the mesh from which to extract the VertexData
  35094. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  35095. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  35096. * @returns the object VertexData associated to the passed mesh
  35097. */
  35098. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  35099. /**
  35100. * Extracts the vertexData from the geometry
  35101. * @param geometry the geometry from which to extract the VertexData
  35102. * @param copyWhenShared defines if the VertexData must be cloned when the geometry is shared between multiple meshes, optional, default false
  35103. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  35104. * @returns the object VertexData associated to the passed mesh
  35105. */
  35106. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  35107. private static _ExtractFrom;
  35108. /**
  35109. * Creates the VertexData for a Ribbon
  35110. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  35111. * * pathArray array of paths, each of which an array of successive Vector3
  35112. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  35113. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  35114. * * 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
  35115. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35116. * * 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)
  35117. * * 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)
  35118. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  35119. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  35120. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  35121. * @returns the VertexData of the ribbon
  35122. */
  35123. static CreateRibbon(options: {
  35124. pathArray: Vector3[][];
  35125. closeArray?: boolean;
  35126. closePath?: boolean;
  35127. offset?: number;
  35128. sideOrientation?: number;
  35129. frontUVs?: Vector4;
  35130. backUVs?: Vector4;
  35131. invertUV?: boolean;
  35132. uvs?: Vector2[];
  35133. colors?: Color4[];
  35134. }): VertexData;
  35135. /**
  35136. * Creates the VertexData for a box
  35137. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35138. * * size sets the width, height and depth of the box to the value of size, optional default 1
  35139. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  35140. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  35141. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  35142. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  35143. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  35144. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35145. * * 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)
  35146. * * 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)
  35147. * @returns the VertexData of the box
  35148. */
  35149. static CreateBox(options: {
  35150. size?: number;
  35151. width?: number;
  35152. height?: number;
  35153. depth?: number;
  35154. faceUV?: Vector4[];
  35155. faceColors?: Color4[];
  35156. sideOrientation?: number;
  35157. frontUVs?: Vector4;
  35158. backUVs?: Vector4;
  35159. }): VertexData;
  35160. /**
  35161. * Creates the VertexData for a tiled box
  35162. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35163. * * faceTiles sets the pattern, tile size and number of tiles for a face
  35164. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  35165. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  35166. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35167. * @returns the VertexData of the box
  35168. */
  35169. static CreateTiledBox(options: {
  35170. pattern?: number;
  35171. width?: number;
  35172. height?: number;
  35173. depth?: number;
  35174. tileSize?: number;
  35175. tileWidth?: number;
  35176. tileHeight?: number;
  35177. alignHorizontal?: number;
  35178. alignVertical?: number;
  35179. faceUV?: Vector4[];
  35180. faceColors?: Color4[];
  35181. sideOrientation?: number;
  35182. }): VertexData;
  35183. /**
  35184. * Creates the VertexData for a tiled plane
  35185. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35186. * * pattern a limited pattern arrangement depending on the number
  35187. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  35188. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  35189. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  35190. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35191. * * 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)
  35192. * * 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)
  35193. * @returns the VertexData of the tiled plane
  35194. */
  35195. static CreateTiledPlane(options: {
  35196. pattern?: number;
  35197. tileSize?: number;
  35198. tileWidth?: number;
  35199. tileHeight?: number;
  35200. size?: number;
  35201. width?: number;
  35202. height?: number;
  35203. alignHorizontal?: number;
  35204. alignVertical?: number;
  35205. sideOrientation?: number;
  35206. frontUVs?: Vector4;
  35207. backUVs?: Vector4;
  35208. }): VertexData;
  35209. /**
  35210. * Creates the VertexData for an ellipsoid, defaults to a sphere
  35211. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35212. * * segments sets the number of horizontal strips optional, default 32
  35213. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  35214. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  35215. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  35216. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  35217. * * 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
  35218. * * 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
  35219. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35220. * * 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)
  35221. * * 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)
  35222. * @returns the VertexData of the ellipsoid
  35223. */
  35224. static CreateSphere(options: {
  35225. segments?: number;
  35226. diameter?: number;
  35227. diameterX?: number;
  35228. diameterY?: number;
  35229. diameterZ?: number;
  35230. arc?: number;
  35231. slice?: number;
  35232. sideOrientation?: number;
  35233. frontUVs?: Vector4;
  35234. backUVs?: Vector4;
  35235. }): VertexData;
  35236. /**
  35237. * Creates the VertexData for a cylinder, cone or prism
  35238. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35239. * * height sets the height (y direction) of the cylinder, optional, default 2
  35240. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  35241. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  35242. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  35243. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  35244. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  35245. * * 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
  35246. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35247. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35248. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  35249. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  35250. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35251. * * 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)
  35252. * * 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)
  35253. * @returns the VertexData of the cylinder, cone or prism
  35254. */
  35255. static CreateCylinder(options: {
  35256. height?: number;
  35257. diameterTop?: number;
  35258. diameterBottom?: number;
  35259. diameter?: number;
  35260. tessellation?: number;
  35261. subdivisions?: number;
  35262. arc?: number;
  35263. faceColors?: Color4[];
  35264. faceUV?: Vector4[];
  35265. hasRings?: boolean;
  35266. enclose?: boolean;
  35267. sideOrientation?: number;
  35268. frontUVs?: Vector4;
  35269. backUVs?: Vector4;
  35270. }): VertexData;
  35271. /**
  35272. * Creates the VertexData for a torus
  35273. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35274. * * diameter the diameter of the torus, optional default 1
  35275. * * thickness the diameter of the tube forming the torus, optional default 0.5
  35276. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  35277. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35278. * * 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)
  35279. * * 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)
  35280. * @returns the VertexData of the torus
  35281. */
  35282. static CreateTorus(options: {
  35283. diameter?: number;
  35284. thickness?: number;
  35285. tessellation?: number;
  35286. sideOrientation?: number;
  35287. frontUVs?: Vector4;
  35288. backUVs?: Vector4;
  35289. }): VertexData;
  35290. /**
  35291. * Creates the VertexData of the LineSystem
  35292. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  35293. * - lines an array of lines, each line being an array of successive Vector3
  35294. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  35295. * @returns the VertexData of the LineSystem
  35296. */
  35297. static CreateLineSystem(options: {
  35298. lines: Vector3[][];
  35299. colors?: Nullable<Color4[][]>;
  35300. }): VertexData;
  35301. /**
  35302. * Create the VertexData for a DashedLines
  35303. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  35304. * - points an array successive Vector3
  35305. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  35306. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  35307. * - dashNb the intended total number of dashes, optional, default 200
  35308. * @returns the VertexData for the DashedLines
  35309. */
  35310. static CreateDashedLines(options: {
  35311. points: Vector3[];
  35312. dashSize?: number;
  35313. gapSize?: number;
  35314. dashNb?: number;
  35315. }): VertexData;
  35316. /**
  35317. * Creates the VertexData for a Ground
  35318. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  35319. * - width the width (x direction) of the ground, optional, default 1
  35320. * - height the height (z direction) of the ground, optional, default 1
  35321. * - subdivisions the number of subdivisions per side, optional, default 1
  35322. * @returns the VertexData of the Ground
  35323. */
  35324. static CreateGround(options: {
  35325. width?: number;
  35326. height?: number;
  35327. subdivisions?: number;
  35328. subdivisionsX?: number;
  35329. subdivisionsY?: number;
  35330. }): VertexData;
  35331. /**
  35332. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  35333. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  35334. * * xmin the ground minimum X coordinate, optional, default -1
  35335. * * zmin the ground minimum Z coordinate, optional, default -1
  35336. * * xmax the ground maximum X coordinate, optional, default 1
  35337. * * zmax the ground maximum Z coordinate, optional, default 1
  35338. * * 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}
  35339. * * 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}
  35340. * @returns the VertexData of the TiledGround
  35341. */
  35342. static CreateTiledGround(options: {
  35343. xmin: number;
  35344. zmin: number;
  35345. xmax: number;
  35346. zmax: number;
  35347. subdivisions?: {
  35348. w: number;
  35349. h: number;
  35350. };
  35351. precision?: {
  35352. w: number;
  35353. h: number;
  35354. };
  35355. }): VertexData;
  35356. /**
  35357. * Creates the VertexData of the Ground designed from a heightmap
  35358. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  35359. * * width the width (x direction) of the ground
  35360. * * height the height (z direction) of the ground
  35361. * * subdivisions the number of subdivisions per side
  35362. * * minHeight the minimum altitude on the ground, optional, default 0
  35363. * * maxHeight the maximum altitude on the ground, optional default 1
  35364. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  35365. * * buffer the array holding the image color data
  35366. * * bufferWidth the width of image
  35367. * * bufferHeight the height of image
  35368. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  35369. * @returns the VertexData of the Ground designed from a heightmap
  35370. */
  35371. static CreateGroundFromHeightMap(options: {
  35372. width: number;
  35373. height: number;
  35374. subdivisions: number;
  35375. minHeight: number;
  35376. maxHeight: number;
  35377. colorFilter: Color3;
  35378. buffer: Uint8Array;
  35379. bufferWidth: number;
  35380. bufferHeight: number;
  35381. alphaFilter: number;
  35382. }): VertexData;
  35383. /**
  35384. * Creates the VertexData for a Plane
  35385. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  35386. * * size sets the width and height of the plane to the value of size, optional default 1
  35387. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  35388. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  35389. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35390. * * 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)
  35391. * * 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)
  35392. * @returns the VertexData of the box
  35393. */
  35394. static CreatePlane(options: {
  35395. size?: number;
  35396. width?: number;
  35397. height?: number;
  35398. sideOrientation?: number;
  35399. frontUVs?: Vector4;
  35400. backUVs?: Vector4;
  35401. }): VertexData;
  35402. /**
  35403. * Creates the VertexData of the Disc or regular Polygon
  35404. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  35405. * * radius the radius of the disc, optional default 0.5
  35406. * * tessellation the number of polygon sides, optional, default 64
  35407. * * 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
  35408. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35409. * * 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)
  35410. * * 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)
  35411. * @returns the VertexData of the box
  35412. */
  35413. static CreateDisc(options: {
  35414. radius?: number;
  35415. tessellation?: number;
  35416. arc?: number;
  35417. sideOrientation?: number;
  35418. frontUVs?: Vector4;
  35419. backUVs?: Vector4;
  35420. }): VertexData;
  35421. /**
  35422. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  35423. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  35424. * @param polygon a mesh built from polygonTriangulation.build()
  35425. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35426. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35427. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35428. * @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)
  35429. * @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)
  35430. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  35431. * @returns the VertexData of the Polygon
  35432. */
  35433. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  35434. /**
  35435. * Creates the VertexData of the IcoSphere
  35436. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  35437. * * radius the radius of the IcoSphere, optional default 1
  35438. * * radiusX allows stretching in the x direction, optional, default radius
  35439. * * radiusY allows stretching in the y direction, optional, default radius
  35440. * * radiusZ allows stretching in the z direction, optional, default radius
  35441. * * flat when true creates a flat shaded mesh, optional, default true
  35442. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  35443. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35444. * * 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)
  35445. * * 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)
  35446. * @returns the VertexData of the IcoSphere
  35447. */
  35448. static CreateIcoSphere(options: {
  35449. radius?: number;
  35450. radiusX?: number;
  35451. radiusY?: number;
  35452. radiusZ?: number;
  35453. flat?: boolean;
  35454. subdivisions?: number;
  35455. sideOrientation?: number;
  35456. frontUVs?: Vector4;
  35457. backUVs?: Vector4;
  35458. }): VertexData;
  35459. /**
  35460. * Creates the VertexData for a Polyhedron
  35461. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  35462. * * type provided types are:
  35463. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  35464. * * 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)
  35465. * * size the size of the IcoSphere, optional default 1
  35466. * * sizeX allows stretching in the x direction, optional, default size
  35467. * * sizeY allows stretching in the y direction, optional, default size
  35468. * * sizeZ allows stretching in the z direction, optional, default size
  35469. * * 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
  35470. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35471. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35472. * * flat when true creates a flat shaded mesh, optional, default true
  35473. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  35474. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35475. * * 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)
  35476. * * 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)
  35477. * @returns the VertexData of the Polyhedron
  35478. */
  35479. static CreatePolyhedron(options: {
  35480. type?: number;
  35481. size?: number;
  35482. sizeX?: number;
  35483. sizeY?: number;
  35484. sizeZ?: number;
  35485. custom?: any;
  35486. faceUV?: Vector4[];
  35487. faceColors?: Color4[];
  35488. flat?: boolean;
  35489. sideOrientation?: number;
  35490. frontUVs?: Vector4;
  35491. backUVs?: Vector4;
  35492. }): VertexData;
  35493. /**
  35494. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  35495. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  35496. * @returns the VertexData of the Capsule
  35497. */
  35498. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  35499. /**
  35500. * Creates the VertexData for a TorusKnot
  35501. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  35502. * * radius the radius of the torus knot, optional, default 2
  35503. * * tube the thickness of the tube, optional, default 0.5
  35504. * * radialSegments the number of sides on each tube segments, optional, default 32
  35505. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  35506. * * p the number of windings around the z axis, optional, default 2
  35507. * * q the number of windings around the x axis, optional, default 3
  35508. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35509. * * 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)
  35510. * * 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)
  35511. * @returns the VertexData of the Torus Knot
  35512. */
  35513. static CreateTorusKnot(options: {
  35514. radius?: number;
  35515. tube?: number;
  35516. radialSegments?: number;
  35517. tubularSegments?: number;
  35518. p?: number;
  35519. q?: number;
  35520. sideOrientation?: number;
  35521. frontUVs?: Vector4;
  35522. backUVs?: Vector4;
  35523. }): VertexData;
  35524. /**
  35525. * Compute normals for given positions and indices
  35526. * @param positions an array of vertex positions, [...., x, y, z, ......]
  35527. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  35528. * @param normals an array of vertex normals, [...., x, y, z, ......]
  35529. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  35530. * * facetNormals : optional array of facet normals (vector3)
  35531. * * facetPositions : optional array of facet positions (vector3)
  35532. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  35533. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  35534. * * bInfo : optional bounding info, required for facetPartitioning computation
  35535. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  35536. * * subDiv : optional partitioning data about subdivisions on each axis (int), required for facetPartitioning computation
  35537. * * useRightHandedSystem: optional boolean to for right handed system computation
  35538. * * depthSort : optional boolean to enable the facet depth sort computation
  35539. * * distanceTo : optional Vector3 to compute the facet depth from this location
  35540. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  35541. */
  35542. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  35543. facetNormals?: any;
  35544. facetPositions?: any;
  35545. facetPartitioning?: any;
  35546. ratio?: number;
  35547. bInfo?: any;
  35548. bbSize?: Vector3;
  35549. subDiv?: any;
  35550. useRightHandedSystem?: boolean;
  35551. depthSort?: boolean;
  35552. distanceTo?: Vector3;
  35553. depthSortedFacets?: any;
  35554. }): void;
  35555. /** @hidden */
  35556. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  35557. /**
  35558. * Applies VertexData created from the imported parameters to the geometry
  35559. * @param parsedVertexData the parsed data from an imported file
  35560. * @param geometry the geometry to apply the VertexData to
  35561. */
  35562. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  35563. }
  35564. }
  35565. declare module BABYLON {
  35566. /**
  35567. * Class containing static functions to help procedurally build meshes
  35568. */
  35569. export class DiscBuilder {
  35570. /**
  35571. * Creates a plane polygonal mesh. By default, this is a disc
  35572. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  35573. * * 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
  35574. * * 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
  35575. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35576. * * 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
  35577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35578. * @param name defines the name of the mesh
  35579. * @param options defines the options used to create the mesh
  35580. * @param scene defines the hosting scene
  35581. * @returns the plane polygonal mesh
  35582. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  35583. */
  35584. static CreateDisc(name: string, options: {
  35585. radius?: number;
  35586. tessellation?: number;
  35587. arc?: number;
  35588. updatable?: boolean;
  35589. sideOrientation?: number;
  35590. frontUVs?: Vector4;
  35591. backUVs?: Vector4;
  35592. }, scene?: Nullable<Scene>): Mesh;
  35593. }
  35594. }
  35595. declare module BABYLON {
  35596. /**
  35597. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  35598. *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.
  35599. * The SPS is also a particle system. It provides some methods to manage the particles.
  35600. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  35601. *
  35602. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  35603. */
  35604. export class SolidParticleSystem implements IDisposable {
  35605. /**
  35606. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  35607. * Example : var p = SPS.particles[i];
  35608. */
  35609. particles: SolidParticle[];
  35610. /**
  35611. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  35612. */
  35613. nbParticles: number;
  35614. /**
  35615. * If the particles must ever face the camera (default false). Useful for planar particles.
  35616. */
  35617. billboard: boolean;
  35618. /**
  35619. * Recompute normals when adding a shape
  35620. */
  35621. recomputeNormals: boolean;
  35622. /**
  35623. * This a counter ofr your own usage. It's not set by any SPS functions.
  35624. */
  35625. counter: number;
  35626. /**
  35627. * The SPS name. This name is also given to the underlying mesh.
  35628. */
  35629. name: string;
  35630. /**
  35631. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are available.
  35632. */
  35633. mesh: Mesh;
  35634. /**
  35635. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  35636. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  35637. */
  35638. vars: any;
  35639. /**
  35640. * This array is populated when the SPS is set as 'pickable'.
  35641. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  35642. * Each element of this array is an object `{idx: int, faceId: int}`.
  35643. * `idx` is the picked particle index in the `SPS.particles` array
  35644. * `faceId` is the picked face index counted within this particle.
  35645. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  35646. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  35647. * Use the method SPS.pickedParticle(pickingInfo) instead.
  35648. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35649. */
  35650. pickedParticles: {
  35651. idx: number;
  35652. faceId: number;
  35653. }[];
  35654. /**
  35655. * This array is populated when the SPS is set as 'pickable'
  35656. * Each key of this array is a submesh index.
  35657. * Each element of this array is a second array defined like this :
  35658. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  35659. * Each element of this second array is an object `{idx: int, faceId: int}`.
  35660. * `idx` is the picked particle index in the `SPS.particles` array
  35661. * `faceId` is the picked face index counted within this particle.
  35662. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  35663. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35664. */
  35665. pickedBySubMesh: {
  35666. idx: number;
  35667. faceId: number;
  35668. }[][];
  35669. /**
  35670. * This array is populated when `enableDepthSort` is set to true.
  35671. * Each element of this array is an instance of the class DepthSortedParticle.
  35672. */
  35673. depthSortedParticles: DepthSortedParticle[];
  35674. /**
  35675. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  35676. * @hidden
  35677. */
  35678. _bSphereOnly: boolean;
  35679. /**
  35680. * A number to multiply the bounding sphere radius by in order to reduce it for instance. (Internal use only)
  35681. * @hidden
  35682. */
  35683. _bSphereRadiusFactor: number;
  35684. private _scene;
  35685. private _positions;
  35686. private _indices;
  35687. private _normals;
  35688. private _colors;
  35689. private _uvs;
  35690. private _indices32;
  35691. private _positions32;
  35692. private _normals32;
  35693. private _fixedNormal32;
  35694. private _colors32;
  35695. private _uvs32;
  35696. private _index;
  35697. private _updatable;
  35698. private _pickable;
  35699. private _isVisibilityBoxLocked;
  35700. private _alwaysVisible;
  35701. private _depthSort;
  35702. private _expandable;
  35703. private _shapeCounter;
  35704. private _copy;
  35705. private _color;
  35706. private _computeParticleColor;
  35707. private _computeParticleTexture;
  35708. private _computeParticleRotation;
  35709. private _computeParticleVertex;
  35710. private _computeBoundingBox;
  35711. private _depthSortParticles;
  35712. private _camera;
  35713. private _mustUnrotateFixedNormals;
  35714. private _particlesIntersect;
  35715. private _needs32Bits;
  35716. private _isNotBuilt;
  35717. private _lastParticleId;
  35718. private _idxOfId;
  35719. private _multimaterialEnabled;
  35720. private _useModelMaterial;
  35721. private _indicesByMaterial;
  35722. private _materialIndexes;
  35723. private _depthSortFunction;
  35724. private _materialSortFunction;
  35725. private _materials;
  35726. private _multimaterial;
  35727. private _materialIndexesById;
  35728. private _defaultMaterial;
  35729. private _autoUpdateSubMeshes;
  35730. private _tmpVertex;
  35731. /**
  35732. * Creates a SPS (Solid Particle System) object.
  35733. * @param name (String) is the SPS name, this will be the underlying mesh name.
  35734. * @param scene (Scene) is the scene in which the SPS is added.
  35735. * @param options defines the options of the sps e.g.
  35736. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  35737. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  35738. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  35739. * * 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.
  35740. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  35741. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  35742. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  35743. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  35744. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the bounding sphere radius by in order to reduce it for instance.
  35745. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  35746. */
  35747. constructor(name: string, scene: Scene, options?: {
  35748. updatable?: boolean;
  35749. isPickable?: boolean;
  35750. enableDepthSort?: boolean;
  35751. particleIntersection?: boolean;
  35752. boundingSphereOnly?: boolean;
  35753. bSphereRadiusFactor?: number;
  35754. expandable?: boolean;
  35755. useModelMaterial?: boolean;
  35756. enableMultiMaterial?: boolean;
  35757. });
  35758. /**
  35759. * Builds the SPS underlying mesh. Returns a standard Mesh.
  35760. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  35761. * @returns the created mesh
  35762. */
  35763. buildMesh(): Mesh;
  35764. /**
  35765. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  35766. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  35767. * Thus the particles generated from `digest()` have their property `position` set yet.
  35768. * @param mesh ( Mesh ) is the mesh to be digested
  35769. * @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
  35770. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  35771. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  35772. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35773. * @returns the current SPS
  35774. */
  35775. digest(mesh: Mesh, options?: {
  35776. facetNb?: number;
  35777. number?: number;
  35778. delta?: number;
  35779. storage?: [];
  35780. }): SolidParticleSystem;
  35781. /**
  35782. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  35783. * @hidden
  35784. */
  35785. private _unrotateFixedNormals;
  35786. /**
  35787. * Resets the temporary working copy particle
  35788. * @hidden
  35789. */
  35790. private _resetCopy;
  35791. /**
  35792. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  35793. * @param p the current index in the positions array to be updated
  35794. * @param ind the current index in the indices array
  35795. * @param shape a Vector3 array, the shape geometry
  35796. * @param positions the positions array to be updated
  35797. * @param meshInd the shape indices array
  35798. * @param indices the indices array to be updated
  35799. * @param meshUV the shape uv array
  35800. * @param uvs the uv array to be updated
  35801. * @param meshCol the shape color array
  35802. * @param colors the color array to be updated
  35803. * @param meshNor the shape normals array
  35804. * @param normals the normals array to be updated
  35805. * @param idx the particle index
  35806. * @param idxInShape the particle index in its shape
  35807. * @param options the addShape() method passed options
  35808. * @model the particle model
  35809. * @hidden
  35810. */
  35811. private _meshBuilder;
  35812. /**
  35813. * Returns a shape Vector3 array from positions float array
  35814. * @param positions float array
  35815. * @returns a vector3 array
  35816. * @hidden
  35817. */
  35818. private _posToShape;
  35819. /**
  35820. * Returns a shapeUV array from a float uvs (array deep copy)
  35821. * @param uvs as a float array
  35822. * @returns a shapeUV array
  35823. * @hidden
  35824. */
  35825. private _uvsToShapeUV;
  35826. /**
  35827. * Adds a new particle object in the particles array
  35828. * @param idx particle index in particles array
  35829. * @param id particle id
  35830. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  35831. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  35832. * @param model particle ModelShape object
  35833. * @param shapeId model shape identifier
  35834. * @param idxInShape index of the particle in the current model
  35835. * @param bInfo model bounding info object
  35836. * @param storage target storage array, if any
  35837. * @hidden
  35838. */
  35839. private _addParticle;
  35840. /**
  35841. * Adds some particles to the SPS from the model shape. Returns the shape id.
  35842. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  35843. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  35844. * @param nb (positive integer) the number of particles to be created from this model
  35845. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  35846. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  35847. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35848. * @returns the number of shapes in the system
  35849. */
  35850. addShape(mesh: Mesh, nb: number, options?: {
  35851. positionFunction?: any;
  35852. vertexFunction?: any;
  35853. storage?: [];
  35854. }): number;
  35855. /**
  35856. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  35857. * @hidden
  35858. */
  35859. private _rebuildParticle;
  35860. /**
  35861. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  35862. * @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.
  35863. * @returns the SPS.
  35864. */
  35865. rebuildMesh(reset?: boolean): SolidParticleSystem;
  35866. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  35867. * Returns an array with the removed particles.
  35868. * 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.
  35869. * The SPS can't be empty so at least one particle needs to remain in place.
  35870. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  35871. * @param start index of the first particle to remove
  35872. * @param end index of the last particle to remove (included)
  35873. * @returns an array populated with the removed particles
  35874. */
  35875. removeParticles(start: number, end: number): SolidParticle[];
  35876. /**
  35877. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  35878. * @param solidParticleArray an array populated with Solid Particles objects
  35879. * @returns the SPS
  35880. */
  35881. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  35882. /**
  35883. * Creates a new particle and modifies the SPS mesh geometry :
  35884. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  35885. * - calls _addParticle() to populate the particle array
  35886. * factorized code from addShape() and insertParticlesFromArray()
  35887. * @param idx particle index in the particles array
  35888. * @param i particle index in its shape
  35889. * @param modelShape particle ModelShape object
  35890. * @param shape shape vertex array
  35891. * @param meshInd shape indices array
  35892. * @param meshUV shape uv array
  35893. * @param meshCol shape color array
  35894. * @param meshNor shape normals array
  35895. * @param bbInfo shape bounding info
  35896. * @param storage target particle storage
  35897. * @options addShape() passed options
  35898. * @hidden
  35899. */
  35900. private _insertNewParticle;
  35901. /**
  35902. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  35903. * This method calls `updateParticle()` for each particle of the SPS.
  35904. * For an animated SPS, it is usually called within the render loop.
  35905. * 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.
  35906. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  35907. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  35908. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  35909. * @returns the SPS.
  35910. */
  35911. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  35912. /**
  35913. * Disposes the SPS.
  35914. */
  35915. dispose(): void;
  35916. /** Returns an object {idx: number faceId: number} for the picked particle from the passed pickingInfo object.
  35917. * idx is the particle index in the SPS
  35918. * faceId is the picked face index counted within this particle.
  35919. * Returns null if the pickInfo can't identify a picked particle.
  35920. * @param pickingInfo (PickingInfo object)
  35921. * @returns {idx: number, faceId: number} or null
  35922. */
  35923. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  35924. idx: number;
  35925. faceId: number;
  35926. }>;
  35927. /**
  35928. * Returns a SolidParticle object from its identifier : particle.id
  35929. * @param id (integer) the particle Id
  35930. * @returns the searched particle or null if not found in the SPS.
  35931. */
  35932. getParticleById(id: number): Nullable<SolidParticle>;
  35933. /**
  35934. * Returns a new array populated with the particles having the passed shapeId.
  35935. * @param shapeId (integer) the shape identifier
  35936. * @returns a new solid particle array
  35937. */
  35938. getParticlesByShapeId(shapeId: number): SolidParticle[];
  35939. /**
  35940. * Populates the passed array "ref" with the particles having the passed shapeId.
  35941. * @param shapeId the shape identifier
  35942. * @returns the SPS
  35943. * @param ref
  35944. */
  35945. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  35946. /**
  35947. * Computes the required SubMeshes according the materials assigned to the particles.
  35948. * @returns the solid particle system.
  35949. * Does nothing if called before the SPS mesh is built.
  35950. */
  35951. computeSubMeshes(): SolidParticleSystem;
  35952. /**
  35953. * Sorts the solid particles by material when MultiMaterial is enabled.
  35954. * Updates the indices32 array.
  35955. * Updates the indicesByMaterial array.
  35956. * Updates the mesh indices array.
  35957. * @returns the SPS
  35958. * @hidden
  35959. */
  35960. private _sortParticlesByMaterial;
  35961. /**
  35962. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  35963. * @hidden
  35964. */
  35965. private _setMaterialIndexesById;
  35966. /**
  35967. * Returns an array with unique values of Materials from the passed array
  35968. * @param array the material array to be checked and filtered
  35969. * @hidden
  35970. */
  35971. private _filterUniqueMaterialId;
  35972. /**
  35973. * Sets a new Standard Material as _defaultMaterial if not already set.
  35974. * @hidden
  35975. */
  35976. private _setDefaultMaterial;
  35977. /**
  35978. * Visibility helper : Recomputes the visible size according to the mesh bounding box
  35979. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35980. * @returns the SPS.
  35981. */
  35982. refreshVisibleSize(): SolidParticleSystem;
  35983. /**
  35984. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  35985. * @param size the size (float) of the visibility box
  35986. * note : this doesn't lock the SPS mesh bounding box.
  35987. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35988. */
  35989. setVisibilityBox(size: number): void;
  35990. /**
  35991. * Gets whether the SPS as always visible or not
  35992. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35993. */
  35994. get isAlwaysVisible(): boolean;
  35995. /**
  35996. * Sets the SPS as always visible or not
  35997. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35998. */
  35999. set isAlwaysVisible(val: boolean);
  36000. /**
  36001. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  36002. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36003. */
  36004. set isVisibilityBoxLocked(val: boolean);
  36005. /**
  36006. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  36007. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36008. */
  36009. get isVisibilityBoxLocked(): boolean;
  36010. /**
  36011. * Tells to `setParticles()` to compute the particle rotations or not.
  36012. * Default value : true. The SPS is faster when it's set to false.
  36013. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  36014. */
  36015. set computeParticleRotation(val: boolean);
  36016. /**
  36017. * Tells to `setParticles()` to compute the particle colors or not.
  36018. * Default value : true. The SPS is faster when it's set to false.
  36019. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  36020. */
  36021. set computeParticleColor(val: boolean);
  36022. set computeParticleTexture(val: boolean);
  36023. /**
  36024. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  36025. * Default value : false. The SPS is faster when it's set to false.
  36026. * Note : the particle custom vertex positions aren't stored values.
  36027. */
  36028. set computeParticleVertex(val: boolean);
  36029. /**
  36030. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  36031. */
  36032. set computeBoundingBox(val: boolean);
  36033. /**
  36034. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  36035. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  36036. * Default : `true`
  36037. */
  36038. set depthSortParticles(val: boolean);
  36039. /**
  36040. * Gets if `setParticles()` computes the particle rotations or not.
  36041. * Default value : true. The SPS is faster when it's set to false.
  36042. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  36043. */
  36044. get computeParticleRotation(): boolean;
  36045. /**
  36046. * Gets if `setParticles()` computes the particle colors or not.
  36047. * Default value : true. The SPS is faster when it's set to false.
  36048. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  36049. */
  36050. get computeParticleColor(): boolean;
  36051. /**
  36052. * Gets if `setParticles()` computes the particle textures or not.
  36053. * Default value : true. The SPS is faster when it's set to false.
  36054. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  36055. */
  36056. get computeParticleTexture(): boolean;
  36057. /**
  36058. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  36059. * Default value : false. The SPS is faster when it's set to false.
  36060. * Note : the particle custom vertex positions aren't stored values.
  36061. */
  36062. get computeParticleVertex(): boolean;
  36063. /**
  36064. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  36065. */
  36066. get computeBoundingBox(): boolean;
  36067. /**
  36068. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  36069. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  36070. * Default : `true`
  36071. */
  36072. get depthSortParticles(): boolean;
  36073. /**
  36074. * Gets if the SPS is created as expandable at construction time.
  36075. * Default : `false`
  36076. */
  36077. get expandable(): boolean;
  36078. /**
  36079. * Gets if the SPS supports the Multi Materials
  36080. */
  36081. get multimaterialEnabled(): boolean;
  36082. /**
  36083. * Gets if the SPS uses the model materials for its own multimaterial.
  36084. */
  36085. get useModelMaterial(): boolean;
  36086. /**
  36087. * The SPS used material array.
  36088. */
  36089. get materials(): Material[];
  36090. /**
  36091. * Sets the SPS MultiMaterial from the passed materials.
  36092. * Note : the passed array is internally copied and not used then by reference.
  36093. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  36094. */
  36095. setMultiMaterial(materials: Material[]): void;
  36096. /**
  36097. * The SPS computed multimaterial object
  36098. */
  36099. get multimaterial(): MultiMaterial;
  36100. set multimaterial(mm: MultiMaterial);
  36101. /**
  36102. * If the subMeshes must be updated on the next call to setParticles()
  36103. */
  36104. get autoUpdateSubMeshes(): boolean;
  36105. set autoUpdateSubMeshes(val: boolean);
  36106. /**
  36107. * This function does nothing. It may be overwritten to set all the particle first values.
  36108. * The SPS doesn't call this function, you may have to call it by your own.
  36109. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36110. */
  36111. initParticles(): void;
  36112. /**
  36113. * This function does nothing. It may be overwritten to recycle a particle.
  36114. * The SPS doesn't call this function, you may have to call it by your own.
  36115. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36116. * @param particle The particle to recycle
  36117. * @returns the recycled particle
  36118. */
  36119. recycleParticle(particle: SolidParticle): SolidParticle;
  36120. /**
  36121. * Updates a particle : this function should be overwritten by the user.
  36122. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  36123. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36124. * @example : just set a particle position or velocity and recycle conditions
  36125. * @param particle The particle to update
  36126. * @returns the updated particle
  36127. */
  36128. updateParticle(particle: SolidParticle): SolidParticle;
  36129. /**
  36130. * Updates a vertex of a particle : it can be overwritten by the user.
  36131. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  36132. * @param particle the current particle
  36133. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  36134. * @param pt the index of the current vertex in the particle shape
  36135. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  36136. * @example : just set a vertex particle position or color
  36137. * @returns the sps
  36138. */
  36139. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  36140. /**
  36141. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  36142. * This does nothing and may be overwritten by the user.
  36143. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36144. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36145. * @param update the boolean update value actually passed to setParticles()
  36146. */
  36147. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36148. /**
  36149. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  36150. * This will be passed three parameters.
  36151. * This does nothing and may be overwritten by the user.
  36152. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36153. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36154. * @param update the boolean update value actually passed to setParticles()
  36155. */
  36156. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36157. }
  36158. }
  36159. declare module BABYLON {
  36160. /**
  36161. * Represents one particle of a solid particle system.
  36162. */
  36163. export class SolidParticle {
  36164. /**
  36165. * particle global index
  36166. */
  36167. idx: number;
  36168. /**
  36169. * particle identifier
  36170. */
  36171. id: number;
  36172. /**
  36173. * The color of the particle
  36174. */
  36175. color: Nullable<Color4>;
  36176. /**
  36177. * The world space position of the particle.
  36178. */
  36179. position: Vector3;
  36180. /**
  36181. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  36182. */
  36183. rotation: Vector3;
  36184. /**
  36185. * The world space rotation quaternion of the particle.
  36186. */
  36187. rotationQuaternion: Nullable<Quaternion>;
  36188. /**
  36189. * The scaling of the particle.
  36190. */
  36191. scaling: Vector3;
  36192. /**
  36193. * The uvs of the particle.
  36194. */
  36195. uvs: Vector4;
  36196. /**
  36197. * The current speed of the particle.
  36198. */
  36199. velocity: Vector3;
  36200. /**
  36201. * The pivot point in the particle local space.
  36202. */
  36203. pivot: Vector3;
  36204. /**
  36205. * Must the particle be translated from its pivot point in its local space ?
  36206. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  36207. * Default : false
  36208. */
  36209. translateFromPivot: boolean;
  36210. /**
  36211. * Is the particle active or not ?
  36212. */
  36213. alive: boolean;
  36214. /**
  36215. * Is the particle visible or not ?
  36216. */
  36217. isVisible: boolean;
  36218. /**
  36219. * Index of this particle in the global "positions" array (Internal use)
  36220. * @hidden
  36221. */
  36222. _pos: number;
  36223. /**
  36224. * @hidden Index of this particle in the global "indices" array (Internal use)
  36225. */
  36226. _ind: number;
  36227. /**
  36228. * @hidden ModelShape of this particle (Internal use)
  36229. */
  36230. _model: ModelShape;
  36231. /**
  36232. * ModelShape id of this particle
  36233. */
  36234. shapeId: number;
  36235. /**
  36236. * Index of the particle in its shape id
  36237. */
  36238. idxInShape: number;
  36239. /**
  36240. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  36241. */
  36242. _modelBoundingInfo: BoundingInfo;
  36243. /**
  36244. * @hidden Particle BoundingInfo object (Internal use)
  36245. */
  36246. _boundingInfo: BoundingInfo;
  36247. /**
  36248. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  36249. */
  36250. _sps: SolidParticleSystem;
  36251. /**
  36252. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  36253. */
  36254. _stillInvisible: boolean;
  36255. /**
  36256. * @hidden Last computed particle rotation matrix
  36257. */
  36258. _rotationMatrix: number[];
  36259. /**
  36260. * Parent particle Id, if any.
  36261. * Default null.
  36262. */
  36263. parentId: Nullable<number>;
  36264. /**
  36265. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  36266. */
  36267. materialIndex: Nullable<number>;
  36268. /**
  36269. * Custom object or properties.
  36270. */
  36271. props: Nullable<any>;
  36272. /**
  36273. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  36274. * The possible values are :
  36275. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36276. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36277. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36278. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36279. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36280. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  36281. * */
  36282. cullingStrategy: number;
  36283. /**
  36284. * @hidden Internal global position in the SPS.
  36285. */
  36286. _globalPosition: Vector3;
  36287. /**
  36288. * Creates a Solid Particle object.
  36289. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  36290. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  36291. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  36292. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  36293. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  36294. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  36295. * @param shapeId (integer) is the model shape identifier in the SPS.
  36296. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  36297. * @param sps defines the sps it is associated to
  36298. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  36299. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  36300. */
  36301. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  36302. /**
  36303. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  36304. * @param target the particle target
  36305. * @returns the current particle
  36306. */
  36307. copyToRef(target: SolidParticle): SolidParticle;
  36308. /**
  36309. * Legacy support, changed scale to scaling
  36310. */
  36311. get scale(): Vector3;
  36312. /**
  36313. * Legacy support, changed scale to scaling
  36314. */
  36315. set scale(scale: Vector3);
  36316. /**
  36317. * Legacy support, changed quaternion to rotationQuaternion
  36318. */
  36319. get quaternion(): Nullable<Quaternion>;
  36320. /**
  36321. * Legacy support, changed quaternion to rotationQuaternion
  36322. */
  36323. set quaternion(q: Nullable<Quaternion>);
  36324. /**
  36325. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  36326. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  36327. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  36328. * @returns true if it intersects
  36329. */
  36330. intersectsMesh(target: Mesh | SolidParticle): boolean;
  36331. /**
  36332. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  36333. * A particle is in the frustum if its bounding box intersects the frustum
  36334. * @param frustumPlanes defines the frustum to test
  36335. * @returns true if the particle is in the frustum planes
  36336. */
  36337. isInFrustum(frustumPlanes: Plane[]): boolean;
  36338. /**
  36339. * get the rotation matrix of the particle
  36340. * @hidden
  36341. */
  36342. getRotationMatrix(m: Matrix): void;
  36343. }
  36344. /**
  36345. * Represents the shape of the model used by one particle of a solid particle system.
  36346. * SPS internal tool, don't use it manually.
  36347. */
  36348. export class ModelShape {
  36349. /**
  36350. * The shape id
  36351. * @hidden
  36352. */
  36353. shapeID: number;
  36354. /**
  36355. * flat array of model positions (internal use)
  36356. * @hidden
  36357. */
  36358. _shape: Vector3[];
  36359. /**
  36360. * flat array of model UVs (internal use)
  36361. * @hidden
  36362. */
  36363. _shapeUV: number[];
  36364. /**
  36365. * color array of the model
  36366. * @hidden
  36367. */
  36368. _shapeColors: number[];
  36369. /**
  36370. * indices array of the model
  36371. * @hidden
  36372. */
  36373. _indices: number[];
  36374. /**
  36375. * normals array of the model
  36376. * @hidden
  36377. */
  36378. _normals: number[];
  36379. /**
  36380. * length of the shape in the model indices array (internal use)
  36381. * @hidden
  36382. */
  36383. _indicesLength: number;
  36384. /**
  36385. * Custom position function (internal use)
  36386. * @hidden
  36387. */
  36388. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  36389. /**
  36390. * Custom vertex function (internal use)
  36391. * @hidden
  36392. */
  36393. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  36394. /**
  36395. * Model material (internal use)
  36396. * @hidden
  36397. */
  36398. _material: Nullable<Material>;
  36399. /**
  36400. * 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.
  36401. * SPS internal tool, don't use it manually.
  36402. * @hidden
  36403. */
  36404. 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>);
  36405. }
  36406. /**
  36407. * Represents a Depth Sorted Particle in the solid particle system.
  36408. * @hidden
  36409. */
  36410. export class DepthSortedParticle {
  36411. /**
  36412. * Particle index
  36413. */
  36414. idx: number;
  36415. /**
  36416. * Index of the particle in the "indices" array
  36417. */
  36418. ind: number;
  36419. /**
  36420. * Length of the particle shape in the "indices" array
  36421. */
  36422. indicesLength: number;
  36423. /**
  36424. * Squared distance from the particle to the camera
  36425. */
  36426. sqDistance: number;
  36427. /**
  36428. * Material index when used with MultiMaterials
  36429. */
  36430. materialIndex: number;
  36431. /**
  36432. * Creates a new sorted particle
  36433. * @param materialIndex
  36434. */
  36435. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  36436. }
  36437. /**
  36438. * Represents a solid particle vertex
  36439. */
  36440. export class SolidParticleVertex {
  36441. /**
  36442. * Vertex position
  36443. */
  36444. position: Vector3;
  36445. /**
  36446. * Vertex color
  36447. */
  36448. color: Color4;
  36449. /**
  36450. * Vertex UV
  36451. */
  36452. uv: Vector2;
  36453. /**
  36454. * Creates a new solid particle vertex
  36455. */
  36456. constructor();
  36457. /** Vertex x coordinate */
  36458. get x(): number;
  36459. set x(val: number);
  36460. /** Vertex y coordinate */
  36461. get y(): number;
  36462. set y(val: number);
  36463. /** Vertex z coordinate */
  36464. get z(): number;
  36465. set z(val: number);
  36466. }
  36467. }
  36468. declare module BABYLON {
  36469. /**
  36470. * @hidden
  36471. */
  36472. export class _MeshCollisionData {
  36473. _checkCollisions: boolean;
  36474. _collisionMask: number;
  36475. _collisionGroup: number;
  36476. _surroundingMeshes: Nullable<AbstractMesh[]>;
  36477. _collider: Nullable<Collider>;
  36478. _oldPositionForCollisions: Vector3;
  36479. _diffPositionForCollisions: Vector3;
  36480. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  36481. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  36482. _collisionResponse: boolean;
  36483. }
  36484. }
  36485. declare module BABYLON {
  36486. /** @hidden */
  36487. class _FacetDataStorage {
  36488. facetPositions: Vector3[];
  36489. facetNormals: Vector3[];
  36490. facetPartitioning: number[][];
  36491. facetNb: number;
  36492. partitioningSubdivisions: number;
  36493. partitioningBBoxRatio: number;
  36494. facetDataEnabled: boolean;
  36495. facetParameters: any;
  36496. bbSize: Vector3;
  36497. subDiv: {
  36498. max: number;
  36499. X: number;
  36500. Y: number;
  36501. Z: number;
  36502. };
  36503. facetDepthSort: boolean;
  36504. facetDepthSortEnabled: boolean;
  36505. depthSortedIndices: IndicesArray;
  36506. depthSortedFacets: {
  36507. ind: number;
  36508. sqDistance: number;
  36509. }[];
  36510. facetDepthSortFunction: (f1: {
  36511. ind: number;
  36512. sqDistance: number;
  36513. }, f2: {
  36514. ind: number;
  36515. sqDistance: number;
  36516. }) => number;
  36517. facetDepthSortFrom: Vector3;
  36518. facetDepthSortOrigin: Vector3;
  36519. invertedMatrix: Matrix;
  36520. }
  36521. /**
  36522. * @hidden
  36523. **/
  36524. class _InternalAbstractMeshDataInfo {
  36525. _hasVertexAlpha: boolean;
  36526. _useVertexColors: boolean;
  36527. _numBoneInfluencers: number;
  36528. _applyFog: boolean;
  36529. _receiveShadows: boolean;
  36530. _facetData: _FacetDataStorage;
  36531. _visibility: number;
  36532. _skeleton: Nullable<Skeleton>;
  36533. _layerMask: number;
  36534. _computeBonesUsingShaders: boolean;
  36535. _isActive: boolean;
  36536. _onlyForInstances: boolean;
  36537. _isActiveIntermediate: boolean;
  36538. _onlyForInstancesIntermediate: boolean;
  36539. _actAsRegularMesh: boolean;
  36540. _currentLOD: Nullable<AbstractMesh>;
  36541. _currentLODIsUpToDate: boolean;
  36542. }
  36543. /**
  36544. * Class used to store all common mesh properties
  36545. */
  36546. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  36547. /** No occlusion */
  36548. static OCCLUSION_TYPE_NONE: number;
  36549. /** Occlusion set to optimistic */
  36550. static OCCLUSION_TYPE_OPTIMISTIC: number;
  36551. /** Occlusion set to strict */
  36552. static OCCLUSION_TYPE_STRICT: number;
  36553. /** Use an accurate occlusion algorithm */
  36554. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  36555. /** Use a conservative occlusion algorithm */
  36556. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  36557. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  36558. * Test order :
  36559. * Is the bounding sphere outside the frustum ?
  36560. * If not, are the bounding box vertices outside the frustum ?
  36561. * It not, then the cullable object is in the frustum.
  36562. */
  36563. static readonly CULLINGSTRATEGY_STANDARD: number;
  36564. /** Culling strategy : Bounding Sphere Only.
  36565. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  36566. * It's also less accurate than the standard because some not visible objects can still be selected.
  36567. * Test : is the bounding sphere outside the frustum ?
  36568. * If not, then the cullable object is in the frustum.
  36569. */
  36570. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  36571. /** Culling strategy : Optimistic Inclusion.
  36572. * This in an inclusion test first, then the standard exclusion test.
  36573. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  36574. * 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.
  36575. * Anyway, it's as accurate as the standard strategy.
  36576. * Test :
  36577. * Is the cullable object bounding sphere center in the frustum ?
  36578. * If not, apply the default culling strategy.
  36579. */
  36580. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  36581. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  36582. * This in an inclusion test first, then the bounding sphere only exclusion test.
  36583. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  36584. * 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.
  36585. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  36586. * Test :
  36587. * Is the cullable object bounding sphere center in the frustum ?
  36588. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  36589. */
  36590. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  36591. /**
  36592. * No billboard
  36593. */
  36594. static get BILLBOARDMODE_NONE(): number;
  36595. /** Billboard on X axis */
  36596. static get BILLBOARDMODE_X(): number;
  36597. /** Billboard on Y axis */
  36598. static get BILLBOARDMODE_Y(): number;
  36599. /** Billboard on Z axis */
  36600. static get BILLBOARDMODE_Z(): number;
  36601. /** Billboard on all axes */
  36602. static get BILLBOARDMODE_ALL(): number;
  36603. /** Billboard on using position instead of orientation */
  36604. static get BILLBOARDMODE_USE_POSITION(): number;
  36605. /** @hidden */
  36606. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  36607. /**
  36608. * The culling strategy to use to check whether the mesh must be rendered or not.
  36609. * This value can be changed at any time and will be used on the next render mesh selection.
  36610. * The possible values are :
  36611. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36612. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36613. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36614. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36615. * Please read each static variable documentation to get details about the culling process.
  36616. * */
  36617. cullingStrategy: number;
  36618. /**
  36619. * Gets the number of facets in the mesh
  36620. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36621. */
  36622. get facetNb(): number;
  36623. /**
  36624. * Gets or set the number (integer) of subdivisions per axis in the partitioning space
  36625. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36626. */
  36627. get partitioningSubdivisions(): number;
  36628. set partitioningSubdivisions(nb: number);
  36629. /**
  36630. * The ratio (float) to apply to the bounding box size to set to the partitioning space.
  36631. * Ex : 1.01 (default) the partitioning space is 1% bigger than the bounding box
  36632. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36633. */
  36634. get partitioningBBoxRatio(): number;
  36635. set partitioningBBoxRatio(ratio: number);
  36636. /**
  36637. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  36638. * Works only for updatable meshes.
  36639. * Doesn't work with multi-materials
  36640. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36641. */
  36642. get mustDepthSortFacets(): boolean;
  36643. set mustDepthSortFacets(sort: boolean);
  36644. /**
  36645. * The location (Vector3) where the facet depth sort must be computed from.
  36646. * By default, the active camera position.
  36647. * Used only when facet depth sort is enabled
  36648. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36649. */
  36650. get facetDepthSortFrom(): Vector3;
  36651. set facetDepthSortFrom(location: Vector3);
  36652. /**
  36653. * gets a boolean indicating if facetData is enabled
  36654. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36655. */
  36656. get isFacetDataEnabled(): boolean;
  36657. /** @hidden */
  36658. _updateNonUniformScalingState(value: boolean): boolean;
  36659. /**
  36660. * An event triggered when this mesh collides with another one
  36661. */
  36662. onCollideObservable: Observable<AbstractMesh>;
  36663. /** Set a function to call when this mesh collides with another one */
  36664. set onCollide(callback: () => void);
  36665. /**
  36666. * An event triggered when the collision's position changes
  36667. */
  36668. onCollisionPositionChangeObservable: Observable<Vector3>;
  36669. /** Set a function to call when the collision's position changes */
  36670. set onCollisionPositionChange(callback: () => void);
  36671. /**
  36672. * An event triggered when material is changed
  36673. */
  36674. onMaterialChangedObservable: Observable<AbstractMesh>;
  36675. /**
  36676. * Gets or sets the orientation for POV movement & rotation
  36677. */
  36678. definedFacingForward: boolean;
  36679. /** @hidden */
  36680. _occlusionQuery: Nullable<WebGLQuery>;
  36681. /** @hidden */
  36682. _renderingGroup: Nullable<RenderingGroup>;
  36683. /**
  36684. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36685. */
  36686. get visibility(): number;
  36687. /**
  36688. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36689. */
  36690. set visibility(value: number);
  36691. /** Gets or sets the alpha index used to sort transparent meshes
  36692. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  36693. */
  36694. alphaIndex: number;
  36695. /**
  36696. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  36697. */
  36698. isVisible: boolean;
  36699. /**
  36700. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36701. */
  36702. isPickable: boolean;
  36703. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  36704. showSubMeshesBoundingBox: boolean;
  36705. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  36706. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  36707. */
  36708. isBlocker: boolean;
  36709. /**
  36710. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  36711. */
  36712. enablePointerMoveEvents: boolean;
  36713. private _renderingGroupId;
  36714. /**
  36715. * Specifies the rendering group id for this mesh (0 by default)
  36716. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36717. */
  36718. get renderingGroupId(): number;
  36719. set renderingGroupId(value: number);
  36720. private _material;
  36721. /** Gets or sets current material */
  36722. get material(): Nullable<Material>;
  36723. set material(value: Nullable<Material>);
  36724. /**
  36725. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  36726. * @see https://doc.babylonjs.com/babylon101/shadows
  36727. */
  36728. get receiveShadows(): boolean;
  36729. set receiveShadows(value: boolean);
  36730. /** Defines color to use when rendering outline */
  36731. outlineColor: Color3;
  36732. /** Define width to use when rendering outline */
  36733. outlineWidth: number;
  36734. /** Defines color to use when rendering overlay */
  36735. overlayColor: Color3;
  36736. /** Defines alpha to use when rendering overlay */
  36737. overlayAlpha: number;
  36738. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  36739. get hasVertexAlpha(): boolean;
  36740. set hasVertexAlpha(value: boolean);
  36741. /** 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) */
  36742. get useVertexColors(): boolean;
  36743. set useVertexColors(value: boolean);
  36744. /**
  36745. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  36746. */
  36747. get computeBonesUsingShaders(): boolean;
  36748. set computeBonesUsingShaders(value: boolean);
  36749. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  36750. get numBoneInfluencers(): number;
  36751. set numBoneInfluencers(value: number);
  36752. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  36753. get applyFog(): boolean;
  36754. set applyFog(value: boolean);
  36755. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  36756. useOctreeForRenderingSelection: boolean;
  36757. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  36758. useOctreeForPicking: boolean;
  36759. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  36760. useOctreeForCollisions: boolean;
  36761. /**
  36762. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  36763. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  36764. */
  36765. get layerMask(): number;
  36766. set layerMask(value: number);
  36767. /**
  36768. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  36769. */
  36770. alwaysSelectAsActiveMesh: boolean;
  36771. /**
  36772. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  36773. */
  36774. doNotSyncBoundingInfo: boolean;
  36775. /**
  36776. * Gets or sets the current action manager
  36777. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36778. */
  36779. actionManager: Nullable<AbstractActionManager>;
  36780. private _meshCollisionData;
  36781. /**
  36782. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  36783. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36784. */
  36785. ellipsoid: Vector3;
  36786. /**
  36787. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  36788. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36789. */
  36790. ellipsoidOffset: Vector3;
  36791. /**
  36792. * Gets or sets a collision mask used to mask collisions (default is -1).
  36793. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36794. */
  36795. get collisionMask(): number;
  36796. set collisionMask(mask: number);
  36797. /**
  36798. * Gets or sets a collision response flag (default is true).
  36799. * when collisionResponse is false, events are still triggered but colliding entity has no response
  36800. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  36801. * to respond to the collision.
  36802. */
  36803. get collisionResponse(): boolean;
  36804. set collisionResponse(response: boolean);
  36805. /**
  36806. * Gets or sets the current collision group mask (-1 by default).
  36807. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36808. */
  36809. get collisionGroup(): number;
  36810. set collisionGroup(mask: number);
  36811. /**
  36812. * Gets or sets current surrounding meshes (null by default).
  36813. *
  36814. * By default collision detection is tested against every mesh in the scene.
  36815. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  36816. * meshes will be tested for the collision.
  36817. *
  36818. * Note: if set to an empty array no collision will happen when this mesh is moved.
  36819. */
  36820. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  36821. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  36822. /**
  36823. * Defines edge width used when edgesRenderer is enabled
  36824. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36825. */
  36826. edgesWidth: number;
  36827. /**
  36828. * Defines edge color used when edgesRenderer is enabled
  36829. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36830. */
  36831. edgesColor: Color4;
  36832. /** @hidden */
  36833. _edgesRenderer: Nullable<IEdgesRenderer>;
  36834. /** @hidden */
  36835. _masterMesh: Nullable<AbstractMesh>;
  36836. /** @hidden */
  36837. _boundingInfo: Nullable<BoundingInfo>;
  36838. /** @hidden */
  36839. _renderId: number;
  36840. /**
  36841. * Gets or sets the list of subMeshes
  36842. * @see https://doc.babylonjs.com/how_to/multi_materials
  36843. */
  36844. subMeshes: SubMesh[];
  36845. /** @hidden */
  36846. _intersectionsInProgress: AbstractMesh[];
  36847. /** @hidden */
  36848. _unIndexed: boolean;
  36849. /** @hidden */
  36850. _lightSources: Light[];
  36851. /** Gets the list of lights affecting that mesh */
  36852. get lightSources(): Light[];
  36853. /** @hidden */
  36854. get _positions(): Nullable<Vector3[]>;
  36855. /** @hidden */
  36856. _waitingData: {
  36857. lods: Nullable<any>;
  36858. actions: Nullable<any>;
  36859. freezeWorldMatrix: Nullable<boolean>;
  36860. };
  36861. /** @hidden */
  36862. _bonesTransformMatrices: Nullable<Float32Array>;
  36863. /** @hidden */
  36864. _transformMatrixTexture: Nullable<RawTexture>;
  36865. /**
  36866. * Gets or sets a skeleton to apply skinning transformations
  36867. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36868. */
  36869. set skeleton(value: Nullable<Skeleton>);
  36870. get skeleton(): Nullable<Skeleton>;
  36871. /**
  36872. * An event triggered when the mesh is rebuilt.
  36873. */
  36874. onRebuildObservable: Observable<AbstractMesh>;
  36875. /**
  36876. * The current mesh uniform buffer.
  36877. * @hidden Internal use only.
  36878. */
  36879. _uniformBuffer: UniformBuffer;
  36880. /**
  36881. * Creates a new AbstractMesh
  36882. * @param name defines the name of the mesh
  36883. * @param scene defines the hosting scene
  36884. */
  36885. constructor(name: string, scene?: Nullable<Scene>);
  36886. protected _buildUniformLayout(): void;
  36887. /**
  36888. * Transfer the mesh values to its UBO.
  36889. * @param world The world matrix associated with the mesh
  36890. */
  36891. transferToEffect(world: Matrix): void;
  36892. /**
  36893. * Gets the mesh uniform buffer.
  36894. * @return the uniform buffer of the mesh.
  36895. */
  36896. getMeshUniformBuffer(): UniformBuffer;
  36897. /**
  36898. * Returns the string "AbstractMesh"
  36899. * @returns "AbstractMesh"
  36900. */
  36901. getClassName(): string;
  36902. /**
  36903. * Gets a string representation of the current mesh
  36904. * @param fullDetails defines a boolean indicating if full details must be included
  36905. * @returns a string representation of the current mesh
  36906. */
  36907. toString(fullDetails?: boolean): string;
  36908. /**
  36909. * @hidden
  36910. */
  36911. protected _getEffectiveParent(): Nullable<Node>;
  36912. /** @hidden */
  36913. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36914. /** @hidden */
  36915. _rebuild(): void;
  36916. /** @hidden */
  36917. _resyncLightSources(): void;
  36918. /** @hidden */
  36919. _resyncLightSource(light: Light): void;
  36920. /** @hidden */
  36921. _unBindEffect(): void;
  36922. /** @hidden */
  36923. _removeLightSource(light: Light, dispose: boolean): void;
  36924. private _markSubMeshesAsDirty;
  36925. /** @hidden */
  36926. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  36927. /** @hidden */
  36928. _markSubMeshesAsAttributesDirty(): void;
  36929. /** @hidden */
  36930. _markSubMeshesAsMiscDirty(): void;
  36931. /**
  36932. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  36933. */
  36934. get scaling(): Vector3;
  36935. set scaling(newScaling: Vector3);
  36936. /**
  36937. * Returns true if the mesh is blocked. Implemented by child classes
  36938. */
  36939. get isBlocked(): boolean;
  36940. /**
  36941. * Returns the mesh itself by default. Implemented by child classes
  36942. * @param camera defines the camera to use to pick the right LOD level
  36943. * @returns the currentAbstractMesh
  36944. */
  36945. getLOD(camera: Camera): Nullable<AbstractMesh>;
  36946. /**
  36947. * Returns 0 by default. Implemented by child classes
  36948. * @returns an integer
  36949. */
  36950. getTotalVertices(): number;
  36951. /**
  36952. * Returns a positive integer : the total number of indices in this mesh geometry.
  36953. * @returns the number of indices or zero if the mesh has no geometry.
  36954. */
  36955. getTotalIndices(): number;
  36956. /**
  36957. * Returns null by default. Implemented by child classes
  36958. * @returns null
  36959. */
  36960. getIndices(): Nullable<IndicesArray>;
  36961. /**
  36962. * Returns the array of the requested vertex data kind. Implemented by child classes
  36963. * @param kind defines the vertex data kind to use
  36964. * @returns null
  36965. */
  36966. getVerticesData(kind: string): Nullable<FloatArray>;
  36967. /**
  36968. * Sets the vertex data of the mesh geometry for the requested `kind`.
  36969. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  36970. * Note that a new underlying VertexBuffer object is created each call.
  36971. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  36972. * @param kind defines vertex data kind:
  36973. * * VertexBuffer.PositionKind
  36974. * * VertexBuffer.UVKind
  36975. * * VertexBuffer.UV2Kind
  36976. * * VertexBuffer.UV3Kind
  36977. * * VertexBuffer.UV4Kind
  36978. * * VertexBuffer.UV5Kind
  36979. * * VertexBuffer.UV6Kind
  36980. * * VertexBuffer.ColorKind
  36981. * * VertexBuffer.MatricesIndicesKind
  36982. * * VertexBuffer.MatricesIndicesExtraKind
  36983. * * VertexBuffer.MatricesWeightsKind
  36984. * * VertexBuffer.MatricesWeightsExtraKind
  36985. * @param data defines the data source
  36986. * @param updatable defines if the data must be flagged as updatable (or static)
  36987. * @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
  36988. * @returns the current mesh
  36989. */
  36990. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  36991. /**
  36992. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  36993. * If the mesh has no geometry, it is simply returned as it is.
  36994. * @param kind defines vertex data kind:
  36995. * * VertexBuffer.PositionKind
  36996. * * VertexBuffer.UVKind
  36997. * * VertexBuffer.UV2Kind
  36998. * * VertexBuffer.UV3Kind
  36999. * * VertexBuffer.UV4Kind
  37000. * * VertexBuffer.UV5Kind
  37001. * * VertexBuffer.UV6Kind
  37002. * * VertexBuffer.ColorKind
  37003. * * VertexBuffer.MatricesIndicesKind
  37004. * * VertexBuffer.MatricesIndicesExtraKind
  37005. * * VertexBuffer.MatricesWeightsKind
  37006. * * VertexBuffer.MatricesWeightsExtraKind
  37007. * @param data defines the data source
  37008. * @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
  37009. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  37010. * @returns the current mesh
  37011. */
  37012. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  37013. /**
  37014. * Sets the mesh indices,
  37015. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  37016. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  37017. * @param totalVertices Defines the total number of vertices
  37018. * @returns the current mesh
  37019. */
  37020. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  37021. /**
  37022. * Gets a boolean indicating if specific vertex data is present
  37023. * @param kind defines the vertex data kind to use
  37024. * @returns true is data kind is present
  37025. */
  37026. isVerticesDataPresent(kind: string): boolean;
  37027. /**
  37028. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  37029. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  37030. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  37031. * @returns a BoundingInfo
  37032. */
  37033. getBoundingInfo(): BoundingInfo;
  37034. /**
  37035. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  37036. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  37037. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  37038. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  37039. * @returns the current mesh
  37040. */
  37041. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  37042. /**
  37043. * Overwrite the current bounding info
  37044. * @param boundingInfo defines the new bounding info
  37045. * @returns the current mesh
  37046. */
  37047. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  37048. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  37049. get useBones(): boolean;
  37050. /** @hidden */
  37051. _preActivate(): void;
  37052. /** @hidden */
  37053. _preActivateForIntermediateRendering(renderId: number): void;
  37054. /** @hidden */
  37055. _activate(renderId: number, intermediateRendering: boolean): boolean;
  37056. /** @hidden */
  37057. _postActivate(): void;
  37058. /** @hidden */
  37059. _freeze(): void;
  37060. /** @hidden */
  37061. _unFreeze(): void;
  37062. /**
  37063. * Gets the current world matrix
  37064. * @returns a Matrix
  37065. */
  37066. getWorldMatrix(): Matrix;
  37067. /** @hidden */
  37068. _getWorldMatrixDeterminant(): number;
  37069. /**
  37070. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  37071. */
  37072. get isAnInstance(): boolean;
  37073. /**
  37074. * Gets a boolean indicating if this mesh has instances
  37075. */
  37076. get hasInstances(): boolean;
  37077. /**
  37078. * Gets a boolean indicating if this mesh has thin instances
  37079. */
  37080. get hasThinInstances(): boolean;
  37081. /**
  37082. * Perform relative position change from the point of view of behind the front of the mesh.
  37083. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37084. * Supports definition of mesh facing forward or backward
  37085. * @param amountRight defines the distance on the right axis
  37086. * @param amountUp defines the distance on the up axis
  37087. * @param amountForward defines the distance on the forward axis
  37088. * @returns the current mesh
  37089. */
  37090. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  37091. /**
  37092. * Calculate relative position change from the point of view of behind the front of the mesh.
  37093. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37094. * Supports definition of mesh facing forward or backward
  37095. * @param amountRight defines the distance on the right axis
  37096. * @param amountUp defines the distance on the up axis
  37097. * @param amountForward defines the distance on the forward axis
  37098. * @returns the new displacement vector
  37099. */
  37100. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  37101. /**
  37102. * Perform relative rotation change from the point of view of behind the front of the mesh.
  37103. * Supports definition of mesh facing forward or backward
  37104. * @param flipBack defines the flip
  37105. * @param twirlClockwise defines the twirl
  37106. * @param tiltRight defines the tilt
  37107. * @returns the current mesh
  37108. */
  37109. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  37110. /**
  37111. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  37112. * Supports definition of mesh facing forward or backward.
  37113. * @param flipBack defines the flip
  37114. * @param twirlClockwise defines the twirl
  37115. * @param tiltRight defines the tilt
  37116. * @returns the new rotation vector
  37117. */
  37118. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  37119. /**
  37120. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  37121. * This means the mesh underlying bounding box and sphere are recomputed.
  37122. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  37123. * @returns the current mesh
  37124. */
  37125. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  37126. /** @hidden */
  37127. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  37128. /** @hidden */
  37129. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  37130. /** @hidden */
  37131. _updateBoundingInfo(): AbstractMesh;
  37132. /** @hidden */
  37133. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  37134. /** @hidden */
  37135. protected _afterComputeWorldMatrix(): void;
  37136. /** @hidden */
  37137. get _effectiveMesh(): AbstractMesh;
  37138. /**
  37139. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  37140. * A mesh is in the frustum if its bounding box intersects the frustum
  37141. * @param frustumPlanes defines the frustum to test
  37142. * @returns true if the mesh is in the frustum planes
  37143. */
  37144. isInFrustum(frustumPlanes: Plane[]): boolean;
  37145. /**
  37146. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  37147. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  37148. * @param frustumPlanes defines the frustum to test
  37149. * @returns true if the mesh is completely in the frustum planes
  37150. */
  37151. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  37152. /**
  37153. * True if the mesh intersects another mesh or a SolidParticle object
  37154. * @param mesh defines a target mesh or SolidParticle to test
  37155. * @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)
  37156. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  37157. * @returns true if there is an intersection
  37158. */
  37159. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  37160. /**
  37161. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  37162. * @param point defines the point to test
  37163. * @returns true if there is an intersection
  37164. */
  37165. intersectsPoint(point: Vector3): boolean;
  37166. /**
  37167. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  37168. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37169. */
  37170. get checkCollisions(): boolean;
  37171. set checkCollisions(collisionEnabled: boolean);
  37172. /**
  37173. * Gets Collider object used to compute collisions (not physics)
  37174. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37175. */
  37176. get collider(): Nullable<Collider>;
  37177. /**
  37178. * Move the mesh using collision engine
  37179. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37180. * @param displacement defines the requested displacement vector
  37181. * @returns the current mesh
  37182. */
  37183. moveWithCollisions(displacement: Vector3): AbstractMesh;
  37184. private _onCollisionPositionChange;
  37185. /** @hidden */
  37186. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  37187. /** @hidden */
  37188. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  37189. /** @hidden */
  37190. _checkCollision(collider: Collider): AbstractMesh;
  37191. /** @hidden */
  37192. _generatePointsArray(): boolean;
  37193. /**
  37194. * Checks if the passed Ray intersects with the mesh
  37195. * @param ray defines the ray to use
  37196. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  37197. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37198. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  37199. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  37200. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  37201. * @returns the picking info
  37202. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  37203. */
  37204. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  37205. /**
  37206. * Clones the current mesh
  37207. * @param name defines the mesh name
  37208. * @param newParent defines the new mesh parent
  37209. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  37210. * @returns the new mesh
  37211. */
  37212. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  37213. /**
  37214. * Disposes all the submeshes of the current meshnp
  37215. * @returns the current mesh
  37216. */
  37217. releaseSubMeshes(): AbstractMesh;
  37218. /**
  37219. * Releases resources associated with this abstract mesh.
  37220. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37221. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37222. */
  37223. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37224. /**
  37225. * Adds the passed mesh as a child to the current mesh
  37226. * @param mesh defines the child mesh
  37227. * @returns the current mesh
  37228. */
  37229. addChild(mesh: AbstractMesh): AbstractMesh;
  37230. /**
  37231. * Removes the passed mesh from the current mesh children list
  37232. * @param mesh defines the child mesh
  37233. * @returns the current mesh
  37234. */
  37235. removeChild(mesh: AbstractMesh): AbstractMesh;
  37236. /** @hidden */
  37237. private _initFacetData;
  37238. /**
  37239. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  37240. * This method can be called within the render loop.
  37241. * 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
  37242. * @returns the current mesh
  37243. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37244. */
  37245. updateFacetData(): AbstractMesh;
  37246. /**
  37247. * Returns the facetLocalNormals array.
  37248. * The normals are expressed in the mesh local spac
  37249. * @returns an array of Vector3
  37250. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37251. */
  37252. getFacetLocalNormals(): Vector3[];
  37253. /**
  37254. * Returns the facetLocalPositions array.
  37255. * The facet positions are expressed in the mesh local space
  37256. * @returns an array of Vector3
  37257. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37258. */
  37259. getFacetLocalPositions(): Vector3[];
  37260. /**
  37261. * Returns the facetLocalPartitioning array
  37262. * @returns an array of array of numbers
  37263. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37264. */
  37265. getFacetLocalPartitioning(): number[][];
  37266. /**
  37267. * Returns the i-th facet position in the world system.
  37268. * This method allocates a new Vector3 per call
  37269. * @param i defines the facet index
  37270. * @returns a new Vector3
  37271. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37272. */
  37273. getFacetPosition(i: number): Vector3;
  37274. /**
  37275. * Sets the reference Vector3 with the i-th facet position in the world system
  37276. * @param i defines the facet index
  37277. * @param ref defines the target vector
  37278. * @returns the current mesh
  37279. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37280. */
  37281. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  37282. /**
  37283. * Returns the i-th facet normal in the world system.
  37284. * This method allocates a new Vector3 per call
  37285. * @param i defines the facet index
  37286. * @returns a new Vector3
  37287. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37288. */
  37289. getFacetNormal(i: number): Vector3;
  37290. /**
  37291. * Sets the reference Vector3 with the i-th facet normal in the world system
  37292. * @param i defines the facet index
  37293. * @param ref defines the target vector
  37294. * @returns the current mesh
  37295. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37296. */
  37297. getFacetNormalToRef(i: number, ref: Vector3): this;
  37298. /**
  37299. * 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)
  37300. * @param x defines x coordinate
  37301. * @param y defines y coordinate
  37302. * @param z defines z coordinate
  37303. * @returns the array of facet indexes
  37304. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37305. */
  37306. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  37307. /**
  37308. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  37309. * @param projected sets as the (x,y,z) world projection on the facet
  37310. * @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
  37311. * @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
  37312. * @param x defines x coordinate
  37313. * @param y defines y coordinate
  37314. * @param z defines z coordinate
  37315. * @returns the face index if found (or null instead)
  37316. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37317. */
  37318. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37319. /**
  37320. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  37321. * @param projected sets as the (x,y,z) local projection on the facet
  37322. * @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
  37323. * @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
  37324. * @param x defines x coordinate
  37325. * @param y defines y coordinate
  37326. * @param z defines z coordinate
  37327. * @returns the face index if found (or null instead)
  37328. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37329. */
  37330. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37331. /**
  37332. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  37333. * @returns the parameters
  37334. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37335. */
  37336. getFacetDataParameters(): any;
  37337. /**
  37338. * Disables the feature FacetData and frees the related memory
  37339. * @returns the current mesh
  37340. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37341. */
  37342. disableFacetData(): AbstractMesh;
  37343. /**
  37344. * Updates the AbstractMesh indices array
  37345. * @param indices defines the data source
  37346. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  37347. * @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)
  37348. * @returns the current mesh
  37349. */
  37350. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  37351. /**
  37352. * Creates new normals data for the mesh
  37353. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  37354. * @returns the current mesh
  37355. */
  37356. createNormals(updatable: boolean): AbstractMesh;
  37357. /**
  37358. * Align the mesh with a normal
  37359. * @param normal defines the normal to use
  37360. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  37361. * @returns the current mesh
  37362. */
  37363. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  37364. /** @hidden */
  37365. _checkOcclusionQuery(): boolean;
  37366. /**
  37367. * Disables the mesh edge rendering mode
  37368. * @returns the currentAbstractMesh
  37369. */
  37370. disableEdgesRendering(): AbstractMesh;
  37371. /**
  37372. * Enables the edge rendering mode on the mesh.
  37373. * This mode makes the mesh edges visible
  37374. * @param epsilon defines the maximal distance between two angles to detect a face
  37375. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  37376. * @param options options to the edge renderer
  37377. * @returns the currentAbstractMesh
  37378. * @see https://www.babylonjs-playground.com/#19O9TU#0
  37379. */
  37380. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  37381. /**
  37382. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  37383. * @returns an array of particle systems in the scene that use the mesh as an emitter
  37384. */
  37385. getConnectedParticleSystems(): IParticleSystem[];
  37386. }
  37387. }
  37388. declare module BABYLON {
  37389. /**
  37390. * Interface used to define ActionEvent
  37391. */
  37392. export interface IActionEvent {
  37393. /** The mesh or sprite that triggered the action */
  37394. source: any;
  37395. /** The X mouse cursor position at the time of the event */
  37396. pointerX: number;
  37397. /** The Y mouse cursor position at the time of the event */
  37398. pointerY: number;
  37399. /** The mesh that is currently pointed at (can be null) */
  37400. meshUnderPointer: Nullable<AbstractMesh>;
  37401. /** the original (browser) event that triggered the ActionEvent */
  37402. sourceEvent?: any;
  37403. /** additional data for the event */
  37404. additionalData?: any;
  37405. }
  37406. /**
  37407. * ActionEvent is the event being sent when an action is triggered.
  37408. */
  37409. export class ActionEvent implements IActionEvent {
  37410. /** The mesh or sprite that triggered the action */
  37411. source: any;
  37412. /** The X mouse cursor position at the time of the event */
  37413. pointerX: number;
  37414. /** The Y mouse cursor position at the time of the event */
  37415. pointerY: number;
  37416. /** The mesh that is currently pointed at (can be null) */
  37417. meshUnderPointer: Nullable<AbstractMesh>;
  37418. /** the original (browser) event that triggered the ActionEvent */
  37419. sourceEvent?: any;
  37420. /** additional data for the event */
  37421. additionalData?: any;
  37422. /**
  37423. * Creates a new ActionEvent
  37424. * @param source The mesh or sprite that triggered the action
  37425. * @param pointerX The X mouse cursor position at the time of the event
  37426. * @param pointerY The Y mouse cursor position at the time of the event
  37427. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  37428. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  37429. * @param additionalData additional data for the event
  37430. */
  37431. constructor(
  37432. /** The mesh or sprite that triggered the action */
  37433. source: any,
  37434. /** The X mouse cursor position at the time of the event */
  37435. pointerX: number,
  37436. /** The Y mouse cursor position at the time of the event */
  37437. pointerY: number,
  37438. /** The mesh that is currently pointed at (can be null) */
  37439. meshUnderPointer: Nullable<AbstractMesh>,
  37440. /** the original (browser) event that triggered the ActionEvent */
  37441. sourceEvent?: any,
  37442. /** additional data for the event */
  37443. additionalData?: any);
  37444. /**
  37445. * Helper function to auto-create an ActionEvent from a source mesh.
  37446. * @param source The source mesh that triggered the event
  37447. * @param evt The original (browser) event
  37448. * @param additionalData additional data for the event
  37449. * @returns the new ActionEvent
  37450. */
  37451. static CreateNew(source: AbstractMesh, evt?: IEvent, additionalData?: any): ActionEvent;
  37452. /**
  37453. * Helper function to auto-create an ActionEvent from a source sprite
  37454. * @param source The source sprite that triggered the event
  37455. * @param scene Scene associated with the sprite
  37456. * @param evt The original (browser) event
  37457. * @param additionalData additional data for the event
  37458. * @returns the new ActionEvent
  37459. */
  37460. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: IEvent, additionalData?: any): ActionEvent;
  37461. /**
  37462. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  37463. * @param scene the scene where the event occurred
  37464. * @param evt The original (browser) event
  37465. * @returns the new ActionEvent
  37466. */
  37467. static CreateNewFromScene(scene: Scene, evt: IEvent): ActionEvent;
  37468. /**
  37469. * Helper function to auto-create an ActionEvent from a primitive
  37470. * @param prim defines the target primitive
  37471. * @param pointerPos defines the pointer position
  37472. * @param evt The original (browser) event
  37473. * @param additionalData additional data for the event
  37474. * @returns the new ActionEvent
  37475. */
  37476. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  37477. }
  37478. }
  37479. declare module BABYLON {
  37480. /**
  37481. * Abstract class used to decouple action Manager from scene and meshes.
  37482. * Do not instantiate.
  37483. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  37484. */
  37485. export abstract class AbstractActionManager implements IDisposable {
  37486. /** Gets the list of active triggers */
  37487. static Triggers: {
  37488. [key: string]: number;
  37489. };
  37490. /** Gets the cursor to use when hovering items */
  37491. hoverCursor: string;
  37492. /** Gets the list of actions */
  37493. actions: IAction[];
  37494. /**
  37495. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  37496. */
  37497. isRecursive: boolean;
  37498. /**
  37499. * Releases all associated resources
  37500. */
  37501. abstract dispose(): void;
  37502. /**
  37503. * Does this action manager has pointer triggers
  37504. */
  37505. abstract get hasPointerTriggers(): boolean;
  37506. /**
  37507. * Does this action manager has pick triggers
  37508. */
  37509. abstract get hasPickTriggers(): boolean;
  37510. /**
  37511. * Process a specific trigger
  37512. * @param trigger defines the trigger to process
  37513. * @param evt defines the event details to be processed
  37514. */
  37515. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  37516. /**
  37517. * Does this action manager handles actions of any of the given triggers
  37518. * @param triggers defines the triggers to be tested
  37519. * @return a boolean indicating whether one (or more) of the triggers is handled
  37520. */
  37521. abstract hasSpecificTriggers(triggers: number[]): boolean;
  37522. /**
  37523. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  37524. * speed.
  37525. * @param triggerA defines the trigger to be tested
  37526. * @param triggerB defines the trigger to be tested
  37527. * @return a boolean indicating whether one (or more) of the triggers is handled
  37528. */
  37529. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  37530. /**
  37531. * Does this action manager handles actions of a given trigger
  37532. * @param trigger defines the trigger to be tested
  37533. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  37534. * @return whether the trigger is handled
  37535. */
  37536. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  37537. /**
  37538. * Serialize this manager to a JSON object
  37539. * @param name defines the property name to store this manager
  37540. * @returns a JSON representation of this manager
  37541. */
  37542. abstract serialize(name: string): any;
  37543. /**
  37544. * Registers an action to this action manager
  37545. * @param action defines the action to be registered
  37546. * @return the action amended (prepared) after registration
  37547. */
  37548. abstract registerAction(action: IAction): Nullable<IAction>;
  37549. /**
  37550. * Unregisters an action to this action manager
  37551. * @param action defines the action to be unregistered
  37552. * @return a boolean indicating whether the action has been unregistered
  37553. */
  37554. abstract unregisterAction(action: IAction): Boolean;
  37555. /**
  37556. * Does exist one action manager with at least one trigger
  37557. **/
  37558. static get HasTriggers(): boolean;
  37559. /**
  37560. * Does exist one action manager with at least one pick trigger
  37561. **/
  37562. static get HasPickTriggers(): boolean;
  37563. /**
  37564. * Does exist one action manager that handles actions of a given trigger
  37565. * @param trigger defines the trigger to be tested
  37566. * @return a boolean indicating whether the trigger is handled by at least one action manager
  37567. **/
  37568. static HasSpecificTrigger(trigger: number): boolean;
  37569. }
  37570. }
  37571. declare module BABYLON {
  37572. /**
  37573. * Defines how a node can be built from a string name.
  37574. */
  37575. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  37576. /**
  37577. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  37578. */
  37579. export class Node implements IBehaviorAware<Node> {
  37580. /** @hidden */
  37581. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  37582. private static _NodeConstructors;
  37583. /**
  37584. * Add a new node constructor
  37585. * @param type defines the type name of the node to construct
  37586. * @param constructorFunc defines the constructor function
  37587. */
  37588. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  37589. /**
  37590. * Returns a node constructor based on type name
  37591. * @param type defines the type name
  37592. * @param name defines the new node name
  37593. * @param scene defines the hosting scene
  37594. * @param options defines optional options to transmit to constructors
  37595. * @returns the new constructor or null
  37596. */
  37597. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  37598. /**
  37599. * Gets or sets the name of the node
  37600. */
  37601. name: string;
  37602. /**
  37603. * Gets or sets the id of the node
  37604. */
  37605. id: string;
  37606. /**
  37607. * Gets or sets the unique id of the node
  37608. */
  37609. uniqueId: number;
  37610. /**
  37611. * Gets or sets a string used to store user defined state for the node
  37612. */
  37613. state: string;
  37614. /**
  37615. * Gets or sets an object used to store user defined information for the node
  37616. */
  37617. metadata: any;
  37618. /**
  37619. * For internal use only. Please do not use.
  37620. */
  37621. reservedDataStore: any;
  37622. /**
  37623. * List of inspectable custom properties (used by the Inspector)
  37624. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  37625. */
  37626. inspectableCustomProperties: IInspectable[];
  37627. private _doNotSerialize;
  37628. /**
  37629. * Gets or sets a boolean used to define if the node must be serialized
  37630. */
  37631. get doNotSerialize(): boolean;
  37632. set doNotSerialize(value: boolean);
  37633. /** @hidden */
  37634. _isDisposed: boolean;
  37635. /**
  37636. * Gets a list of Animations associated with the node
  37637. */
  37638. animations: Animation[];
  37639. protected _ranges: {
  37640. [name: string]: Nullable<AnimationRange>;
  37641. };
  37642. /**
  37643. * Callback raised when the node is ready to be used
  37644. */
  37645. onReady: Nullable<(node: Node) => void>;
  37646. private _isEnabled;
  37647. private _isParentEnabled;
  37648. private _isReady;
  37649. /** @hidden */
  37650. _currentRenderId: number;
  37651. private _parentUpdateId;
  37652. /** @hidden */
  37653. _childUpdateId: number;
  37654. /** @hidden */
  37655. _waitingParentId: Nullable<string>;
  37656. /** @hidden */
  37657. _scene: Scene;
  37658. /** @hidden */
  37659. _cache: any;
  37660. private _parentNode;
  37661. private _children;
  37662. /** @hidden */
  37663. _worldMatrix: Matrix;
  37664. /** @hidden */
  37665. _worldMatrixDeterminant: number;
  37666. /** @hidden */
  37667. _worldMatrixDeterminantIsDirty: boolean;
  37668. /** @hidden */
  37669. private _sceneRootNodesIndex;
  37670. /**
  37671. * Gets a boolean indicating if the node has been disposed
  37672. * @returns true if the node was disposed
  37673. */
  37674. isDisposed(): boolean;
  37675. /**
  37676. * Gets or sets the parent of the node (without keeping the current position in the scene)
  37677. * @see https://doc.babylonjs.com/how_to/parenting
  37678. */
  37679. set parent(parent: Nullable<Node>);
  37680. get parent(): Nullable<Node>;
  37681. /** @hidden */
  37682. _addToSceneRootNodes(): void;
  37683. /** @hidden */
  37684. _removeFromSceneRootNodes(): void;
  37685. private _animationPropertiesOverride;
  37686. /**
  37687. * Gets or sets the animation properties override
  37688. */
  37689. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  37690. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  37691. /**
  37692. * Gets a string identifying the name of the class
  37693. * @returns "Node" string
  37694. */
  37695. getClassName(): string;
  37696. /** @hidden */
  37697. readonly _isNode: boolean;
  37698. /**
  37699. * An event triggered when the mesh is disposed
  37700. */
  37701. onDisposeObservable: Observable<Node>;
  37702. private _onDisposeObserver;
  37703. /**
  37704. * Sets a callback that will be raised when the node will be disposed
  37705. */
  37706. set onDispose(callback: () => void);
  37707. /**
  37708. * Creates a new Node
  37709. * @param name the name and id to be given to this node
  37710. * @param scene the scene this node will be added to
  37711. */
  37712. constructor(name: string, scene?: Nullable<Scene>);
  37713. /**
  37714. * Gets the scene of the node
  37715. * @returns a scene
  37716. */
  37717. getScene(): Scene;
  37718. /**
  37719. * Gets the engine of the node
  37720. * @returns a Engine
  37721. */
  37722. getEngine(): Engine;
  37723. private _behaviors;
  37724. /**
  37725. * Attach a behavior to the node
  37726. * @see https://doc.babylonjs.com/features/behaviour
  37727. * @param behavior defines the behavior to attach
  37728. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  37729. * @returns the current Node
  37730. */
  37731. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  37732. /**
  37733. * Remove an attached behavior
  37734. * @see https://doc.babylonjs.com/features/behaviour
  37735. * @param behavior defines the behavior to attach
  37736. * @returns the current Node
  37737. */
  37738. removeBehavior(behavior: Behavior<Node>): Node;
  37739. /**
  37740. * Gets the list of attached behaviors
  37741. * @see https://doc.babylonjs.com/features/behaviour
  37742. */
  37743. get behaviors(): Behavior<Node>[];
  37744. /**
  37745. * Gets an attached behavior by name
  37746. * @param name defines the name of the behavior to look for
  37747. * @see https://doc.babylonjs.com/features/behaviour
  37748. * @returns null if behavior was not found else the requested behavior
  37749. */
  37750. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  37751. /**
  37752. * Returns the latest update of the World matrix
  37753. * @returns a Matrix
  37754. */
  37755. getWorldMatrix(): Matrix;
  37756. /** @hidden */
  37757. _getWorldMatrixDeterminant(): number;
  37758. /**
  37759. * Returns directly the latest state of the mesh World matrix.
  37760. * A Matrix is returned.
  37761. */
  37762. get worldMatrixFromCache(): Matrix;
  37763. /** @hidden */
  37764. _initCache(): void;
  37765. /** @hidden */
  37766. updateCache(force?: boolean): void;
  37767. /** @hidden */
  37768. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37769. /** @hidden */
  37770. _updateCache(ignoreParentClass?: boolean): void;
  37771. /** @hidden */
  37772. _isSynchronized(): boolean;
  37773. /** @hidden */
  37774. _markSyncedWithParent(): void;
  37775. /** @hidden */
  37776. isSynchronizedWithParent(): boolean;
  37777. /** @hidden */
  37778. isSynchronized(): boolean;
  37779. /**
  37780. * Is this node ready to be used/rendered
  37781. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  37782. * @return true if the node is ready
  37783. */
  37784. isReady(completeCheck?: boolean): boolean;
  37785. /**
  37786. * Is this node enabled?
  37787. * 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
  37788. * @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
  37789. * @return whether this node (and its parent) is enabled
  37790. */
  37791. isEnabled(checkAncestors?: boolean): boolean;
  37792. /** @hidden */
  37793. protected _syncParentEnabledState(): void;
  37794. /**
  37795. * Set the enabled state of this node
  37796. * @param value defines the new enabled state
  37797. */
  37798. setEnabled(value: boolean): void;
  37799. /**
  37800. * Is this node a descendant of the given node?
  37801. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  37802. * @param ancestor defines the parent node to inspect
  37803. * @returns a boolean indicating if this node is a descendant of the given node
  37804. */
  37805. isDescendantOf(ancestor: Node): boolean;
  37806. /** @hidden */
  37807. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  37808. /**
  37809. * Will return all nodes that have this node as ascendant
  37810. * @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
  37811. * @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
  37812. * @return all children nodes of all types
  37813. */
  37814. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  37815. /**
  37816. * Get all child-meshes of this node
  37817. * @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)
  37818. * @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
  37819. * @returns an array of AbstractMesh
  37820. */
  37821. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  37822. /**
  37823. * Get all direct children of this node
  37824. * @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
  37825. * @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)
  37826. * @returns an array of Node
  37827. */
  37828. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  37829. /** @hidden */
  37830. _setReady(state: boolean): void;
  37831. /**
  37832. * Get an animation by name
  37833. * @param name defines the name of the animation to look for
  37834. * @returns null if not found else the requested animation
  37835. */
  37836. getAnimationByName(name: string): Nullable<Animation>;
  37837. /**
  37838. * Creates an animation range for this node
  37839. * @param name defines the name of the range
  37840. * @param from defines the starting key
  37841. * @param to defines the end key
  37842. */
  37843. createAnimationRange(name: string, from: number, to: number): void;
  37844. /**
  37845. * Delete a specific animation range
  37846. * @param name defines the name of the range to delete
  37847. * @param deleteFrames defines if animation frames from the range must be deleted as well
  37848. */
  37849. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  37850. /**
  37851. * Get an animation range by name
  37852. * @param name defines the name of the animation range to look for
  37853. * @returns null if not found else the requested animation range
  37854. */
  37855. getAnimationRange(name: string): Nullable<AnimationRange>;
  37856. /**
  37857. * Gets the list of all animation ranges defined on this node
  37858. * @returns an array
  37859. */
  37860. getAnimationRanges(): Nullable<AnimationRange>[];
  37861. /**
  37862. * Will start the animation sequence
  37863. * @param name defines the range frames for animation sequence
  37864. * @param loop defines if the animation should loop (false by default)
  37865. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  37866. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  37867. * @returns the object created for this animation. If range does not exist, it will return null
  37868. */
  37869. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  37870. /**
  37871. * Serialize animation ranges into a JSON compatible object
  37872. * @returns serialization object
  37873. */
  37874. serializeAnimationRanges(): any;
  37875. /**
  37876. * Computes the world matrix of the node
  37877. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  37878. * @returns the world matrix
  37879. */
  37880. computeWorldMatrix(force?: boolean): Matrix;
  37881. /**
  37882. * Releases resources associated with this node.
  37883. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37884. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37885. */
  37886. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37887. /**
  37888. * Parse animation range data from a serialization object and store them into a given node
  37889. * @param node defines where to store the animation ranges
  37890. * @param parsedNode defines the serialization object to read data from
  37891. * @param scene defines the hosting scene
  37892. */
  37893. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  37894. /**
  37895. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  37896. * @param includeDescendants Include bounding info from descendants as well (true by default)
  37897. * @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
  37898. * @returns the new bounding vectors
  37899. */
  37900. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  37901. min: Vector3;
  37902. max: Vector3;
  37903. };
  37904. }
  37905. }
  37906. declare module BABYLON {
  37907. /**
  37908. * @hidden
  37909. */
  37910. export class _IAnimationState {
  37911. key: number;
  37912. repeatCount: number;
  37913. workValue?: any;
  37914. loopMode?: number;
  37915. offsetValue?: any;
  37916. highLimitValue?: any;
  37917. }
  37918. /**
  37919. * Class used to store any kind of animation
  37920. */
  37921. export class Animation {
  37922. /**Name of the animation */
  37923. name: string;
  37924. /**Property to animate */
  37925. targetProperty: string;
  37926. /**The frames per second of the animation */
  37927. framePerSecond: number;
  37928. /**The data type of the animation */
  37929. dataType: number;
  37930. /**The loop mode of the animation */
  37931. loopMode?: number | undefined;
  37932. /**Specifies if blending should be enabled */
  37933. enableBlending?: boolean | undefined;
  37934. /**
  37935. * Use matrix interpolation instead of using direct key value when animating matrices
  37936. */
  37937. static AllowMatricesInterpolation: boolean;
  37938. /**
  37939. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  37940. */
  37941. static AllowMatrixDecomposeForInterpolation: boolean;
  37942. /** Define the Url to load snippets */
  37943. static SnippetUrl: string;
  37944. /** Snippet ID if the animation was created from the snippet server */
  37945. snippetId: string;
  37946. /**
  37947. * Stores the key frames of the animation
  37948. */
  37949. private _keys;
  37950. /**
  37951. * Stores the easing function of the animation
  37952. */
  37953. private _easingFunction;
  37954. /**
  37955. * @hidden Internal use only
  37956. */
  37957. _runtimeAnimations: RuntimeAnimation[];
  37958. /**
  37959. * The set of event that will be linked to this animation
  37960. */
  37961. private _events;
  37962. /**
  37963. * Stores an array of target property paths
  37964. */
  37965. targetPropertyPath: string[];
  37966. /**
  37967. * Stores the blending speed of the animation
  37968. */
  37969. blendingSpeed: number;
  37970. /**
  37971. * Stores the animation ranges for the animation
  37972. */
  37973. private _ranges;
  37974. /**
  37975. * @hidden Internal use
  37976. */
  37977. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  37978. /**
  37979. * Sets up an animation
  37980. * @param property The property to animate
  37981. * @param animationType The animation type to apply
  37982. * @param framePerSecond The frames per second of the animation
  37983. * @param easingFunction The easing function used in the animation
  37984. * @returns The created animation
  37985. */
  37986. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  37987. /**
  37988. * Create and start an animation on a node
  37989. * @param name defines the name of the global animation that will be run on all nodes
  37990. * @param node defines the root node where the animation will take place
  37991. * @param targetProperty defines property to animate
  37992. * @param framePerSecond defines the number of frame per second yo use
  37993. * @param totalFrame defines the number of frames in total
  37994. * @param from defines the initial value
  37995. * @param to defines the final value
  37996. * @param loopMode defines which loop mode you want to use (off by default)
  37997. * @param easingFunction defines the easing function to use (linear by default)
  37998. * @param onAnimationEnd defines the callback to call when animation end
  37999. * @returns the animatable created for this animation
  38000. */
  38001. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  38002. /**
  38003. * Create and start an animation on a node and its descendants
  38004. * @param name defines the name of the global animation that will be run on all nodes
  38005. * @param node defines the root node where the animation will take place
  38006. * @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
  38007. * @param targetProperty defines property to animate
  38008. * @param framePerSecond defines the number of frame per second to use
  38009. * @param totalFrame defines the number of frames in total
  38010. * @param from defines the initial value
  38011. * @param to defines the final value
  38012. * @param loopMode defines which loop mode you want to use (off by default)
  38013. * @param easingFunction defines the easing function to use (linear by default)
  38014. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  38015. * @returns the list of animatables created for all nodes
  38016. * @example https://www.babylonjs-playground.com/#MH0VLI
  38017. */
  38018. 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[]>;
  38019. /**
  38020. * Creates a new animation, merges it with the existing animations and starts it
  38021. * @param name Name of the animation
  38022. * @param node Node which contains the scene that begins the animations
  38023. * @param targetProperty Specifies which property to animate
  38024. * @param framePerSecond The frames per second of the animation
  38025. * @param totalFrame The total number of frames
  38026. * @param from The frame at the beginning of the animation
  38027. * @param to The frame at the end of the animation
  38028. * @param loopMode Specifies the loop mode of the animation
  38029. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  38030. * @param onAnimationEnd Callback to run once the animation is complete
  38031. * @returns Nullable animation
  38032. */
  38033. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  38034. /**
  38035. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38036. * @param sourceAnimation defines the Animation containing keyframes to convert
  38037. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38038. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  38039. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  38040. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  38041. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  38042. */
  38043. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  38044. /**
  38045. * Transition property of an host to the target Value
  38046. * @param property The property to transition
  38047. * @param targetValue The target Value of the property
  38048. * @param host The object where the property to animate belongs
  38049. * @param scene Scene used to run the animation
  38050. * @param frameRate Framerate (in frame/s) to use
  38051. * @param transition The transition type we want to use
  38052. * @param duration The duration of the animation, in milliseconds
  38053. * @param onAnimationEnd Callback trigger at the end of the animation
  38054. * @returns Nullable animation
  38055. */
  38056. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  38057. /**
  38058. * Return the array of runtime animations currently using this animation
  38059. */
  38060. get runtimeAnimations(): RuntimeAnimation[];
  38061. /**
  38062. * Specifies if any of the runtime animations are currently running
  38063. */
  38064. get hasRunningRuntimeAnimations(): boolean;
  38065. /**
  38066. * Initializes the animation
  38067. * @param name Name of the animation
  38068. * @param targetProperty Property to animate
  38069. * @param framePerSecond The frames per second of the animation
  38070. * @param dataType The data type of the animation
  38071. * @param loopMode The loop mode of the animation
  38072. * @param enableBlending Specifies if blending should be enabled
  38073. */
  38074. constructor(
  38075. /**Name of the animation */
  38076. name: string,
  38077. /**Property to animate */
  38078. targetProperty: string,
  38079. /**The frames per second of the animation */
  38080. framePerSecond: number,
  38081. /**The data type of the animation */
  38082. dataType: number,
  38083. /**The loop mode of the animation */
  38084. loopMode?: number | undefined,
  38085. /**Specifies if blending should be enabled */
  38086. enableBlending?: boolean | undefined);
  38087. /**
  38088. * Converts the animation to a string
  38089. * @param fullDetails support for multiple levels of logging within scene loading
  38090. * @returns String form of the animation
  38091. */
  38092. toString(fullDetails?: boolean): string;
  38093. /**
  38094. * Add an event to this animation
  38095. * @param event Event to add
  38096. */
  38097. addEvent(event: AnimationEvent): void;
  38098. /**
  38099. * Remove all events found at the given frame
  38100. * @param frame The frame to remove events from
  38101. */
  38102. removeEvents(frame: number): void;
  38103. /**
  38104. * Retrieves all the events from the animation
  38105. * @returns Events from the animation
  38106. */
  38107. getEvents(): AnimationEvent[];
  38108. /**
  38109. * Creates an animation range
  38110. * @param name Name of the animation range
  38111. * @param from Starting frame of the animation range
  38112. * @param to Ending frame of the animation
  38113. */
  38114. createRange(name: string, from: number, to: number): void;
  38115. /**
  38116. * Deletes an animation range by name
  38117. * @param name Name of the animation range to delete
  38118. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  38119. */
  38120. deleteRange(name: string, deleteFrames?: boolean): void;
  38121. /**
  38122. * Gets the animation range by name, or null if not defined
  38123. * @param name Name of the animation range
  38124. * @returns Nullable animation range
  38125. */
  38126. getRange(name: string): Nullable<AnimationRange>;
  38127. /**
  38128. * Gets the key frames from the animation
  38129. * @returns The key frames of the animation
  38130. */
  38131. getKeys(): Array<IAnimationKey>;
  38132. /**
  38133. * Gets the highest frame rate of the animation
  38134. * @returns Highest frame rate of the animation
  38135. */
  38136. getHighestFrame(): number;
  38137. /**
  38138. * Gets the easing function of the animation
  38139. * @returns Easing function of the animation
  38140. */
  38141. getEasingFunction(): IEasingFunction;
  38142. /**
  38143. * Sets the easing function of the animation
  38144. * @param easingFunction A custom mathematical formula for animation
  38145. */
  38146. setEasingFunction(easingFunction: EasingFunction): void;
  38147. /**
  38148. * Interpolates a scalar linearly
  38149. * @param startValue Start value of the animation curve
  38150. * @param endValue End value of the animation curve
  38151. * @param gradient Scalar amount to interpolate
  38152. * @returns Interpolated scalar value
  38153. */
  38154. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  38155. /**
  38156. * Interpolates a scalar cubically
  38157. * @param startValue Start value of the animation curve
  38158. * @param outTangent End tangent of the animation
  38159. * @param endValue End value of the animation curve
  38160. * @param inTangent Start tangent of the animation curve
  38161. * @param gradient Scalar amount to interpolate
  38162. * @returns Interpolated scalar value
  38163. */
  38164. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  38165. /**
  38166. * Interpolates a quaternion using a spherical linear interpolation
  38167. * @param startValue Start value of the animation curve
  38168. * @param endValue End value of the animation curve
  38169. * @param gradient Scalar amount to interpolate
  38170. * @returns Interpolated quaternion value
  38171. */
  38172. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  38173. /**
  38174. * Interpolates a quaternion cubically
  38175. * @param startValue Start value of the animation curve
  38176. * @param outTangent End tangent of the animation curve
  38177. * @param endValue End value of the animation curve
  38178. * @param inTangent Start tangent of the animation curve
  38179. * @param gradient Scalar amount to interpolate
  38180. * @returns Interpolated quaternion value
  38181. */
  38182. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  38183. /**
  38184. * Interpolates a Vector3 linearly
  38185. * @param startValue Start value of the animation curve
  38186. * @param endValue End value of the animation curve
  38187. * @param gradient Scalar amount to interpolate
  38188. * @returns Interpolated scalar value
  38189. */
  38190. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  38191. /**
  38192. * Interpolates a Vector3 cubically
  38193. * @param startValue Start value of the animation curve
  38194. * @param outTangent End tangent of the animation
  38195. * @param endValue End value of the animation curve
  38196. * @param inTangent Start tangent of the animation curve
  38197. * @param gradient Scalar amount to interpolate
  38198. * @returns InterpolatedVector3 value
  38199. */
  38200. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  38201. /**
  38202. * Interpolates a Vector2 linearly
  38203. * @param startValue Start value of the animation curve
  38204. * @param endValue End value of the animation curve
  38205. * @param gradient Scalar amount to interpolate
  38206. * @returns Interpolated Vector2 value
  38207. */
  38208. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  38209. /**
  38210. * Interpolates a Vector2 cubically
  38211. * @param startValue Start value of the animation curve
  38212. * @param outTangent End tangent of the animation
  38213. * @param endValue End value of the animation curve
  38214. * @param inTangent Start tangent of the animation curve
  38215. * @param gradient Scalar amount to interpolate
  38216. * @returns Interpolated Vector2 value
  38217. */
  38218. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  38219. /**
  38220. * Interpolates a size linearly
  38221. * @param startValue Start value of the animation curve
  38222. * @param endValue End value of the animation curve
  38223. * @param gradient Scalar amount to interpolate
  38224. * @returns Interpolated Size value
  38225. */
  38226. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  38227. /**
  38228. * Interpolates a Color3 linearly
  38229. * @param startValue Start value of the animation curve
  38230. * @param endValue End value of the animation curve
  38231. * @param gradient Scalar amount to interpolate
  38232. * @returns Interpolated Color3 value
  38233. */
  38234. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  38235. /**
  38236. * Interpolates a Color4 linearly
  38237. * @param startValue Start value of the animation curve
  38238. * @param endValue End value of the animation curve
  38239. * @param gradient Scalar amount to interpolate
  38240. * @returns Interpolated Color3 value
  38241. */
  38242. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  38243. /**
  38244. * @hidden Internal use only
  38245. */
  38246. _getKeyValue(value: any): any;
  38247. /**
  38248. * @hidden Internal use only
  38249. */
  38250. _interpolate(currentFrame: number, state: _IAnimationState): any;
  38251. /**
  38252. * Defines the function to use to interpolate matrices
  38253. * @param startValue defines the start matrix
  38254. * @param endValue defines the end matrix
  38255. * @param gradient defines the gradient between both matrices
  38256. * @param result defines an optional target matrix where to store the interpolation
  38257. * @returns the interpolated matrix
  38258. */
  38259. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  38260. /**
  38261. * Makes a copy of the animation
  38262. * @returns Cloned animation
  38263. */
  38264. clone(): Animation;
  38265. /**
  38266. * Sets the key frames of the animation
  38267. * @param values The animation key frames to set
  38268. */
  38269. setKeys(values: Array<IAnimationKey>): void;
  38270. /**
  38271. * Serializes the animation to an object
  38272. * @returns Serialized object
  38273. */
  38274. serialize(): any;
  38275. /**
  38276. * Float animation type
  38277. */
  38278. static readonly ANIMATIONTYPE_FLOAT: number;
  38279. /**
  38280. * Vector3 animation type
  38281. */
  38282. static readonly ANIMATIONTYPE_VECTOR3: number;
  38283. /**
  38284. * Quaternion animation type
  38285. */
  38286. static readonly ANIMATIONTYPE_QUATERNION: number;
  38287. /**
  38288. * Matrix animation type
  38289. */
  38290. static readonly ANIMATIONTYPE_MATRIX: number;
  38291. /**
  38292. * Color3 animation type
  38293. */
  38294. static readonly ANIMATIONTYPE_COLOR3: number;
  38295. /**
  38296. * Color3 animation type
  38297. */
  38298. static readonly ANIMATIONTYPE_COLOR4: number;
  38299. /**
  38300. * Vector2 animation type
  38301. */
  38302. static readonly ANIMATIONTYPE_VECTOR2: number;
  38303. /**
  38304. * Size animation type
  38305. */
  38306. static readonly ANIMATIONTYPE_SIZE: number;
  38307. /**
  38308. * Relative Loop Mode
  38309. */
  38310. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  38311. /**
  38312. * Cycle Loop Mode
  38313. */
  38314. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  38315. /**
  38316. * Constant Loop Mode
  38317. */
  38318. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  38319. /** @hidden */
  38320. static _UniversalLerp(left: any, right: any, amount: number): any;
  38321. /**
  38322. * Parses an animation object and creates an animation
  38323. * @param parsedAnimation Parsed animation object
  38324. * @returns Animation object
  38325. */
  38326. static Parse(parsedAnimation: any): Animation;
  38327. /**
  38328. * Appends the serialized animations from the source animations
  38329. * @param source Source containing the animations
  38330. * @param destination Target to store the animations
  38331. */
  38332. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38333. /**
  38334. * Creates a new animation or an array of animations from a snippet saved in a remote file
  38335. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  38336. * @param url defines the url to load from
  38337. * @returns a promise that will resolve to the new animation or an array of animations
  38338. */
  38339. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  38340. /**
  38341. * Creates an animation or an array of animations from a snippet saved by the Inspector
  38342. * @param snippetId defines the snippet to load
  38343. * @returns a promise that will resolve to the new animation or a new array of animations
  38344. */
  38345. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  38346. }
  38347. }
  38348. declare module BABYLON {
  38349. /**
  38350. * Interface containing an array of animations
  38351. */
  38352. export interface IAnimatable {
  38353. /**
  38354. * Array of animations
  38355. */
  38356. animations: Nullable<Array<Animation>>;
  38357. }
  38358. }
  38359. declare module BABYLON {
  38360. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  38361. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38362. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38363. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38364. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38365. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38366. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38367. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38368. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38369. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38370. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38371. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38372. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38373. /**
  38374. * Decorator used to define property that can be serialized as reference to a camera
  38375. * @param sourceName defines the name of the property to decorate
  38376. */
  38377. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38378. /**
  38379. * Class used to help serialization objects
  38380. */
  38381. export class SerializationHelper {
  38382. /** @hidden */
  38383. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  38384. /** @hidden */
  38385. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  38386. /** @hidden */
  38387. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  38388. /** @hidden */
  38389. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  38390. /**
  38391. * Appends the serialized animations from the source animations
  38392. * @param source Source containing the animations
  38393. * @param destination Target to store the animations
  38394. */
  38395. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38396. /**
  38397. * Static function used to serialized a specific entity
  38398. * @param entity defines the entity to serialize
  38399. * @param serializationObject defines the optional target object where serialization data will be stored
  38400. * @returns a JSON compatible object representing the serialization of the entity
  38401. */
  38402. static Serialize<T>(entity: T, serializationObject?: any): any;
  38403. /**
  38404. * Creates a new entity from a serialization data object
  38405. * @param creationFunction defines a function used to instanciated the new entity
  38406. * @param source defines the source serialization data
  38407. * @param scene defines the hosting scene
  38408. * @param rootUrl defines the root url for resources
  38409. * @returns a new entity
  38410. */
  38411. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38412. /**
  38413. * Clones an object
  38414. * @param creationFunction defines the function used to instanciate the new object
  38415. * @param source defines the source object
  38416. * @returns the cloned object
  38417. */
  38418. static Clone<T>(creationFunction: () => T, source: T): T;
  38419. /**
  38420. * Instanciates a new object based on a source one (some data will be shared between both object)
  38421. * @param creationFunction defines the function used to instanciate the new object
  38422. * @param source defines the source object
  38423. * @returns the new object
  38424. */
  38425. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38426. }
  38427. }
  38428. declare module BABYLON {
  38429. /**
  38430. * This is the base class of all the camera used in the application.
  38431. * @see https://doc.babylonjs.com/features/cameras
  38432. */
  38433. export class Camera extends Node {
  38434. /** @hidden */
  38435. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  38436. /**
  38437. * This is the default projection mode used by the cameras.
  38438. * It helps recreating a feeling of perspective and better appreciate depth.
  38439. * This is the best way to simulate real life cameras.
  38440. */
  38441. static readonly PERSPECTIVE_CAMERA: number;
  38442. /**
  38443. * This helps creating camera with an orthographic mode.
  38444. * 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.
  38445. */
  38446. static readonly ORTHOGRAPHIC_CAMERA: number;
  38447. /**
  38448. * This is the default FOV mode for perspective cameras.
  38449. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  38450. */
  38451. static readonly FOVMODE_VERTICAL_FIXED: number;
  38452. /**
  38453. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  38454. */
  38455. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  38456. /**
  38457. * This specifies there is no need for a camera rig.
  38458. * Basically only one eye is rendered corresponding to the camera.
  38459. */
  38460. static readonly RIG_MODE_NONE: number;
  38461. /**
  38462. * Simulates a camera Rig with one blue eye and one red eye.
  38463. * This can be use with 3d blue and red glasses.
  38464. */
  38465. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  38466. /**
  38467. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  38468. */
  38469. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  38470. /**
  38471. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  38472. */
  38473. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  38474. /**
  38475. * Defines that both eyes of the camera will be rendered over under each other.
  38476. */
  38477. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  38478. /**
  38479. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  38480. */
  38481. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  38482. /**
  38483. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  38484. */
  38485. static readonly RIG_MODE_VR: number;
  38486. /**
  38487. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  38488. */
  38489. static readonly RIG_MODE_WEBVR: number;
  38490. /**
  38491. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  38492. */
  38493. static readonly RIG_MODE_CUSTOM: number;
  38494. /**
  38495. * Defines if by default attaching controls should prevent the default javascript event to continue.
  38496. */
  38497. static ForceAttachControlToAlwaysPreventDefault: boolean;
  38498. /**
  38499. * Define the input manager associated with the camera.
  38500. */
  38501. inputs: CameraInputsManager<Camera>;
  38502. /** @hidden */
  38503. _position: Vector3;
  38504. /**
  38505. * Define the current local position of the camera in the scene
  38506. */
  38507. get position(): Vector3;
  38508. set position(newPosition: Vector3);
  38509. protected _upVector: Vector3;
  38510. /**
  38511. * The vector the camera should consider as up.
  38512. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  38513. */
  38514. set upVector(vec: Vector3);
  38515. get upVector(): Vector3;
  38516. /**
  38517. * Define the current limit on the left side for an orthographic camera
  38518. * In scene unit
  38519. */
  38520. orthoLeft: Nullable<number>;
  38521. /**
  38522. * Define the current limit on the right side for an orthographic camera
  38523. * In scene unit
  38524. */
  38525. orthoRight: Nullable<number>;
  38526. /**
  38527. * Define the current limit on the bottom side for an orthographic camera
  38528. * In scene unit
  38529. */
  38530. orthoBottom: Nullable<number>;
  38531. /**
  38532. * Define the current limit on the top side for an orthographic camera
  38533. * In scene unit
  38534. */
  38535. orthoTop: Nullable<number>;
  38536. /**
  38537. * Field Of View is set in Radians. (default is 0.8)
  38538. */
  38539. fov: number;
  38540. /**
  38541. * Define the minimum distance the camera can see from.
  38542. * This is important to note that the depth buffer are not infinite and the closer it starts
  38543. * the more your scene might encounter depth fighting issue.
  38544. */
  38545. minZ: number;
  38546. /**
  38547. * Define the maximum distance the camera can see to.
  38548. * This is important to note that the depth buffer are not infinite and the further it end
  38549. * the more your scene might encounter depth fighting issue.
  38550. */
  38551. maxZ: number;
  38552. /**
  38553. * Define the default inertia of the camera.
  38554. * This helps giving a smooth feeling to the camera movement.
  38555. */
  38556. inertia: number;
  38557. /**
  38558. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  38559. */
  38560. mode: number;
  38561. /**
  38562. * Define whether the camera is intermediate.
  38563. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  38564. */
  38565. isIntermediate: boolean;
  38566. /**
  38567. * Define the viewport of the camera.
  38568. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  38569. */
  38570. viewport: Viewport;
  38571. /**
  38572. * Restricts the camera to viewing objects with the same layerMask.
  38573. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  38574. */
  38575. layerMask: number;
  38576. /**
  38577. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  38578. */
  38579. fovMode: number;
  38580. /**
  38581. * Rig mode of the camera.
  38582. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  38583. * This is normally controlled byt the camera themselves as internal use.
  38584. */
  38585. cameraRigMode: number;
  38586. /**
  38587. * Defines the distance between both "eyes" in case of a RIG
  38588. */
  38589. interaxialDistance: number;
  38590. /**
  38591. * Defines if stereoscopic rendering is done side by side or over under.
  38592. */
  38593. isStereoscopicSideBySide: boolean;
  38594. /**
  38595. * 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
  38596. * This is pretty helpful if you wish to make a camera render to a texture you could reuse somewhere
  38597. * else in the scene. (Eg. security camera)
  38598. *
  38599. * 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)
  38600. */
  38601. customRenderTargets: RenderTargetTexture[];
  38602. /**
  38603. * When set, the camera will render to this render target instead of the default canvas
  38604. *
  38605. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  38606. */
  38607. outputRenderTarget: Nullable<RenderTargetTexture>;
  38608. /**
  38609. * Observable triggered when the camera view matrix has changed.
  38610. */
  38611. onViewMatrixChangedObservable: Observable<Camera>;
  38612. /**
  38613. * Observable triggered when the camera Projection matrix has changed.
  38614. */
  38615. onProjectionMatrixChangedObservable: Observable<Camera>;
  38616. /**
  38617. * Observable triggered when the inputs have been processed.
  38618. */
  38619. onAfterCheckInputsObservable: Observable<Camera>;
  38620. /**
  38621. * Observable triggered when reset has been called and applied to the camera.
  38622. */
  38623. onRestoreStateObservable: Observable<Camera>;
  38624. /**
  38625. * Is this camera a part of a rig system?
  38626. */
  38627. isRigCamera: boolean;
  38628. /**
  38629. * If isRigCamera set to true this will be set with the parent camera.
  38630. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  38631. */
  38632. rigParent?: Camera;
  38633. /** @hidden */
  38634. _cameraRigParams: any;
  38635. /** @hidden */
  38636. _rigCameras: Camera[];
  38637. /** @hidden */
  38638. _rigPostProcess: Nullable<PostProcess>;
  38639. protected _webvrViewMatrix: Matrix;
  38640. /** @hidden */
  38641. _skipRendering: boolean;
  38642. /** @hidden */
  38643. _projectionMatrix: Matrix;
  38644. /** @hidden */
  38645. _postProcesses: Nullable<PostProcess>[];
  38646. /** @hidden */
  38647. _activeMeshes: SmartArray<AbstractMesh>;
  38648. protected _globalPosition: Vector3;
  38649. /** @hidden */
  38650. _computedViewMatrix: Matrix;
  38651. private _doNotComputeProjectionMatrix;
  38652. private _transformMatrix;
  38653. private _frustumPlanes;
  38654. private _refreshFrustumPlanes;
  38655. private _storedFov;
  38656. private _stateStored;
  38657. /**
  38658. * Instantiates a new camera object.
  38659. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  38660. * @see https://doc.babylonjs.com/features/cameras
  38661. * @param name Defines the name of the camera in the scene
  38662. * @param position Defines the position of the camera
  38663. * @param scene Defines the scene the camera belongs too
  38664. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  38665. */
  38666. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38667. /**
  38668. * Store current camera state (fov, position, etc..)
  38669. * @returns the camera
  38670. */
  38671. storeState(): Camera;
  38672. /**
  38673. * Restores the camera state values if it has been stored. You must call storeState() first
  38674. */
  38675. protected _restoreStateValues(): boolean;
  38676. /**
  38677. * Restored camera state. You must call storeState() first.
  38678. * @returns true if restored and false otherwise
  38679. */
  38680. restoreState(): boolean;
  38681. /**
  38682. * Gets the class name of the camera.
  38683. * @returns the class name
  38684. */
  38685. getClassName(): string;
  38686. /** @hidden */
  38687. readonly _isCamera: boolean;
  38688. /**
  38689. * Gets a string representation of the camera useful for debug purpose.
  38690. * @param fullDetails Defines that a more verboe level of logging is required
  38691. * @returns the string representation
  38692. */
  38693. toString(fullDetails?: boolean): string;
  38694. /**
  38695. * Gets the current world space position of the camera.
  38696. */
  38697. get globalPosition(): Vector3;
  38698. /**
  38699. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  38700. * @returns the active meshe list
  38701. */
  38702. getActiveMeshes(): SmartArray<AbstractMesh>;
  38703. /**
  38704. * Check whether a mesh is part of the current active mesh list of the camera
  38705. * @param mesh Defines the mesh to check
  38706. * @returns true if active, false otherwise
  38707. */
  38708. isActiveMesh(mesh: Mesh): boolean;
  38709. /**
  38710. * Is this camera ready to be used/rendered
  38711. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  38712. * @return true if the camera is ready
  38713. */
  38714. isReady(completeCheck?: boolean): boolean;
  38715. /** @hidden */
  38716. _initCache(): void;
  38717. /** @hidden */
  38718. _updateCache(ignoreParentClass?: boolean): void;
  38719. /** @hidden */
  38720. _isSynchronized(): boolean;
  38721. /** @hidden */
  38722. _isSynchronizedViewMatrix(): boolean;
  38723. /** @hidden */
  38724. _isSynchronizedProjectionMatrix(): boolean;
  38725. /**
  38726. * Attach the input controls to a specific dom element to get the input from.
  38727. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38728. */
  38729. attachControl(noPreventDefault?: boolean): void;
  38730. /**
  38731. * Attach the input controls to a specific dom element to get the input from.
  38732. * @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
  38733. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38734. * BACK COMPAT SIGNATURE ONLY.
  38735. */
  38736. attachControl(ignored: any, noPreventDefault?: boolean): void;
  38737. /**
  38738. * Detach the current controls from the specified dom element.
  38739. */
  38740. detachControl(): void;
  38741. /**
  38742. * Detach the current controls from the specified dom element.
  38743. * @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
  38744. */
  38745. detachControl(ignored: any): void;
  38746. /**
  38747. * Update the camera state according to the different inputs gathered during the frame.
  38748. */
  38749. update(): void;
  38750. /** @hidden */
  38751. _checkInputs(): void;
  38752. /** @hidden */
  38753. get rigCameras(): Camera[];
  38754. /**
  38755. * Gets the post process used by the rig cameras
  38756. */
  38757. get rigPostProcess(): Nullable<PostProcess>;
  38758. /**
  38759. * Internal, gets the first post process.
  38760. * @returns the first post process to be run on this camera.
  38761. */
  38762. _getFirstPostProcess(): Nullable<PostProcess>;
  38763. private _cascadePostProcessesToRigCams;
  38764. /**
  38765. * Attach a post process to the camera.
  38766. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38767. * @param postProcess The post process to attach to the camera
  38768. * @param insertAt The position of the post process in case several of them are in use in the scene
  38769. * @returns the position the post process has been inserted at
  38770. */
  38771. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  38772. /**
  38773. * Detach a post process to the camera.
  38774. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38775. * @param postProcess The post process to detach from the camera
  38776. */
  38777. detachPostProcess(postProcess: PostProcess): void;
  38778. /**
  38779. * Gets the current world matrix of the camera
  38780. */
  38781. getWorldMatrix(): Matrix;
  38782. /** @hidden */
  38783. _getViewMatrix(): Matrix;
  38784. /**
  38785. * Gets the current view matrix of the camera.
  38786. * @param force forces the camera to recompute the matrix without looking at the cached state
  38787. * @returns the view matrix
  38788. */
  38789. getViewMatrix(force?: boolean): Matrix;
  38790. /**
  38791. * Freeze the projection matrix.
  38792. * It will prevent the cache check of the camera projection compute and can speed up perf
  38793. * if no parameter of the camera are meant to change
  38794. * @param projection Defines manually a projection if necessary
  38795. */
  38796. freezeProjectionMatrix(projection?: Matrix): void;
  38797. /**
  38798. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  38799. */
  38800. unfreezeProjectionMatrix(): void;
  38801. /**
  38802. * Gets the current projection matrix of the camera.
  38803. * @param force forces the camera to recompute the matrix without looking at the cached state
  38804. * @returns the projection matrix
  38805. */
  38806. getProjectionMatrix(force?: boolean): Matrix;
  38807. /**
  38808. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  38809. * @returns a Matrix
  38810. */
  38811. getTransformationMatrix(): Matrix;
  38812. private _updateFrustumPlanes;
  38813. /**
  38814. * Checks if a cullable object (mesh...) is in the camera frustum
  38815. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  38816. * @param target The object to check
  38817. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  38818. * @returns true if the object is in frustum otherwise false
  38819. */
  38820. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  38821. /**
  38822. * Checks if a cullable object (mesh...) is in the camera frustum
  38823. * Unlike isInFrustum this checks the full bounding box
  38824. * @param target The object to check
  38825. * @returns true if the object is in frustum otherwise false
  38826. */
  38827. isCompletelyInFrustum(target: ICullable): boolean;
  38828. /**
  38829. * Gets a ray in the forward direction from the camera.
  38830. * @param length Defines the length of the ray to create
  38831. * @param transform Defines the transform to apply to the ray, by default the world matrix is used to create a workd space ray
  38832. * @param origin Defines the start point of the ray which defaults to the camera position
  38833. * @returns the forward ray
  38834. */
  38835. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38836. /**
  38837. * Gets a ray in the forward direction from the camera.
  38838. * @param refRay the ray to (re)use when setting the values
  38839. * @param length Defines the length of the ray to create
  38840. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38841. * @param origin Defines the start point of the ray which defaults to the camera position
  38842. * @returns the forward ray
  38843. */
  38844. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38845. /**
  38846. * Releases resources associated with this node.
  38847. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  38848. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  38849. */
  38850. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  38851. /** @hidden */
  38852. _isLeftCamera: boolean;
  38853. /**
  38854. * Gets the left camera of a rig setup in case of Rigged Camera
  38855. */
  38856. get isLeftCamera(): boolean;
  38857. /** @hidden */
  38858. _isRightCamera: boolean;
  38859. /**
  38860. * Gets the right camera of a rig setup in case of Rigged Camera
  38861. */
  38862. get isRightCamera(): boolean;
  38863. /**
  38864. * Gets the left camera of a rig setup in case of Rigged Camera
  38865. */
  38866. get leftCamera(): Nullable<FreeCamera>;
  38867. /**
  38868. * Gets the right camera of a rig setup in case of Rigged Camera
  38869. */
  38870. get rightCamera(): Nullable<FreeCamera>;
  38871. /**
  38872. * Gets the left camera target of a rig setup in case of Rigged Camera
  38873. * @returns the target position
  38874. */
  38875. getLeftTarget(): Nullable<Vector3>;
  38876. /**
  38877. * Gets the right camera target of a rig setup in case of Rigged Camera
  38878. * @returns the target position
  38879. */
  38880. getRightTarget(): Nullable<Vector3>;
  38881. /**
  38882. * @hidden
  38883. */
  38884. setCameraRigMode(mode: number, rigParams: any): void;
  38885. /** @hidden */
  38886. static _setStereoscopicRigMode(camera: Camera): void;
  38887. /** @hidden */
  38888. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  38889. /** @hidden */
  38890. static _setVRRigMode(camera: Camera, rigParams: any): void;
  38891. /** @hidden */
  38892. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  38893. /** @hidden */
  38894. _getVRProjectionMatrix(): Matrix;
  38895. protected _updateCameraRotationMatrix(): void;
  38896. protected _updateWebVRCameraRotationMatrix(): void;
  38897. /**
  38898. * This function MUST be overwritten by the different WebVR cameras available.
  38899. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38900. * @hidden
  38901. */
  38902. _getWebVRProjectionMatrix(): Matrix;
  38903. /**
  38904. * This function MUST be overwritten by the different WebVR cameras available.
  38905. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38906. * @hidden
  38907. */
  38908. _getWebVRViewMatrix(): Matrix;
  38909. /** @hidden */
  38910. setCameraRigParameter(name: string, value: any): void;
  38911. /**
  38912. * needs to be overridden by children so sub has required properties to be copied
  38913. * @hidden
  38914. */
  38915. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  38916. /**
  38917. * May need to be overridden by children
  38918. * @hidden
  38919. */
  38920. _updateRigCameras(): void;
  38921. /** @hidden */
  38922. _setupInputs(): void;
  38923. /**
  38924. * Serialiaze the camera setup to a json representation
  38925. * @returns the JSON representation
  38926. */
  38927. serialize(): any;
  38928. /**
  38929. * Clones the current camera.
  38930. * @param name The cloned camera name
  38931. * @returns the cloned camera
  38932. */
  38933. clone(name: string): Camera;
  38934. /**
  38935. * Gets the direction of the camera relative to a given local axis.
  38936. * @param localAxis Defines the reference axis to provide a relative direction.
  38937. * @return the direction
  38938. */
  38939. getDirection(localAxis: Vector3): Vector3;
  38940. /**
  38941. * Returns the current camera absolute rotation
  38942. */
  38943. get absoluteRotation(): Quaternion;
  38944. /**
  38945. * Gets the direction of the camera relative to a given local axis into a passed vector.
  38946. * @param localAxis Defines the reference axis to provide a relative direction.
  38947. * @param result Defines the vector to store the result in
  38948. */
  38949. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  38950. /**
  38951. * Gets a camera constructor for a given camera type
  38952. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  38953. * @param name The name of the camera the result will be able to instantiate
  38954. * @param scene The scene the result will construct the camera in
  38955. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  38956. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  38957. * @returns a factory method to construct the camera
  38958. */
  38959. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  38960. /**
  38961. * Compute the world matrix of the camera.
  38962. * @returns the camera world matrix
  38963. */
  38964. computeWorldMatrix(): Matrix;
  38965. /**
  38966. * Parse a JSON and creates the camera from the parsed information
  38967. * @param parsedCamera The JSON to parse
  38968. * @param scene The scene to instantiate the camera in
  38969. * @returns the newly constructed camera
  38970. */
  38971. static Parse(parsedCamera: any, scene: Scene): Camera;
  38972. }
  38973. }
  38974. declare module BABYLON {
  38975. /**
  38976. * PostProcessManager is used to manage one or more post processes or post process pipelines
  38977. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  38978. */
  38979. export class PostProcessManager {
  38980. private _scene;
  38981. private _indexBuffer;
  38982. private _vertexBuffers;
  38983. /**
  38984. * Creates a new instance PostProcess
  38985. * @param scene The scene that the post process is associated with.
  38986. */
  38987. constructor(scene: Scene);
  38988. private _prepareBuffers;
  38989. private _buildIndexBuffer;
  38990. /**
  38991. * Rebuilds the vertex buffers of the manager.
  38992. * @hidden
  38993. */
  38994. _rebuild(): void;
  38995. /**
  38996. * Prepares a frame to be run through a post process.
  38997. * @param sourceTexture The input texture to the post processes. (default: null)
  38998. * @param postProcesses An array of post processes to be run. (default: null)
  38999. * @returns True if the post processes were able to be run.
  39000. * @hidden
  39001. */
  39002. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  39003. /**
  39004. * Manually render a set of post processes to a texture.
  39005. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  39006. * @param postProcesses An array of post processes to be run.
  39007. * @param targetTexture The target texture to render to.
  39008. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  39009. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  39010. * @param lodLevel defines which lod of the texture to render to
  39011. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  39012. */
  39013. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  39014. /**
  39015. * Finalize the result of the output of the postprocesses.
  39016. * @param doNotPresent If true the result will not be displayed to the screen.
  39017. * @param targetTexture The target texture to render to.
  39018. * @param faceIndex The index of the face to bind the target texture to.
  39019. * @param postProcesses The array of post processes to render.
  39020. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  39021. * @hidden
  39022. */
  39023. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  39024. /**
  39025. * Disposes of the post process manager.
  39026. */
  39027. dispose(): void;
  39028. }
  39029. }
  39030. declare module BABYLON {
  39031. /**
  39032. * This Helps creating a texture that will be created from a camera in your scene.
  39033. * It is basically a dynamic texture that could be used to create special effects for instance.
  39034. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  39035. */
  39036. export class RenderTargetTexture extends Texture {
  39037. /**
  39038. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  39039. */
  39040. static readonly REFRESHRATE_RENDER_ONCE: number;
  39041. /**
  39042. * The texture will only be rendered rendered every frame and is recommended for dynamic contents.
  39043. */
  39044. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  39045. /**
  39046. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  39047. * the central point of your effect and can save a lot of performances.
  39048. */
  39049. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  39050. /**
  39051. * Use this predicate to dynamically define the list of mesh you want to render.
  39052. * If set, the renderList property will be overwritten.
  39053. */
  39054. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  39055. private _renderList;
  39056. /**
  39057. * Use this list to define the list of mesh you want to render.
  39058. */
  39059. get renderList(): Nullable<Array<AbstractMesh>>;
  39060. set renderList(value: Nullable<Array<AbstractMesh>>);
  39061. /**
  39062. * Use this function to overload the renderList array at rendering time.
  39063. * Return null to render with the current renderList, else return the list of meshes to use for rendering.
  39064. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  39065. * the cube (if the RTT is a cube, else layerOrFace=0).
  39066. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  39067. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  39068. * hold dummy elements!
  39069. */
  39070. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  39071. private _hookArray;
  39072. /**
  39073. * Define if particles should be rendered in your texture.
  39074. */
  39075. renderParticles: boolean;
  39076. /**
  39077. * Define if sprites should be rendered in your texture.
  39078. */
  39079. renderSprites: boolean;
  39080. /**
  39081. * Define the camera used to render the texture.
  39082. */
  39083. activeCamera: Nullable<Camera>;
  39084. /**
  39085. * Override the mesh isReady function with your own one.
  39086. */
  39087. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  39088. /**
  39089. * Override the render function of the texture with your own one.
  39090. */
  39091. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  39092. /**
  39093. * Define if camera post processes should be use while rendering the texture.
  39094. */
  39095. useCameraPostProcesses: boolean;
  39096. /**
  39097. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  39098. */
  39099. ignoreCameraViewport: boolean;
  39100. private _postProcessManager;
  39101. /**
  39102. * Post-processes for this render target
  39103. */
  39104. get postProcesses(): PostProcess[];
  39105. private _postProcesses;
  39106. private _resizeObserver;
  39107. private get _prePassEnabled();
  39108. /**
  39109. * An event triggered when the texture is unbind.
  39110. */
  39111. onBeforeBindObservable: Observable<RenderTargetTexture>;
  39112. /**
  39113. * An event triggered when the texture is unbind.
  39114. */
  39115. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  39116. private _onAfterUnbindObserver;
  39117. /**
  39118. * Set a after unbind callback in the texture.
  39119. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  39120. */
  39121. set onAfterUnbind(callback: () => void);
  39122. /**
  39123. * An event triggered before rendering the texture
  39124. */
  39125. onBeforeRenderObservable: Observable<number>;
  39126. private _onBeforeRenderObserver;
  39127. /**
  39128. * Set a before render callback in the texture.
  39129. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  39130. */
  39131. set onBeforeRender(callback: (faceIndex: number) => void);
  39132. /**
  39133. * An event triggered after rendering the texture
  39134. */
  39135. onAfterRenderObservable: Observable<number>;
  39136. private _onAfterRenderObserver;
  39137. /**
  39138. * Set a after render callback in the texture.
  39139. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  39140. */
  39141. set onAfterRender(callback: (faceIndex: number) => void);
  39142. /**
  39143. * An event triggered after the texture clear
  39144. */
  39145. onClearObservable: Observable<Engine>;
  39146. private _onClearObserver;
  39147. /**
  39148. * Set a clear callback in the texture.
  39149. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  39150. */
  39151. set onClear(callback: (Engine: Engine) => void);
  39152. /**
  39153. * An event triggered when the texture is resized.
  39154. */
  39155. onResizeObservable: Observable<RenderTargetTexture>;
  39156. /**
  39157. * Define the clear color of the Render Target if it should be different from the scene.
  39158. */
  39159. clearColor: Color4;
  39160. protected _size: number | {
  39161. width: number;
  39162. height: number;
  39163. layers?: number;
  39164. };
  39165. protected _initialSizeParameter: number | {
  39166. width: number;
  39167. height: number;
  39168. } | {
  39169. ratio: number;
  39170. };
  39171. protected _sizeRatio: Nullable<number>;
  39172. /** @hidden */
  39173. _generateMipMaps: boolean;
  39174. protected _renderingManager: RenderingManager;
  39175. /** @hidden */
  39176. _waitingRenderList?: string[];
  39177. protected _doNotChangeAspectRatio: boolean;
  39178. protected _currentRefreshId: number;
  39179. protected _refreshRate: number;
  39180. protected _textureMatrix: Matrix;
  39181. protected _samples: number;
  39182. protected _renderTargetOptions: RenderTargetCreationOptions;
  39183. /**
  39184. * Gets render target creation options that were used.
  39185. */
  39186. get renderTargetOptions(): RenderTargetCreationOptions;
  39187. protected _onRatioRescale(): void;
  39188. /**
  39189. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  39190. * It must define where the camera used to render the texture is set
  39191. */
  39192. boundingBoxPosition: Vector3;
  39193. private _boundingBoxSize;
  39194. /**
  39195. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  39196. * When defined, the cubemap will switch to local mode
  39197. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  39198. * @example https://www.babylonjs-playground.com/#RNASML
  39199. */
  39200. set boundingBoxSize(value: Vector3);
  39201. get boundingBoxSize(): Vector3;
  39202. /**
  39203. * In case the RTT has been created with a depth texture, get the associated
  39204. * depth texture.
  39205. * Otherwise, return null.
  39206. */
  39207. get depthStencilTexture(): Nullable<InternalTexture>;
  39208. /**
  39209. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post process
  39210. * or used a shadow, depth texture...
  39211. * @param name The friendly name of the texture
  39212. * @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)
  39213. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  39214. * @param generateMipMaps True if mip maps need to be generated after render.
  39215. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  39216. * @param type The type of the buffer in the RTT (int, half float, float...)
  39217. * @param isCube True if a cube texture needs to be created
  39218. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  39219. * @param generateDepthBuffer True to generate a depth buffer
  39220. * @param generateStencilBuffer True to generate a stencil buffer
  39221. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  39222. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  39223. * @param delayAllocation if the texture allocation should be delayed (default: false)
  39224. * @param samples sample count to use when creating the RTT
  39225. */
  39226. constructor(name: string, size: number | {
  39227. width: number;
  39228. height: number;
  39229. layers?: number;
  39230. } | {
  39231. ratio: number;
  39232. }, 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);
  39233. /**
  39234. * Creates a depth stencil texture.
  39235. * This is only available in WebGL 2 or with the depth texture extension available.
  39236. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  39237. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  39238. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  39239. * @param samples sample count of the depth/stencil texture
  39240. */
  39241. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean, samples?: number): void;
  39242. private _processSizeParameter;
  39243. /**
  39244. * Define the number of samples to use in case of MSAA.
  39245. * It defaults to one meaning no MSAA has been enabled.
  39246. */
  39247. get samples(): number;
  39248. set samples(value: number);
  39249. /**
  39250. * Resets the refresh counter of the texture and start bak from scratch.
  39251. * Could be useful to regenerate the texture if it is setup to render only once.
  39252. */
  39253. resetRefreshCounter(): void;
  39254. /**
  39255. * Define the refresh rate of the texture or the rendering frequency.
  39256. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  39257. */
  39258. get refreshRate(): number;
  39259. set refreshRate(value: number);
  39260. /**
  39261. * Adds a post process to the render target rendering passes.
  39262. * @param postProcess define the post process to add
  39263. */
  39264. addPostProcess(postProcess: PostProcess): void;
  39265. /**
  39266. * Clear all the post processes attached to the render target
  39267. * @param dispose define if the cleared post processes should also be disposed (false by default)
  39268. */
  39269. clearPostProcesses(dispose?: boolean): void;
  39270. /**
  39271. * Remove one of the post process from the list of attached post processes to the texture
  39272. * @param postProcess define the post process to remove from the list
  39273. */
  39274. removePostProcess(postProcess: PostProcess): void;
  39275. /** @hidden */
  39276. _shouldRender(): boolean;
  39277. /**
  39278. * Gets the actual render size of the texture.
  39279. * @returns the width of the render size
  39280. */
  39281. getRenderSize(): number;
  39282. /**
  39283. * Gets the actual render width of the texture.
  39284. * @returns the width of the render size
  39285. */
  39286. getRenderWidth(): number;
  39287. /**
  39288. * Gets the actual render height of the texture.
  39289. * @returns the height of the render size
  39290. */
  39291. getRenderHeight(): number;
  39292. /**
  39293. * Gets the actual number of layers of the texture.
  39294. * @returns the number of layers
  39295. */
  39296. getRenderLayers(): number;
  39297. /**
  39298. * Get if the texture can be rescaled or not.
  39299. */
  39300. get canRescale(): boolean;
  39301. /**
  39302. * Resize the texture using a ratio.
  39303. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  39304. */
  39305. scale(ratio: number): void;
  39306. /**
  39307. * Get the texture reflection matrix used to rotate/transform the reflection.
  39308. * @returns the reflection matrix
  39309. */
  39310. getReflectionTextureMatrix(): Matrix;
  39311. /**
  39312. * Resize the texture to a new desired size.
  39313. * Be careful as it will recreate all the data in the new texture.
  39314. * @param size Define the new size. It can be:
  39315. * - a number for squared texture,
  39316. * - an object containing { width: number, height: number }
  39317. * - or an object containing a ratio { ratio: number }
  39318. */
  39319. resize(size: number | {
  39320. width: number;
  39321. height: number;
  39322. } | {
  39323. ratio: number;
  39324. }): void;
  39325. private _defaultRenderListPrepared;
  39326. /**
  39327. * Renders all the objects from the render list into the texture.
  39328. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  39329. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  39330. */
  39331. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  39332. private _bestReflectionRenderTargetDimension;
  39333. private _prepareRenderingManager;
  39334. /**
  39335. * @hidden
  39336. * @param faceIndex face index to bind to if this is a cubetexture
  39337. * @param layer defines the index of the texture to bind in the array
  39338. */
  39339. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  39340. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  39341. /**
  39342. * @hidden
  39343. */
  39344. _prepareFrame(scene: Scene, faceIndex?: number, layer?: number, useCameraPostProcess?: boolean): void;
  39345. private renderToTarget;
  39346. /**
  39347. * Overrides the default sort function applied in the rendering group to prepare the meshes.
  39348. * This allowed control for front to back rendering or reversely depending of the special needs.
  39349. *
  39350. * @param renderingGroupId The rendering group id corresponding to its index
  39351. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  39352. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  39353. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  39354. */
  39355. 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;
  39356. /**
  39357. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  39358. *
  39359. * @param renderingGroupId The rendering group id corresponding to its index
  39360. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  39361. */
  39362. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  39363. /**
  39364. * Clones the texture.
  39365. * @returns the cloned texture
  39366. */
  39367. clone(): RenderTargetTexture;
  39368. /**
  39369. * Serialize the texture to a JSON representation we can easily use in the respective Parse function.
  39370. * @returns The JSON representation of the texture
  39371. */
  39372. serialize(): any;
  39373. /**
  39374. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  39375. */
  39376. disposeFramebufferObjects(): void;
  39377. /**
  39378. * Dispose the texture and release its associated resources.
  39379. */
  39380. dispose(): void;
  39381. /** @hidden */
  39382. _rebuild(): void;
  39383. /**
  39384. * Clear the info related to rendering groups preventing retention point in material dispose.
  39385. */
  39386. freeRenderingGroups(): void;
  39387. /**
  39388. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  39389. * @returns the view count
  39390. */
  39391. getViewCount(): number;
  39392. }
  39393. }
  39394. declare module BABYLON {
  39395. /**
  39396. * Options to be used when creating an effect.
  39397. */
  39398. export interface IEffectCreationOptions {
  39399. /**
  39400. * Attributes that will be used in the shader.
  39401. */
  39402. attributes: string[];
  39403. /**
  39404. * Uniform variable names that will be set in the shader.
  39405. */
  39406. uniformsNames: string[];
  39407. /**
  39408. * Uniform buffer variable names that will be set in the shader.
  39409. */
  39410. uniformBuffersNames: string[];
  39411. /**
  39412. * Sampler texture variable names that will be set in the shader.
  39413. */
  39414. samplers: string[];
  39415. /**
  39416. * Define statements that will be set in the shader.
  39417. */
  39418. defines: any;
  39419. /**
  39420. * Possible fallbacks for this effect to improve performance when needed.
  39421. */
  39422. fallbacks: Nullable<IEffectFallbacks>;
  39423. /**
  39424. * Callback that will be called when the shader is compiled.
  39425. */
  39426. onCompiled: Nullable<(effect: Effect) => void>;
  39427. /**
  39428. * Callback that will be called if an error occurs during shader compilation.
  39429. */
  39430. onError: Nullable<(effect: Effect, errors: string) => void>;
  39431. /**
  39432. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39433. */
  39434. indexParameters?: any;
  39435. /**
  39436. * Max number of lights that can be used in the shader.
  39437. */
  39438. maxSimultaneousLights?: number;
  39439. /**
  39440. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  39441. */
  39442. transformFeedbackVaryings?: Nullable<string[]>;
  39443. /**
  39444. * 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
  39445. */
  39446. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  39447. /**
  39448. * Is this effect rendering to several color attachments ?
  39449. */
  39450. multiTarget?: boolean;
  39451. }
  39452. /**
  39453. * Effect containing vertex and fragment shader that can be executed on an object.
  39454. */
  39455. export class Effect implements IDisposable {
  39456. /**
  39457. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39458. */
  39459. static ShadersRepository: string;
  39460. /**
  39461. * Enable logging of the shader code when a compilation error occurs
  39462. */
  39463. static LogShaderCodeOnCompilationError: boolean;
  39464. /**
  39465. * Name of the effect.
  39466. */
  39467. name: any;
  39468. /**
  39469. * String container all the define statements that should be set on the shader.
  39470. */
  39471. defines: string;
  39472. /**
  39473. * Callback that will be called when the shader is compiled.
  39474. */
  39475. onCompiled: Nullable<(effect: Effect) => void>;
  39476. /**
  39477. * Callback that will be called if an error occurs during shader compilation.
  39478. */
  39479. onError: Nullable<(effect: Effect, errors: string) => void>;
  39480. /**
  39481. * Callback that will be called when effect is bound.
  39482. */
  39483. onBind: Nullable<(effect: Effect) => void>;
  39484. /**
  39485. * Unique ID of the effect.
  39486. */
  39487. uniqueId: number;
  39488. /**
  39489. * Observable that will be called when the shader is compiled.
  39490. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  39491. */
  39492. onCompileObservable: Observable<Effect>;
  39493. /**
  39494. * Observable that will be called if an error occurs during shader compilation.
  39495. */
  39496. onErrorObservable: Observable<Effect>;
  39497. /** @hidden */
  39498. _onBindObservable: Nullable<Observable<Effect>>;
  39499. /**
  39500. * @hidden
  39501. * Specifies if the effect was previously ready
  39502. */
  39503. _wasPreviouslyReady: boolean;
  39504. /**
  39505. * Observable that will be called when effect is bound.
  39506. */
  39507. get onBindObservable(): Observable<Effect>;
  39508. /** @hidden */
  39509. _bonesComputationForcedToCPU: boolean;
  39510. /** @hidden */
  39511. _uniformBuffersNames: {
  39512. [key: string]: number;
  39513. };
  39514. /** @hidden */
  39515. _samplerList: string[];
  39516. /** @hidden */
  39517. _multiTarget: boolean;
  39518. private static _uniqueIdSeed;
  39519. private _engine;
  39520. private _uniformBuffersNamesList;
  39521. private _uniformsNames;
  39522. private _samplers;
  39523. private _isReady;
  39524. private _compilationError;
  39525. private _allFallbacksProcessed;
  39526. private _attributesNames;
  39527. private _attributes;
  39528. private _attributeLocationByName;
  39529. private _uniforms;
  39530. /**
  39531. * Key for the effect.
  39532. * @hidden
  39533. */
  39534. _key: string;
  39535. private _indexParameters;
  39536. private _fallbacks;
  39537. private _vertexSourceCodeOverride;
  39538. private _fragmentSourceCodeOverride;
  39539. private _transformFeedbackVaryings;
  39540. /**
  39541. * Compiled shader to webGL program.
  39542. * @hidden
  39543. */
  39544. _pipelineContext: Nullable<IPipelineContext>;
  39545. /** @hidden */
  39546. _vertexSourceCode: string;
  39547. /** @hidden */
  39548. _fragmentSourceCode: string;
  39549. /** @hidden */
  39550. private _rawVertexSourceCode;
  39551. /** @hidden */
  39552. private _rawFragmentSourceCode;
  39553. private static _baseCache;
  39554. private _processingContext;
  39555. /**
  39556. * Instantiates an effect.
  39557. * An effect can be used to create/manage/execute vertex and fragment shaders.
  39558. * @param baseName Name of the effect.
  39559. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  39560. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  39561. * @param samplers List of sampler variables that will be passed to the shader.
  39562. * @param engine Engine to be used to render the effect
  39563. * @param defines Define statements to be added to the shader.
  39564. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  39565. * @param onCompiled Callback that will be called when the shader is compiled.
  39566. * @param onError Callback that will be called if an error occurs during shader compilation.
  39567. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39568. * @param key Effect Key identifying uniquely compiled shader variants
  39569. */
  39570. 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);
  39571. private _useFinalCode;
  39572. /**
  39573. * Unique key for this effect
  39574. */
  39575. get key(): string;
  39576. /**
  39577. * If the effect has been compiled and prepared.
  39578. * @returns if the effect is compiled and prepared.
  39579. */
  39580. isReady(): boolean;
  39581. private _isReadyInternal;
  39582. /**
  39583. * The engine the effect was initialized with.
  39584. * @returns the engine.
  39585. */
  39586. getEngine(): Engine;
  39587. /**
  39588. * The pipeline context for this effect
  39589. * @returns the associated pipeline context
  39590. */
  39591. getPipelineContext(): Nullable<IPipelineContext>;
  39592. /**
  39593. * The set of names of attribute variables for the shader.
  39594. * @returns An array of attribute names.
  39595. */
  39596. getAttributesNames(): string[];
  39597. /**
  39598. * Returns the attribute at the given index.
  39599. * @param index The index of the attribute.
  39600. * @returns The location of the attribute.
  39601. */
  39602. getAttributeLocation(index: number): number;
  39603. /**
  39604. * Returns the attribute based on the name of the variable.
  39605. * @param name of the attribute to look up.
  39606. * @returns the attribute location.
  39607. */
  39608. getAttributeLocationByName(name: string): number;
  39609. /**
  39610. * The number of attributes.
  39611. * @returns the number of attributes.
  39612. */
  39613. getAttributesCount(): number;
  39614. /**
  39615. * Gets the index of a uniform variable.
  39616. * @param uniformName of the uniform to look up.
  39617. * @returns the index.
  39618. */
  39619. getUniformIndex(uniformName: string): number;
  39620. /**
  39621. * Returns the attribute based on the name of the variable.
  39622. * @param uniformName of the uniform to look up.
  39623. * @returns the location of the uniform.
  39624. */
  39625. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  39626. /**
  39627. * Returns an array of sampler variable names
  39628. * @returns The array of sampler variable names.
  39629. */
  39630. getSamplers(): string[];
  39631. /**
  39632. * Returns an array of uniform variable names
  39633. * @returns The array of uniform variable names.
  39634. */
  39635. getUniformNames(): string[];
  39636. /**
  39637. * Returns an array of uniform buffer variable names
  39638. * @returns The array of uniform buffer variable names.
  39639. */
  39640. getUniformBuffersNames(): string[];
  39641. /**
  39642. * Returns the index parameters used to create the effect
  39643. * @returns The index parameters object
  39644. */
  39645. getIndexParameters(): any;
  39646. /**
  39647. * The error from the last compilation.
  39648. * @returns the error string.
  39649. */
  39650. getCompilationError(): string;
  39651. /**
  39652. * Gets a boolean indicating that all fallbacks were used during compilation
  39653. * @returns true if all fallbacks were used
  39654. */
  39655. allFallbacksProcessed(): boolean;
  39656. /**
  39657. * Adds a callback to the onCompiled observable and call the callback immediately if already ready.
  39658. * @param func The callback to be used.
  39659. */
  39660. executeWhenCompiled(func: (effect: Effect) => void): void;
  39661. private _checkIsReady;
  39662. private _loadShader;
  39663. /**
  39664. * Gets the vertex shader source code of this effect
  39665. */
  39666. get vertexSourceCode(): string;
  39667. /**
  39668. * Gets the fragment shader source code of this effect
  39669. */
  39670. get fragmentSourceCode(): string;
  39671. /**
  39672. * Gets the vertex shader source code before it has been processed by the preprocessor
  39673. */
  39674. get rawVertexSourceCode(): string;
  39675. /**
  39676. * Gets the fragment shader source code before it has been processed by the preprocessor
  39677. */
  39678. get rawFragmentSourceCode(): string;
  39679. /**
  39680. * Recompiles the webGL program
  39681. * @param vertexSourceCode The source code for the vertex shader.
  39682. * @param fragmentSourceCode The source code for the fragment shader.
  39683. * @param onCompiled Callback called when completed.
  39684. * @param onError Callback called on error.
  39685. * @hidden
  39686. */
  39687. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  39688. /**
  39689. * Prepares the effect
  39690. * @hidden
  39691. */
  39692. _prepareEffect(): void;
  39693. private _getShaderCodeAndErrorLine;
  39694. private _processCompilationErrors;
  39695. /**
  39696. * Checks if the effect is supported. (Must be called after compilation)
  39697. */
  39698. get isSupported(): boolean;
  39699. /**
  39700. * Binds a texture to the engine to be used as output of the shader.
  39701. * @param channel Name of the output variable.
  39702. * @param texture Texture to bind.
  39703. * @hidden
  39704. */
  39705. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  39706. /**
  39707. * Sets a texture on the engine to be used in the shader.
  39708. * @param channel Name of the sampler variable.
  39709. * @param texture Texture to set.
  39710. */
  39711. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  39712. /**
  39713. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  39714. * @param channel Name of the sampler variable.
  39715. * @param texture Texture to set.
  39716. */
  39717. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  39718. /**
  39719. * Sets an array of textures on the engine to be used in the shader.
  39720. * @param channel Name of the variable.
  39721. * @param textures Textures to set.
  39722. */
  39723. setTextureArray(channel: string, textures: ThinTexture[]): void;
  39724. /**
  39725. * 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)
  39726. * @param channel Name of the sampler variable.
  39727. * @param postProcess Post process to get the input texture from.
  39728. */
  39729. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  39730. /**
  39731. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  39732. * 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)
  39733. * @param channel Name of the sampler variable.
  39734. * @param postProcess Post process to get the output texture from.
  39735. */
  39736. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  39737. /**
  39738. * Binds a buffer to a uniform.
  39739. * @param buffer Buffer to bind.
  39740. * @param name Name of the uniform variable to bind to.
  39741. */
  39742. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  39743. /**
  39744. * Binds block to a uniform.
  39745. * @param blockName Name of the block to bind.
  39746. * @param index Index to bind.
  39747. */
  39748. bindUniformBlock(blockName: string, index: number): void;
  39749. /**
  39750. * Sets an integer value on a uniform variable.
  39751. * @param uniformName Name of the variable.
  39752. * @param value Value to be set.
  39753. * @returns this effect.
  39754. */
  39755. setInt(uniformName: string, value: number): Effect;
  39756. /**
  39757. * Sets an int2 value on a uniform variable.
  39758. * @param uniformName Name of the variable.
  39759. * @param x First int in int2.
  39760. * @param y Second int in int2.
  39761. * @returns this effect.
  39762. */
  39763. setInt2(uniformName: string, x: number, y: number): Effect;
  39764. /**
  39765. * Sets an int3 value on a uniform variable.
  39766. * @param uniformName Name of the variable.
  39767. * @param x First int in int3.
  39768. * @param y Second int in int3.
  39769. * @param z Third int in int3.
  39770. * @returns this effect.
  39771. */
  39772. setInt3(uniformName: string, x: number, y: number, z: number): Effect;
  39773. /**
  39774. * Sets an int4 value on a uniform variable.
  39775. * @param uniformName Name of the variable.
  39776. * @param x First int in int4.
  39777. * @param y Second int in int4.
  39778. * @param z Third int in int4.
  39779. * @param w Fourth int in int4.
  39780. * @returns this effect.
  39781. */
  39782. setInt4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39783. /**
  39784. * Sets an int array on a uniform variable.
  39785. * @param uniformName Name of the variable.
  39786. * @param array array to be set.
  39787. * @returns this effect.
  39788. */
  39789. setIntArray(uniformName: string, array: Int32Array): Effect;
  39790. /**
  39791. * 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)
  39792. * @param uniformName Name of the variable.
  39793. * @param array array to be set.
  39794. * @returns this effect.
  39795. */
  39796. setIntArray2(uniformName: string, array: Int32Array): Effect;
  39797. /**
  39798. * 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)
  39799. * @param uniformName Name of the variable.
  39800. * @param array array to be set.
  39801. * @returns this effect.
  39802. */
  39803. setIntArray3(uniformName: string, array: Int32Array): Effect;
  39804. /**
  39805. * 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)
  39806. * @param uniformName Name of the variable.
  39807. * @param array array to be set.
  39808. * @returns this effect.
  39809. */
  39810. setIntArray4(uniformName: string, array: Int32Array): Effect;
  39811. /**
  39812. * Sets an float array on a uniform variable.
  39813. * @param uniformName Name of the variable.
  39814. * @param array array to be set.
  39815. * @returns this effect.
  39816. */
  39817. setFloatArray(uniformName: string, array: FloatArray): Effect;
  39818. /**
  39819. * 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)
  39820. * @param uniformName Name of the variable.
  39821. * @param array array to be set.
  39822. * @returns this effect.
  39823. */
  39824. setFloatArray2(uniformName: string, array: FloatArray): Effect;
  39825. /**
  39826. * 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)
  39827. * @param uniformName Name of the variable.
  39828. * @param array array to be set.
  39829. * @returns this effect.
  39830. */
  39831. setFloatArray3(uniformName: string, array: FloatArray): Effect;
  39832. /**
  39833. * 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)
  39834. * @param uniformName Name of the variable.
  39835. * @param array array to be set.
  39836. * @returns this effect.
  39837. */
  39838. setFloatArray4(uniformName: string, array: FloatArray): Effect;
  39839. /**
  39840. * Sets an array on a uniform variable.
  39841. * @param uniformName Name of the variable.
  39842. * @param array array to be set.
  39843. * @returns this effect.
  39844. */
  39845. setArray(uniformName: string, array: number[]): Effect;
  39846. /**
  39847. * 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)
  39848. * @param uniformName Name of the variable.
  39849. * @param array array to be set.
  39850. * @returns this effect.
  39851. */
  39852. setArray2(uniformName: string, array: number[]): Effect;
  39853. /**
  39854. * 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)
  39855. * @param uniformName Name of the variable.
  39856. * @param array array to be set.
  39857. * @returns this effect.
  39858. */
  39859. setArray3(uniformName: string, array: number[]): Effect;
  39860. /**
  39861. * 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)
  39862. * @param uniformName Name of the variable.
  39863. * @param array array to be set.
  39864. * @returns this effect.
  39865. */
  39866. setArray4(uniformName: string, array: number[]): Effect;
  39867. /**
  39868. * Sets matrices on a uniform variable.
  39869. * @param uniformName Name of the variable.
  39870. * @param matrices matrices to be set.
  39871. * @returns this effect.
  39872. */
  39873. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  39874. /**
  39875. * Sets matrix on a uniform variable.
  39876. * @param uniformName Name of the variable.
  39877. * @param matrix matrix to be set.
  39878. * @returns this effect.
  39879. */
  39880. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  39881. /**
  39882. * 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)
  39883. * @param uniformName Name of the variable.
  39884. * @param matrix matrix to be set.
  39885. * @returns this effect.
  39886. */
  39887. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39888. /**
  39889. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  39890. * @param uniformName Name of the variable.
  39891. * @param matrix matrix to be set.
  39892. * @returns this effect.
  39893. */
  39894. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39895. /**
  39896. * Sets a float on a uniform variable.
  39897. * @param uniformName Name of the variable.
  39898. * @param value value to be set.
  39899. * @returns this effect.
  39900. */
  39901. setFloat(uniformName: string, value: number): Effect;
  39902. /**
  39903. * Sets a boolean on a uniform variable.
  39904. * @param uniformName Name of the variable.
  39905. * @param bool value to be set.
  39906. * @returns this effect.
  39907. */
  39908. setBool(uniformName: string, bool: boolean): Effect;
  39909. /**
  39910. * Sets a Vector2 on a uniform variable.
  39911. * @param uniformName Name of the variable.
  39912. * @param vector2 vector2 to be set.
  39913. * @returns this effect.
  39914. */
  39915. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  39916. /**
  39917. * Sets a float2 on a uniform variable.
  39918. * @param uniformName Name of the variable.
  39919. * @param x First float in float2.
  39920. * @param y Second float in float2.
  39921. * @returns this effect.
  39922. */
  39923. setFloat2(uniformName: string, x: number, y: number): Effect;
  39924. /**
  39925. * Sets a Vector3 on a uniform variable.
  39926. * @param uniformName Name of the variable.
  39927. * @param vector3 Value to be set.
  39928. * @returns this effect.
  39929. */
  39930. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  39931. /**
  39932. * Sets a float3 on a uniform variable.
  39933. * @param uniformName Name of the variable.
  39934. * @param x First float in float3.
  39935. * @param y Second float in float3.
  39936. * @param z Third float in float3.
  39937. * @returns this effect.
  39938. */
  39939. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  39940. /**
  39941. * Sets a Vector4 on a uniform variable.
  39942. * @param uniformName Name of the variable.
  39943. * @param vector4 Value to be set.
  39944. * @returns this effect.
  39945. */
  39946. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  39947. /**
  39948. * Sets a float4 on a uniform variable.
  39949. * @param uniformName Name of the variable.
  39950. * @param x First float in float4.
  39951. * @param y Second float in float4.
  39952. * @param z Third float in float4.
  39953. * @param w Fourth float in float4.
  39954. * @returns this effect.
  39955. */
  39956. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39957. /**
  39958. * Sets a Color3 on a uniform variable.
  39959. * @param uniformName Name of the variable.
  39960. * @param color3 Value to be set.
  39961. * @returns this effect.
  39962. */
  39963. setColor3(uniformName: string, color3: IColor3Like): Effect;
  39964. /**
  39965. * Sets a Color4 on a uniform variable.
  39966. * @param uniformName Name of the variable.
  39967. * @param color3 Value to be set.
  39968. * @param alpha Alpha value to be set.
  39969. * @returns this effect.
  39970. */
  39971. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  39972. /**
  39973. * Sets a Color4 on a uniform variable
  39974. * @param uniformName defines the name of the variable
  39975. * @param color4 defines the value to be set
  39976. * @returns this effect.
  39977. */
  39978. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  39979. /**
  39980. * Release all associated resources.
  39981. **/
  39982. dispose(): void;
  39983. /**
  39984. * This function will add a new shader to the shader store
  39985. * @param name the name of the shader
  39986. * @param pixelShader optional pixel shader content
  39987. * @param vertexShader optional vertex shader content
  39988. */
  39989. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  39990. /**
  39991. * Store of each shader (The can be looked up using effect.key)
  39992. */
  39993. static ShadersStore: {
  39994. [key: string]: string;
  39995. };
  39996. /**
  39997. * Store of each included file for a shader (The can be looked up using effect.key)
  39998. */
  39999. static IncludesShadersStore: {
  40000. [key: string]: string;
  40001. };
  40002. /**
  40003. * Resets the cache of effects.
  40004. */
  40005. static ResetCache(): void;
  40006. }
  40007. }
  40008. declare module BABYLON {
  40009. /**
  40010. * Interface used to describe the capabilities of the engine relatively to the current browser
  40011. */
  40012. export interface EngineCapabilities {
  40013. /** Maximum textures units per fragment shader */
  40014. maxTexturesImageUnits: number;
  40015. /** Maximum texture units per vertex shader */
  40016. maxVertexTextureImageUnits: number;
  40017. /** Maximum textures units in the entire pipeline */
  40018. maxCombinedTexturesImageUnits: number;
  40019. /** Maximum texture size */
  40020. maxTextureSize: number;
  40021. /** Maximum texture samples */
  40022. maxSamples?: number;
  40023. /** Maximum cube texture size */
  40024. maxCubemapTextureSize: number;
  40025. /** Maximum render texture size */
  40026. maxRenderTextureSize: number;
  40027. /** Maximum number of vertex attributes */
  40028. maxVertexAttribs: number;
  40029. /** Maximum number of varyings */
  40030. maxVaryingVectors: number;
  40031. /** Maximum number of uniforms per vertex shader */
  40032. maxVertexUniformVectors: number;
  40033. /** Maximum number of uniforms per fragment shader */
  40034. maxFragmentUniformVectors: number;
  40035. /** Defines if standard derivatives (dx/dy) are supported */
  40036. standardDerivatives: boolean;
  40037. /** Defines if s3tc texture compression is supported */
  40038. s3tc?: WEBGL_compressed_texture_s3tc;
  40039. /** Defines if pvrtc texture compression is supported */
  40040. pvrtc: any;
  40041. /** Defines if etc1 texture compression is supported */
  40042. etc1: any;
  40043. /** Defines if etc2 texture compression is supported */
  40044. etc2: any;
  40045. /** Defines if astc texture compression is supported */
  40046. astc: any;
  40047. /** Defines if bptc texture compression is supported */
  40048. bptc: any;
  40049. /** Defines if float textures are supported */
  40050. textureFloat: boolean;
  40051. /** Defines if vertex array objects are supported */
  40052. vertexArrayObject: boolean;
  40053. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  40054. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  40055. /** Gets the maximum level of anisotropy supported */
  40056. maxAnisotropy: number;
  40057. /** Defines if instancing is supported */
  40058. instancedArrays: boolean;
  40059. /** Defines if 32 bits indices are supported */
  40060. uintIndices: boolean;
  40061. /** Defines if high precision shaders are supported */
  40062. highPrecisionShaderSupported: boolean;
  40063. /** Defines if depth reading in the fragment shader is supported */
  40064. fragmentDepthSupported: boolean;
  40065. /** Defines if float texture linear filtering is supported*/
  40066. textureFloatLinearFiltering: boolean;
  40067. /** Defines if rendering to float textures is supported */
  40068. textureFloatRender: boolean;
  40069. /** Defines if half float textures are supported*/
  40070. textureHalfFloat: boolean;
  40071. /** Defines if half float texture linear filtering is supported*/
  40072. textureHalfFloatLinearFiltering: boolean;
  40073. /** Defines if rendering to half float textures is supported */
  40074. textureHalfFloatRender: boolean;
  40075. /** Defines if textureLOD shader command is supported */
  40076. textureLOD: boolean;
  40077. /** Defines if draw buffers extension is supported */
  40078. drawBuffersExtension: boolean;
  40079. /** Defines if depth textures are supported */
  40080. depthTextureExtension: boolean;
  40081. /** Defines if float color buffer are supported */
  40082. colorBufferFloat: boolean;
  40083. /** Gets disjoint timer query extension (null if not supported) */
  40084. timerQuery?: EXT_disjoint_timer_query;
  40085. /** Defines if timestamp can be used with timer query */
  40086. canUseTimestampForTimerQuery: boolean;
  40087. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  40088. multiview?: any;
  40089. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  40090. oculusMultiview?: any;
  40091. /** Function used to let the system compiles shaders in background */
  40092. parallelShaderCompile?: {
  40093. COMPLETION_STATUS_KHR: number;
  40094. };
  40095. /** Max number of texture samples for MSAA */
  40096. maxMSAASamples: number;
  40097. /** Defines if the blend min max extension is supported */
  40098. blendMinMax: boolean;
  40099. /** 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 */
  40100. canUseGLInstanceID: boolean;
  40101. /** Defines if gl_vertexID is available */
  40102. canUseGLVertexID: boolean;
  40103. }
  40104. }
  40105. declare module BABYLON {
  40106. /**
  40107. * @hidden
  40108. **/
  40109. export class DepthCullingState {
  40110. protected _isDepthTestDirty: boolean;
  40111. protected _isDepthMaskDirty: boolean;
  40112. protected _isDepthFuncDirty: boolean;
  40113. protected _isCullFaceDirty: boolean;
  40114. protected _isCullDirty: boolean;
  40115. protected _isZOffsetDirty: boolean;
  40116. protected _isFrontFaceDirty: boolean;
  40117. protected _depthTest: boolean;
  40118. protected _depthMask: boolean;
  40119. protected _depthFunc: Nullable<number>;
  40120. protected _cull: Nullable<boolean>;
  40121. protected _cullFace: Nullable<number>;
  40122. protected _zOffset: number;
  40123. protected _frontFace: Nullable<number>;
  40124. /**
  40125. * Initializes the state.
  40126. */
  40127. constructor(reset?: boolean);
  40128. get isDirty(): boolean;
  40129. get zOffset(): number;
  40130. set zOffset(value: number);
  40131. get cullFace(): Nullable<number>;
  40132. set cullFace(value: Nullable<number>);
  40133. get cull(): Nullable<boolean>;
  40134. set cull(value: Nullable<boolean>);
  40135. get depthFunc(): Nullable<number>;
  40136. set depthFunc(value: Nullable<number>);
  40137. get depthMask(): boolean;
  40138. set depthMask(value: boolean);
  40139. get depthTest(): boolean;
  40140. set depthTest(value: boolean);
  40141. get frontFace(): Nullable<number>;
  40142. set frontFace(value: Nullable<number>);
  40143. reset(): void;
  40144. apply(gl: WebGLRenderingContext): void;
  40145. }
  40146. }
  40147. declare module BABYLON {
  40148. /**
  40149. * @hidden
  40150. **/
  40151. export class StencilState {
  40152. /** 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 */
  40153. static readonly ALWAYS: number;
  40154. /** Passed to stencilOperation to specify that stencil value must be kept */
  40155. static readonly KEEP: number;
  40156. /** Passed to stencilOperation to specify that stencil value must be replaced */
  40157. static readonly REPLACE: number;
  40158. protected _isStencilTestDirty: boolean;
  40159. protected _isStencilMaskDirty: boolean;
  40160. protected _isStencilFuncDirty: boolean;
  40161. protected _isStencilOpDirty: boolean;
  40162. protected _stencilTest: boolean;
  40163. protected _stencilMask: number;
  40164. protected _stencilFunc: number;
  40165. protected _stencilFuncRef: number;
  40166. protected _stencilFuncMask: number;
  40167. protected _stencilOpStencilFail: number;
  40168. protected _stencilOpDepthFail: number;
  40169. protected _stencilOpStencilDepthPass: number;
  40170. get isDirty(): boolean;
  40171. get stencilFunc(): number;
  40172. set stencilFunc(value: number);
  40173. get stencilFuncRef(): number;
  40174. set stencilFuncRef(value: number);
  40175. get stencilFuncMask(): number;
  40176. set stencilFuncMask(value: number);
  40177. get stencilOpStencilFail(): number;
  40178. set stencilOpStencilFail(value: number);
  40179. get stencilOpDepthFail(): number;
  40180. set stencilOpDepthFail(value: number);
  40181. get stencilOpStencilDepthPass(): number;
  40182. set stencilOpStencilDepthPass(value: number);
  40183. get stencilMask(): number;
  40184. set stencilMask(value: number);
  40185. get stencilTest(): boolean;
  40186. set stencilTest(value: boolean);
  40187. constructor(reset?: boolean);
  40188. reset(): void;
  40189. apply(gl: WebGLRenderingContext): void;
  40190. }
  40191. }
  40192. declare module BABYLON {
  40193. /**
  40194. * @hidden
  40195. **/
  40196. export class AlphaState {
  40197. _blendFunctionParameters: Nullable<number>[];
  40198. _blendEquationParameters: Nullable<number>[];
  40199. _blendConstants: Nullable<number>[];
  40200. _isBlendConstantsDirty: boolean;
  40201. private _alphaBlend;
  40202. private _isAlphaBlendDirty;
  40203. private _isBlendFunctionParametersDirty;
  40204. private _isBlendEquationParametersDirty;
  40205. /**
  40206. * Initializes the state.
  40207. */
  40208. constructor();
  40209. get isDirty(): boolean;
  40210. get alphaBlend(): boolean;
  40211. set alphaBlend(value: boolean);
  40212. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  40213. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  40214. setAlphaEquationParameters(rgb: number, alpha: number): void;
  40215. reset(): void;
  40216. apply(gl: WebGLRenderingContext): void;
  40217. }
  40218. }
  40219. declare module BABYLON {
  40220. /** @hidden */
  40221. export class WebGLShaderProcessor implements IShaderProcessor {
  40222. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  40223. }
  40224. }
  40225. declare module BABYLON {
  40226. /** @hidden */
  40227. export class WebGL2ShaderProcessor implements IShaderProcessor {
  40228. attributeProcessor(attribute: string): string;
  40229. varyingProcessor(varying: string, isFragment: boolean): string;
  40230. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  40231. }
  40232. }
  40233. declare module BABYLON {
  40234. /**
  40235. * Interface for attribute information associated with buffer instantiation
  40236. */
  40237. export interface InstancingAttributeInfo {
  40238. /**
  40239. * Name of the GLSL attribute
  40240. * if attribute index is not specified, this is used to retrieve the index from the effect
  40241. */
  40242. attributeName: string;
  40243. /**
  40244. * Index/offset of the attribute in the vertex shader
  40245. * if not specified, this will be computes from the name.
  40246. */
  40247. index?: number;
  40248. /**
  40249. * size of the attribute, 1, 2, 3 or 4
  40250. */
  40251. attributeSize: number;
  40252. /**
  40253. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  40254. */
  40255. offset: number;
  40256. /**
  40257. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  40258. * default to 1
  40259. */
  40260. divisor?: number;
  40261. /**
  40262. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  40263. * default is FLOAT
  40264. */
  40265. attributeType?: number;
  40266. /**
  40267. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  40268. */
  40269. normalized?: boolean;
  40270. }
  40271. }
  40272. declare module BABYLON {
  40273. /** @hidden */
  40274. export interface EngineFeatures {
  40275. /** Force using Bitmap when Bitmap or HTMLImageElement can be used */
  40276. forceBitmapOverHTMLImageElement: boolean;
  40277. /** Indicates that the engine support rendering to as well as copying to lod float textures */
  40278. supportRenderAndCopyToLodForFloatTextures: boolean;
  40279. /** Indicates that the engine support handling depth/stencil textures */
  40280. supportDepthStencilTexture: boolean;
  40281. /** Indicates that the engine support shadow samplers */
  40282. supportShadowSamplers: boolean;
  40283. /** 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 */
  40284. uniformBufferHardCheckMatrix: boolean;
  40285. /** Indicates that prefiltered mipmaps can be generated in some processes (for eg when loading an HDR cube texture) */
  40286. allowTexturePrefiltering: boolean;
  40287. /** Indicates to track the usage of ubos and to create new ones as necessary during a frame duration */
  40288. trackUbosInFrame: boolean;
  40289. /** Indicates that the Cascaded Shadow Map technic is supported */
  40290. supportCSM: boolean;
  40291. /** Indicates that the textures transcoded by the basis transcoder must have power of 2 width and height */
  40292. basisNeedsPOT: boolean;
  40293. /** Indicates that the engine supports 3D textures */
  40294. support3DTextures: boolean;
  40295. /** Indicates that constants need a type suffix in shaders (used by realtime filtering...) */
  40296. needTypeSuffixInShaderConstants: boolean;
  40297. /** Indicates that MSAA is supported */
  40298. supportMSAA: boolean;
  40299. /** Indicates that SSAO2 is supported */
  40300. supportSSAO2: boolean;
  40301. /** Indicates that some additional texture formats are supported (like TEXTUREFORMAT_R for eg) */
  40302. supportExtendedTextureFormats: boolean;
  40303. /** Indicates that the switch/case construct is supported in shaders */
  40304. supportSwitchCaseInShader: boolean;
  40305. /** Indicates that synchronous texture reading is supported */
  40306. supportSyncTextureRead: boolean;
  40307. /** Indicates that y should be inverted when dealing with bitmaps (notably in environment tools) */
  40308. needsInvertingBitmap: boolean;
  40309. /** @hidden */
  40310. _collectUbosUpdatedInFrame: boolean;
  40311. }
  40312. }
  40313. declare module BABYLON {
  40314. /** @hidden */
  40315. export class WebGLHardwareTexture implements HardwareTextureWrapper {
  40316. private _webGLTexture;
  40317. private _context;
  40318. get underlyingResource(): Nullable<WebGLTexture>;
  40319. constructor(existingTexture: WebGLTexture | null | undefined, context: WebGLRenderingContext);
  40320. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  40321. set(hardwareTexture: WebGLTexture): void;
  40322. reset(): void;
  40323. release(): void;
  40324. }
  40325. }
  40326. declare module BABYLON {
  40327. interface ThinEngine {
  40328. /**
  40329. * Update a video texture
  40330. * @param texture defines the texture to update
  40331. * @param video defines the video element to use
  40332. * @param invertY defines if data must be stored with Y axis inverted
  40333. */
  40334. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  40335. }
  40336. }
  40337. declare module BABYLON {
  40338. interface ThinEngine {
  40339. /**
  40340. * Creates a dynamic texture
  40341. * @param width defines the width of the texture
  40342. * @param height defines the height of the texture
  40343. * @param generateMipMaps defines if the engine should generate the mip levels
  40344. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  40345. * @returns the dynamic texture inside an InternalTexture
  40346. */
  40347. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  40348. /**
  40349. * Update the content of a dynamic texture
  40350. * @param texture defines the texture to update
  40351. * @param source defines the source containing the data
  40352. * @param invertY defines if data must be stored with Y axis inverted
  40353. * @param premulAlpha defines if alpha is stored as premultiplied
  40354. * @param format defines the format of the data
  40355. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  40356. */
  40357. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  40358. }
  40359. }
  40360. declare module BABYLON {
  40361. /**
  40362. * Settings for finer control over video usage
  40363. */
  40364. export interface VideoTextureSettings {
  40365. /**
  40366. * Applies `autoplay` to video, if specified
  40367. */
  40368. autoPlay?: boolean;
  40369. /**
  40370. * Applies `muted` to video, if specified
  40371. */
  40372. muted?: boolean;
  40373. /**
  40374. * Applies `loop` to video, if specified
  40375. */
  40376. loop?: boolean;
  40377. /**
  40378. * Automatically updates internal texture from video at every frame in the render loop
  40379. */
  40380. autoUpdateTexture: boolean;
  40381. /**
  40382. * Image src displayed during the video loading or until the user interacts with the video.
  40383. */
  40384. poster?: string;
  40385. }
  40386. /**
  40387. * If you want to display a video in your scene, this is the special texture for that.
  40388. * This special texture works similar to other textures, with the exception of a few parameters.
  40389. * @see https://doc.babylonjs.com/how_to/video_texture
  40390. */
  40391. export class VideoTexture extends Texture {
  40392. /**
  40393. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  40394. */
  40395. readonly autoUpdateTexture: boolean;
  40396. /**
  40397. * The video instance used by the texture internally
  40398. */
  40399. readonly video: HTMLVideoElement;
  40400. private _onUserActionRequestedObservable;
  40401. /**
  40402. * Event triggered when a dom action is required by the user to play the video.
  40403. * This happens due to recent changes in browser policies preventing video to auto start.
  40404. */
  40405. get onUserActionRequestedObservable(): Observable<Texture>;
  40406. private _generateMipMaps;
  40407. private _stillImageCaptured;
  40408. private _displayingPosterTexture;
  40409. private _settings;
  40410. private _createInternalTextureOnEvent;
  40411. private _frameId;
  40412. private _currentSrc;
  40413. /**
  40414. * Creates a video texture.
  40415. * If you want to display a video in your scene, this is the special texture for that.
  40416. * This special texture works similar to other textures, with the exception of a few parameters.
  40417. * @see https://doc.babylonjs.com/how_to/video_texture
  40418. * @param name optional name, will detect from video source, if not defined
  40419. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  40420. * @param scene is obviously the current scene.
  40421. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  40422. * @param invertY is false by default but can be used to invert video on Y axis
  40423. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  40424. * @param settings allows finer control over video usage
  40425. */
  40426. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  40427. private _getName;
  40428. private _getVideo;
  40429. private _createInternalTexture;
  40430. private reset;
  40431. /**
  40432. * @hidden Internal method to initiate `update`.
  40433. */
  40434. _rebuild(): void;
  40435. /**
  40436. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  40437. */
  40438. update(): void;
  40439. /**
  40440. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  40441. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or otherwise.
  40442. */
  40443. updateTexture(isVisible: boolean): void;
  40444. protected _updateInternalTexture: () => void;
  40445. /**
  40446. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  40447. * @param url New url.
  40448. */
  40449. updateURL(url: string): void;
  40450. /**
  40451. * Clones the texture.
  40452. * @returns the cloned texture
  40453. */
  40454. clone(): VideoTexture;
  40455. /**
  40456. * Dispose the texture and release its associated resources.
  40457. */
  40458. dispose(): void;
  40459. /**
  40460. * Creates a video texture straight from a stream.
  40461. * @param scene Define the scene the texture should be created in
  40462. * @param stream Define the stream the texture should be created from
  40463. * @returns The created video texture as a promise
  40464. */
  40465. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  40466. /**
  40467. * Creates a video texture straight from your WebCam video feed.
  40468. * @param scene Define the scene the texture should be created in
  40469. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40470. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40471. * @returns The created video texture as a promise
  40472. */
  40473. static CreateFromWebCamAsync(scene: Scene, constraints: {
  40474. minWidth: number;
  40475. maxWidth: number;
  40476. minHeight: number;
  40477. maxHeight: number;
  40478. deviceId: string;
  40479. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  40480. /**
  40481. * Creates a video texture straight from your WebCam video feed.
  40482. * @param scene Define the scene the texture should be created in
  40483. * @param onReady Define a callback to triggered once the texture will be ready
  40484. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40485. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40486. */
  40487. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  40488. minWidth: number;
  40489. maxWidth: number;
  40490. minHeight: number;
  40491. maxHeight: number;
  40492. deviceId: string;
  40493. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  40494. }
  40495. }
  40496. declare module BABYLON {
  40497. /**
  40498. * Defines the interface used by objects working like Scene
  40499. * @hidden
  40500. */
  40501. export interface ISceneLike {
  40502. _addPendingData(data: any): void;
  40503. _removePendingData(data: any): void;
  40504. offlineProvider: IOfflineProvider;
  40505. }
  40506. /**
  40507. * Information about the current host
  40508. */
  40509. export interface HostInformation {
  40510. /**
  40511. * Defines if the current host is a mobile
  40512. */
  40513. isMobile: boolean;
  40514. }
  40515. /** Interface defining initialization parameters for Engine class */
  40516. export interface EngineOptions extends WebGLContextAttributes {
  40517. /**
  40518. * Defines if the engine should no exceed a specified device ratio
  40519. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  40520. */
  40521. limitDeviceRatio?: number;
  40522. /**
  40523. * Defines if webvr should be enabled automatically
  40524. * @see https://doc.babylonjs.com/how_to/webvr_camera
  40525. */
  40526. autoEnableWebVR?: boolean;
  40527. /**
  40528. * Defines if webgl2 should be turned off even if supported
  40529. * @see https://doc.babylonjs.com/features/webgl2
  40530. */
  40531. disableWebGL2Support?: boolean;
  40532. /**
  40533. * Defines if webaudio should be initialized as well
  40534. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40535. */
  40536. audioEngine?: boolean;
  40537. /**
  40538. * Defines if animations should run using a deterministic lock step
  40539. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40540. */
  40541. deterministicLockstep?: boolean;
  40542. /** Defines the maximum steps to use with deterministic lock step mode */
  40543. lockstepMaxSteps?: number;
  40544. /** Defines the seconds between each deterministic lock step */
  40545. timeStep?: number;
  40546. /**
  40547. * Defines that engine should ignore context lost events
  40548. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  40549. */
  40550. doNotHandleContextLost?: boolean;
  40551. /**
  40552. * Defines that engine should ignore modifying touch action attribute and style
  40553. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  40554. */
  40555. doNotHandleTouchAction?: boolean;
  40556. /**
  40557. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  40558. */
  40559. useHighPrecisionFloats?: boolean;
  40560. /**
  40561. * Make the canvas XR Compatible for XR sessions
  40562. */
  40563. xrCompatible?: boolean;
  40564. /**
  40565. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  40566. */
  40567. useHighPrecisionMatrix?: boolean;
  40568. /**
  40569. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  40570. */
  40571. failIfMajorPerformanceCaveat?: boolean;
  40572. /**
  40573. * Defines whether to adapt to the device's viewport characteristics (default: false)
  40574. */
  40575. adaptToDeviceRatio?: boolean;
  40576. }
  40577. /**
  40578. * The base engine class (root of all engines)
  40579. */
  40580. export class ThinEngine {
  40581. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  40582. static ExceptionList: ({
  40583. key: string;
  40584. capture: string;
  40585. captureConstraint: number;
  40586. targets: string[];
  40587. } | {
  40588. key: string;
  40589. capture: null;
  40590. captureConstraint: null;
  40591. targets: string[];
  40592. })[];
  40593. /** @hidden */
  40594. static _TextureLoaders: IInternalTextureLoader[];
  40595. /**
  40596. * Returns the current npm package of the sdk
  40597. */
  40598. static get NpmPackage(): string;
  40599. /**
  40600. * Returns the current version of the framework
  40601. */
  40602. static get Version(): string;
  40603. /**
  40604. * Returns a string describing the current engine
  40605. */
  40606. get description(): string;
  40607. /**
  40608. * Returns the name of the engine
  40609. */
  40610. get name(): string;
  40611. /**
  40612. * Returns the version of the engine
  40613. */
  40614. get version(): number;
  40615. /**
  40616. * Gets or sets the epsilon value used by collision engine
  40617. */
  40618. static CollisionsEpsilon: number;
  40619. /**
  40620. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  40621. */
  40622. static get ShadersRepository(): string;
  40623. static set ShadersRepository(value: string);
  40624. /** @hidden */
  40625. _shaderProcessor: Nullable<IShaderProcessor>;
  40626. /**
  40627. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  40628. */
  40629. forcePOTTextures: boolean;
  40630. /**
  40631. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  40632. */
  40633. isFullscreen: boolean;
  40634. /**
  40635. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  40636. */
  40637. cullBackFaces: boolean;
  40638. /**
  40639. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  40640. */
  40641. renderEvenInBackground: boolean;
  40642. /**
  40643. * Gets or sets a boolean indicating that cache can be kept between frames
  40644. */
  40645. preventCacheWipeBetweenFrames: boolean;
  40646. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  40647. validateShaderPrograms: boolean;
  40648. /**
  40649. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  40650. * This can provide greater z depth for distant objects.
  40651. */
  40652. useReverseDepthBuffer: boolean;
  40653. /**
  40654. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  40655. */
  40656. disableUniformBuffers: boolean;
  40657. private _frameId;
  40658. /**
  40659. * Gets the current frame id
  40660. */
  40661. get frameId(): number;
  40662. /** @hidden */
  40663. _uniformBuffers: UniformBuffer[];
  40664. /**
  40665. * Gets a boolean indicating that the engine supports uniform buffers
  40666. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  40667. */
  40668. get supportsUniformBuffers(): boolean;
  40669. /** @hidden */
  40670. _gl: WebGLRenderingContext;
  40671. /** @hidden */
  40672. _webGLVersion: number;
  40673. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  40674. protected _windowIsBackground: boolean;
  40675. protected _creationOptions: EngineOptions;
  40676. protected _highPrecisionShadersAllowed: boolean;
  40677. /** @hidden */
  40678. get _shouldUseHighPrecisionShader(): boolean;
  40679. /**
  40680. * Gets a boolean indicating that only power of 2 textures are supported
  40681. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  40682. */
  40683. get needPOTTextures(): boolean;
  40684. /** @hidden */
  40685. _badOS: boolean;
  40686. /** @hidden */
  40687. _badDesktopOS: boolean;
  40688. protected _hardwareScalingLevel: number;
  40689. /** @hidden */
  40690. _caps: EngineCapabilities;
  40691. /** @hidden */
  40692. _features: EngineFeatures;
  40693. protected _isStencilEnable: boolean;
  40694. private _glVersion;
  40695. private _glRenderer;
  40696. private _glVendor;
  40697. /** @hidden */
  40698. _videoTextureSupported: boolean;
  40699. protected _renderingQueueLaunched: boolean;
  40700. protected _activeRenderLoops: (() => void)[];
  40701. /**
  40702. * Observable signaled when a context lost event is raised
  40703. */
  40704. onContextLostObservable: Observable<ThinEngine>;
  40705. /**
  40706. * Observable signaled when a context restored event is raised
  40707. */
  40708. onContextRestoredObservable: Observable<ThinEngine>;
  40709. private _onContextLost;
  40710. private _onContextRestored;
  40711. protected _contextWasLost: boolean;
  40712. /** @hidden */
  40713. _doNotHandleContextLost: boolean;
  40714. /**
  40715. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  40716. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  40717. */
  40718. get doNotHandleContextLost(): boolean;
  40719. set doNotHandleContextLost(value: boolean);
  40720. /**
  40721. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  40722. */
  40723. disableVertexArrayObjects: boolean;
  40724. /** @hidden */
  40725. protected _colorWrite: boolean;
  40726. /** @hidden */
  40727. protected _colorWriteChanged: boolean;
  40728. /** @hidden */
  40729. protected _depthCullingState: DepthCullingState;
  40730. /** @hidden */
  40731. protected _stencilState: StencilState;
  40732. /** @hidden */
  40733. _alphaState: AlphaState;
  40734. /** @hidden */
  40735. _alphaMode: number;
  40736. /** @hidden */
  40737. _alphaEquation: number;
  40738. /** @hidden */
  40739. _internalTexturesCache: InternalTexture[];
  40740. /** @hidden */
  40741. protected _activeChannel: number;
  40742. private _currentTextureChannel;
  40743. /** @hidden */
  40744. protected _boundTexturesCache: {
  40745. [key: string]: Nullable<InternalTexture>;
  40746. };
  40747. /** @hidden */
  40748. protected _currentEffect: Nullable<Effect>;
  40749. /** @hidden */
  40750. protected _currentProgram: Nullable<WebGLProgram>;
  40751. protected _compiledEffects: {
  40752. [key: string]: Effect;
  40753. };
  40754. private _vertexAttribArraysEnabled;
  40755. /** @hidden */
  40756. protected _cachedViewport: Nullable<IViewportLike>;
  40757. private _cachedVertexArrayObject;
  40758. /** @hidden */
  40759. protected _cachedVertexBuffers: any;
  40760. /** @hidden */
  40761. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  40762. /** @hidden */
  40763. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  40764. /** @hidden */
  40765. _currentRenderTarget: Nullable<InternalTexture>;
  40766. private _uintIndicesCurrentlySet;
  40767. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  40768. /** @hidden */
  40769. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  40770. /** @hidden */
  40771. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  40772. private _currentBufferPointers;
  40773. private _currentInstanceLocations;
  40774. private _currentInstanceBuffers;
  40775. private _textureUnits;
  40776. /** @hidden */
  40777. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40778. /** @hidden */
  40779. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40780. /** @hidden */
  40781. _boundRenderFunction: any;
  40782. private _vaoRecordInProgress;
  40783. private _mustWipeVertexAttributes;
  40784. private _emptyTexture;
  40785. private _emptyCubeTexture;
  40786. private _emptyTexture3D;
  40787. private _emptyTexture2DArray;
  40788. /** @hidden */
  40789. _frameHandler: number;
  40790. private _nextFreeTextureSlots;
  40791. private _maxSimultaneousTextures;
  40792. private _activeRequests;
  40793. /** @hidden */
  40794. _transformTextureUrl: Nullable<(url: string) => string>;
  40795. /**
  40796. * Gets information about the current host
  40797. */
  40798. hostInformation: HostInformation;
  40799. protected get _supportsHardwareTextureRescaling(): boolean;
  40800. private _framebufferDimensionsObject;
  40801. /**
  40802. * sets the object from which width and height will be taken from when getting render width and height
  40803. * Will fallback to the gl object
  40804. * @param dimensions the framebuffer width and height that will be used.
  40805. */
  40806. set framebufferDimensionsObject(dimensions: Nullable<{
  40807. framebufferWidth: number;
  40808. framebufferHeight: number;
  40809. }>);
  40810. /**
  40811. * Gets the current viewport
  40812. */
  40813. get currentViewport(): Nullable<IViewportLike>;
  40814. /**
  40815. * Gets the default empty texture
  40816. */
  40817. get emptyTexture(): InternalTexture;
  40818. /**
  40819. * Gets the default empty 3D texture
  40820. */
  40821. get emptyTexture3D(): InternalTexture;
  40822. /**
  40823. * Gets the default empty 2D array texture
  40824. */
  40825. get emptyTexture2DArray(): InternalTexture;
  40826. /**
  40827. * Gets the default empty cube texture
  40828. */
  40829. get emptyCubeTexture(): InternalTexture;
  40830. /**
  40831. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  40832. */
  40833. premultipliedAlpha: boolean;
  40834. /**
  40835. * Observable event triggered before each texture is initialized
  40836. */
  40837. onBeforeTextureInitObservable: Observable<Texture>;
  40838. /** @hidden */
  40839. protected _isWebGPU: boolean;
  40840. /**
  40841. * Gets a boolean indicating if the engine runs in WebGPU or not.
  40842. */
  40843. get isWebGPU(): boolean;
  40844. /** @hidden */
  40845. protected _shaderPlatformName: string;
  40846. /**
  40847. * Gets the shader platfrom name used by the effects.
  40848. */
  40849. get shaderPlatformName(): string;
  40850. /**
  40851. * Creates a new engine
  40852. * @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
  40853. * @param antialias defines enable antialiasing (default: false)
  40854. * @param options defines further options to be sent to the getContext() function
  40855. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40856. */
  40857. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40858. /**
  40859. * @hidden
  40860. */
  40861. _debugPushGroup(groupName: string, targetObject?: number): void;
  40862. /**
  40863. * @hidden
  40864. */
  40865. _debugPopGroup(targetObject?: number): void;
  40866. /**
  40867. * @hidden
  40868. */
  40869. _debugInsertMarker(text: string, targetObject?: number): void;
  40870. /**
  40871. * Shared initialization across engines types.
  40872. * @param canvas The canvas associated with this instance of the engine.
  40873. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  40874. * @param audioEngine Defines if an audio engine should be created by default
  40875. */
  40876. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  40877. /**
  40878. * Gets a shader processor implementation fitting with the current engine type.
  40879. * @returns The shader processor implementation.
  40880. */
  40881. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  40882. /** @hidden */
  40883. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  40884. private _rebuildInternalTextures;
  40885. private _rebuildEffects;
  40886. /**
  40887. * Gets a boolean indicating if all created effects are ready
  40888. * @returns true if all effects are ready
  40889. */
  40890. areAllEffectsReady(): boolean;
  40891. protected _rebuildBuffers(): void;
  40892. protected _initGLContext(): void;
  40893. protected _initFeatures(): void;
  40894. /**
  40895. * Gets version of the current webGL context
  40896. * Keep it for back compat - use version instead
  40897. */
  40898. get webGLVersion(): number;
  40899. /**
  40900. * Gets a string identifying the name of the class
  40901. * @returns "Engine" string
  40902. */
  40903. getClassName(): string;
  40904. /**
  40905. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  40906. */
  40907. get isStencilEnable(): boolean;
  40908. /** @hidden */
  40909. _prepareWorkingCanvas(): void;
  40910. /**
  40911. * Reset the texture cache to empty state
  40912. */
  40913. resetTextureCache(): void;
  40914. /**
  40915. * Gets an object containing information about the current webGL context
  40916. * @returns an object containing the vendor, the renderer and the version of the current webGL context
  40917. */
  40918. getGlInfo(): {
  40919. vendor: string;
  40920. renderer: string;
  40921. version: string;
  40922. };
  40923. /**
  40924. * Defines the hardware scaling level.
  40925. * By default the hardware scaling level is computed from the window device ratio.
  40926. * 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.
  40927. * @param level defines the level to use
  40928. */
  40929. setHardwareScalingLevel(level: number): void;
  40930. /**
  40931. * Gets the current hardware scaling level.
  40932. * By default the hardware scaling level is computed from the window device ratio.
  40933. * 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.
  40934. * @returns a number indicating the current hardware scaling level
  40935. */
  40936. getHardwareScalingLevel(): number;
  40937. /**
  40938. * Gets the list of loaded textures
  40939. * @returns an array containing all loaded textures
  40940. */
  40941. getLoadedTexturesCache(): InternalTexture[];
  40942. /**
  40943. * Gets the object containing all engine capabilities
  40944. * @returns the EngineCapabilities object
  40945. */
  40946. getCaps(): EngineCapabilities;
  40947. /**
  40948. * stop executing a render loop function and remove it from the execution array
  40949. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  40950. */
  40951. stopRenderLoop(renderFunction?: () => void): void;
  40952. /** @hidden */
  40953. _renderLoop(): void;
  40954. /**
  40955. * Gets the HTML canvas attached with the current webGL context
  40956. * @returns a HTML canvas
  40957. */
  40958. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  40959. /**
  40960. * Gets host window
  40961. * @returns the host window object
  40962. */
  40963. getHostWindow(): Nullable<Window>;
  40964. /**
  40965. * Gets the current render width
  40966. * @param useScreen defines if screen size must be used (or the current render target if any)
  40967. * @returns a number defining the current render width
  40968. */
  40969. getRenderWidth(useScreen?: boolean): number;
  40970. /**
  40971. * Gets the current render height
  40972. * @param useScreen defines if screen size must be used (or the current render target if any)
  40973. * @returns a number defining the current render height
  40974. */
  40975. getRenderHeight(useScreen?: boolean): number;
  40976. /**
  40977. * Can be used to override the current requestAnimationFrame requester.
  40978. * @hidden
  40979. */
  40980. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  40981. /**
  40982. * Register and execute a render loop. The engine can have more than one render function
  40983. * @param renderFunction defines the function to continuously execute
  40984. */
  40985. runRenderLoop(renderFunction: () => void): void;
  40986. /**
  40987. * Clear the current render buffer or the current render target (if any is set up)
  40988. * @param color defines the color to use
  40989. * @param backBuffer defines if the back buffer must be cleared
  40990. * @param depth defines if the depth buffer must be cleared
  40991. * @param stencil defines if the stencil buffer must be cleared
  40992. */
  40993. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40994. protected _viewportCached: {
  40995. x: number;
  40996. y: number;
  40997. z: number;
  40998. w: number;
  40999. };
  41000. /** @hidden */
  41001. _viewport(x: number, y: number, width: number, height: number): void;
  41002. /**
  41003. * Set the WebGL's viewport
  41004. * @param viewport defines the viewport element to be used
  41005. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  41006. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  41007. */
  41008. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  41009. /**
  41010. * Begin a new frame
  41011. */
  41012. beginFrame(): void;
  41013. /**
  41014. * Enf the current frame
  41015. */
  41016. endFrame(): void;
  41017. /**
  41018. * Resize the view according to the canvas' size
  41019. * @param forceSetSize true to force setting the sizes of the underlying canvas
  41020. */
  41021. resize(forceSetSize?: boolean): void;
  41022. /**
  41023. * Force a specific size of the canvas
  41024. * @param width defines the new canvas' width
  41025. * @param height defines the new canvas' height
  41026. * @param forceSetSize true to force setting the sizes of the underlying canvas
  41027. * @returns true if the size was changed
  41028. */
  41029. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  41030. /**
  41031. * Binds the frame buffer to the specified texture.
  41032. * @param texture The texture to render to or null for the default canvas
  41033. * @param faceIndex The face of the texture to render to in case of cube texture
  41034. * @param requiredWidth The width of the target to render to
  41035. * @param requiredHeight The height of the target to render to
  41036. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  41037. * @param lodLevel defines the lod level to bind to the frame buffer
  41038. * @param layer defines the 2d array index to bind to frame buffer to
  41039. */
  41040. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  41041. /** @hidden */
  41042. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  41043. /**
  41044. * Unbind the current render target texture from the webGL context
  41045. * @param texture defines the render target texture to unbind
  41046. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  41047. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  41048. */
  41049. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41050. /**
  41051. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  41052. */
  41053. flushFramebuffer(): void;
  41054. /**
  41055. * Unbind the current render target and bind the default framebuffer
  41056. */
  41057. restoreDefaultFramebuffer(): void;
  41058. /** @hidden */
  41059. protected _resetVertexBufferBinding(): void;
  41060. /**
  41061. * Creates a vertex buffer
  41062. * @param data the data for the vertex buffer
  41063. * @returns the new WebGL static buffer
  41064. */
  41065. createVertexBuffer(data: DataArray): DataBuffer;
  41066. private _createVertexBuffer;
  41067. /**
  41068. * Creates a dynamic vertex buffer
  41069. * @param data the data for the dynamic vertex buffer
  41070. * @returns the new WebGL dynamic buffer
  41071. */
  41072. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  41073. protected _resetIndexBufferBinding(): void;
  41074. /**
  41075. * Creates a new index buffer
  41076. * @param indices defines the content of the index buffer
  41077. * @param updatable defines if the index buffer must be updatable
  41078. * @returns a new webGL buffer
  41079. */
  41080. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  41081. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  41082. /**
  41083. * Bind a webGL buffer to the webGL context
  41084. * @param buffer defines the buffer to bind
  41085. */
  41086. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  41087. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  41088. private bindBuffer;
  41089. /**
  41090. * update the bound buffer with the given data
  41091. * @param data defines the data to update
  41092. */
  41093. updateArrayBuffer(data: Float32Array): void;
  41094. private _vertexAttribPointer;
  41095. /** @hidden */
  41096. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  41097. private _bindVertexBuffersAttributes;
  41098. /**
  41099. * Records a vertex array object
  41100. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  41101. * @param vertexBuffers defines the list of vertex buffers to store
  41102. * @param indexBuffer defines the index buffer to store
  41103. * @param effect defines the effect to store
  41104. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  41105. * @returns the new vertex array object
  41106. */
  41107. recordVertexArrayObject(vertexBuffers: {
  41108. [key: string]: VertexBuffer;
  41109. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  41110. [kind: string]: Nullable<VertexBuffer>;
  41111. }): WebGLVertexArrayObject;
  41112. /**
  41113. * Bind a specific vertex array object
  41114. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  41115. * @param vertexArrayObject defines the vertex array object to bind
  41116. * @param indexBuffer defines the index buffer to bind
  41117. */
  41118. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  41119. /**
  41120. * Bind webGl buffers directly to the webGL context
  41121. * @param vertexBuffer defines the vertex buffer to bind
  41122. * @param indexBuffer defines the index buffer to bind
  41123. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  41124. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  41125. * @param effect defines the effect associated with the vertex buffer
  41126. */
  41127. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  41128. private _unbindVertexArrayObject;
  41129. /**
  41130. * Bind a list of vertex buffers to the webGL context
  41131. * @param vertexBuffers defines the list of vertex buffers to bind
  41132. * @param indexBuffer defines the index buffer to bind
  41133. * @param effect defines the effect associated with the vertex buffers
  41134. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  41135. */
  41136. bindBuffers(vertexBuffers: {
  41137. [key: string]: Nullable<VertexBuffer>;
  41138. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  41139. [kind: string]: Nullable<VertexBuffer>;
  41140. }): void;
  41141. /**
  41142. * Unbind all instance attributes
  41143. */
  41144. unbindInstanceAttributes(): void;
  41145. /**
  41146. * Release and free the memory of a vertex array object
  41147. * @param vao defines the vertex array object to delete
  41148. */
  41149. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  41150. /** @hidden */
  41151. _releaseBuffer(buffer: DataBuffer): boolean;
  41152. protected _deleteBuffer(buffer: DataBuffer): void;
  41153. /**
  41154. * Update the content of a webGL buffer used with instantiation and bind it to the webGL context
  41155. * @param instancesBuffer defines the webGL buffer to update and bind
  41156. * @param data defines the data to store in the buffer
  41157. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  41158. */
  41159. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  41160. /**
  41161. * Bind the content of a webGL buffer used with instantiation
  41162. * @param instancesBuffer defines the webGL buffer to bind
  41163. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  41164. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  41165. */
  41166. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  41167. /**
  41168. * Disable the instance attribute corresponding to the name in parameter
  41169. * @param name defines the name of the attribute to disable
  41170. */
  41171. disableInstanceAttributeByName(name: string): void;
  41172. /**
  41173. * Disable the instance attribute corresponding to the location in parameter
  41174. * @param attributeLocation defines the attribute location of the attribute to disable
  41175. */
  41176. disableInstanceAttribute(attributeLocation: number): void;
  41177. /**
  41178. * Disable the attribute corresponding to the location in parameter
  41179. * @param attributeLocation defines the attribute location of the attribute to disable
  41180. */
  41181. disableAttributeByIndex(attributeLocation: number): void;
  41182. /**
  41183. * Send a draw order
  41184. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  41185. * @param indexStart defines the starting index
  41186. * @param indexCount defines the number of index to draw
  41187. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  41188. */
  41189. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41190. /**
  41191. * Draw a list of points
  41192. * @param verticesStart defines the index of first vertex to draw
  41193. * @param verticesCount defines the count of vertices to draw
  41194. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  41195. */
  41196. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41197. /**
  41198. * Draw a list of unindexed primitives
  41199. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  41200. * @param verticesStart defines the index of first vertex to draw
  41201. * @param verticesCount defines the count of vertices to draw
  41202. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  41203. */
  41204. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41205. /**
  41206. * Draw a list of indexed primitives
  41207. * @param fillMode defines the primitive to use
  41208. * @param indexStart defines the starting index
  41209. * @param indexCount defines the number of index to draw
  41210. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  41211. */
  41212. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41213. /**
  41214. * Draw a list of unindexed primitives
  41215. * @param fillMode defines the primitive to use
  41216. * @param verticesStart defines the index of first vertex to draw
  41217. * @param verticesCount defines the count of vertices to draw
  41218. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  41219. */
  41220. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41221. private _drawMode;
  41222. /** @hidden */
  41223. protected _reportDrawCall(): void;
  41224. /** @hidden */
  41225. _releaseEffect(effect: Effect): void;
  41226. /** @hidden */
  41227. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  41228. /**
  41229. * Create a new effect (used to store vertex/fragment shaders)
  41230. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  41231. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  41232. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  41233. * @param samplers defines an array of string used to represent textures
  41234. * @param defines defines the string containing the defines to use to compile the shaders
  41235. * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails
  41236. * @param onCompiled defines a function to call when the effect creation is successful
  41237. * @param onError defines a function to call when the effect creation has failed
  41238. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  41239. * @returns the new Effect
  41240. */
  41241. 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;
  41242. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  41243. private _compileShader;
  41244. private _compileRawShader;
  41245. /** @hidden */
  41246. _getShaderSource(shader: WebGLShader): Nullable<string>;
  41247. /**
  41248. * Directly creates a webGL program
  41249. * @param pipelineContext defines the pipeline context to attach to
  41250. * @param vertexCode defines the vertex shader code to use
  41251. * @param fragmentCode defines the fragment shader code to use
  41252. * @param context defines the webGL context to use (if not set, the current one will be used)
  41253. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  41254. * @returns the new webGL program
  41255. */
  41256. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41257. /**
  41258. * Creates a webGL program
  41259. * @param pipelineContext defines the pipeline context to attach to
  41260. * @param vertexCode defines the vertex shader code to use
  41261. * @param fragmentCode defines the fragment shader code to use
  41262. * @param defines defines the string containing the defines to use to compile the shaders
  41263. * @param context defines the webGL context to use (if not set, the current one will be used)
  41264. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  41265. * @returns the new webGL program
  41266. */
  41267. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41268. /**
  41269. * Creates a new pipeline context
  41270. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  41271. * @returns the new pipeline
  41272. */
  41273. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  41274. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41275. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  41276. /** @hidden */
  41277. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  41278. /** @hidden */
  41279. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  41280. /** @hidden */
  41281. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  41282. /**
  41283. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  41284. * @param pipelineContext defines the pipeline context to use
  41285. * @param uniformsNames defines the list of uniform names
  41286. * @returns an array of webGL uniform locations
  41287. */
  41288. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  41289. /**
  41290. * Gets the list of active attributes for a given webGL program
  41291. * @param pipelineContext defines the pipeline context to use
  41292. * @param attributesNames defines the list of attribute names to get
  41293. * @returns an array of indices indicating the offset of each attribute
  41294. */
  41295. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  41296. /**
  41297. * Activates an effect, making it the current one (ie. the one used for rendering)
  41298. * @param effect defines the effect to activate
  41299. */
  41300. enableEffect(effect: Nullable<Effect>): void;
  41301. /**
  41302. * Set the value of an uniform to a number (int)
  41303. * @param uniform defines the webGL uniform location where to store the value
  41304. * @param value defines the int number to store
  41305. * @returns true if the value was set
  41306. */
  41307. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  41308. /**
  41309. * Set the value of an uniform to a int2
  41310. * @param uniform defines the webGL uniform location where to store the value
  41311. * @param x defines the 1st component of the value
  41312. * @param y defines the 2nd component of the value
  41313. * @returns true if the value was set
  41314. */
  41315. setInt2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  41316. /**
  41317. * Set the value of an uniform to a int3
  41318. * @param uniform defines the webGL uniform location where to store the value
  41319. * @param x defines the 1st component of the value
  41320. * @param y defines the 2nd component of the value
  41321. * @param z defines the 3rd component of the value
  41322. * @returns true if the value was set
  41323. */
  41324. setInt3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  41325. /**
  41326. * Set the value of an uniform to a int4
  41327. * @param uniform defines the webGL uniform location where to store the value
  41328. * @param x defines the 1st component of the value
  41329. * @param y defines the 2nd component of the value
  41330. * @param z defines the 3rd component of the value
  41331. * @param w defines the 4th component of the value
  41332. * @returns true if the value was set
  41333. */
  41334. setInt4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  41335. /**
  41336. * Set the value of an uniform to an array of int32
  41337. * @param uniform defines the webGL uniform location where to store the value
  41338. * @param array defines the array of int32 to store
  41339. * @returns true if the value was set
  41340. */
  41341. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41342. /**
  41343. * Set the value of an uniform to an array of int32 (stored as vec2)
  41344. * @param uniform defines the webGL uniform location where to store the value
  41345. * @param array defines the array of int32 to store
  41346. * @returns true if the value was set
  41347. */
  41348. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41349. /**
  41350. * Set the value of an uniform to an array of int32 (stored as vec3)
  41351. * @param uniform defines the webGL uniform location where to store the value
  41352. * @param array defines the array of int32 to store
  41353. * @returns true if the value was set
  41354. */
  41355. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41356. /**
  41357. * Set the value of an uniform to an array of int32 (stored as vec4)
  41358. * @param uniform defines the webGL uniform location where to store the value
  41359. * @param array defines the array of int32 to store
  41360. * @returns true if the value was set
  41361. */
  41362. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41363. /**
  41364. * Set the value of an uniform to an array of number
  41365. * @param uniform defines the webGL uniform location where to store the value
  41366. * @param array defines the array of number to store
  41367. * @returns true if the value was set
  41368. */
  41369. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41370. /**
  41371. * Set the value of an uniform to an array of number (stored as vec2)
  41372. * @param uniform defines the webGL uniform location where to store the value
  41373. * @param array defines the array of number to store
  41374. * @returns true if the value was set
  41375. */
  41376. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41377. /**
  41378. * Set the value of an uniform to an array of number (stored as vec3)
  41379. * @param uniform defines the webGL uniform location where to store the value
  41380. * @param array defines the array of number to store
  41381. * @returns true if the value was set
  41382. */
  41383. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41384. /**
  41385. * Set the value of an uniform to an array of number (stored as vec4)
  41386. * @param uniform defines the webGL uniform location where to store the value
  41387. * @param array defines the array of number to store
  41388. * @returns true if the value was set
  41389. */
  41390. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41391. /**
  41392. * Set the value of an uniform to an array of float32 (stored as matrices)
  41393. * @param uniform defines the webGL uniform location where to store the value
  41394. * @param matrices defines the array of float32 to store
  41395. * @returns true if the value was set
  41396. */
  41397. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  41398. /**
  41399. * Set the value of an uniform to a matrix (3x3)
  41400. * @param uniform defines the webGL uniform location where to store the value
  41401. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  41402. * @returns true if the value was set
  41403. */
  41404. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  41405. /**
  41406. * Set the value of an uniform to a matrix (2x2)
  41407. * @param uniform defines the webGL uniform location where to store the value
  41408. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  41409. * @returns true if the value was set
  41410. */
  41411. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  41412. /**
  41413. * Set the value of an uniform to a number (float)
  41414. * @param uniform defines the webGL uniform location where to store the value
  41415. * @param value defines the float number to store
  41416. * @returns true if the value was transferred
  41417. */
  41418. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  41419. /**
  41420. * Set the value of an uniform to a vec2
  41421. * @param uniform defines the webGL uniform location where to store the value
  41422. * @param x defines the 1st component of the value
  41423. * @param y defines the 2nd component of the value
  41424. * @returns true if the value was set
  41425. */
  41426. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  41427. /**
  41428. * Set the value of an uniform to a vec3
  41429. * @param uniform defines the webGL uniform location where to store the value
  41430. * @param x defines the 1st component of the value
  41431. * @param y defines the 2nd component of the value
  41432. * @param z defines the 3rd component of the value
  41433. * @returns true if the value was set
  41434. */
  41435. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  41436. /**
  41437. * Set the value of an uniform to a vec4
  41438. * @param uniform defines the webGL uniform location where to store the value
  41439. * @param x defines the 1st component of the value
  41440. * @param y defines the 2nd component of the value
  41441. * @param z defines the 3rd component of the value
  41442. * @param w defines the 4th component of the value
  41443. * @returns true if the value was set
  41444. */
  41445. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  41446. /**
  41447. * Apply all cached states (depth, culling, stencil and alpha)
  41448. */
  41449. applyStates(): void;
  41450. /**
  41451. * Enable or disable color writing
  41452. * @param enable defines the state to set
  41453. */
  41454. setColorWrite(enable: boolean): void;
  41455. /**
  41456. * Gets a boolean indicating if color writing is enabled
  41457. * @returns the current color writing state
  41458. */
  41459. getColorWrite(): boolean;
  41460. /**
  41461. * Gets the depth culling state manager
  41462. */
  41463. get depthCullingState(): DepthCullingState;
  41464. /**
  41465. * Gets the alpha state manager
  41466. */
  41467. get alphaState(): AlphaState;
  41468. /**
  41469. * Gets the stencil state manager
  41470. */
  41471. get stencilState(): StencilState;
  41472. /**
  41473. * Clears the list of texture accessible through engine.
  41474. * This can help preventing texture load conflict due to name collision.
  41475. */
  41476. clearInternalTexturesCache(): void;
  41477. /**
  41478. * Force the entire cache to be cleared
  41479. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  41480. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  41481. */
  41482. wipeCaches(bruteForce?: boolean): void;
  41483. /** @hidden */
  41484. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  41485. min: number;
  41486. mag: number;
  41487. };
  41488. /** @hidden */
  41489. protected _createTexture(): WebGLTexture;
  41490. /** @hidden */
  41491. _createHardwareTexture(): HardwareTextureWrapper;
  41492. 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 | {
  41493. width: number;
  41494. height: number;
  41495. }, invertY: boolean, noMipmap: boolean, isCompressed: boolean, processFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  41496. width: number;
  41497. height: number;
  41498. }, extension: string, texture: InternalTexture, continuationCallback: () => void) => boolean, samplingMode: number) => void, prepareTextureProcessFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  41499. width: number;
  41500. height: number;
  41501. }, 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;
  41502. /**
  41503. * Usually called from Texture.ts.
  41504. * Passed information to create a WebGLTexture
  41505. * @param url defines a value which contains one of the following:
  41506. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  41507. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  41508. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  41509. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  41510. * @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)
  41511. * @param scene needed for loading to the correct scene
  41512. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  41513. * @param onLoad optional callback to be called upon successful completion
  41514. * @param onError optional callback to be called upon failure
  41515. * @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
  41516. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  41517. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  41518. * @param forcedExtension defines the extension to use to pick the right loader
  41519. * @param mimeType defines an optional mime type
  41520. * @param loaderOptions options to be passed to the loader
  41521. * @returns a InternalTexture for assignment back into BABYLON.Texture
  41522. */
  41523. 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;
  41524. /**
  41525. * Loads an image as an HTMLImageElement.
  41526. * @param input url string, ArrayBuffer, or Blob to load
  41527. * @param onLoad callback called when the image successfully loads
  41528. * @param onError callback called when the image fails to load
  41529. * @param offlineProvider offline provider for caching
  41530. * @param mimeType optional mime type
  41531. * @returns the HTMLImageElement of the loaded image
  41532. * @hidden
  41533. */
  41534. 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>;
  41535. /**
  41536. * @hidden
  41537. */
  41538. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41539. private _unpackFlipYCached;
  41540. /**
  41541. * In case you are sharing the context with other applications, it might
  41542. * be interested to not cache the unpack flip y state to ensure a consistent
  41543. * value would be set.
  41544. */
  41545. enableUnpackFlipYCached: boolean;
  41546. /** @hidden */
  41547. _unpackFlipY(value: boolean): void;
  41548. /** @hidden */
  41549. _getUnpackAlignement(): number;
  41550. private _getTextureTarget;
  41551. /**
  41552. * Update the sampling mode of a given texture
  41553. * @param samplingMode defines the required sampling mode
  41554. * @param texture defines the texture to update
  41555. * @param generateMipMaps defines whether to generate mipmaps for the texture
  41556. */
  41557. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  41558. /**
  41559. * Update the dimensions of a texture
  41560. * @param texture texture to update
  41561. * @param width new width of the texture
  41562. * @param height new height of the texture
  41563. * @param depth new depth of the texture
  41564. */
  41565. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  41566. /**
  41567. * Update the sampling mode of a given texture
  41568. * @param texture defines the texture to update
  41569. * @param wrapU defines the texture wrap mode of the u coordinates
  41570. * @param wrapV defines the texture wrap mode of the v coordinates
  41571. * @param wrapR defines the texture wrap mode of the r coordinates
  41572. */
  41573. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  41574. /** @hidden */
  41575. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  41576. width: number;
  41577. height: number;
  41578. layers?: number;
  41579. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  41580. /** @hidden */
  41581. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41582. /** @hidden */
  41583. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  41584. /**
  41585. * Update a portion of an internal texture
  41586. * @param texture defines the texture to update
  41587. * @param imageData defines the data to store into the texture
  41588. * @param xOffset defines the x coordinates of the update rectangle
  41589. * @param yOffset defines the y coordinates of the update rectangle
  41590. * @param width defines the width of the update rectangle
  41591. * @param height defines the height of the update rectangle
  41592. * @param faceIndex defines the face index if texture is a cube (0 by default)
  41593. * @param lod defines the lod level to update (0 by default)
  41594. */
  41595. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  41596. /** @hidden */
  41597. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41598. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  41599. private _prepareWebGLTexture;
  41600. /** @hidden */
  41601. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  41602. private _getDepthStencilBuffer;
  41603. /** @hidden */
  41604. _releaseFramebufferObjects(texture: InternalTexture): void;
  41605. /** @hidden */
  41606. _releaseTexture(texture: InternalTexture): void;
  41607. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  41608. protected _setProgram(program: WebGLProgram): void;
  41609. protected _boundUniforms: {
  41610. [key: number]: WebGLUniformLocation;
  41611. };
  41612. /**
  41613. * Binds an effect to the webGL context
  41614. * @param effect defines the effect to bind
  41615. */
  41616. bindSamplers(effect: Effect): void;
  41617. private _activateCurrentTexture;
  41618. /** @hidden */
  41619. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  41620. /** @hidden */
  41621. _bindTexture(channel: number, texture: Nullable<InternalTexture>, name: string): void;
  41622. /**
  41623. * Unbind all textures from the webGL context
  41624. */
  41625. unbindAllTextures(): void;
  41626. /**
  41627. * Sets a texture to the according uniform.
  41628. * @param channel The texture channel
  41629. * @param uniform The uniform to set
  41630. * @param texture The texture to apply
  41631. * @param name The name of the uniform in the effect
  41632. */
  41633. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>, name: string): void;
  41634. private _bindSamplerUniformToChannel;
  41635. private _getTextureWrapMode;
  41636. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string): boolean;
  41637. /**
  41638. * Sets an array of texture to the webGL context
  41639. * @param channel defines the channel where the texture array must be set
  41640. * @param uniform defines the associated uniform location
  41641. * @param textures defines the array of textures to bind
  41642. * @param name name of the channel
  41643. */
  41644. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[], name: string): void;
  41645. /** @hidden */
  41646. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  41647. private _setTextureParameterFloat;
  41648. private _setTextureParameterInteger;
  41649. /**
  41650. * Unbind all vertex attributes from the webGL context
  41651. */
  41652. unbindAllAttributes(): void;
  41653. /**
  41654. * 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
  41655. */
  41656. releaseEffects(): void;
  41657. /**
  41658. * Dispose and release all associated resources
  41659. */
  41660. dispose(): void;
  41661. /**
  41662. * Attach a new callback raised when context lost event is fired
  41663. * @param callback defines the callback to call
  41664. */
  41665. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41666. /**
  41667. * Attach a new callback raised when context restored event is fired
  41668. * @param callback defines the callback to call
  41669. */
  41670. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41671. /**
  41672. * Get the current error code of the webGL context
  41673. * @returns the error code
  41674. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41675. */
  41676. getError(): number;
  41677. private _canRenderToFloatFramebuffer;
  41678. private _canRenderToHalfFloatFramebuffer;
  41679. private _canRenderToFramebuffer;
  41680. /** @hidden */
  41681. _getWebGLTextureType(type: number): number;
  41682. /** @hidden */
  41683. _getInternalFormat(format: number): number;
  41684. /** @hidden */
  41685. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  41686. /** @hidden */
  41687. _getRGBAMultiSampleBufferFormat(type: number): number;
  41688. /** @hidden */
  41689. _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;
  41690. /**
  41691. * Loads a file from a url
  41692. * @param url url to load
  41693. * @param onSuccess callback called when the file successfully loads
  41694. * @param onProgress callback called while file is loading (if the server supports this mode)
  41695. * @param offlineProvider defines the offline provider for caching
  41696. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41697. * @param onError callback called when the file fails to load
  41698. * @returns a file request object
  41699. * @hidden
  41700. */
  41701. 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;
  41702. /**
  41703. * Reads pixels from the current frame buffer. Please note that this function can be slow
  41704. * @param x defines the x coordinate of the rectangle where pixels must be read
  41705. * @param y defines the y coordinate of the rectangle where pixels must be read
  41706. * @param width defines the width of the rectangle where pixels must be read
  41707. * @param height defines the height of the rectangle where pixels must be read
  41708. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  41709. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  41710. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  41711. */
  41712. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  41713. private static _IsSupported;
  41714. private static _HasMajorPerformanceCaveat;
  41715. /**
  41716. * Gets a boolean indicating if the engine can be instantiated (ie. if a webGL context can be found)
  41717. */
  41718. static get IsSupported(): boolean;
  41719. /**
  41720. * Gets a boolean indicating if the engine can be instantiated (ie. if a webGL context can be found)
  41721. * @returns true if the engine can be created
  41722. * @ignorenaming
  41723. */
  41724. static isSupported(): boolean;
  41725. /**
  41726. * 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)
  41727. */
  41728. static get HasMajorPerformanceCaveat(): boolean;
  41729. /**
  41730. * Find the next highest power of two.
  41731. * @param x Number to start search from.
  41732. * @return Next highest power of two.
  41733. */
  41734. static CeilingPOT(x: number): number;
  41735. /**
  41736. * Find the next lowest power of two.
  41737. * @param x Number to start search from.
  41738. * @return Next lowest power of two.
  41739. */
  41740. static FloorPOT(x: number): number;
  41741. /**
  41742. * Find the nearest power of two.
  41743. * @param x Number to start search from.
  41744. * @return Next nearest power of two.
  41745. */
  41746. static NearestPOT(x: number): number;
  41747. /**
  41748. * Get the closest exponent of two
  41749. * @param value defines the value to approximate
  41750. * @param max defines the maximum value to return
  41751. * @param mode defines how to define the closest value
  41752. * @returns closest exponent of two of the given value
  41753. */
  41754. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  41755. /**
  41756. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  41757. * @param func - the function to be called
  41758. * @param requester - the object that will request the next frame. Falls back to window.
  41759. * @returns frame number
  41760. */
  41761. static QueueNewFrame(func: () => void, requester?: any): number;
  41762. /**
  41763. * Gets host document
  41764. * @returns the host document object
  41765. */
  41766. getHostDocument(): Nullable<Document>;
  41767. }
  41768. }
  41769. declare module BABYLON {
  41770. /**
  41771. * Defines the source of the internal texture
  41772. */
  41773. export enum InternalTextureSource {
  41774. /**
  41775. * The source of the texture data is unknown
  41776. */
  41777. Unknown = 0,
  41778. /**
  41779. * Texture data comes from an URL
  41780. */
  41781. Url = 1,
  41782. /**
  41783. * Texture data is only used for temporary storage
  41784. */
  41785. Temp = 2,
  41786. /**
  41787. * Texture data comes from raw data (ArrayBuffer)
  41788. */
  41789. Raw = 3,
  41790. /**
  41791. * Texture content is dynamic (video or dynamic texture)
  41792. */
  41793. Dynamic = 4,
  41794. /**
  41795. * Texture content is generated by rendering to it
  41796. */
  41797. RenderTarget = 5,
  41798. /**
  41799. * Texture content is part of a multi render target process
  41800. */
  41801. MultiRenderTarget = 6,
  41802. /**
  41803. * Texture data comes from a cube data file
  41804. */
  41805. Cube = 7,
  41806. /**
  41807. * Texture data comes from a raw cube data
  41808. */
  41809. CubeRaw = 8,
  41810. /**
  41811. * Texture data come from a prefiltered cube data file
  41812. */
  41813. CubePrefiltered = 9,
  41814. /**
  41815. * Texture content is raw 3D data
  41816. */
  41817. Raw3D = 10,
  41818. /**
  41819. * Texture content is raw 2D array data
  41820. */
  41821. Raw2DArray = 11,
  41822. /**
  41823. * Texture content is a depth texture
  41824. */
  41825. Depth = 12,
  41826. /**
  41827. * Texture data comes from a raw cube data encoded with RGBD
  41828. */
  41829. CubeRawRGBD = 13
  41830. }
  41831. /**
  41832. * Class used to store data associated with WebGL texture data for the engine
  41833. * This class should not be used directly
  41834. */
  41835. export class InternalTexture {
  41836. /** @hidden */
  41837. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  41838. /**
  41839. * Defines if the texture is ready
  41840. */
  41841. isReady: boolean;
  41842. /**
  41843. * Defines if the texture is a cube texture
  41844. */
  41845. isCube: boolean;
  41846. /**
  41847. * Defines if the texture contains 3D data
  41848. */
  41849. is3D: boolean;
  41850. /**
  41851. * Defines if the texture contains 2D array data
  41852. */
  41853. is2DArray: boolean;
  41854. /**
  41855. * Defines if the texture contains multiview data
  41856. */
  41857. isMultiview: boolean;
  41858. /**
  41859. * Gets the URL used to load this texture
  41860. */
  41861. url: string;
  41862. /** @hidden */
  41863. _originalUrl: string;
  41864. /**
  41865. * Gets the sampling mode of the texture
  41866. */
  41867. samplingMode: number;
  41868. /**
  41869. * Gets a boolean indicating if the texture needs mipmaps generation
  41870. */
  41871. generateMipMaps: boolean;
  41872. /**
  41873. * Gets the number of samples used by the texture (WebGL2+ only)
  41874. */
  41875. samples: number;
  41876. /**
  41877. * Gets the type of the texture (int, float...)
  41878. */
  41879. type: number;
  41880. /**
  41881. * Gets the format of the texture (RGB, RGBA...)
  41882. */
  41883. format: number;
  41884. /**
  41885. * Observable called when the texture is loaded
  41886. */
  41887. onLoadedObservable: Observable<InternalTexture>;
  41888. /**
  41889. * Gets the width of the texture
  41890. */
  41891. width: number;
  41892. /**
  41893. * Gets the height of the texture
  41894. */
  41895. height: number;
  41896. /**
  41897. * Gets the depth of the texture
  41898. */
  41899. depth: number;
  41900. /**
  41901. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41902. */
  41903. baseWidth: number;
  41904. /**
  41905. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41906. */
  41907. baseHeight: number;
  41908. /**
  41909. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41910. */
  41911. baseDepth: number;
  41912. /**
  41913. * Gets a boolean indicating if the texture is inverted on Y axis
  41914. */
  41915. invertY: boolean;
  41916. /** @hidden */
  41917. _invertVScale: boolean;
  41918. /** @hidden */
  41919. _associatedChannel: number;
  41920. /** @hidden */
  41921. _source: InternalTextureSource;
  41922. /** @hidden */
  41923. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  41924. /** @hidden */
  41925. _bufferView: Nullable<ArrayBufferView>;
  41926. /** @hidden */
  41927. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41928. /** @hidden */
  41929. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41930. /** @hidden */
  41931. _size: number;
  41932. /** @hidden */
  41933. _extension: string;
  41934. /** @hidden */
  41935. _files: Nullable<string[]>;
  41936. /** @hidden */
  41937. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41938. /** @hidden */
  41939. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41940. /** @hidden */
  41941. _framebuffer: Nullable<WebGLFramebuffer>;
  41942. /** @hidden */
  41943. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41944. /** @hidden */
  41945. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41946. /** @hidden */
  41947. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41948. /** @hidden */
  41949. _attachments: Nullable<number[]>;
  41950. /** @hidden */
  41951. _textureArray: Nullable<InternalTexture[]>;
  41952. /** @hidden */
  41953. _cachedCoordinatesMode: Nullable<number>;
  41954. /** @hidden */
  41955. _cachedWrapU: Nullable<number>;
  41956. /** @hidden */
  41957. _cachedWrapV: Nullable<number>;
  41958. /** @hidden */
  41959. _cachedWrapR: Nullable<number>;
  41960. /** @hidden */
  41961. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41962. /** @hidden */
  41963. _isDisabled: boolean;
  41964. /** @hidden */
  41965. _compression: Nullable<string>;
  41966. /** @hidden */
  41967. _generateStencilBuffer: boolean;
  41968. /** @hidden */
  41969. _generateDepthBuffer: boolean;
  41970. /** @hidden */
  41971. _comparisonFunction: number;
  41972. /** @hidden */
  41973. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41974. /** @hidden */
  41975. _sphericalPolynomialPromise: Nullable<Promise<SphericalPolynomial>>;
  41976. /** @hidden */
  41977. _sphericalPolynomialComputed: boolean;
  41978. /** @hidden */
  41979. _lodGenerationScale: number;
  41980. /** @hidden */
  41981. _lodGenerationOffset: number;
  41982. /** @hidden */
  41983. _depthStencilTexture: Nullable<InternalTexture>;
  41984. /** @hidden */
  41985. _colorTextureArray: Nullable<WebGLTexture>;
  41986. /** @hidden */
  41987. _depthStencilTextureArray: Nullable<WebGLTexture>;
  41988. /** @hidden */
  41989. _lodTextureHigh: Nullable<BaseTexture>;
  41990. /** @hidden */
  41991. _lodTextureMid: Nullable<BaseTexture>;
  41992. /** @hidden */
  41993. _lodTextureLow: Nullable<BaseTexture>;
  41994. /** @hidden */
  41995. _isRGBD: boolean;
  41996. /** @hidden */
  41997. _linearSpecularLOD: boolean;
  41998. /** @hidden */
  41999. _irradianceTexture: Nullable<BaseTexture>;
  42000. /** @hidden */
  42001. _hardwareTexture: Nullable<HardwareTextureWrapper>;
  42002. /** @hidden */
  42003. _references: number;
  42004. /** @hidden */
  42005. _gammaSpace: Nullable<boolean>;
  42006. private _engine;
  42007. private _uniqueId;
  42008. private static _Counter;
  42009. /** Gets the unique id of the internal texture */
  42010. get uniqueId(): number;
  42011. /**
  42012. * Gets the Engine the texture belongs to.
  42013. * @returns The babylon engine
  42014. */
  42015. getEngine(): ThinEngine;
  42016. /**
  42017. * Gets the data source type of the texture
  42018. */
  42019. get source(): InternalTextureSource;
  42020. /**
  42021. * Creates a new InternalTexture
  42022. * @param engine defines the engine to use
  42023. * @param source defines the type of data that will be used
  42024. * @param delayAllocation if the texture allocation should be delayed (default: false)
  42025. */
  42026. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  42027. /**
  42028. * Increments the number of references (ie. the number of Texture that point to it)
  42029. */
  42030. incrementReferences(): void;
  42031. /**
  42032. * Change the size of the texture (not the size of the content)
  42033. * @param width defines the new width
  42034. * @param height defines the new height
  42035. * @param depth defines the new depth (1 by default)
  42036. */
  42037. updateSize(width: int, height: int, depth?: int): void;
  42038. /** @hidden */
  42039. _rebuild(): void;
  42040. /** @hidden */
  42041. _swapAndDie(target: InternalTexture): void;
  42042. /**
  42043. * Dispose the current allocated resources
  42044. */
  42045. dispose(): void;
  42046. }
  42047. }
  42048. declare module BABYLON {
  42049. /**
  42050. * Interface used to present a loading screen while loading a scene
  42051. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42052. */
  42053. export interface ILoadingScreen {
  42054. /**
  42055. * Function called to display the loading screen
  42056. */
  42057. displayLoadingUI: () => void;
  42058. /**
  42059. * Function called to hide the loading screen
  42060. */
  42061. hideLoadingUI: () => void;
  42062. /**
  42063. * Gets or sets the color to use for the background
  42064. */
  42065. loadingUIBackgroundColor: string;
  42066. /**
  42067. * Gets or sets the text to display while loading
  42068. */
  42069. loadingUIText: string;
  42070. }
  42071. /**
  42072. * Class used for the default loading screen
  42073. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42074. */
  42075. export class DefaultLoadingScreen implements ILoadingScreen {
  42076. private _renderingCanvas;
  42077. private _loadingText;
  42078. private _loadingDivBackgroundColor;
  42079. private _loadingDiv;
  42080. private _loadingTextDiv;
  42081. /** Gets or sets the logo url to use for the default loading screen */
  42082. static DefaultLogoUrl: string;
  42083. /** Gets or sets the spinner url to use for the default loading screen */
  42084. static DefaultSpinnerUrl: string;
  42085. /**
  42086. * Creates a new default loading screen
  42087. * @param _renderingCanvas defines the canvas used to render the scene
  42088. * @param _loadingText defines the default text to display
  42089. * @param _loadingDivBackgroundColor defines the default background color
  42090. */
  42091. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  42092. /**
  42093. * Function called to display the loading screen
  42094. */
  42095. displayLoadingUI(): void;
  42096. /**
  42097. * Function called to hide the loading screen
  42098. */
  42099. hideLoadingUI(): void;
  42100. /**
  42101. * Gets or sets the text to display while loading
  42102. */
  42103. set loadingUIText(text: string);
  42104. get loadingUIText(): string;
  42105. /**
  42106. * Gets or sets the color to use for the background
  42107. */
  42108. get loadingUIBackgroundColor(): string;
  42109. set loadingUIBackgroundColor(color: string);
  42110. private _resizeLoadingUI;
  42111. }
  42112. }
  42113. declare module BABYLON {
  42114. /**
  42115. * Interface for any object that can request an animation frame
  42116. */
  42117. export interface ICustomAnimationFrameRequester {
  42118. /**
  42119. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  42120. */
  42121. renderFunction?: Function;
  42122. /**
  42123. * Called to request the next frame to render to
  42124. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  42125. */
  42126. requestAnimationFrame: Function;
  42127. /**
  42128. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  42129. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  42130. */
  42131. requestID?: number;
  42132. }
  42133. }
  42134. declare module BABYLON {
  42135. /**
  42136. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  42137. */
  42138. export class PerformanceMonitor {
  42139. private _enabled;
  42140. private _rollingFrameTime;
  42141. private _lastFrameTimeMs;
  42142. /**
  42143. * constructor
  42144. * @param frameSampleSize The number of samples required to saturate the sliding window
  42145. */
  42146. constructor(frameSampleSize?: number);
  42147. /**
  42148. * Samples current frame
  42149. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  42150. */
  42151. sampleFrame(timeMs?: number): void;
  42152. /**
  42153. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  42154. */
  42155. get averageFrameTime(): number;
  42156. /**
  42157. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  42158. */
  42159. get averageFrameTimeVariance(): number;
  42160. /**
  42161. * Returns the frame time of the most recent frame
  42162. */
  42163. get instantaneousFrameTime(): number;
  42164. /**
  42165. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  42166. */
  42167. get averageFPS(): number;
  42168. /**
  42169. * Returns the average framerate in frames per second using the most recent frame time
  42170. */
  42171. get instantaneousFPS(): number;
  42172. /**
  42173. * Returns true if enough samples have been taken to completely fill the sliding window
  42174. */
  42175. get isSaturated(): boolean;
  42176. /**
  42177. * Enables contributions to the sliding window sample set
  42178. */
  42179. enable(): void;
  42180. /**
  42181. * Disables contributions to the sliding window sample set
  42182. * Samples will not be interpolated over the disabled period
  42183. */
  42184. disable(): void;
  42185. /**
  42186. * Returns true if sampling is enabled
  42187. */
  42188. get isEnabled(): boolean;
  42189. /**
  42190. * Resets performance monitor
  42191. */
  42192. reset(): void;
  42193. }
  42194. /**
  42195. * RollingAverage
  42196. *
  42197. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  42198. */
  42199. export class RollingAverage {
  42200. /**
  42201. * Current average
  42202. */
  42203. average: number;
  42204. /**
  42205. * Current variance
  42206. */
  42207. variance: number;
  42208. protected _samples: Array<number>;
  42209. protected _sampleCount: number;
  42210. protected _pos: number;
  42211. protected _m2: number;
  42212. /**
  42213. * constructor
  42214. * @param length The number of samples required to saturate the sliding window
  42215. */
  42216. constructor(length: number);
  42217. /**
  42218. * Adds a sample to the sample set
  42219. * @param v The sample value
  42220. */
  42221. add(v: number): void;
  42222. /**
  42223. * Returns previously added values or null if outside of history or outside the sliding window domain
  42224. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  42225. * @return Value previously recorded with add() or null if outside of range
  42226. */
  42227. history(i: number): number;
  42228. /**
  42229. * Returns true if enough samples have been taken to completely fill the sliding window
  42230. * @return true if sample-set saturated
  42231. */
  42232. isSaturated(): boolean;
  42233. /**
  42234. * Resets the rolling average (equivalent to 0 samples taken so far)
  42235. */
  42236. reset(): void;
  42237. /**
  42238. * Wraps a value around the sample range boundaries
  42239. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  42240. * @return Wrapped position in sample range
  42241. */
  42242. protected _wrapPosition(i: number): number;
  42243. }
  42244. }
  42245. declare module BABYLON {
  42246. /**
  42247. * This class is used to track a performance counter which is number based.
  42248. * The user has access to many properties which give statistics of different nature.
  42249. *
  42250. * The implementer can track two kinds of Performance Counter: time and count.
  42251. * 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.
  42252. * 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.
  42253. */
  42254. export class PerfCounter {
  42255. /**
  42256. * Gets or sets a global boolean to turn on and off all the counters
  42257. */
  42258. static Enabled: boolean;
  42259. /**
  42260. * Returns the smallest value ever
  42261. */
  42262. get min(): number;
  42263. /**
  42264. * Returns the biggest value ever
  42265. */
  42266. get max(): number;
  42267. /**
  42268. * Returns the average value since the performance counter is running
  42269. */
  42270. get average(): number;
  42271. /**
  42272. * Returns the average value of the last second the counter was monitored
  42273. */
  42274. get lastSecAverage(): number;
  42275. /**
  42276. * Returns the current value
  42277. */
  42278. get current(): number;
  42279. /**
  42280. * Gets the accumulated total
  42281. */
  42282. get total(): number;
  42283. /**
  42284. * Gets the total value count
  42285. */
  42286. get count(): number;
  42287. /**
  42288. * Creates a new counter
  42289. */
  42290. constructor();
  42291. /**
  42292. * Call this method to start monitoring a new frame.
  42293. * 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.
  42294. */
  42295. fetchNewFrame(): void;
  42296. /**
  42297. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  42298. * @param newCount the count value to add to the monitored count
  42299. * @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.
  42300. */
  42301. addCount(newCount: number, fetchResult: boolean): void;
  42302. /**
  42303. * Start monitoring this performance counter
  42304. */
  42305. beginMonitoring(): void;
  42306. /**
  42307. * Compute the time lapsed since the previous beginMonitoring() call.
  42308. * @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
  42309. */
  42310. endMonitoring(newFrame?: boolean): void;
  42311. private _fetchResult;
  42312. private _startMonitoringTime;
  42313. private _min;
  42314. private _max;
  42315. private _average;
  42316. private _current;
  42317. private _totalValueCount;
  42318. private _totalAccumulated;
  42319. private _lastSecAverage;
  42320. private _lastSecAccumulated;
  42321. private _lastSecTime;
  42322. private _lastSecValueCount;
  42323. }
  42324. }
  42325. declare module BABYLON {
  42326. interface ThinEngine {
  42327. /** @hidden */
  42328. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  42329. /** @hidden */
  42330. _readTexturePixelsSync(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): ArrayBufferView;
  42331. }
  42332. }
  42333. declare module BABYLON {
  42334. /**
  42335. * Class used to work with sound analyzer using fast fourier transform (FFT)
  42336. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42337. */
  42338. export class Analyser {
  42339. /**
  42340. * Gets or sets the smoothing
  42341. * @ignorenaming
  42342. */
  42343. SMOOTHING: number;
  42344. /**
  42345. * Gets or sets the FFT table size
  42346. * @ignorenaming
  42347. */
  42348. FFT_SIZE: number;
  42349. /**
  42350. * Gets or sets the bar graph amplitude
  42351. * @ignorenaming
  42352. */
  42353. BARGRAPHAMPLITUDE: number;
  42354. /**
  42355. * Gets or sets the position of the debug canvas
  42356. * @ignorenaming
  42357. */
  42358. DEBUGCANVASPOS: {
  42359. x: number;
  42360. y: number;
  42361. };
  42362. /**
  42363. * Gets or sets the debug canvas size
  42364. * @ignorenaming
  42365. */
  42366. DEBUGCANVASSIZE: {
  42367. width: number;
  42368. height: number;
  42369. };
  42370. private _byteFreqs;
  42371. private _byteTime;
  42372. private _floatFreqs;
  42373. private _webAudioAnalyser;
  42374. private _debugCanvas;
  42375. private _debugCanvasContext;
  42376. private _scene;
  42377. private _registerFunc;
  42378. private _audioEngine;
  42379. /**
  42380. * Creates a new analyser
  42381. * @param scene defines hosting scene
  42382. */
  42383. constructor(scene: Scene);
  42384. /**
  42385. * Get the number of data values you will have to play with for the visualization
  42386. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  42387. * @returns a number
  42388. */
  42389. getFrequencyBinCount(): number;
  42390. /**
  42391. * Gets the current frequency data as a byte array
  42392. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  42393. * @returns a Uint8Array
  42394. */
  42395. getByteFrequencyData(): Uint8Array;
  42396. /**
  42397. * Gets the current waveform as a byte array
  42398. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  42399. * @returns a Uint8Array
  42400. */
  42401. getByteTimeDomainData(): Uint8Array;
  42402. /**
  42403. * Gets the current frequency data as a float array
  42404. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  42405. * @returns a Float32Array
  42406. */
  42407. getFloatFrequencyData(): Float32Array;
  42408. /**
  42409. * Renders the debug canvas
  42410. */
  42411. drawDebugCanvas(): void;
  42412. /**
  42413. * Stops rendering the debug canvas and removes it
  42414. */
  42415. stopDebugCanvas(): void;
  42416. /**
  42417. * Connects two audio nodes
  42418. * @param inputAudioNode defines first node to connect
  42419. * @param outputAudioNode defines second node to connect
  42420. */
  42421. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  42422. /**
  42423. * Releases all associated resources
  42424. */
  42425. dispose(): void;
  42426. }
  42427. }
  42428. declare module BABYLON {
  42429. /**
  42430. * This represents an audio engine and it is responsible
  42431. * to play, synchronize and analyse sounds throughout the application.
  42432. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42433. */
  42434. export interface IAudioEngine extends IDisposable {
  42435. /**
  42436. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  42437. */
  42438. readonly canUseWebAudio: boolean;
  42439. /**
  42440. * Gets the current AudioContext if available.
  42441. */
  42442. readonly audioContext: Nullable<AudioContext>;
  42443. /**
  42444. * The master gain node defines the global audio volume of your audio engine.
  42445. */
  42446. readonly masterGain: GainNode;
  42447. /**
  42448. * Gets whether or not mp3 are supported by your browser.
  42449. */
  42450. readonly isMP3supported: boolean;
  42451. /**
  42452. * Gets whether or not ogg are supported by your browser.
  42453. */
  42454. readonly isOGGsupported: boolean;
  42455. /**
  42456. * Defines if Babylon should emit a warning if WebAudio is not supported.
  42457. * @ignoreNaming
  42458. */
  42459. WarnedWebAudioUnsupported: boolean;
  42460. /**
  42461. * Defines if the audio engine relies on a custom unlocked button.
  42462. * In this case, the embedded button will not be displayed.
  42463. */
  42464. useCustomUnlockedButton: boolean;
  42465. /**
  42466. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  42467. */
  42468. readonly unlocked: boolean;
  42469. /**
  42470. * Event raised when audio has been unlocked on the browser.
  42471. */
  42472. onAudioUnlockedObservable: Observable<IAudioEngine>;
  42473. /**
  42474. * Event raised when audio has been locked on the browser.
  42475. */
  42476. onAudioLockedObservable: Observable<IAudioEngine>;
  42477. /**
  42478. * Flags the audio engine in Locked state.
  42479. * This happens due to new browser policies preventing audio to autoplay.
  42480. */
  42481. lock(): void;
  42482. /**
  42483. * Unlocks the audio engine once a user action has been done on the dom.
  42484. * This is helpful to resume play once browser policies have been satisfied.
  42485. */
  42486. unlock(): void;
  42487. /**
  42488. * Gets the global volume sets on the master gain.
  42489. * @returns the global volume if set or -1 otherwise
  42490. */
  42491. getGlobalVolume(): number;
  42492. /**
  42493. * Sets the global volume of your experience (sets on the master gain).
  42494. * @param newVolume Defines the new global volume of the application
  42495. */
  42496. setGlobalVolume(newVolume: number): void;
  42497. /**
  42498. * Connect the audio engine to an audio analyser allowing some amazing
  42499. * synchronization between the sounds/music and your visualization (VuMeter for instance).
  42500. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42501. * @param analyser The analyser to connect to the engine
  42502. */
  42503. connectToAnalyser(analyser: Analyser): void;
  42504. }
  42505. }
  42506. declare module BABYLON {
  42507. /**
  42508. * Defines the interface used by display changed events
  42509. */
  42510. export interface IDisplayChangedEventArgs {
  42511. /** Gets the vrDisplay object (if any) */
  42512. vrDisplay: Nullable<any>;
  42513. /** Gets a boolean indicating if webVR is supported */
  42514. vrSupported: boolean;
  42515. }
  42516. /**
  42517. * Defines the interface used by objects containing a viewport (like a camera)
  42518. */
  42519. interface IViewportOwnerLike {
  42520. /**
  42521. * Gets or sets the viewport
  42522. */
  42523. viewport: IViewportLike;
  42524. }
  42525. /**
  42526. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  42527. */
  42528. export class Engine extends ThinEngine {
  42529. /** Defines that alpha blending is disabled */
  42530. static readonly ALPHA_DISABLE: number;
  42531. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  42532. static readonly ALPHA_ADD: number;
  42533. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  42534. static readonly ALPHA_COMBINE: number;
  42535. /** Defines that alpha blending to DEST - SRC * DEST */
  42536. static readonly ALPHA_SUBTRACT: number;
  42537. /** Defines that alpha blending to SRC * DEST */
  42538. static readonly ALPHA_MULTIPLY: number;
  42539. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  42540. static readonly ALPHA_MAXIMIZED: number;
  42541. /** Defines that alpha blending to SRC + DEST */
  42542. static readonly ALPHA_ONEONE: number;
  42543. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  42544. static readonly ALPHA_PREMULTIPLIED: number;
  42545. /**
  42546. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  42547. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  42548. */
  42549. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  42550. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  42551. static readonly ALPHA_INTERPOLATE: number;
  42552. /**
  42553. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  42554. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  42555. */
  42556. static readonly ALPHA_SCREENMODE: number;
  42557. /** Defines that the resource is not delayed*/
  42558. static readonly DELAYLOADSTATE_NONE: number;
  42559. /** Defines that the resource was successfully delay loaded */
  42560. static readonly DELAYLOADSTATE_LOADED: number;
  42561. /** Defines that the resource is currently delay loading */
  42562. static readonly DELAYLOADSTATE_LOADING: number;
  42563. /** Defines that the resource is delayed and has not started loading */
  42564. static readonly DELAYLOADSTATE_NOTLOADED: number;
  42565. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  42566. static readonly NEVER: number;
  42567. /** 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 */
  42568. static readonly ALWAYS: number;
  42569. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  42570. static readonly LESS: number;
  42571. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  42572. static readonly EQUAL: number;
  42573. /** 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 */
  42574. static readonly LEQUAL: number;
  42575. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  42576. static readonly GREATER: number;
  42577. /** 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 */
  42578. static readonly GEQUAL: number;
  42579. /** 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 */
  42580. static readonly NOTEQUAL: number;
  42581. /** Passed to stencilOperation to specify that stencil value must be kept */
  42582. static readonly KEEP: number;
  42583. /** Passed to stencilOperation to specify that stencil value must be replaced */
  42584. static readonly REPLACE: number;
  42585. /** Passed to stencilOperation to specify that stencil value must be incremented */
  42586. static readonly INCR: number;
  42587. /** Passed to stencilOperation to specify that stencil value must be decremented */
  42588. static readonly DECR: number;
  42589. /** Passed to stencilOperation to specify that stencil value must be inverted */
  42590. static readonly INVERT: number;
  42591. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  42592. static readonly INCR_WRAP: number;
  42593. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  42594. static readonly DECR_WRAP: number;
  42595. /** Texture is not repeating outside of 0..1 UVs */
  42596. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  42597. /** Texture is repeating outside of 0..1 UVs */
  42598. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  42599. /** Texture is repeating and mirrored */
  42600. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  42601. /** ALPHA */
  42602. static readonly TEXTUREFORMAT_ALPHA: number;
  42603. /** LUMINANCE */
  42604. static readonly TEXTUREFORMAT_LUMINANCE: number;
  42605. /** LUMINANCE_ALPHA */
  42606. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  42607. /** RGB */
  42608. static readonly TEXTUREFORMAT_RGB: number;
  42609. /** RGBA */
  42610. static readonly TEXTUREFORMAT_RGBA: number;
  42611. /** RED */
  42612. static readonly TEXTUREFORMAT_RED: number;
  42613. /** RED (2nd reference) */
  42614. static readonly TEXTUREFORMAT_R: number;
  42615. /** RG */
  42616. static readonly TEXTUREFORMAT_RG: number;
  42617. /** RED_INTEGER */
  42618. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  42619. /** RED_INTEGER (2nd reference) */
  42620. static readonly TEXTUREFORMAT_R_INTEGER: number;
  42621. /** RG_INTEGER */
  42622. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  42623. /** RGB_INTEGER */
  42624. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  42625. /** RGBA_INTEGER */
  42626. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  42627. /** UNSIGNED_BYTE */
  42628. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  42629. /** UNSIGNED_BYTE (2nd reference) */
  42630. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  42631. /** FLOAT */
  42632. static readonly TEXTURETYPE_FLOAT: number;
  42633. /** HALF_FLOAT */
  42634. static readonly TEXTURETYPE_HALF_FLOAT: number;
  42635. /** BYTE */
  42636. static readonly TEXTURETYPE_BYTE: number;
  42637. /** SHORT */
  42638. static readonly TEXTURETYPE_SHORT: number;
  42639. /** UNSIGNED_SHORT */
  42640. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  42641. /** INT */
  42642. static readonly TEXTURETYPE_INT: number;
  42643. /** UNSIGNED_INT */
  42644. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  42645. /** UNSIGNED_SHORT_4_4_4_4 */
  42646. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  42647. /** UNSIGNED_SHORT_5_5_5_1 */
  42648. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  42649. /** UNSIGNED_SHORT_5_6_5 */
  42650. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  42651. /** UNSIGNED_INT_2_10_10_10_REV */
  42652. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  42653. /** UNSIGNED_INT_24_8 */
  42654. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  42655. /** UNSIGNED_INT_10F_11F_11F_REV */
  42656. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  42657. /** UNSIGNED_INT_5_9_9_9_REV */
  42658. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  42659. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  42660. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  42661. /** nearest is mag = nearest and min = nearest and mip = none */
  42662. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  42663. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42664. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  42665. /** Trilinear is mag = linear and min = linear and mip = linear */
  42666. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  42667. /** nearest is mag = nearest and min = nearest and mip = linear */
  42668. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  42669. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42670. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  42671. /** Trilinear is mag = linear and min = linear and mip = linear */
  42672. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  42673. /** mag = nearest and min = nearest and mip = nearest */
  42674. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  42675. /** mag = nearest and min = linear and mip = nearest */
  42676. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  42677. /** mag = nearest and min = linear and mip = linear */
  42678. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  42679. /** mag = nearest and min = linear and mip = none */
  42680. static readonly TEXTURE_NEAREST_LINEAR: number;
  42681. /** mag = nearest and min = nearest and mip = none */
  42682. static readonly TEXTURE_NEAREST_NEAREST: number;
  42683. /** mag = linear and min = nearest and mip = nearest */
  42684. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  42685. /** mag = linear and min = nearest and mip = linear */
  42686. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  42687. /** mag = linear and min = linear and mip = none */
  42688. static readonly TEXTURE_LINEAR_LINEAR: number;
  42689. /** mag = linear and min = nearest and mip = none */
  42690. static readonly TEXTURE_LINEAR_NEAREST: number;
  42691. /** Explicit coordinates mode */
  42692. static readonly TEXTURE_EXPLICIT_MODE: number;
  42693. /** Spherical coordinates mode */
  42694. static readonly TEXTURE_SPHERICAL_MODE: number;
  42695. /** Planar coordinates mode */
  42696. static readonly TEXTURE_PLANAR_MODE: number;
  42697. /** Cubic coordinates mode */
  42698. static readonly TEXTURE_CUBIC_MODE: number;
  42699. /** Projection coordinates mode */
  42700. static readonly TEXTURE_PROJECTION_MODE: number;
  42701. /** Skybox coordinates mode */
  42702. static readonly TEXTURE_SKYBOX_MODE: number;
  42703. /** Inverse Cubic coordinates mode */
  42704. static readonly TEXTURE_INVCUBIC_MODE: number;
  42705. /** Equirectangular coordinates mode */
  42706. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  42707. /** Equirectangular Fixed coordinates mode */
  42708. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  42709. /** Equirectangular Fixed Mirrored coordinates mode */
  42710. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  42711. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  42712. static readonly SCALEMODE_FLOOR: number;
  42713. /** Defines that texture rescaling will look for the nearest power of 2 size */
  42714. static readonly SCALEMODE_NEAREST: number;
  42715. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  42716. static readonly SCALEMODE_CEILING: number;
  42717. /**
  42718. * Returns the current npm package of the sdk
  42719. */
  42720. static get NpmPackage(): string;
  42721. /**
  42722. * Returns the current version of the framework
  42723. */
  42724. static get Version(): string;
  42725. /** Gets the list of created engines */
  42726. static get Instances(): Engine[];
  42727. /**
  42728. * Gets the latest created engine
  42729. */
  42730. static get LastCreatedEngine(): Nullable<Engine>;
  42731. /**
  42732. * Gets the latest created scene
  42733. */
  42734. static get LastCreatedScene(): Nullable<Scene>;
  42735. /**
  42736. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  42737. * @param flag defines which part of the materials must be marked as dirty
  42738. * @param predicate defines a predicate used to filter which materials should be affected
  42739. */
  42740. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42741. /**
  42742. * Method called to create the default loading screen.
  42743. * This can be overridden in your own app.
  42744. * @param canvas The rendering canvas element
  42745. * @returns The loading screen
  42746. */
  42747. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  42748. /**
  42749. * Method called to create the default rescale post process on each engine.
  42750. */
  42751. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  42752. /**
  42753. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  42754. **/
  42755. enableOfflineSupport: boolean;
  42756. /**
  42757. * 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)
  42758. **/
  42759. disableManifestCheck: boolean;
  42760. /**
  42761. * Gets the list of created scenes
  42762. */
  42763. scenes: Scene[];
  42764. /**
  42765. * Event raised when a new scene is created
  42766. */
  42767. onNewSceneAddedObservable: Observable<Scene>;
  42768. /**
  42769. * Gets the list of created postprocesses
  42770. */
  42771. postProcesses: PostProcess[];
  42772. /**
  42773. * Gets a boolean indicating if the pointer is currently locked
  42774. */
  42775. isPointerLock: boolean;
  42776. /**
  42777. * Observable event triggered each time the rendering canvas is resized
  42778. */
  42779. onResizeObservable: Observable<Engine>;
  42780. /**
  42781. * Observable event triggered each time the canvas loses focus
  42782. */
  42783. onCanvasBlurObservable: Observable<Engine>;
  42784. /**
  42785. * Observable event triggered each time the canvas gains focus
  42786. */
  42787. onCanvasFocusObservable: Observable<Engine>;
  42788. /**
  42789. * Observable event triggered each time the canvas receives pointerout event
  42790. */
  42791. onCanvasPointerOutObservable: Observable<IPointerEvent>;
  42792. /**
  42793. * Observable raised when the engine begins a new frame
  42794. */
  42795. onBeginFrameObservable: Observable<Engine>;
  42796. /**
  42797. * If set, will be used to request the next animation frame for the render loop
  42798. */
  42799. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  42800. /**
  42801. * Observable raised when the engine ends the current frame
  42802. */
  42803. onEndFrameObservable: Observable<Engine>;
  42804. /**
  42805. * Observable raised when the engine is about to compile a shader
  42806. */
  42807. onBeforeShaderCompilationObservable: Observable<Engine>;
  42808. /**
  42809. * Observable raised when the engine has just compiled a shader
  42810. */
  42811. onAfterShaderCompilationObservable: Observable<Engine>;
  42812. /**
  42813. * Gets the audio engine
  42814. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42815. * @ignorenaming
  42816. */
  42817. static audioEngine: IAudioEngine;
  42818. /**
  42819. * Default AudioEngine factory responsible of creating the Audio Engine.
  42820. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  42821. */
  42822. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  42823. /**
  42824. * Default offline support factory responsible of creating a tool used to store data locally.
  42825. * By default, this will create a Database object if the workload has been embedded.
  42826. */
  42827. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  42828. private _loadingScreen;
  42829. private _pointerLockRequested;
  42830. private _rescalePostProcess;
  42831. protected _deterministicLockstep: boolean;
  42832. protected _lockstepMaxSteps: number;
  42833. protected _timeStep: number;
  42834. protected get _supportsHardwareTextureRescaling(): boolean;
  42835. private _fps;
  42836. private _deltaTime;
  42837. /** @hidden */
  42838. _drawCalls: PerfCounter;
  42839. /** 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 */
  42840. canvasTabIndex: number;
  42841. /**
  42842. * Turn this value on if you want to pause FPS computation when in background
  42843. */
  42844. disablePerformanceMonitorInBackground: boolean;
  42845. private _performanceMonitor;
  42846. /**
  42847. * Gets the performance monitor attached to this engine
  42848. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42849. */
  42850. get performanceMonitor(): PerformanceMonitor;
  42851. private _onFocus;
  42852. private _onBlur;
  42853. private _onCanvasPointerOut;
  42854. private _onCanvasBlur;
  42855. private _onCanvasFocus;
  42856. private _onFullscreenChange;
  42857. private _onPointerLockChange;
  42858. /**
  42859. * Gets the HTML element used to attach event listeners
  42860. * @returns a HTML element
  42861. */
  42862. getInputElement(): Nullable<HTMLElement>;
  42863. /**
  42864. * Creates a new engine
  42865. * @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
  42866. * @param antialias defines enable antialiasing (default: false)
  42867. * @param options defines further options to be sent to the getContext() function
  42868. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42869. */
  42870. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42871. /**
  42872. * Shared initialization across engines types.
  42873. * @param canvas The canvas associated with this instance of the engine.
  42874. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  42875. * @param audioEngine Defines if an audio engine should be created by default
  42876. */
  42877. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  42878. /**
  42879. * Gets current aspect ratio
  42880. * @param viewportOwner defines the camera to use to get the aspect ratio
  42881. * @param useScreen defines if screen size must be used (or the current render target if any)
  42882. * @returns a number defining the aspect ratio
  42883. */
  42884. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  42885. /**
  42886. * Gets current screen aspect ratio
  42887. * @returns a number defining the aspect ratio
  42888. */
  42889. getScreenAspectRatio(): number;
  42890. /**
  42891. * Gets the client rect of the HTML canvas attached with the current webGL context
  42892. * @returns a client rectangle
  42893. */
  42894. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  42895. /**
  42896. * Gets the client rect of the HTML element used for events
  42897. * @returns a client rectangle
  42898. */
  42899. getInputElementClientRect(): Nullable<ClientRect>;
  42900. /**
  42901. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42902. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42903. * @returns true if engine is in deterministic lock step mode
  42904. */
  42905. isDeterministicLockStep(): boolean;
  42906. /**
  42907. * Gets the max steps when engine is running in deterministic lock step
  42908. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42909. * @returns the max steps
  42910. */
  42911. getLockstepMaxSteps(): number;
  42912. /**
  42913. * Returns the time in ms between steps when using deterministic lock step.
  42914. * @returns time step in (ms)
  42915. */
  42916. getTimeStep(): number;
  42917. /**
  42918. * Force the mipmap generation for the given render target texture
  42919. * @param texture defines the render target texture to use
  42920. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  42921. */
  42922. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  42923. /** States */
  42924. /**
  42925. * Set various states to the webGL context
  42926. * @param culling defines backface culling state
  42927. * @param zOffset defines the value to apply to zOffset (0 by default)
  42928. * @param force defines if states must be applied even if cache is up to date
  42929. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42930. */
  42931. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42932. /**
  42933. * Set the z offset to apply to current rendering
  42934. * @param value defines the offset to apply
  42935. */
  42936. setZOffset(value: number): void;
  42937. /**
  42938. * Gets the current value of the zOffset
  42939. * @returns the current zOffset state
  42940. */
  42941. getZOffset(): number;
  42942. /**
  42943. * Gets a boolean indicating if depth testing is enabled
  42944. * @returns the current state
  42945. */
  42946. getDepthBuffer(): boolean;
  42947. /**
  42948. * Enable or disable depth buffering
  42949. * @param enable defines the state to set
  42950. */
  42951. setDepthBuffer(enable: boolean): void;
  42952. /**
  42953. * Gets a boolean indicating if depth writing is enabled
  42954. * @returns the current depth writing state
  42955. */
  42956. getDepthWrite(): boolean;
  42957. /**
  42958. * Enable or disable depth writing
  42959. * @param enable defines the state to set
  42960. */
  42961. setDepthWrite(enable: boolean): void;
  42962. /**
  42963. * Gets a boolean indicating if stencil buffer is enabled
  42964. * @returns the current stencil buffer state
  42965. */
  42966. getStencilBuffer(): boolean;
  42967. /**
  42968. * Enable or disable the stencil buffer
  42969. * @param enable defines if the stencil buffer must be enabled or disabled
  42970. */
  42971. setStencilBuffer(enable: boolean): void;
  42972. /**
  42973. * Gets the current stencil mask
  42974. * @returns a number defining the new stencil mask to use
  42975. */
  42976. getStencilMask(): number;
  42977. /**
  42978. * Sets the current stencil mask
  42979. * @param mask defines the new stencil mask to use
  42980. */
  42981. setStencilMask(mask: number): void;
  42982. /**
  42983. * Gets the current stencil function
  42984. * @returns a number defining the stencil function to use
  42985. */
  42986. getStencilFunction(): number;
  42987. /**
  42988. * Gets the current stencil reference value
  42989. * @returns a number defining the stencil reference value to use
  42990. */
  42991. getStencilFunctionReference(): number;
  42992. /**
  42993. * Gets the current stencil mask
  42994. * @returns a number defining the stencil mask to use
  42995. */
  42996. getStencilFunctionMask(): number;
  42997. /**
  42998. * Sets the current stencil function
  42999. * @param stencilFunc defines the new stencil function to use
  43000. */
  43001. setStencilFunction(stencilFunc: number): void;
  43002. /**
  43003. * Sets the current stencil reference
  43004. * @param reference defines the new stencil reference to use
  43005. */
  43006. setStencilFunctionReference(reference: number): void;
  43007. /**
  43008. * Sets the current stencil mask
  43009. * @param mask defines the new stencil mask to use
  43010. */
  43011. setStencilFunctionMask(mask: number): void;
  43012. /**
  43013. * Gets the current stencil operation when stencil fails
  43014. * @returns a number defining stencil operation to use when stencil fails
  43015. */
  43016. getStencilOperationFail(): number;
  43017. /**
  43018. * Gets the current stencil operation when depth fails
  43019. * @returns a number defining stencil operation to use when depth fails
  43020. */
  43021. getStencilOperationDepthFail(): number;
  43022. /**
  43023. * Gets the current stencil operation when stencil passes
  43024. * @returns a number defining stencil operation to use when stencil passes
  43025. */
  43026. getStencilOperationPass(): number;
  43027. /**
  43028. * Sets the stencil operation to use when stencil fails
  43029. * @param operation defines the stencil operation to use when stencil fails
  43030. */
  43031. setStencilOperationFail(operation: number): void;
  43032. /**
  43033. * Sets the stencil operation to use when depth fails
  43034. * @param operation defines the stencil operation to use when depth fails
  43035. */
  43036. setStencilOperationDepthFail(operation: number): void;
  43037. /**
  43038. * Sets the stencil operation to use when stencil passes
  43039. * @param operation defines the stencil operation to use when stencil passes
  43040. */
  43041. setStencilOperationPass(operation: number): void;
  43042. /**
  43043. * Sets a boolean indicating if the dithering state is enabled or disabled
  43044. * @param value defines the dithering state
  43045. */
  43046. setDitheringState(value: boolean): void;
  43047. /**
  43048. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  43049. * @param value defines the rasterizer state
  43050. */
  43051. setRasterizerState(value: boolean): void;
  43052. /**
  43053. * Gets the current depth function
  43054. * @returns a number defining the depth function
  43055. */
  43056. getDepthFunction(): Nullable<number>;
  43057. /**
  43058. * Sets the current depth function
  43059. * @param depthFunc defines the function to use
  43060. */
  43061. setDepthFunction(depthFunc: number): void;
  43062. /**
  43063. * Sets the current depth function to GREATER
  43064. */
  43065. setDepthFunctionToGreater(): void;
  43066. /**
  43067. * Sets the current depth function to GEQUAL
  43068. */
  43069. setDepthFunctionToGreaterOrEqual(): void;
  43070. /**
  43071. * Sets the current depth function to LESS
  43072. */
  43073. setDepthFunctionToLess(): void;
  43074. /**
  43075. * Sets the current depth function to LEQUAL
  43076. */
  43077. setDepthFunctionToLessOrEqual(): void;
  43078. private _cachedStencilBuffer;
  43079. private _cachedStencilFunction;
  43080. private _cachedStencilMask;
  43081. private _cachedStencilOperationPass;
  43082. private _cachedStencilOperationFail;
  43083. private _cachedStencilOperationDepthFail;
  43084. private _cachedStencilReference;
  43085. /**
  43086. * Caches the the state of the stencil buffer
  43087. */
  43088. cacheStencilState(): void;
  43089. /**
  43090. * Restores the state of the stencil buffer
  43091. */
  43092. restoreStencilState(): void;
  43093. /**
  43094. * Directly set the WebGL Viewport
  43095. * @param x defines the x coordinate of the viewport (in screen space)
  43096. * @param y defines the y coordinate of the viewport (in screen space)
  43097. * @param width defines the width of the viewport (in screen space)
  43098. * @param height defines the height of the viewport (in screen space)
  43099. * @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
  43100. */
  43101. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  43102. /**
  43103. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  43104. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  43105. * @param y defines the y-coordinate of the corner of the clear rectangle
  43106. * @param width defines the width of the clear rectangle
  43107. * @param height defines the height of the clear rectangle
  43108. * @param clearColor defines the clear color
  43109. */
  43110. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  43111. /**
  43112. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  43113. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  43114. * @param y defines the y-coordinate of the corner of the clear rectangle
  43115. * @param width defines the width of the clear rectangle
  43116. * @param height defines the height of the clear rectangle
  43117. */
  43118. enableScissor(x: number, y: number, width: number, height: number): void;
  43119. /**
  43120. * Disable previously set scissor test rectangle
  43121. */
  43122. disableScissor(): void;
  43123. protected _reportDrawCall(): void;
  43124. /**
  43125. * Initializes a webVR display and starts listening to display change events
  43126. * The onVRDisplayChangedObservable will be notified upon these changes
  43127. * @returns The onVRDisplayChangedObservable
  43128. */
  43129. initWebVR(): Observable<IDisplayChangedEventArgs>;
  43130. /** @hidden */
  43131. _prepareVRComponent(): void;
  43132. /** @hidden */
  43133. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  43134. /** @hidden */
  43135. _submitVRFrame(): void;
  43136. /**
  43137. * Call this function to leave webVR mode
  43138. * Will do nothing if webVR is not supported or if there is no webVR device
  43139. * @see https://doc.babylonjs.com/how_to/webvr_camera
  43140. */
  43141. disableVR(): void;
  43142. /**
  43143. * Gets a boolean indicating that the system is in VR mode and is presenting
  43144. * @returns true if VR mode is engaged
  43145. */
  43146. isVRPresenting(): boolean;
  43147. /** @hidden */
  43148. _requestVRFrame(): void;
  43149. /** @hidden */
  43150. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  43151. /**
  43152. * Gets the source code of the vertex shader associated with a specific webGL program
  43153. * @param program defines the program to use
  43154. * @returns a string containing the source code of the vertex shader associated with the program
  43155. */
  43156. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  43157. /**
  43158. * Gets the source code of the fragment shader associated with a specific webGL program
  43159. * @param program defines the program to use
  43160. * @returns a string containing the source code of the fragment shader associated with the program
  43161. */
  43162. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  43163. /**
  43164. * Sets a depth stencil texture from a render target to the according uniform.
  43165. * @param channel The texture channel
  43166. * @param uniform The uniform to set
  43167. * @param texture The render target texture containing the depth stencil texture to apply
  43168. * @param name The texture name
  43169. */
  43170. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>, name?: string): void;
  43171. /**
  43172. * Sets a texture to the webGL context from a postprocess
  43173. * @param channel defines the channel to use
  43174. * @param postProcess defines the source postprocess
  43175. * @param name name of the channel
  43176. */
  43177. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  43178. /**
  43179. * Binds the output of the passed in post process to the texture channel specified
  43180. * @param channel The channel the texture should be bound to
  43181. * @param postProcess The post process which's output should be bound
  43182. * @param name name of the channel
  43183. */
  43184. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  43185. protected _rebuildBuffers(): void;
  43186. /** @hidden */
  43187. _renderFrame(): void;
  43188. _renderLoop(): void;
  43189. /** @hidden */
  43190. _renderViews(): boolean;
  43191. /**
  43192. * Toggle full screen mode
  43193. * @param requestPointerLock defines if a pointer lock should be requested from the user
  43194. */
  43195. switchFullscreen(requestPointerLock: boolean): void;
  43196. /**
  43197. * Enters full screen mode
  43198. * @param requestPointerLock defines if a pointer lock should be requested from the user
  43199. */
  43200. enterFullscreen(requestPointerLock: boolean): void;
  43201. /**
  43202. * Exits full screen mode
  43203. */
  43204. exitFullscreen(): void;
  43205. /**
  43206. * Enters Pointerlock mode
  43207. */
  43208. enterPointerlock(): void;
  43209. /**
  43210. * Exits Pointerlock mode
  43211. */
  43212. exitPointerlock(): void;
  43213. /**
  43214. * Begin a new frame
  43215. */
  43216. beginFrame(): void;
  43217. /**
  43218. * End the current frame
  43219. */
  43220. endFrame(): void;
  43221. /**
  43222. * Resize the view according to the canvas' size
  43223. * @param forceSetSize true to force setting the sizes of the underlying canvas
  43224. */
  43225. resize(forceSetSize?: boolean): void;
  43226. /**
  43227. * Force a specific size of the canvas
  43228. * @param width defines the new canvas' width
  43229. * @param height defines the new canvas' height
  43230. * @param forceSetSize true to force setting the sizes of the underlying canvas
  43231. * @returns true if the size was changed
  43232. */
  43233. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  43234. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  43235. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  43236. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  43237. _releaseTexture(texture: InternalTexture): void;
  43238. /**
  43239. * @hidden
  43240. * Rescales a texture
  43241. * @param source input texture
  43242. * @param destination destination texture
  43243. * @param scene scene to use to render the resize
  43244. * @param internalFormat format to use when resizing
  43245. * @param onComplete callback to be called when resize has completed
  43246. */
  43247. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  43248. /**
  43249. * Gets the current framerate
  43250. * @returns a number representing the framerate
  43251. */
  43252. getFps(): number;
  43253. /**
  43254. * Gets the time spent between current and previous frame
  43255. * @returns a number representing the delta time in ms
  43256. */
  43257. getDeltaTime(): number;
  43258. private _measureFps;
  43259. /** @hidden */
  43260. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  43261. /**
  43262. * Updates the sample count of a render target texture
  43263. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43264. * @param texture defines the texture to update
  43265. * @param samples defines the sample count to set
  43266. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43267. */
  43268. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  43269. /**
  43270. * Updates a depth texture Comparison Mode and Function.
  43271. * If the comparison Function is equal to 0, the mode will be set to none.
  43272. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  43273. * @param texture The texture to set the comparison function for
  43274. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  43275. */
  43276. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  43277. /**
  43278. * Creates a webGL buffer to use with instantiation
  43279. * @param capacity defines the size of the buffer
  43280. * @returns the webGL buffer
  43281. */
  43282. createInstancesBuffer(capacity: number): DataBuffer;
  43283. /**
  43284. * Delete a webGL buffer used with instantiation
  43285. * @param buffer defines the webGL buffer to delete
  43286. */
  43287. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  43288. private _clientWaitAsync;
  43289. /** @hidden */
  43290. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Nullable<Promise<ArrayBufferView>>;
  43291. dispose(): void;
  43292. private _disableTouchAction;
  43293. /**
  43294. * Display the loading screen
  43295. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43296. */
  43297. displayLoadingUI(): void;
  43298. /**
  43299. * Hide the loading screen
  43300. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43301. */
  43302. hideLoadingUI(): void;
  43303. /**
  43304. * Gets the current loading screen object
  43305. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43306. */
  43307. get loadingScreen(): ILoadingScreen;
  43308. /**
  43309. * Sets the current loading screen object
  43310. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43311. */
  43312. set loadingScreen(loadingScreen: ILoadingScreen);
  43313. /**
  43314. * Sets the current loading screen text
  43315. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43316. */
  43317. set loadingUIText(text: string);
  43318. /**
  43319. * Sets the current loading screen background color
  43320. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43321. */
  43322. set loadingUIBackgroundColor(color: string);
  43323. /** Pointerlock and fullscreen */
  43324. /**
  43325. * Ask the browser to promote the current element to pointerlock mode
  43326. * @param element defines the DOM element to promote
  43327. */
  43328. static _RequestPointerlock(element: HTMLElement): void;
  43329. /**
  43330. * Asks the browser to exit pointerlock mode
  43331. */
  43332. static _ExitPointerlock(): void;
  43333. /**
  43334. * Ask the browser to promote the current element to fullscreen rendering mode
  43335. * @param element defines the DOM element to promote
  43336. */
  43337. static _RequestFullscreen(element: HTMLElement): void;
  43338. /**
  43339. * Asks the browser to exit fullscreen mode
  43340. */
  43341. static _ExitFullscreen(): void;
  43342. }
  43343. }
  43344. declare module BABYLON {
  43345. /**
  43346. * The engine store class is responsible to hold all the instances of Engine and Scene created
  43347. * during the life time of the application.
  43348. */
  43349. export class EngineStore {
  43350. /** Gets the list of created engines */
  43351. static Instances: Engine[];
  43352. /** @hidden */
  43353. static _LastCreatedScene: Nullable<Scene>;
  43354. /**
  43355. * Gets the latest created engine
  43356. */
  43357. static get LastCreatedEngine(): Nullable<Engine>;
  43358. /**
  43359. * Gets the latest created scene
  43360. */
  43361. static get LastCreatedScene(): Nullable<Scene>;
  43362. /**
  43363. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  43364. * @ignorenaming
  43365. */
  43366. static UseFallbackTexture: boolean;
  43367. /**
  43368. * Texture content used if a texture cannot loaded
  43369. * @ignorenaming
  43370. */
  43371. static FallbackTexture: string;
  43372. }
  43373. }
  43374. declare module BABYLON {
  43375. /**
  43376. * Helper class that provides a small promise polyfill
  43377. */
  43378. export class PromisePolyfill {
  43379. /**
  43380. * Static function used to check if the polyfill is required
  43381. * If this is the case then the function will inject the polyfill to window.Promise
  43382. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  43383. */
  43384. static Apply(force?: boolean): void;
  43385. }
  43386. }
  43387. declare module BABYLON {
  43388. /**
  43389. * Interface for screenshot methods with describe argument called `size` as object with options
  43390. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  43391. */
  43392. export interface IScreenshotSize {
  43393. /**
  43394. * number in pixels for canvas height
  43395. */
  43396. height?: number;
  43397. /**
  43398. * multiplier allowing render at a higher or lower resolution
  43399. * If value is defined then height and width will be ignored and taken from camera
  43400. */
  43401. precision?: number;
  43402. /**
  43403. * number in pixels for canvas width
  43404. */
  43405. width?: number;
  43406. }
  43407. }
  43408. declare module BABYLON {
  43409. interface IColor4Like {
  43410. r: float;
  43411. g: float;
  43412. b: float;
  43413. a: float;
  43414. }
  43415. /**
  43416. * Class containing a set of static utilities functions
  43417. */
  43418. export class Tools {
  43419. /**
  43420. * Gets or sets the base URL to use to load assets
  43421. */
  43422. static get BaseUrl(): string;
  43423. static set BaseUrl(value: string);
  43424. /**
  43425. * Enable/Disable Custom HTTP Request Headers globally.
  43426. * default = false
  43427. * @see CustomRequestHeaders
  43428. */
  43429. static UseCustomRequestHeaders: boolean;
  43430. /**
  43431. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  43432. * i.e. when loading files, where the server/service expects an Authorization header
  43433. */
  43434. static CustomRequestHeaders: {
  43435. [key: string]: string;
  43436. };
  43437. /**
  43438. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  43439. */
  43440. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  43441. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  43442. /**
  43443. * Default behaviour for cors in the application.
  43444. * It can be a string if the expected behavior is identical in the entire app.
  43445. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  43446. */
  43447. static get CorsBehavior(): string | ((url: string | string[]) => string);
  43448. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  43449. /**
  43450. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  43451. * @ignorenaming
  43452. */
  43453. static get UseFallbackTexture(): boolean;
  43454. static set UseFallbackTexture(value: boolean);
  43455. /**
  43456. * Use this object to register external classes like custom textures or material
  43457. * to allow the loaders to instantiate them
  43458. */
  43459. static get RegisteredExternalClasses(): {
  43460. [key: string]: Object;
  43461. };
  43462. static set RegisteredExternalClasses(classes: {
  43463. [key: string]: Object;
  43464. });
  43465. /**
  43466. * Texture content used if a texture cannot loaded
  43467. * @ignorenaming
  43468. */
  43469. static get fallbackTexture(): string;
  43470. static set fallbackTexture(value: string);
  43471. /**
  43472. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  43473. * @param u defines the coordinate on X axis
  43474. * @param v defines the coordinate on Y axis
  43475. * @param width defines the width of the source data
  43476. * @param height defines the height of the source data
  43477. * @param pixels defines the source byte array
  43478. * @param color defines the output color
  43479. */
  43480. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  43481. /**
  43482. * Interpolates between a and b via alpha
  43483. * @param a The lower value (returned when alpha = 0)
  43484. * @param b The upper value (returned when alpha = 1)
  43485. * @param alpha The interpolation-factor
  43486. * @return The mixed value
  43487. */
  43488. static Mix(a: number, b: number, alpha: number): number;
  43489. /**
  43490. * Tries to instantiate a new object from a given class name
  43491. * @param className defines the class name to instantiate
  43492. * @returns the new object or null if the system was not able to do the instantiation
  43493. */
  43494. static Instantiate(className: string): any;
  43495. /**
  43496. * Provides a slice function that will work even on IE
  43497. * @param data defines the array to slice
  43498. * @param start defines the start of the data (optional)
  43499. * @param end defines the end of the data (optional)
  43500. * @returns the new sliced array
  43501. */
  43502. static Slice<T>(data: T, start?: number, end?: number): T;
  43503. /**
  43504. * Provides a slice function that will work even on IE
  43505. * The difference between this and Slice is that this will force-convert to array
  43506. * @param data defines the array to slice
  43507. * @param start defines the start of the data (optional)
  43508. * @param end defines the end of the data (optional)
  43509. * @returns the new sliced array
  43510. */
  43511. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  43512. /**
  43513. * Polyfill for setImmediate
  43514. * @param action defines the action to execute after the current execution block
  43515. */
  43516. static SetImmediate(action: () => void): void;
  43517. /**
  43518. * Function indicating if a number is an exponent of 2
  43519. * @param value defines the value to test
  43520. * @returns true if the value is an exponent of 2
  43521. */
  43522. static IsExponentOfTwo(value: number): boolean;
  43523. private static _tmpFloatArray;
  43524. /**
  43525. * Returns the nearest 32-bit single precision float representation of a Number
  43526. * @param value A Number. If the parameter is of a different type, it will get converted
  43527. * to a number or to NaN if it cannot be converted
  43528. * @returns number
  43529. */
  43530. static FloatRound(value: number): number;
  43531. /**
  43532. * Extracts the filename from a path
  43533. * @param path defines the path to use
  43534. * @returns the filename
  43535. */
  43536. static GetFilename(path: string): string;
  43537. /**
  43538. * Extracts the "folder" part of a path (everything before the filename).
  43539. * @param uri The URI to extract the info from
  43540. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  43541. * @returns The "folder" part of the path
  43542. */
  43543. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  43544. /**
  43545. * Extracts text content from a DOM element hierarchy
  43546. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  43547. */
  43548. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  43549. /**
  43550. * Convert an angle in radians to degrees
  43551. * @param angle defines the angle to convert
  43552. * @returns the angle in degrees
  43553. */
  43554. static ToDegrees(angle: number): number;
  43555. /**
  43556. * Convert an angle in degrees to radians
  43557. * @param angle defines the angle to convert
  43558. * @returns the angle in radians
  43559. */
  43560. static ToRadians(angle: number): number;
  43561. /**
  43562. * Returns an array if obj is not an array
  43563. * @param obj defines the object to evaluate as an array
  43564. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  43565. * @returns either obj directly if obj is an array or a new array containing obj
  43566. */
  43567. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  43568. /**
  43569. * Gets the pointer prefix to use
  43570. * @param engine defines the engine we are finding the prefix for
  43571. * @returns "pointer" if touch is enabled. Else returns "mouse"
  43572. */
  43573. static GetPointerPrefix(engine: Engine): string;
  43574. /**
  43575. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  43576. * @param url define the url we are trying
  43577. * @param element define the dom element where to configure the cors policy
  43578. */
  43579. static SetCorsBehavior(url: string | string[], element: {
  43580. crossOrigin: string | null;
  43581. }): void;
  43582. /**
  43583. * Removes unwanted characters from an url
  43584. * @param url defines the url to clean
  43585. * @returns the cleaned url
  43586. */
  43587. static CleanUrl(url: string): string;
  43588. /**
  43589. * Gets or sets a function used to pre-process url before using them to load assets
  43590. */
  43591. static get PreprocessUrl(): (url: string) => string;
  43592. static set PreprocessUrl(processor: (url: string) => string);
  43593. /**
  43594. * Loads an image as an HTMLImageElement.
  43595. * @param input url string, ArrayBuffer, or Blob to load
  43596. * @param onLoad callback called when the image successfully loads
  43597. * @param onError callback called when the image fails to load
  43598. * @param offlineProvider offline provider for caching
  43599. * @param mimeType optional mime type
  43600. * @returns the HTMLImageElement of the loaded image
  43601. */
  43602. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  43603. /**
  43604. * Loads a file from a url
  43605. * @param url url string, ArrayBuffer, or Blob to load
  43606. * @param onSuccess callback called when the file successfully loads
  43607. * @param onProgress callback called while file is loading (if the server supports this mode)
  43608. * @param offlineProvider defines the offline provider for caching
  43609. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43610. * @param onError callback called when the file fails to load
  43611. * @returns a file request object
  43612. */
  43613. 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;
  43614. /**
  43615. * Loads a file from a url
  43616. * @param url the file url to load
  43617. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43618. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  43619. */
  43620. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  43621. /**
  43622. * Load a script (identified by an url). When the url returns, the
  43623. * content of this file is added into a new script element, attached to the DOM (body element)
  43624. * @param scriptUrl defines the url of the script to laod
  43625. * @param onSuccess defines the callback called when the script is loaded
  43626. * @param onError defines the callback to call if an error occurs
  43627. * @param scriptId defines the id of the script element
  43628. */
  43629. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  43630. /**
  43631. * Load an asynchronous script (identified by an url). When the url returns, the
  43632. * content of this file is added into a new script element, attached to the DOM (body element)
  43633. * @param scriptUrl defines the url of the script to laod
  43634. * @param scriptId defines the id of the script element
  43635. * @returns a promise request object
  43636. */
  43637. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  43638. /**
  43639. * Loads a file from a blob
  43640. * @param fileToLoad defines the blob to use
  43641. * @param callback defines the callback to call when data is loaded
  43642. * @param progressCallback defines the callback to call during loading process
  43643. * @returns a file request object
  43644. */
  43645. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  43646. /**
  43647. * Reads a file from a File object
  43648. * @param file defines the file to load
  43649. * @param onSuccess defines the callback to call when data is loaded
  43650. * @param onProgress defines the callback to call during loading process
  43651. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43652. * @param onError defines the callback to call when an error occurs
  43653. * @returns a file request object
  43654. */
  43655. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  43656. /**
  43657. * Creates a data url from a given string content
  43658. * @param content defines the content to convert
  43659. * @returns the new data url link
  43660. */
  43661. static FileAsURL(content: string): string;
  43662. /**
  43663. * Format the given number to a specific decimal format
  43664. * @param value defines the number to format
  43665. * @param decimals defines the number of decimals to use
  43666. * @returns the formatted string
  43667. */
  43668. static Format(value: number, decimals?: number): string;
  43669. /**
  43670. * Tries to copy an object by duplicating every property
  43671. * @param source defines the source object
  43672. * @param destination defines the target object
  43673. * @param doNotCopyList defines a list of properties to avoid
  43674. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  43675. */
  43676. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  43677. /**
  43678. * Gets a boolean indicating if the given object has no own property
  43679. * @param obj defines the object to test
  43680. * @returns true if object has no own property
  43681. */
  43682. static IsEmpty(obj: any): boolean;
  43683. /**
  43684. * Function used to register events at window level
  43685. * @param windowElement defines the Window object to use
  43686. * @param events defines the events to register
  43687. */
  43688. static RegisterTopRootEvents(windowElement: Window, events: {
  43689. name: string;
  43690. handler: Nullable<(e: FocusEvent) => any>;
  43691. }[]): void;
  43692. /**
  43693. * Function used to unregister events from window level
  43694. * @param windowElement defines the Window object to use
  43695. * @param events defines the events to unregister
  43696. */
  43697. static UnregisterTopRootEvents(windowElement: Window, events: {
  43698. name: string;
  43699. handler: Nullable<(e: FocusEvent) => any>;
  43700. }[]): void;
  43701. /**
  43702. * @ignore
  43703. */
  43704. static _ScreenshotCanvas: HTMLCanvasElement;
  43705. /**
  43706. * Dumps the current bound framebuffer
  43707. * @param width defines the rendering width
  43708. * @param height defines the rendering height
  43709. * @param engine defines the hosting engine
  43710. * @param successCallback defines the callback triggered once the data are available
  43711. * @param mimeType defines the mime type of the result
  43712. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43713. * @return a void promise
  43714. */
  43715. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): Promise<void>;
  43716. /**
  43717. * Dumps an array buffer
  43718. * @param width defines the rendering width
  43719. * @param height defines the rendering height
  43720. * @param data the data array
  43721. * @param successCallback defines the callback triggered once the data are available
  43722. * @param mimeType defines the mime type of the result
  43723. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43724. * @param invertY true to invert the picture in the Y dimension
  43725. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  43726. */
  43727. static DumpData(width: number, height: number, data: ArrayBufferView, successCallback?: (data: string | ArrayBuffer) => void, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): void;
  43728. /**
  43729. * Dumps an array buffer
  43730. * @param width defines the rendering width
  43731. * @param height defines the rendering height
  43732. * @param data the data array
  43733. * @param successCallback defines the callback triggered once the data are available
  43734. * @param mimeType defines the mime type of the result
  43735. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43736. * @param invertY true to invert the picture in the Y dimension
  43737. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  43738. * @return a promise that resolve to the final data
  43739. */
  43740. static DumpDataAsync(width: number, height: number, data: ArrayBufferView, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  43741. /**
  43742. * Converts the canvas data to blob.
  43743. * This acts as a polyfill for browsers not supporting the to blob function.
  43744. * @param canvas Defines the canvas to extract the data from
  43745. * @param successCallback Defines the callback triggered once the data are available
  43746. * @param mimeType Defines the mime type of the result
  43747. */
  43748. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  43749. /**
  43750. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  43751. * @param successCallback defines the callback triggered once the data are available
  43752. * @param mimeType defines the mime type of the result
  43753. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  43754. * @param canvas canvas to get the data from. If not provided, use the default screenshot canvas
  43755. */
  43756. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string, canvas?: HTMLCanvasElement): void;
  43757. /**
  43758. * Downloads a blob in the browser
  43759. * @param blob defines the blob to download
  43760. * @param fileName defines the name of the downloaded file
  43761. */
  43762. static Download(blob: Blob, fileName: string): void;
  43763. /**
  43764. * Will return the right value of the noPreventDefault variable
  43765. * Needed to keep backwards compatibility to the old API.
  43766. *
  43767. * @param args arguments passed to the attachControl function
  43768. * @returns the correct value for noPreventDefault
  43769. */
  43770. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  43771. /**
  43772. * Captures a screenshot of the current rendering
  43773. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43774. * @param engine defines the rendering engine
  43775. * @param camera defines the source camera
  43776. * @param size This parameter can be set to a single number or to an object with the
  43777. * following (optional) properties: precision, width, height. If a single number is passed,
  43778. * it will be used for both width and height. If an object is passed, the screenshot size
  43779. * will be derived from the parameters. The precision property is a multiplier allowing
  43780. * rendering at a higher or lower resolution
  43781. * @param successCallback defines the callback receives a single parameter which contains the
  43782. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43783. * src parameter of an <img> to display it
  43784. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43785. * Check your browser for supported MIME types
  43786. */
  43787. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  43788. /**
  43789. * Captures a screenshot of the current rendering
  43790. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43791. * @param engine defines the rendering engine
  43792. * @param camera defines the source camera
  43793. * @param size This parameter can be set to a single number or to an object with the
  43794. * following (optional) properties: precision, width, height. If a single number is passed,
  43795. * it will be used for both width and height. If an object is passed, the screenshot size
  43796. * will be derived from the parameters. The precision property is a multiplier allowing
  43797. * rendering at a higher or lower resolution
  43798. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43799. * Check your browser for supported MIME types
  43800. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43801. * to the src parameter of an <img> to display it
  43802. */
  43803. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  43804. /**
  43805. * Generates an image screenshot from the specified camera.
  43806. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43807. * @param engine The engine to use for rendering
  43808. * @param camera The camera to use for rendering
  43809. * @param size This parameter can be set to a single number or to an object with the
  43810. * following (optional) properties: precision, width, height. If a single number is passed,
  43811. * it will be used for both width and height. If an object is passed, the screenshot size
  43812. * will be derived from the parameters. The precision property is a multiplier allowing
  43813. * rendering at a higher or lower resolution
  43814. * @param successCallback The callback receives a single parameter which contains the
  43815. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43816. * src parameter of an <img> to display it
  43817. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43818. * Check your browser for supported MIME types
  43819. * @param samples Texture samples (default: 1)
  43820. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43821. * @param fileName A name for for the downloaded file.
  43822. */
  43823. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  43824. /**
  43825. * Generates an image screenshot from the specified camera.
  43826. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43827. * @param engine The engine to use for rendering
  43828. * @param camera The camera to use for rendering
  43829. * @param size This parameter can be set to a single number or to an object with the
  43830. * following (optional) properties: precision, width, height. If a single number is passed,
  43831. * it will be used for both width and height. If an object is passed, the screenshot size
  43832. * will be derived from the parameters. The precision property is a multiplier allowing
  43833. * rendering at a higher or lower resolution
  43834. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43835. * Check your browser for supported MIME types
  43836. * @param samples Texture samples (default: 1)
  43837. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43838. * @param fileName A name for for the downloaded file.
  43839. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43840. * to the src parameter of an <img> to display it
  43841. */
  43842. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  43843. /**
  43844. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  43845. * Be aware Math.random() could cause collisions, but:
  43846. * "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"
  43847. * @returns a pseudo random id
  43848. */
  43849. static RandomId(): string;
  43850. /**
  43851. * Test if the given uri is a base64 string
  43852. * @param uri The uri to test
  43853. * @return True if the uri is a base64 string or false otherwise
  43854. */
  43855. static IsBase64(uri: string): boolean;
  43856. /**
  43857. * Decode the given base64 uri.
  43858. * @param uri The uri to decode
  43859. * @return The decoded base64 data.
  43860. */
  43861. static DecodeBase64(uri: string): ArrayBuffer;
  43862. /**
  43863. * Gets the absolute url.
  43864. * @param url the input url
  43865. * @return the absolute url
  43866. */
  43867. static GetAbsoluteUrl(url: string): string;
  43868. /**
  43869. * No log
  43870. */
  43871. static readonly NoneLogLevel: number;
  43872. /**
  43873. * Only message logs
  43874. */
  43875. static readonly MessageLogLevel: number;
  43876. /**
  43877. * Only warning logs
  43878. */
  43879. static readonly WarningLogLevel: number;
  43880. /**
  43881. * Only error logs
  43882. */
  43883. static readonly ErrorLogLevel: number;
  43884. /**
  43885. * All logs
  43886. */
  43887. static readonly AllLogLevel: number;
  43888. /**
  43889. * Gets a value indicating the number of loading errors
  43890. * @ignorenaming
  43891. */
  43892. static get errorsCount(): number;
  43893. /**
  43894. * Callback called when a new log is added
  43895. */
  43896. static OnNewCacheEntry: (entry: string) => void;
  43897. /**
  43898. * Log a message to the console
  43899. * @param message defines the message to log
  43900. */
  43901. static Log(message: string): void;
  43902. /**
  43903. * Write a warning message to the console
  43904. * @param message defines the message to log
  43905. */
  43906. static Warn(message: string): void;
  43907. /**
  43908. * Write an error message to the console
  43909. * @param message defines the message to log
  43910. */
  43911. static Error(message: string): void;
  43912. /**
  43913. * Gets current log cache (list of logs)
  43914. */
  43915. static get LogCache(): string;
  43916. /**
  43917. * Clears the log cache
  43918. */
  43919. static ClearLogCache(): void;
  43920. /**
  43921. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  43922. */
  43923. static set LogLevels(level: number);
  43924. /**
  43925. * Checks if the window object exists
  43926. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  43927. */
  43928. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  43929. /**
  43930. * No performance log
  43931. */
  43932. static readonly PerformanceNoneLogLevel: number;
  43933. /**
  43934. * Use user marks to log performance
  43935. */
  43936. static readonly PerformanceUserMarkLogLevel: number;
  43937. /**
  43938. * Log performance to the console
  43939. */
  43940. static readonly PerformanceConsoleLogLevel: number;
  43941. private static _performance;
  43942. /**
  43943. * Sets the current performance log level
  43944. */
  43945. static set PerformanceLogLevel(level: number);
  43946. private static _StartPerformanceCounterDisabled;
  43947. private static _EndPerformanceCounterDisabled;
  43948. private static _StartUserMark;
  43949. private static _EndUserMark;
  43950. private static _StartPerformanceConsole;
  43951. private static _EndPerformanceConsole;
  43952. /**
  43953. * Starts a performance counter
  43954. */
  43955. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43956. /**
  43957. * Ends a specific performance counter
  43958. */
  43959. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43960. /**
  43961. * Gets either window.performance.now() if supported or Date.now() else
  43962. */
  43963. static get Now(): number;
  43964. /**
  43965. * This method will return the name of the class used to create the instance of the given object.
  43966. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  43967. * @param object the object to get the class name from
  43968. * @param isType defines if the object is actually a type
  43969. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  43970. */
  43971. static GetClassName(object: any, isType?: boolean): string;
  43972. /**
  43973. * Gets the first element of an array satisfying a given predicate
  43974. * @param array defines the array to browse
  43975. * @param predicate defines the predicate to use
  43976. * @returns null if not found or the element
  43977. */
  43978. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  43979. /**
  43980. * This method will return the name of the full name of the class, including its owning module (if any).
  43981. * 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).
  43982. * @param object the object to get the class name from
  43983. * @param isType defines if the object is actually a type
  43984. * @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.
  43985. * @ignorenaming
  43986. */
  43987. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  43988. /**
  43989. * Returns a promise that resolves after the given amount of time.
  43990. * @param delay Number of milliseconds to delay
  43991. * @returns Promise that resolves after the given amount of time
  43992. */
  43993. static DelayAsync(delay: number): Promise<void>;
  43994. /**
  43995. * Utility function to detect if the current user agent is Safari
  43996. * @returns whether or not the current user agent is safari
  43997. */
  43998. static IsSafari(): boolean;
  43999. }
  44000. /**
  44001. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  44002. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  44003. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  44004. * @param name The name of the class, case should be preserved
  44005. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  44006. */
  44007. export function className(name: string, module?: string): (target: Object) => void;
  44008. /**
  44009. * An implementation of a loop for asynchronous functions.
  44010. */
  44011. export class AsyncLoop {
  44012. /**
  44013. * Defines the number of iterations for the loop
  44014. */
  44015. iterations: number;
  44016. /**
  44017. * Defines the current index of the loop.
  44018. */
  44019. index: number;
  44020. private _done;
  44021. private _fn;
  44022. private _successCallback;
  44023. /**
  44024. * Constructor.
  44025. * @param iterations the number of iterations.
  44026. * @param func the function to run each iteration
  44027. * @param successCallback the callback that will be called upon successful execution
  44028. * @param offset starting offset.
  44029. */
  44030. constructor(
  44031. /**
  44032. * Defines the number of iterations for the loop
  44033. */
  44034. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  44035. /**
  44036. * Execute the next iteration. Must be called after the last iteration was finished.
  44037. */
  44038. executeNext(): void;
  44039. /**
  44040. * Break the loop and run the success callback.
  44041. */
  44042. breakLoop(): void;
  44043. /**
  44044. * Create and run an async loop.
  44045. * @param iterations the number of iterations.
  44046. * @param fn the function to run each iteration
  44047. * @param successCallback the callback that will be called upon successful execution
  44048. * @param offset starting offset.
  44049. * @returns the created async loop object
  44050. */
  44051. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  44052. /**
  44053. * A for-loop that will run a given number of iterations synchronous and the rest async.
  44054. * @param iterations total number of iterations
  44055. * @param syncedIterations number of synchronous iterations in each async iteration.
  44056. * @param fn the function to call each iteration.
  44057. * @param callback a success call back that will be called when iterating stops.
  44058. * @param breakFunction a break condition (optional)
  44059. * @param timeout timeout settings for the setTimeout function. default - 0.
  44060. * @returns the created async loop object
  44061. */
  44062. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  44063. }
  44064. }
  44065. declare module BABYLON {
  44066. /**
  44067. * This class implement a typical dictionary using a string as key and the generic type T as value.
  44068. * The underlying implementation relies on an associative array to ensure the best performances.
  44069. * The value can be anything including 'null' but except 'undefined'
  44070. */
  44071. export class StringDictionary<T> {
  44072. /**
  44073. * This will clear this dictionary and copy the content from the 'source' one.
  44074. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  44075. * @param source the dictionary to take the content from and copy to this dictionary
  44076. */
  44077. copyFrom(source: StringDictionary<T>): void;
  44078. /**
  44079. * Get a value based from its key
  44080. * @param key the given key to get the matching value from
  44081. * @return the value if found, otherwise undefined is returned
  44082. */
  44083. get(key: string): T | undefined;
  44084. /**
  44085. * Get a value from its key or add it if it doesn't exist.
  44086. * This method will ensure you that a given key/data will be present in the dictionary.
  44087. * @param key the given key to get the matching value from
  44088. * @param factory the factory that will create the value if the key is not present in the dictionary.
  44089. * The factory will only be invoked if there's no data for the given key.
  44090. * @return the value corresponding to the key.
  44091. */
  44092. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  44093. /**
  44094. * Get a value from its key if present in the dictionary otherwise add it
  44095. * @param key the key to get the value from
  44096. * @param val if there's no such key/value pair in the dictionary add it with this value
  44097. * @return the value corresponding to the key
  44098. */
  44099. getOrAdd(key: string, val: T): T;
  44100. /**
  44101. * Check if there's a given key in the dictionary
  44102. * @param key the key to check for
  44103. * @return true if the key is present, false otherwise
  44104. */
  44105. contains(key: string): boolean;
  44106. /**
  44107. * Add a new key and its corresponding value
  44108. * @param key the key to add
  44109. * @param value the value corresponding to the key
  44110. * @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
  44111. */
  44112. add(key: string, value: T): boolean;
  44113. /**
  44114. * Update a specific value associated to a key
  44115. * @param key defines the key to use
  44116. * @param value defines the value to store
  44117. * @returns true if the value was updated (or false if the key was not found)
  44118. */
  44119. set(key: string, value: T): boolean;
  44120. /**
  44121. * Get the element of the given key and remove it from the dictionary
  44122. * @param key defines the key to search
  44123. * @returns the value associated with the key or null if not found
  44124. */
  44125. getAndRemove(key: string): Nullable<T>;
  44126. /**
  44127. * Remove a key/value from the dictionary.
  44128. * @param key the key to remove
  44129. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  44130. */
  44131. remove(key: string): boolean;
  44132. /**
  44133. * Clear the whole content of the dictionary
  44134. */
  44135. clear(): void;
  44136. /**
  44137. * Gets the current count
  44138. */
  44139. get count(): number;
  44140. /**
  44141. * Execute a callback on each key/val of the dictionary.
  44142. * Note that you can remove any element in this dictionary in the callback implementation
  44143. * @param callback the callback to execute on a given key/value pair
  44144. */
  44145. forEach(callback: (key: string, val: T) => void): void;
  44146. /**
  44147. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  44148. * If the callback returns null or undefined the method will iterate to the next key/value pair
  44149. * Note that you can remove any element in this dictionary in the callback implementation
  44150. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  44151. * @returns the first item
  44152. */
  44153. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  44154. private _count;
  44155. private _data;
  44156. }
  44157. }
  44158. declare module BABYLON {
  44159. /** @hidden */
  44160. export interface ICollisionCoordinator {
  44161. createCollider(): Collider;
  44162. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  44163. init(scene: Scene): void;
  44164. }
  44165. /** @hidden */
  44166. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  44167. private _scene;
  44168. private _scaledPosition;
  44169. private _scaledVelocity;
  44170. private _finalPosition;
  44171. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  44172. createCollider(): Collider;
  44173. init(scene: Scene): void;
  44174. private _collideWithWorld;
  44175. }
  44176. }
  44177. declare module BABYLON {
  44178. /**
  44179. * Enum for Device Types
  44180. */
  44181. export enum DeviceType {
  44182. /** Generic */
  44183. Generic = 0,
  44184. /** Keyboard */
  44185. Keyboard = 1,
  44186. /** Mouse */
  44187. Mouse = 2,
  44188. /** Touch Pointers */
  44189. Touch = 3,
  44190. /** PS4 Dual Shock */
  44191. DualShock = 4,
  44192. /** Xbox */
  44193. Xbox = 5,
  44194. /** Switch Controller */
  44195. Switch = 6
  44196. }
  44197. /**
  44198. * Enum for All Pointers (Touch/Mouse)
  44199. */
  44200. export enum PointerInput {
  44201. /** Horizontal Axis */
  44202. Horizontal = 0,
  44203. /** Vertical Axis */
  44204. Vertical = 1,
  44205. /** Left Click or Touch */
  44206. LeftClick = 2,
  44207. /** Middle Click */
  44208. MiddleClick = 3,
  44209. /** Right Click */
  44210. RightClick = 4,
  44211. /** Browser Back */
  44212. BrowserBack = 5,
  44213. /** Browser Forward */
  44214. BrowserForward = 6,
  44215. /** Mouse Wheel X */
  44216. MouseWheelX = 7,
  44217. /** Mouse Wheel Y */
  44218. MouseWheelY = 8,
  44219. /** Mouse Wheel Z */
  44220. MouseWheelZ = 9,
  44221. /** Delta X */
  44222. DeltaHorizontal = 10,
  44223. /** Delta Y */
  44224. DeltaVertical = 11
  44225. }
  44226. /**
  44227. * Enum for Dual Shock Gamepad
  44228. */
  44229. export enum DualShockInput {
  44230. /** Cross */
  44231. Cross = 0,
  44232. /** Circle */
  44233. Circle = 1,
  44234. /** Square */
  44235. Square = 2,
  44236. /** Triangle */
  44237. Triangle = 3,
  44238. /** L1 */
  44239. L1 = 4,
  44240. /** R1 */
  44241. R1 = 5,
  44242. /** L2 */
  44243. L2 = 6,
  44244. /** R2 */
  44245. R2 = 7,
  44246. /** Share */
  44247. Share = 8,
  44248. /** Options */
  44249. Options = 9,
  44250. /** L3 */
  44251. L3 = 10,
  44252. /** R3 */
  44253. R3 = 11,
  44254. /** DPadUp */
  44255. DPadUp = 12,
  44256. /** DPadDown */
  44257. DPadDown = 13,
  44258. /** DPadLeft */
  44259. DPadLeft = 14,
  44260. /** DRight */
  44261. DPadRight = 15,
  44262. /** Home */
  44263. Home = 16,
  44264. /** TouchPad */
  44265. TouchPad = 17,
  44266. /** LStickXAxis */
  44267. LStickXAxis = 18,
  44268. /** LStickYAxis */
  44269. LStickYAxis = 19,
  44270. /** RStickXAxis */
  44271. RStickXAxis = 20,
  44272. /** RStickYAxis */
  44273. RStickYAxis = 21
  44274. }
  44275. /**
  44276. * Enum for Xbox Gamepad
  44277. */
  44278. export enum XboxInput {
  44279. /** A */
  44280. A = 0,
  44281. /** B */
  44282. B = 1,
  44283. /** X */
  44284. X = 2,
  44285. /** Y */
  44286. Y = 3,
  44287. /** LB */
  44288. LB = 4,
  44289. /** RB */
  44290. RB = 5,
  44291. /** LT */
  44292. LT = 6,
  44293. /** RT */
  44294. RT = 7,
  44295. /** Back */
  44296. Back = 8,
  44297. /** Start */
  44298. Start = 9,
  44299. /** LS */
  44300. LS = 10,
  44301. /** RS */
  44302. RS = 11,
  44303. /** DPadUp */
  44304. DPadUp = 12,
  44305. /** DPadDown */
  44306. DPadDown = 13,
  44307. /** DPadLeft */
  44308. DPadLeft = 14,
  44309. /** DRight */
  44310. DPadRight = 15,
  44311. /** Home */
  44312. Home = 16,
  44313. /** LStickXAxis */
  44314. LStickXAxis = 17,
  44315. /** LStickYAxis */
  44316. LStickYAxis = 18,
  44317. /** RStickXAxis */
  44318. RStickXAxis = 19,
  44319. /** RStickYAxis */
  44320. RStickYAxis = 20
  44321. }
  44322. /**
  44323. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  44324. */
  44325. export enum SwitchInput {
  44326. /** B */
  44327. B = 0,
  44328. /** A */
  44329. A = 1,
  44330. /** Y */
  44331. Y = 2,
  44332. /** X */
  44333. X = 3,
  44334. /** L */
  44335. L = 4,
  44336. /** R */
  44337. R = 5,
  44338. /** ZL */
  44339. ZL = 6,
  44340. /** ZR */
  44341. ZR = 7,
  44342. /** Minus */
  44343. Minus = 8,
  44344. /** Plus */
  44345. Plus = 9,
  44346. /** LS */
  44347. LS = 10,
  44348. /** RS */
  44349. RS = 11,
  44350. /** DPadUp */
  44351. DPadUp = 12,
  44352. /** DPadDown */
  44353. DPadDown = 13,
  44354. /** DPadLeft */
  44355. DPadLeft = 14,
  44356. /** DRight */
  44357. DPadRight = 15,
  44358. /** Home */
  44359. Home = 16,
  44360. /** Capture */
  44361. Capture = 17,
  44362. /** LStickXAxis */
  44363. LStickXAxis = 18,
  44364. /** LStickYAxis */
  44365. LStickYAxis = 19,
  44366. /** RStickXAxis */
  44367. RStickXAxis = 20,
  44368. /** RStickYAxis */
  44369. RStickYAxis = 21
  44370. }
  44371. }
  44372. declare module BABYLON {
  44373. /**
  44374. * This class will take all inputs from Keyboard, Pointer, and
  44375. * any Gamepads and provide a polling system that all devices
  44376. * will use. This class assumes that there will only be one
  44377. * pointer device and one keyboard.
  44378. */
  44379. export class DeviceInputSystem implements IDisposable {
  44380. /**
  44381. * Returns onDeviceConnected callback property
  44382. * @returns Callback with function to execute when a device is connected
  44383. */
  44384. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  44385. /**
  44386. * Sets callback function when a device is connected and executes against all connected devices
  44387. * @param callback Function to execute when a device is connected
  44388. */
  44389. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  44390. /**
  44391. * Callback to be triggered when a device is disconnected
  44392. */
  44393. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  44394. /**
  44395. * Callback to be triggered when event driven input is updated
  44396. */
  44397. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  44398. private _inputs;
  44399. private _gamepads;
  44400. private _keyboardActive;
  44401. private _pointerActive;
  44402. private _elementToAttachTo;
  44403. private _keyboardDownEvent;
  44404. private _keyboardUpEvent;
  44405. private _pointerMoveEvent;
  44406. private _pointerDownEvent;
  44407. private _pointerUpEvent;
  44408. private _pointerWheelEvent;
  44409. private _wheelEventName;
  44410. private _gamepadConnectedEvent;
  44411. private _gamepadDisconnectedEvent;
  44412. private _onDeviceConnected;
  44413. private static _MAX_KEYCODES;
  44414. private static _MAX_POINTER_INPUTS;
  44415. private _eventPrefix;
  44416. private constructor();
  44417. /**
  44418. * Creates a new DeviceInputSystem instance
  44419. * @param engine Engine to pull input element from
  44420. * @returns The new instance
  44421. */
  44422. static Create(engine: Engine): DeviceInputSystem;
  44423. /**
  44424. * Checks for current device input value, given an id and input index
  44425. * @param deviceName Id of connected device
  44426. * @param inputIndex Index of device input
  44427. * @returns Current value of input
  44428. */
  44429. /**
  44430. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  44431. * @param deviceType Enum specifiying device type
  44432. * @param deviceSlot "Slot" or index that device is referenced in
  44433. * @param inputIndex Id of input to be checked
  44434. * @returns Current value of input
  44435. */
  44436. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  44437. /**
  44438. * Check for a specific device in the DeviceInputSystem
  44439. * @param deviceType Type of device to check for
  44440. * @returns bool with status of device's existence
  44441. */
  44442. isDeviceAvailable(deviceType: DeviceType): boolean;
  44443. /**
  44444. * Dispose of all the eventlisteners
  44445. */
  44446. dispose(): void;
  44447. /**
  44448. * Checks for existing connections to devices and register them, if necessary
  44449. * Currently handles gamepads and mouse
  44450. */
  44451. private _checkForConnectedDevices;
  44452. /**
  44453. * Add a gamepad to the DeviceInputSystem
  44454. * @param gamepad A single DOM Gamepad object
  44455. */
  44456. private _addGamePad;
  44457. /**
  44458. * Add pointer device to DeviceInputSystem
  44459. * @param deviceType Type of Pointer to add
  44460. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  44461. * @param currentX Current X at point of adding
  44462. * @param currentY Current Y at point of adding
  44463. */
  44464. private _addPointerDevice;
  44465. /**
  44466. * Add device and inputs to device array
  44467. * @param deviceType Enum specifiying device type
  44468. * @param deviceSlot "Slot" or index that device is referenced in
  44469. * @param numberOfInputs Number of input entries to create for given device
  44470. */
  44471. private _registerDevice;
  44472. /**
  44473. * Given a specific device name, remove that device from the device map
  44474. * @param deviceType Enum specifiying device type
  44475. * @param deviceSlot "Slot" or index that device is referenced in
  44476. */
  44477. private _unregisterDevice;
  44478. /**
  44479. * Handle all actions that come from keyboard interaction
  44480. */
  44481. private _handleKeyActions;
  44482. /**
  44483. * Handle all actions that come from pointer interaction
  44484. */
  44485. private _handlePointerActions;
  44486. /**
  44487. * Handle all actions that come from gamepad interaction
  44488. */
  44489. private _handleGamepadActions;
  44490. /**
  44491. * Update all non-event based devices with each frame
  44492. * @param deviceType Enum specifiying device type
  44493. * @param deviceSlot "Slot" or index that device is referenced in
  44494. * @param inputIndex Id of input to be checked
  44495. */
  44496. private _updateDevice;
  44497. /**
  44498. * Gets DeviceType from the device name
  44499. * @param deviceName Name of Device from DeviceInputSystem
  44500. * @returns DeviceType enum value
  44501. */
  44502. private _getGamepadDeviceType;
  44503. }
  44504. }
  44505. declare module BABYLON {
  44506. /**
  44507. * Class used to manage all inputs for the scene.
  44508. */
  44509. export class InputManager {
  44510. /** The distance in pixel that you have to move to prevent some events */
  44511. static DragMovementThreshold: number;
  44512. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  44513. static LongPressDelay: number;
  44514. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  44515. static DoubleClickDelay: number;
  44516. /** If you need to check double click without raising a single click at first click, enable this flag */
  44517. static ExclusiveDoubleClickMode: boolean;
  44518. /** 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. */
  44519. private _alreadyAttached;
  44520. private _alreadyAttachedTo;
  44521. private _onPointerMove;
  44522. private _onPointerDown;
  44523. private _onPointerUp;
  44524. private _initClickEvent;
  44525. private _initActionManager;
  44526. private _delayedSimpleClick;
  44527. private _delayedSimpleClickTimeout;
  44528. private _previousDelayedSimpleClickTimeout;
  44529. private _meshPickProceed;
  44530. private _previousButtonPressed;
  44531. private _currentPickResult;
  44532. private _previousPickResult;
  44533. private _totalPointersPressed;
  44534. private _doubleClickOccured;
  44535. private _pointerOverMesh;
  44536. private _pickedDownMesh;
  44537. private _pickedUpMesh;
  44538. private _pointerX;
  44539. private _pointerY;
  44540. private _unTranslatedPointerX;
  44541. private _unTranslatedPointerY;
  44542. private _startingPointerPosition;
  44543. private _previousStartingPointerPosition;
  44544. private _startingPointerTime;
  44545. private _previousStartingPointerTime;
  44546. private _pointerCaptures;
  44547. private _meshUnderPointerId;
  44548. private _onKeyDown;
  44549. private _onKeyUp;
  44550. private _scene;
  44551. private _deviceInputSystem;
  44552. /**
  44553. * Creates a new InputManager
  44554. * @param scene defines the hosting scene
  44555. */
  44556. constructor(scene: Scene);
  44557. /**
  44558. * Gets the mesh that is currently under the pointer
  44559. */
  44560. get meshUnderPointer(): Nullable<AbstractMesh>;
  44561. /**
  44562. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  44563. * @param pointerId the pointer id to use
  44564. * @returns The mesh under this pointer id or null if not found
  44565. */
  44566. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  44567. /**
  44568. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  44569. */
  44570. get unTranslatedPointer(): Vector2;
  44571. /**
  44572. * Gets or sets the current on-screen X position of the pointer
  44573. */
  44574. get pointerX(): number;
  44575. set pointerX(value: number);
  44576. /**
  44577. * Gets or sets the current on-screen Y position of the pointer
  44578. */
  44579. get pointerY(): number;
  44580. set pointerY(value: number);
  44581. private _updatePointerPosition;
  44582. private _processPointerMove;
  44583. private _setRayOnPointerInfo;
  44584. private _checkPrePointerObservable;
  44585. /**
  44586. * Use this method to simulate a pointer move on a mesh
  44587. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44588. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44589. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44590. */
  44591. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  44592. /**
  44593. * Use this method to simulate a pointer down on a mesh
  44594. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44595. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44596. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44597. */
  44598. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  44599. private _processPointerDown;
  44600. /** @hidden */
  44601. _isPointerSwiping(): boolean;
  44602. /**
  44603. * Use this method to simulate a pointer up on a mesh
  44604. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44605. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44606. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44607. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  44608. */
  44609. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  44610. private _processPointerUp;
  44611. /**
  44612. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  44613. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  44614. * @returns true if the pointer was captured
  44615. */
  44616. isPointerCaptured(pointerId?: number): boolean;
  44617. /**
  44618. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  44619. * @param attachUp defines if you want to attach events to pointerup
  44620. * @param attachDown defines if you want to attach events to pointerdown
  44621. * @param attachMove defines if you want to attach events to pointermove
  44622. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  44623. */
  44624. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  44625. /**
  44626. * Detaches all event handlers
  44627. */
  44628. detachControl(): void;
  44629. /**
  44630. * Force the value of meshUnderPointer
  44631. * @param mesh defines the mesh to use
  44632. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  44633. */
  44634. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  44635. /**
  44636. * Gets the mesh under the pointer
  44637. * @returns a Mesh or null if no mesh is under the pointer
  44638. */
  44639. getPointerOverMesh(): Nullable<AbstractMesh>;
  44640. }
  44641. }
  44642. declare module BABYLON {
  44643. /**
  44644. * This class defines the direct association between an animation and a target
  44645. */
  44646. export class TargetedAnimation {
  44647. /**
  44648. * Animation to perform
  44649. */
  44650. animation: Animation;
  44651. /**
  44652. * Target to animate
  44653. */
  44654. target: any;
  44655. /**
  44656. * Returns the string "TargetedAnimation"
  44657. * @returns "TargetedAnimation"
  44658. */
  44659. getClassName(): string;
  44660. /**
  44661. * Serialize the object
  44662. * @returns the JSON object representing the current entity
  44663. */
  44664. serialize(): any;
  44665. }
  44666. /**
  44667. * Use this class to create coordinated animations on multiple targets
  44668. */
  44669. export class AnimationGroup implements IDisposable {
  44670. /** The name of the animation group */
  44671. name: string;
  44672. private _scene;
  44673. private _targetedAnimations;
  44674. private _animatables;
  44675. private _from;
  44676. private _to;
  44677. private _isStarted;
  44678. private _isPaused;
  44679. private _speedRatio;
  44680. private _loopAnimation;
  44681. private _isAdditive;
  44682. /**
  44683. * Gets or sets the unique id of the node
  44684. */
  44685. uniqueId: number;
  44686. /**
  44687. * This observable will notify when one animation have ended
  44688. */
  44689. onAnimationEndObservable: Observable<TargetedAnimation>;
  44690. /**
  44691. * Observer raised when one animation loops
  44692. */
  44693. onAnimationLoopObservable: Observable<TargetedAnimation>;
  44694. /**
  44695. * Observer raised when all animations have looped
  44696. */
  44697. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  44698. /**
  44699. * This observable will notify when all animations have ended.
  44700. */
  44701. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  44702. /**
  44703. * This observable will notify when all animations have paused.
  44704. */
  44705. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  44706. /**
  44707. * This observable will notify when all animations are playing.
  44708. */
  44709. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  44710. /**
  44711. * Gets the first frame
  44712. */
  44713. get from(): number;
  44714. /**
  44715. * Gets the last frame
  44716. */
  44717. get to(): number;
  44718. /**
  44719. * Define if the animations are started
  44720. */
  44721. get isStarted(): boolean;
  44722. /**
  44723. * Gets a value indicating that the current group is playing
  44724. */
  44725. get isPlaying(): boolean;
  44726. /**
  44727. * Gets or sets the speed ratio to use for all animations
  44728. */
  44729. get speedRatio(): number;
  44730. /**
  44731. * Gets or sets the speed ratio to use for all animations
  44732. */
  44733. set speedRatio(value: number);
  44734. /**
  44735. * Gets or sets if all animations should loop or not
  44736. */
  44737. get loopAnimation(): boolean;
  44738. set loopAnimation(value: boolean);
  44739. /**
  44740. * Gets or sets if all animations should be evaluated additively
  44741. */
  44742. get isAdditive(): boolean;
  44743. set isAdditive(value: boolean);
  44744. /**
  44745. * Gets the targeted animations for this animation group
  44746. */
  44747. get targetedAnimations(): Array<TargetedAnimation>;
  44748. /**
  44749. * returning the list of animatables controlled by this animation group.
  44750. */
  44751. get animatables(): Array<Animatable>;
  44752. /**
  44753. * Gets the list of target animations
  44754. */
  44755. get children(): TargetedAnimation[];
  44756. /**
  44757. * Instantiates a new Animation Group.
  44758. * This helps managing several animations at once.
  44759. * @see https://doc.babylonjs.com/how_to/group
  44760. * @param name Defines the name of the group
  44761. * @param scene Defines the scene the group belongs to
  44762. */
  44763. constructor(
  44764. /** The name of the animation group */
  44765. name: string, scene?: Nullable<Scene>);
  44766. /**
  44767. * Add an animation (with its target) in the group
  44768. * @param animation defines the animation we want to add
  44769. * @param target defines the target of the animation
  44770. * @returns the TargetedAnimation object
  44771. */
  44772. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  44773. /**
  44774. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  44775. * It can add constant keys at begin or end
  44776. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  44777. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  44778. * @returns the animation group
  44779. */
  44780. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  44781. private _animationLoopCount;
  44782. private _animationLoopFlags;
  44783. private _processLoop;
  44784. /**
  44785. * Start all animations on given targets
  44786. * @param loop defines if animations must loop
  44787. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  44788. * @param from defines the from key (optional)
  44789. * @param to defines the to key (optional)
  44790. * @param isAdditive defines the additive state for the resulting animatables (optional)
  44791. * @returns the current animation group
  44792. */
  44793. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  44794. /**
  44795. * Pause all animations
  44796. * @returns the animation group
  44797. */
  44798. pause(): AnimationGroup;
  44799. /**
  44800. * Play all animations to initial state
  44801. * This function will start() the animations if they were not started or will restart() them if they were paused
  44802. * @param loop defines if animations must loop
  44803. * @returns the animation group
  44804. */
  44805. play(loop?: boolean): AnimationGroup;
  44806. /**
  44807. * Reset all animations to initial state
  44808. * @returns the animation group
  44809. */
  44810. reset(): AnimationGroup;
  44811. /**
  44812. * Restart animations from key 0
  44813. * @returns the animation group
  44814. */
  44815. restart(): AnimationGroup;
  44816. /**
  44817. * Stop all animations
  44818. * @returns the animation group
  44819. */
  44820. stop(): AnimationGroup;
  44821. /**
  44822. * Set animation weight for all animatables
  44823. * @param weight defines the weight to use
  44824. * @return the animationGroup
  44825. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44826. */
  44827. setWeightForAllAnimatables(weight: number): AnimationGroup;
  44828. /**
  44829. * Synchronize and normalize all animatables with a source animatable
  44830. * @param root defines the root animatable to synchronize with
  44831. * @return the animationGroup
  44832. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44833. */
  44834. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  44835. /**
  44836. * Goes to a specific frame in this animation group
  44837. * @param frame the frame number to go to
  44838. * @return the animationGroup
  44839. */
  44840. goToFrame(frame: number): AnimationGroup;
  44841. /**
  44842. * Dispose all associated resources
  44843. */
  44844. dispose(): void;
  44845. private _checkAnimationGroupEnded;
  44846. /**
  44847. * Clone the current animation group and returns a copy
  44848. * @param newName defines the name of the new group
  44849. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  44850. * @returns the new animation group
  44851. */
  44852. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  44853. /**
  44854. * Serializes the animationGroup to an object
  44855. * @returns Serialized object
  44856. */
  44857. serialize(): any;
  44858. /**
  44859. * Returns a new AnimationGroup object parsed from the source provided.
  44860. * @param parsedAnimationGroup defines the source
  44861. * @param scene defines the scene that will receive the animationGroup
  44862. * @returns a new AnimationGroup
  44863. */
  44864. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  44865. /**
  44866. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  44867. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  44868. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  44869. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  44870. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  44871. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  44872. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  44873. */
  44874. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  44875. /**
  44876. * Returns the string "AnimationGroup"
  44877. * @returns "AnimationGroup"
  44878. */
  44879. getClassName(): string;
  44880. /**
  44881. * Creates a detailed string about the object
  44882. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  44883. * @returns a string representing the object
  44884. */
  44885. toString(fullDetails?: boolean): string;
  44886. }
  44887. }
  44888. declare module BABYLON {
  44889. /**
  44890. * @hidden
  44891. **/
  44892. export class _TimeToken {
  44893. _startTimeQuery: Nullable<WebGLQuery>;
  44894. _endTimeQuery: Nullable<WebGLQuery>;
  44895. _timeElapsedQuery: Nullable<WebGLQuery>;
  44896. _timeElapsedQueryEnded: boolean;
  44897. }
  44898. }
  44899. declare module BABYLON {
  44900. /** @hidden */
  44901. export enum ExtensionName {
  44902. DepthClamping = "depth-clamping",
  44903. Depth24UnormStencil8 = "depth24unorm-stencil8",
  44904. Depth32FloatStencil8 = "depth32float-stencil8",
  44905. PipelineStatisticsQuery = "pipeline-statistics-query",
  44906. TextureCompressionBC = "texture-compression-bc",
  44907. TimestampQuery = "timestamp-query"
  44908. }
  44909. /** @hidden */
  44910. export enum AddressMode {
  44911. ClampToEdge = "clamp-to-edge",
  44912. Repeat = "repeat",
  44913. MirrorRepeat = "mirror-repeat"
  44914. }
  44915. /** @hidden */
  44916. export enum BindingType {
  44917. UniformBuffer = "uniform-buffer",
  44918. StorageBuffer = "storage-buffer",
  44919. ReadonlyStorageBuffer = "readonly-storage-buffer",
  44920. Sampler = "sampler",
  44921. ComparisonSampler = "comparison-sampler",
  44922. SampledTexture = "sampled-texture",
  44923. ReadonlyStorageTexture = "readonly-storage-texture",
  44924. WriteonlyStorageTexture = "writeonly-storage-texture"
  44925. }
  44926. /** @hidden */
  44927. export enum BlendFactor {
  44928. Zero = "zero",
  44929. One = "one",
  44930. SrcColor = "src-color",
  44931. OneMinusSrcColor = "one-minus-src-color",
  44932. SrcAlpha = "src-alpha",
  44933. OneMinusSrcAlpha = "one-minus-src-alpha",
  44934. DstColor = "dst-color",
  44935. OneMinusDstColor = "one-minus-dst-color",
  44936. DstAlpha = "dst-alpha",
  44937. OneMinusDstAlpha = "one-minus-dst-alpha",
  44938. SrcAlphaSaturated = "src-alpha-saturated",
  44939. BlendColor = "blend-color",
  44940. OneMinusBlendColor = "one-minus-blend-color"
  44941. }
  44942. /** @hidden */
  44943. export enum BlendOperation {
  44944. Add = "add",
  44945. Subtract = "subtract",
  44946. ReverseSubtract = "reverse-subtract",
  44947. Min = "min",
  44948. Max = "max"
  44949. }
  44950. /** @hidden */
  44951. export enum CompareFunction {
  44952. Never = "never",
  44953. Less = "less",
  44954. Equal = "equal",
  44955. LessEqual = "less-equal",
  44956. Greater = "greater",
  44957. NotEqual = "not-equal",
  44958. GreaterEqual = "greater-equal",
  44959. Always = "always"
  44960. }
  44961. /** @hidden */
  44962. export enum CullMode {
  44963. None = "none",
  44964. Front = "front",
  44965. Back = "back"
  44966. }
  44967. /** @hidden */
  44968. export enum FilterMode {
  44969. Nearest = "nearest",
  44970. Linear = "linear"
  44971. }
  44972. /** @hidden */
  44973. export enum FrontFace {
  44974. CCW = "ccw",
  44975. CW = "cw"
  44976. }
  44977. /** @hidden */
  44978. export enum IndexFormat {
  44979. Uint16 = "uint16",
  44980. Uint32 = "uint32"
  44981. }
  44982. /** @hidden */
  44983. export enum InputStepMode {
  44984. Vertex = "vertex",
  44985. Instance = "instance"
  44986. }
  44987. /** @hidden */
  44988. export enum LoadOp {
  44989. Load = "load"
  44990. }
  44991. /** @hidden */
  44992. export enum PrimitiveTopology {
  44993. PointList = "point-list",
  44994. LineList = "line-list",
  44995. LineStrip = "line-strip",
  44996. TriangleList = "triangle-list",
  44997. TriangleStrip = "triangle-strip"
  44998. }
  44999. /** @hidden */
  45000. export enum StencilOperation {
  45001. Keep = "keep",
  45002. Zero = "zero",
  45003. Replace = "replace",
  45004. Invert = "invert",
  45005. IncrementClamp = "increment-clamp",
  45006. DecrementClamp = "decrement-clamp",
  45007. IncrementWrap = "increment-wrap",
  45008. DecrementWrap = "decrement-wrap"
  45009. }
  45010. /** @hidden */
  45011. export enum StoreOp {
  45012. Store = "store",
  45013. Clear = "clear"
  45014. }
  45015. /** @hidden */
  45016. export enum TextureDimension {
  45017. E1d = "1d",
  45018. E2d = "2d",
  45019. E3d = "3d"
  45020. }
  45021. /** @hidden */
  45022. export enum TextureFormat {
  45023. R8Unorm = "r8unorm",
  45024. R8Snorm = "r8snorm",
  45025. R8Uint = "r8uint",
  45026. R8Sint = "r8sint",
  45027. R16Uint = "r16uint",
  45028. R16Sint = "r16sint",
  45029. R16Float = "r16float",
  45030. RG8Unorm = "rg8unorm",
  45031. RG8Snorm = "rg8snorm",
  45032. RG8Uint = "rg8uint",
  45033. RG8Sint = "rg8sint",
  45034. R32Uint = "r32uint",
  45035. R32Sint = "r32sint",
  45036. R32Float = "r32float",
  45037. RG16Uint = "rg16uint",
  45038. RG16Sint = "rg16sint",
  45039. RG16Float = "rg16float",
  45040. RGBA8Unorm = "rgba8unorm",
  45041. RGBA8UnormSRGB = "rgba8unorm-srgb",
  45042. RGBA8Snorm = "rgba8snorm",
  45043. RGBA8Uint = "rgba8uint",
  45044. RGBA8Sint = "rgba8sint",
  45045. BGRA8Unorm = "bgra8unorm",
  45046. BGRA8UnormSRGB = "bgra8unorm-srgb",
  45047. RGB9E5UFloat = "rgb9e5ufloat",
  45048. RGB10A2Unorm = "rgb10a2unorm",
  45049. RG11B10UFloat = "rg11b10ufloat",
  45050. RG32Uint = "rg32uint",
  45051. RG32Sint = "rg32sint",
  45052. RG32Float = "rg32float",
  45053. RGBA16Uint = "rgba16uint",
  45054. RGBA16Sint = "rgba16sint",
  45055. RGBA16Float = "rgba16float",
  45056. RGBA32Uint = "rgba32uint",
  45057. RGBA32Sint = "rgba32sint",
  45058. RGBA32Float = "rgba32float",
  45059. Stencil8 = "stencil8",
  45060. Depth16Unorm = "depth16unorm",
  45061. Depth24Plus = "depth24plus",
  45062. Depth24PlusStencil8 = "depth24plus-stencil8",
  45063. Depth32Float = "depth32float",
  45064. BC1RGBAUNorm = "bc1-rgba-unorm",
  45065. BC1RGBAUnormSRGB = "bc1-rgba-unorm-srgb",
  45066. BC2RGBAUnorm = "bc2-rgba-unorm",
  45067. BC2RGBAUnormSRGB = "bc2-rgba-unorm-srgb",
  45068. BC3RGBAUnorm = "bc3-rgba-unorm",
  45069. BC3RGBAUnormSRGB = "bc3-rgba-unorm-srgb",
  45070. BC4RUnorm = "bc4-r-unorm",
  45071. BC4RSnorm = "bc4-r-snorm",
  45072. BC5RGUnorm = "bc5-rg-unorm",
  45073. BC5RGSnorm = "bc5-rg-snorm",
  45074. BC6HRGBUFloat = "bc6h-rgb-ufloat",
  45075. BC6HRGBFloat = "bc6h-rgb-float",
  45076. BC7RGBAUnorm = "bc7-rgba-unorm",
  45077. BC7RGBAUnormSRGB = "bc7-rgba-unorm-srgb",
  45078. Depth24UnormStencil8 = "depth24unorm-stencil8",
  45079. Depth32FloatStencil8 = "depth32float-stencil8"
  45080. }
  45081. /** @hidden */
  45082. export enum TextureComponentType {
  45083. Float = "float",
  45084. Sint = "sint",
  45085. Uint = "uint",
  45086. DepthComparison = "depth-comparison"
  45087. }
  45088. /** @hidden */
  45089. export enum TextureViewDimension {
  45090. E1d = "1d",
  45091. E2d = "2d",
  45092. E2dArray = "2d-array",
  45093. Cube = "cube",
  45094. CubeArray = "cube-array",
  45095. E3d = "3d"
  45096. }
  45097. /** @hidden */
  45098. export enum VertexFormat {
  45099. Uchar2 = "uchar2",
  45100. Uchar4 = "uchar4",
  45101. Char2 = "char2",
  45102. Char4 = "char4",
  45103. Uchar2Norm = "uchar2norm",
  45104. Uchar4Norm = "uchar4norm",
  45105. Char2Norm = "char2norm",
  45106. Char4Norm = "char4norm",
  45107. Ushort2 = "ushort2",
  45108. Ushort4 = "ushort4",
  45109. Short2 = "short2",
  45110. Short4 = "short4",
  45111. Ushort2Norm = "ushort2norm",
  45112. Ushort4Norm = "ushort4norm",
  45113. Short2Norm = "short2norm",
  45114. Short4Norm = "short4norm",
  45115. Half2 = "half2",
  45116. Half4 = "half4",
  45117. Float = "float",
  45118. Float2 = "float2",
  45119. Float3 = "float3",
  45120. Float4 = "float4",
  45121. Uint = "uint",
  45122. Uint2 = "uint2",
  45123. Uint3 = "uint3",
  45124. Uint4 = "uint4",
  45125. Int = "int",
  45126. Int2 = "int2",
  45127. Int3 = "int3",
  45128. Int4 = "int4"
  45129. }
  45130. /** @hidden */
  45131. export enum TextureAspect {
  45132. All = "all",
  45133. StencilOnly = "stencil-only",
  45134. DepthOnly = "depth-only"
  45135. }
  45136. /** @hidden */
  45137. export enum CompilationMessageType {
  45138. Error = "error",
  45139. Warning = "warning",
  45140. Info = "info"
  45141. }
  45142. /** @hidden */
  45143. export enum QueryType {
  45144. Occlusion = "occlusion"
  45145. }
  45146. /** @hidden */
  45147. export enum BufferUsage {
  45148. MapRead = 1,
  45149. MapWrite = 2,
  45150. CopySrc = 4,
  45151. CopyDst = 8,
  45152. Index = 16,
  45153. Vertex = 32,
  45154. Uniform = 64,
  45155. Storage = 128,
  45156. Indirect = 256,
  45157. QueryResolve = 512
  45158. }
  45159. /** @hidden */
  45160. export enum ColorWrite {
  45161. Red = 1,
  45162. Green = 2,
  45163. Blue = 4,
  45164. Alpha = 8,
  45165. All = 15
  45166. }
  45167. /** @hidden */
  45168. export enum ShaderStage {
  45169. Vertex = 1,
  45170. Fragment = 2,
  45171. Compute = 4
  45172. }
  45173. /** @hidden */
  45174. export enum TextureUsage {
  45175. CopySrc = 1,
  45176. CopyDst = 2,
  45177. Sampled = 4,
  45178. Storage = 8,
  45179. OutputAttachment = 16
  45180. }
  45181. /** @hidden */
  45182. export enum MapMode {
  45183. Read = 1,
  45184. Write = 2
  45185. }
  45186. }
  45187. declare module BABYLON {
  45188. /** @hidden */
  45189. export interface WebGPUBindingInfo {
  45190. setIndex: number;
  45191. bindingIndex: number;
  45192. }
  45193. /** @hidden */
  45194. export interface WebGPUTextureSamplerBindingDescription {
  45195. sampler: WebGPUBindingInfo;
  45196. isTextureArray: boolean;
  45197. textures: Array<WebGPUBindingInfo>;
  45198. }
  45199. /** @hidden
  45200. * If the binding is a UBO, isSampler=isTexture=false
  45201. */
  45202. export interface WebGPUBindingDescription {
  45203. name: string;
  45204. usedInVertex: boolean;
  45205. usedInFragment: boolean;
  45206. isSampler: boolean;
  45207. isComparisonSampler?: boolean;
  45208. isTexture: boolean;
  45209. componentType?: GPUTextureComponentType;
  45210. textureDimension?: GPUTextureViewDimension;
  45211. }
  45212. /**
  45213. * @hidden
  45214. */
  45215. export class WebGPUShaderProcessingContext implements ShaderProcessingContext {
  45216. uboNextBindingIndex: number;
  45217. freeSetIndex: number;
  45218. freeBindingIndex: number;
  45219. availableVaryings: {
  45220. [key: string]: number;
  45221. };
  45222. availableAttributes: {
  45223. [key: string]: number;
  45224. };
  45225. availableUBOs: {
  45226. [key: string]: {
  45227. setIndex: number;
  45228. bindingIndex: number;
  45229. };
  45230. };
  45231. availableSamplers: {
  45232. [key: string]: WebGPUTextureSamplerBindingDescription;
  45233. };
  45234. leftOverUniforms: {
  45235. name: string;
  45236. type: string;
  45237. length: number;
  45238. }[];
  45239. orderedAttributes: string[];
  45240. orderedUBOsAndSamplers: WebGPUBindingDescription[][];
  45241. uniformBufferNames: string[];
  45242. attributeNamesFromEffect: string[];
  45243. attributeLocationsFromEffect: number[];
  45244. private _attributeNextLocation;
  45245. private _varyingNextLocation;
  45246. constructor();
  45247. getAttributeNextLocation(dataType: string, arrayLength?: number): number;
  45248. getVaryingNextLocation(dataType: string, arrayLength?: number): number;
  45249. getNextFreeUBOBinding(): {
  45250. setIndex: number;
  45251. bindingIndex: number;
  45252. };
  45253. private _getNextFreeBinding;
  45254. }
  45255. }
  45256. declare module BABYLON {
  45257. /** @hidden */
  45258. export interface IWebGPUPipelineContextSamplerCache {
  45259. samplerBinding: number;
  45260. firstTextureName: string;
  45261. }
  45262. /** @hidden */
  45263. export interface IWebGPUPipelineContextTextureCache {
  45264. textureBinding: number;
  45265. texture: InternalTexture;
  45266. }
  45267. /** @hidden */
  45268. export interface IWebGPUPipelineContextVertexInputsCache {
  45269. indexBuffer: Nullable<GPUBuffer>;
  45270. indexOffset: number;
  45271. vertexStartSlot: number;
  45272. vertexBuffers: GPUBuffer[];
  45273. vertexOffsets: number[];
  45274. }
  45275. /** @hidden */
  45276. export interface IWebGPURenderPipelineStageDescriptor {
  45277. vertexStage: GPUProgrammableStageDescriptor;
  45278. fragmentStage?: GPUProgrammableStageDescriptor;
  45279. }
  45280. /** @hidden */
  45281. export class WebGPUBindGroupCacheNode {
  45282. values: {
  45283. [id: number]: WebGPUBindGroupCacheNode;
  45284. };
  45285. bindGroups: GPUBindGroup[];
  45286. constructor();
  45287. }
  45288. /** @hidden */
  45289. export class WebGPUPipelineContext implements IPipelineContext {
  45290. engine: WebGPUEngine;
  45291. shaderProcessingContext: WebGPUShaderProcessingContext;
  45292. leftOverUniformsByName: {
  45293. [name: string]: string;
  45294. };
  45295. sources: {
  45296. vertex: string;
  45297. fragment: string;
  45298. rawVertex: string;
  45299. rawFragment: string;
  45300. };
  45301. stages: Nullable<IWebGPURenderPipelineStageDescriptor>;
  45302. samplers: {
  45303. [name: string]: Nullable<IWebGPUPipelineContextSamplerCache>;
  45304. };
  45305. textures: {
  45306. [name: string]: Nullable<IWebGPUPipelineContextTextureCache>;
  45307. };
  45308. bindGroupLayouts: GPUBindGroupLayout[];
  45309. bindGroupsCache: WebGPUBindGroupCacheNode;
  45310. /**
  45311. * Stores the uniform buffer
  45312. */
  45313. uniformBuffer: Nullable<UniformBuffer>;
  45314. onCompiled?: () => void;
  45315. get isAsync(): boolean;
  45316. get isReady(): boolean;
  45317. /** @hidden */
  45318. _name: string;
  45319. constructor(shaderProcessingContext: WebGPUShaderProcessingContext, engine: WebGPUEngine);
  45320. _handlesSpectorRebuildCallback(onCompiled: (program: any) => void): void;
  45321. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  45322. [key: string]: number;
  45323. }, uniformsNames: string[], uniforms: {
  45324. [key: string]: Nullable<WebGLUniformLocation>;
  45325. }, samplerList: string[], samplers: {
  45326. [key: string]: number;
  45327. }, attributesNames: string[], attributes: number[]): void;
  45328. /** @hidden */
  45329. /**
  45330. * Build the uniform buffer used in the material.
  45331. */
  45332. buildUniformLayout(): void;
  45333. /**
  45334. * Release all associated resources.
  45335. **/
  45336. dispose(): void;
  45337. /**
  45338. * Sets an integer value on a uniform variable.
  45339. * @param uniformName Name of the variable.
  45340. * @param value Value to be set.
  45341. */
  45342. setInt(uniformName: string, value: number): void;
  45343. /**
  45344. * Sets an int2 value on a uniform variable.
  45345. * @param uniformName Name of the variable.
  45346. * @param x First int in int2.
  45347. * @param y Second int in int2.
  45348. */
  45349. setInt2(uniformName: string, x: number, y: number): void;
  45350. /**
  45351. * Sets an int3 value on a uniform variable.
  45352. * @param uniformName Name of the variable.
  45353. * @param x First int in int3.
  45354. * @param y Second int in int3.
  45355. * @param z Third int in int3.
  45356. */
  45357. setInt3(uniformName: string, x: number, y: number, z: number): void;
  45358. /**
  45359. * Sets an int4 value on a uniform variable.
  45360. * @param uniformName Name of the variable.
  45361. * @param x First int in int4.
  45362. * @param y Second int in int4.
  45363. * @param z Third int in int4.
  45364. * @param w Fourth int in int4.
  45365. */
  45366. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  45367. /**
  45368. * Sets an int array on a uniform variable.
  45369. * @param uniformName Name of the variable.
  45370. * @param array array to be set.
  45371. */
  45372. setIntArray(uniformName: string, array: Int32Array): void;
  45373. /**
  45374. * 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)
  45375. * @param uniformName Name of the variable.
  45376. * @param array array to be set.
  45377. */
  45378. setIntArray2(uniformName: string, array: Int32Array): void;
  45379. /**
  45380. * 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)
  45381. * @param uniformName Name of the variable.
  45382. * @param array array to be set.
  45383. */
  45384. setIntArray3(uniformName: string, array: Int32Array): void;
  45385. /**
  45386. * 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)
  45387. * @param uniformName Name of the variable.
  45388. * @param array array to be set.
  45389. */
  45390. setIntArray4(uniformName: string, array: Int32Array): void;
  45391. /**
  45392. * Sets an array on a uniform variable.
  45393. * @param uniformName Name of the variable.
  45394. * @param array array to be set.
  45395. */
  45396. setArray(uniformName: string, array: number[]): void;
  45397. /**
  45398. * 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)
  45399. * @param uniformName Name of the variable.
  45400. * @param array array to be set.
  45401. */
  45402. setArray2(uniformName: string, array: number[]): void;
  45403. /**
  45404. * 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)
  45405. * @param uniformName Name of the variable.
  45406. * @param array array to be set.
  45407. * @returns this effect.
  45408. */
  45409. setArray3(uniformName: string, array: number[]): void;
  45410. /**
  45411. * 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)
  45412. * @param uniformName Name of the variable.
  45413. * @param array array to be set.
  45414. */
  45415. setArray4(uniformName: string, array: number[]): void;
  45416. /**
  45417. * Sets matrices on a uniform variable.
  45418. * @param uniformName Name of the variable.
  45419. * @param matrices matrices to be set.
  45420. */
  45421. setMatrices(uniformName: string, matrices: Float32Array): void;
  45422. /**
  45423. * Sets matrix on a uniform variable.
  45424. * @param uniformName Name of the variable.
  45425. * @param matrix matrix to be set.
  45426. */
  45427. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  45428. /**
  45429. * 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)
  45430. * @param uniformName Name of the variable.
  45431. * @param matrix matrix to be set.
  45432. */
  45433. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  45434. /**
  45435. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  45436. * @param uniformName Name of the variable.
  45437. * @param matrix matrix to be set.
  45438. */
  45439. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  45440. /**
  45441. * Sets a float on a uniform variable.
  45442. * @param uniformName Name of the variable.
  45443. * @param value value to be set.
  45444. * @returns this effect.
  45445. */
  45446. setFloat(uniformName: string, value: number): void;
  45447. /**
  45448. * Sets a Vector2 on a uniform variable.
  45449. * @param uniformName Name of the variable.
  45450. * @param vector2 vector2 to be set.
  45451. */
  45452. setVector2(uniformName: string, vector2: IVector2Like): void;
  45453. /**
  45454. * Sets a float2 on a uniform variable.
  45455. * @param uniformName Name of the variable.
  45456. * @param x First float in float2.
  45457. * @param y Second float in float2.
  45458. */
  45459. setFloat2(uniformName: string, x: number, y: number): void;
  45460. /**
  45461. * Sets a Vector3 on a uniform variable.
  45462. * @param uniformName Name of the variable.
  45463. * @param vector3 Value to be set.
  45464. */
  45465. setVector3(uniformName: string, vector3: IVector3Like): void;
  45466. /**
  45467. * Sets a float3 on a uniform variable.
  45468. * @param uniformName Name of the variable.
  45469. * @param x First float in float3.
  45470. * @param y Second float in float3.
  45471. * @param z Third float in float3.
  45472. */
  45473. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  45474. /**
  45475. * Sets a Vector4 on a uniform variable.
  45476. * @param uniformName Name of the variable.
  45477. * @param vector4 Value to be set.
  45478. */
  45479. setVector4(uniformName: string, vector4: IVector4Like): void;
  45480. /**
  45481. * Sets a float4 on a uniform variable.
  45482. * @param uniformName Name of the variable.
  45483. * @param x First float in float4.
  45484. * @param y Second float in float4.
  45485. * @param z Third float in float4.
  45486. * @param w Fourth float in float4.
  45487. * @returns this effect.
  45488. */
  45489. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  45490. /**
  45491. * Sets a Color3 on a uniform variable.
  45492. * @param uniformName Name of the variable.
  45493. * @param color3 Value to be set.
  45494. */
  45495. setColor3(uniformName: string, color3: IColor3Like): void;
  45496. /**
  45497. * Sets a Color4 on a uniform variable.
  45498. * @param uniformName Name of the variable.
  45499. * @param color3 Value to be set.
  45500. * @param alpha Alpha value to be set.
  45501. */
  45502. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  45503. /**
  45504. * Sets a Color4 on a uniform variable
  45505. * @param uniformName defines the name of the variable
  45506. * @param color4 defines the value to be set
  45507. */
  45508. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  45509. _getVertexShaderCode(): string | null;
  45510. _getFragmentShaderCode(): string | null;
  45511. }
  45512. }
  45513. declare module BABYLON {
  45514. /** @hidden */
  45515. export class WebGPUDataBuffer extends DataBuffer {
  45516. private _buffer;
  45517. constructor(resource: GPUBuffer);
  45518. get underlyingResource(): any;
  45519. }
  45520. }
  45521. declare module BABYLON {
  45522. /**
  45523. * Class used to inline functions in shader code
  45524. */
  45525. export class ShaderCodeInliner {
  45526. private static readonly _RegexpFindFunctionNameAndType;
  45527. private _sourceCode;
  45528. private _functionDescr;
  45529. private _numMaxIterations;
  45530. /** Gets or sets the token used to mark the functions to inline */
  45531. inlineToken: string;
  45532. /** Gets or sets the debug mode */
  45533. debug: boolean;
  45534. /** Gets the code after the inlining process */
  45535. get code(): string;
  45536. /**
  45537. * Initializes the inliner
  45538. * @param sourceCode shader code source to inline
  45539. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  45540. */
  45541. constructor(sourceCode: string, numMaxIterations?: number);
  45542. /**
  45543. * Start the processing of the shader code
  45544. */
  45545. processCode(): void;
  45546. private _collectFunctions;
  45547. private _processInlining;
  45548. private _extractBetweenMarkers;
  45549. private _skipWhitespaces;
  45550. private _isIdentifierChar;
  45551. private _removeComments;
  45552. private _replaceFunctionCallsByCode;
  45553. private _findBackward;
  45554. private _escapeRegExp;
  45555. private _replaceNames;
  45556. }
  45557. }
  45558. declare module BABYLON {
  45559. /** @hidden */
  45560. export class WebGPUShaderProcessor implements IShaderProcessor {
  45561. protected _missingVaryings: Array<string>;
  45562. protected _textureArrayProcessing: Array<string>;
  45563. protected _preProcessors: {
  45564. [key: string]: string;
  45565. };
  45566. private _getArraySize;
  45567. initializeShaders(processingContext: Nullable<ShaderProcessingContext>): void;
  45568. varyingProcessor(varying: string, isFragment: boolean, preProcessors: {
  45569. [key: string]: string;
  45570. }, processingContext: Nullable<ShaderProcessingContext>): string;
  45571. attributeProcessor(attribute: string, preProcessors: {
  45572. [key: string]: string;
  45573. }, processingContext: Nullable<ShaderProcessingContext>): string;
  45574. uniformProcessor(uniform: string, isFragment: boolean, preProcessors: {
  45575. [key: string]: string;
  45576. }, processingContext: Nullable<ShaderProcessingContext>): string;
  45577. uniformBufferProcessor(uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  45578. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  45579. private _applyTextureArrayProcessing;
  45580. finalizeShaders(vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>): {
  45581. vertexCode: string;
  45582. fragmentCode: string;
  45583. };
  45584. }
  45585. }
  45586. declare module BABYLON {
  45587. /** @hidden */
  45588. export class WebGPUBufferManager {
  45589. private _device;
  45590. private _deferredReleaseBuffers;
  45591. private static _IsGPUBuffer;
  45592. constructor(device: GPUDevice);
  45593. createRawBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags, mappedAtCreation?: boolean): GPUBuffer;
  45594. createBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags): DataBuffer;
  45595. setSubData(dataBuffer: WebGPUDataBuffer, dstByteOffset: number, src: ArrayBufferView, srcByteOffset?: number, byteLength?: number): void;
  45596. private _FromHalfFloat;
  45597. private _GetHalfFloatAsFloatRGBAArrayBuffer;
  45598. readDataFromBuffer(gpuBuffer: GPUBuffer, size: number, width: number, height: number, bytesPerRow: number, bytesPerRowAligned: number, floatFormat?: number, offset?: number, buffer?: Nullable<ArrayBufferView>, destroyBuffer?: boolean): Promise<ArrayBufferView>;
  45599. releaseBuffer(buffer: DataBuffer | GPUBuffer): boolean;
  45600. destroyDeferredBuffers(): void;
  45601. }
  45602. }
  45603. declare module BABYLON {
  45604. /** @hidden */
  45605. export class WebGPUHardwareTexture implements HardwareTextureWrapper {
  45606. private _webgpuTexture;
  45607. private _webgpuMSAATexture;
  45608. get underlyingResource(): Nullable<GPUTexture>;
  45609. get msaaTexture(): Nullable<GPUTexture>;
  45610. set msaaTexture(texture: Nullable<GPUTexture>);
  45611. view: Nullable<GPUTextureView>;
  45612. format: GPUTextureFormat;
  45613. textureUsages: number;
  45614. constructor(existingTexture?: Nullable<GPUTexture>);
  45615. set(hardwareTexture: GPUTexture): void;
  45616. setMSAATexture(hardwareTexture: GPUTexture): void;
  45617. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  45618. createView(descriptor?: GPUTextureViewDescriptor): void;
  45619. reset(): void;
  45620. release(): void;
  45621. }
  45622. }
  45623. declare module BABYLON {
  45624. /** @hidden */
  45625. export class WebGPUTextureHelper {
  45626. private _device;
  45627. private _glslang;
  45628. private _bufferManager;
  45629. private _mipmapSampler;
  45630. private _invertYPreMultiplyAlphaSampler;
  45631. private _pipelines;
  45632. private _compiledShaders;
  45633. private _deferredReleaseTextures;
  45634. private _commandEncoderForCreation;
  45635. static ComputeNumMipmapLevels(width: number, height: number): number;
  45636. constructor(device: GPUDevice, glslang: any, bufferManager: WebGPUBufferManager);
  45637. private _getPipeline;
  45638. private static _GetTextureTypeFromFormat;
  45639. private static _GetBlockInformationFromFormat;
  45640. private static _IsHardwareTexture;
  45641. private static _IsInternalTexture;
  45642. static GetCompareFunction(compareFunction: Nullable<number>): GPUCompareFunction;
  45643. static IsImageBitmap(imageBitmap: ImageBitmap | {
  45644. width: number;
  45645. height: number;
  45646. }): imageBitmap is ImageBitmap;
  45647. static IsImageBitmapArray(imageBitmap: ImageBitmap[] | {
  45648. width: number;
  45649. height: number;
  45650. }): imageBitmap is ImageBitmap[];
  45651. setCommandEncoder(encoder: GPUCommandEncoder): void;
  45652. static IsCompressedFormat(format: GPUTextureFormat): boolean;
  45653. static GetWebGPUTextureFormat(type: number, format: number): GPUTextureFormat;
  45654. invertYPreMultiplyAlpha(gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  45655. clear(format: GPUTextureFormat, color: IColor4Like, passEncoder: GPURenderPassEncoder): void;
  45656. createTexture(imageBitmap: ImageBitmap | {
  45657. width: number;
  45658. height: number;
  45659. layers: number;
  45660. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, is3D?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  45661. createCubeTexture(imageBitmaps: ImageBitmap[] | {
  45662. width: number;
  45663. height: number;
  45664. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  45665. generateCubeMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, commandEncoder?: GPUCommandEncoder): void;
  45666. generateMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  45667. createGPUTextureForInternalTexture(texture: InternalTexture, width?: number, height?: number, depth?: number): WebGPUHardwareTexture;
  45668. createMSAATexture(texture: InternalTexture, samples: number): void;
  45669. updateCubeTextures(imageBitmaps: ImageBitmap[] | Uint8Array[], gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, commandEncoder?: GPUCommandEncoder): void;
  45670. 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;
  45671. readPixels(texture: GPUTexture, x: number, y: number, width: number, height: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, buffer?: Nullable<ArrayBufferView>): Promise<ArrayBufferView>;
  45672. releaseTexture(texture: InternalTexture | GPUTexture): void;
  45673. destroyDeferredTextures(): void;
  45674. }
  45675. }
  45676. declare module BABYLON {
  45677. /** @hidden */
  45678. export class WebGPURenderPassWrapper {
  45679. renderPassDescriptor: Nullable<GPURenderPassDescriptor>;
  45680. renderPass: Nullable<GPURenderPassEncoder>;
  45681. colorAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  45682. depthAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  45683. colorAttachmentGPUTextures: WebGPUHardwareTexture[];
  45684. depthTextureFormat: GPUTextureFormat | undefined;
  45685. constructor();
  45686. reset(fullReset?: boolean): void;
  45687. }
  45688. }
  45689. declare module BABYLON {
  45690. /** @hidden */
  45691. export class WebGPUCacheSampler {
  45692. private _samplers;
  45693. private _device;
  45694. disabled: boolean;
  45695. constructor(device: GPUDevice);
  45696. private static _GetSamplerHashCode;
  45697. private static _GetSamplerFilterDescriptor;
  45698. private static _GetWrappingMode;
  45699. private static _GetSamplerWrappingDescriptor;
  45700. private static _GetSamplerDescriptor;
  45701. getSampler(internalTexture: InternalTexture, bypassCache?: boolean): GPUSampler;
  45702. }
  45703. }
  45704. declare module BABYLON {
  45705. /** @hidden */
  45706. export class WebGPUShaderManager {
  45707. private _shaders;
  45708. private _device;
  45709. constructor(device: GPUDevice);
  45710. getCompiledShaders(name: string): IWebGPURenderPipelineStageDescriptor;
  45711. }
  45712. }
  45713. declare module BABYLON {
  45714. /** @hidden */
  45715. export abstract class WebGPUCacheRenderPipeline {
  45716. static NumCacheHitWithoutHash: number;
  45717. static NumCacheHitWithHash: number;
  45718. static NumCacheMiss: number;
  45719. static NumPipelineCreationLastFrame: number;
  45720. disabled: boolean;
  45721. private static _NumPipelineCreationCurrentFrame;
  45722. protected _states: number[];
  45723. protected _stateDirtyLowestIndex: number;
  45724. lastStateDirtyLowestIndex: number;
  45725. private _device;
  45726. private _isDirty;
  45727. private _emptyVertexBuffer;
  45728. private _parameter;
  45729. private _shaderId;
  45730. private _alphaToCoverageEnabled;
  45731. private _frontFace;
  45732. private _cullEnabled;
  45733. private _cullFace;
  45734. private _clampDepth;
  45735. private _rasterizationState;
  45736. private _depthBias;
  45737. private _depthBiasClamp;
  45738. private _depthBiasSlopeScale;
  45739. private _colorFormat;
  45740. private _webgpuColorFormat;
  45741. private _mrtAttachments1;
  45742. private _mrtAttachments2;
  45743. private _mrtFormats;
  45744. private _alphaBlendEnabled;
  45745. private _alphaBlendFuncParams;
  45746. private _alphaBlendEqParams;
  45747. private _writeMask;
  45748. private _colorStates;
  45749. private _depthStencilFormat;
  45750. private _webgpuDepthStencilFormat;
  45751. private _depthTestEnabled;
  45752. private _depthWriteEnabled;
  45753. private _depthCompare;
  45754. private _stencilEnabled;
  45755. private _stencilFrontCompare;
  45756. private _stencilFrontDepthFailOp;
  45757. private _stencilFrontPassOp;
  45758. private _stencilFrontFailOp;
  45759. private _stencilReadMask;
  45760. private _stencilWriteMask;
  45761. private _depthStencilState;
  45762. private _vertexBuffers;
  45763. private _overrideVertexBuffers;
  45764. private _indexBuffer;
  45765. constructor(device: GPUDevice, emptyVertexBuffer: VertexBuffer);
  45766. reset(): void;
  45767. protected abstract _getRenderPipeline(param: {
  45768. token: any;
  45769. pipeline: Nullable<GPURenderPipeline>;
  45770. }): void;
  45771. protected abstract _setRenderPipeline(param: {
  45772. token: any;
  45773. pipeline: Nullable<GPURenderPipeline>;
  45774. }): void;
  45775. getRenderPipeline(fillMode: number, effect: Effect, sampleCount: number): GPURenderPipeline;
  45776. endFrame(): void;
  45777. setAlphaToCoverage(enabled: boolean): void;
  45778. setFrontFace(frontFace: number): void;
  45779. setCullEnabled(enabled: boolean): void;
  45780. setCullFace(cullFace: number): void;
  45781. setClampDepth(clampDepth: boolean): void;
  45782. resetDepthCullingState(): void;
  45783. setDepthCullingState(cullEnabled: boolean, frontFace: number, cullFace: number, zOffset: number, depthTestEnabled: boolean, depthWriteEnabled: boolean, depthCompare: Nullable<number>): void;
  45784. setDepthBiasSlopeScale(depthBiasSlopeScale: number): void;
  45785. setColorFormat(format: GPUTextureFormat): void;
  45786. setMRTAttachments(attachments: number[], textureArray: InternalTexture[]): void;
  45787. setAlphaBlendEnabled(enabled: boolean): void;
  45788. setAlphaBlendFactors(factors: Array<Nullable<number>>, operations: Array<Nullable<number>>): void;
  45789. setWriteMask(mask: number): void;
  45790. setDepthStencilFormat(format: GPUTextureFormat | undefined): void;
  45791. setDepthTestEnabled(enabled: boolean): void;
  45792. setDepthWriteEnabled(enabled: boolean): void;
  45793. setDepthCompare(func: Nullable<number>): void;
  45794. setStencilEnabled(enabled: boolean): void;
  45795. setStencilCompare(func: Nullable<number>): void;
  45796. setStencilDepthFailOp(op: Nullable<number>): void;
  45797. setStencilPassOp(op: Nullable<number>): void;
  45798. setStencilFailOp(op: Nullable<number>): void;
  45799. setStencilReadMask(mask: number): void;
  45800. setStencilWriteMask(mask: number): void;
  45801. resetStencilState(): void;
  45802. setStencilState(stencilEnabled: boolean, compare: Nullable<number>, depthFailOp: Nullable<number>, passOp: Nullable<number>, failOp: Nullable<number>, readMask: number, writeMask: number): void;
  45803. setBuffers(vertexBuffers: Nullable<{
  45804. [key: string]: Nullable<VertexBuffer>;
  45805. }>, indexBuffer: Nullable<DataBuffer>, overrideVertexBuffers: Nullable<{
  45806. [key: string]: Nullable<VertexBuffer>;
  45807. }>): void;
  45808. private static _GetTopology;
  45809. private static _GetAphaBlendOperation;
  45810. private static _GetAphaBlendFactor;
  45811. private static _GetCompareFunction;
  45812. private static _GetStencilOpFunction;
  45813. private static _GetVertexInputDescriptorFormat;
  45814. private _getAphaBlendState;
  45815. private _getColorBlendState;
  45816. private _setShaderStage;
  45817. private _setRasterizationState;
  45818. private _setColorStates;
  45819. private _setDepthStencilState;
  45820. private _setVertexState;
  45821. private _createPipelineLayout;
  45822. private _getVertexInputDescriptor;
  45823. private _createRenderPipeline;
  45824. }
  45825. }
  45826. declare module BABYLON {
  45827. /** @hidden */
  45828. class NodeState {
  45829. values: {
  45830. [name: number]: NodeState;
  45831. };
  45832. pipeline: GPURenderPipeline;
  45833. constructor();
  45834. count(): [number, number];
  45835. }
  45836. /** @hidden */
  45837. export class WebGPUCacheRenderPipelineTree extends WebGPUCacheRenderPipeline {
  45838. private static _Cache;
  45839. private _nodeStack;
  45840. static GetNodeCounts(): {
  45841. nodeCount: number;
  45842. pipelineCount: number;
  45843. };
  45844. constructor(device: GPUDevice, emptyVertexBuffer: VertexBuffer);
  45845. protected _getRenderPipeline(param: {
  45846. token: any;
  45847. pipeline: Nullable<GPURenderPipeline>;
  45848. }): void;
  45849. protected _setRenderPipeline(param: {
  45850. token: NodeState;
  45851. pipeline: Nullable<GPURenderPipeline>;
  45852. }): void;
  45853. }
  45854. }
  45855. declare module BABYLON {
  45856. /**
  45857. * @hidden
  45858. **/
  45859. export class WebGPUStencilState extends StencilState {
  45860. private _cache;
  45861. constructor(cache: WebGPUCacheRenderPipeline);
  45862. get stencilFunc(): number;
  45863. set stencilFunc(value: number);
  45864. get stencilFuncRef(): number;
  45865. set stencilFuncRef(value: number);
  45866. get stencilFuncMask(): number;
  45867. set stencilFuncMask(value: number);
  45868. get stencilOpStencilFail(): number;
  45869. set stencilOpStencilFail(value: number);
  45870. get stencilOpDepthFail(): number;
  45871. set stencilOpDepthFail(value: number);
  45872. get stencilOpStencilDepthPass(): number;
  45873. set stencilOpStencilDepthPass(value: number);
  45874. get stencilMask(): number;
  45875. set stencilMask(value: number);
  45876. get stencilTest(): boolean;
  45877. set stencilTest(value: boolean);
  45878. reset(): void;
  45879. apply(gl: WebGLRenderingContext): void;
  45880. }
  45881. }
  45882. declare module BABYLON {
  45883. /**
  45884. * @hidden
  45885. **/
  45886. export class WebGPUDepthCullingState extends DepthCullingState {
  45887. private _cache;
  45888. /**
  45889. * Initializes the state.
  45890. */
  45891. constructor(cache: WebGPUCacheRenderPipeline);
  45892. get zOffset(): number;
  45893. set zOffset(value: number);
  45894. get cullFace(): Nullable<number>;
  45895. set cullFace(value: Nullable<number>);
  45896. get cull(): Nullable<boolean>;
  45897. set cull(value: Nullable<boolean>);
  45898. get depthFunc(): Nullable<number>;
  45899. set depthFunc(value: Nullable<number>);
  45900. get depthMask(): boolean;
  45901. set depthMask(value: boolean);
  45902. get depthTest(): boolean;
  45903. set depthTest(value: boolean);
  45904. get frontFace(): Nullable<number>;
  45905. set frontFace(value: Nullable<number>);
  45906. reset(): void;
  45907. apply(gl: WebGLRenderingContext): void;
  45908. }
  45909. }
  45910. declare module BABYLON {
  45911. /** @hidden */
  45912. export var clearQuadVertexShader: {
  45913. name: string;
  45914. shader: string;
  45915. };
  45916. }
  45917. declare module BABYLON {
  45918. /** @hidden */
  45919. export var clearQuadPixelShader: {
  45920. name: string;
  45921. shader: string;
  45922. };
  45923. }
  45924. declare module BABYLON {
  45925. /**
  45926. * Options to load the associated Glslang library
  45927. */
  45928. export interface GlslangOptions {
  45929. /**
  45930. * Defines an existing instance of Glslang (useful in modules who do not access the global instance).
  45931. */
  45932. glslang?: any;
  45933. /**
  45934. * Defines the URL of the glslang JS File.
  45935. */
  45936. jsPath?: string;
  45937. /**
  45938. * Defines the URL of the glslang WASM File.
  45939. */
  45940. wasmPath?: string;
  45941. }
  45942. /**
  45943. * Options to create the WebGPU engine
  45944. */
  45945. export interface WebGPUEngineOptions extends GPURequestAdapterOptions {
  45946. /**
  45947. * If delta time between frames should be constant
  45948. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45949. */
  45950. deterministicLockstep?: boolean;
  45951. /**
  45952. * Maximum about of steps between frames (Default: 4)
  45953. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45954. */
  45955. lockstepMaxSteps?: number;
  45956. /**
  45957. * Defines the seconds between each deterministic lock step
  45958. */
  45959. timeStep?: number;
  45960. /**
  45961. * Defines that engine should ignore modifying touch action attribute and style
  45962. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  45963. */
  45964. doNotHandleTouchAction?: boolean;
  45965. /**
  45966. * Defines if webaudio should be initialized as well
  45967. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  45968. */
  45969. audioEngine?: boolean;
  45970. /**
  45971. * Defines the category of adapter to use.
  45972. * Is it the discrete or integrated device.
  45973. */
  45974. powerPreference?: GPUPowerPreference;
  45975. /**
  45976. * Defines the device descriptor used to create a device.
  45977. */
  45978. deviceDescriptor?: GPUDeviceDescriptor;
  45979. /**
  45980. * Defines the requested Swap Chain Format.
  45981. */
  45982. swapChainFormat?: GPUTextureFormat;
  45983. /**
  45984. * Defines whether MSAA is enabled on the canvas.
  45985. */
  45986. antialiasing?: boolean;
  45987. /**
  45988. * Defines whether the stencil buffer should be enabled.
  45989. */
  45990. stencil?: boolean;
  45991. /**
  45992. * Defines whether we should generate debug markers in the gpu command lists (can be seen with PIX for eg)
  45993. */
  45994. enableGPUDebugMarkers?: boolean;
  45995. /**
  45996. * Options to load the associated Glslang library
  45997. */
  45998. glslangOptions?: GlslangOptions;
  45999. }
  46000. /**
  46001. * The web GPU engine class provides support for WebGPU version of babylon.js.
  46002. */
  46003. export class WebGPUEngine extends Engine {
  46004. private static readonly _glslangDefaultOptions;
  46005. private readonly _uploadEncoderDescriptor;
  46006. private readonly _renderEncoderDescriptor;
  46007. private readonly _renderTargetEncoderDescriptor;
  46008. private readonly _clearDepthValue;
  46009. private readonly _clearReverseDepthValue;
  46010. private readonly _clearStencilValue;
  46011. private readonly _defaultSampleCount;
  46012. private _canvas;
  46013. private _options;
  46014. private _glslang;
  46015. private _adapter;
  46016. private _adapterSupportedExtensions;
  46017. private _device;
  46018. private _deviceEnabledExtensions;
  46019. private _context;
  46020. private _swapChain;
  46021. private _swapChainTexture;
  46022. private _mainPassSampleCount;
  46023. private _textureHelper;
  46024. private _bufferManager;
  46025. private _shaderManager;
  46026. private _cacheSampler;
  46027. private _cacheRenderPipeline;
  46028. private _emptyVertexBuffer;
  46029. private _lastCachedWrapU;
  46030. private _lastCachedWrapV;
  46031. private _lastCachedWrapR;
  46032. private _mrtAttachments;
  46033. private _counters;
  46034. private _mainTexture;
  46035. private _depthTexture;
  46036. private _mainTextureExtends;
  46037. private _depthTextureFormat;
  46038. private _colorFormat;
  46039. private _uploadEncoder;
  46040. private _renderEncoder;
  46041. private _renderTargetEncoder;
  46042. private _commandBuffers;
  46043. private _currentRenderPass;
  46044. private _mainRenderPassWrapper;
  46045. private _rttRenderPassWrapper;
  46046. private _pendingDebugCommands;
  46047. private _currentVertexBuffers;
  46048. private _currentOverrideVertexBuffers;
  46049. private _currentIndexBuffer;
  46050. private __colorWrite;
  46051. private _uniformsBuffers;
  46052. private _forceEnableEffect;
  46053. /** @hidden */
  46054. dbgShowShaderCode: boolean;
  46055. /** @hidden */
  46056. dbgSanityChecks: boolean;
  46057. /** @hidden */
  46058. dbgGenerateLogs: boolean;
  46059. /** @hidden */
  46060. dbgVerboseLogsForFirstFrames: boolean;
  46061. /** @hidden */
  46062. dbgVerboseLogsNumFrames: number;
  46063. /**
  46064. * Sets this to true to disable the cache for the samplers. You should do it only for testing purpose!
  46065. */
  46066. get disableCacheSamplers(): boolean;
  46067. set disableCacheSamplers(disable: boolean);
  46068. /**
  46069. * Sets this to true to disable the cache for the render pipelines. You should do it only for testing purpose!
  46070. */
  46071. get disableCacheRenderPipelines(): boolean;
  46072. set disableCacheRenderPipelines(disable: boolean);
  46073. /**
  46074. * Gets a boolean indicating if the engine can be instantiated (ie. if a WebGPU context can be found)
  46075. * @returns true if the engine can be created
  46076. */
  46077. static get IsSupported(): boolean;
  46078. /**
  46079. * Gets a boolean indicating that the engine supports uniform buffers
  46080. */
  46081. get supportsUniformBuffers(): boolean;
  46082. /** Gets the supported extensions by the WebGPU adapter */
  46083. get supportedExtensions(): Immutable<GPUExtensionName[]>;
  46084. /** Gets the currently enabled extensions on the WebGPU device */
  46085. get enabledExtensions(): Immutable<GPUExtensionName[]>;
  46086. /**
  46087. * Returns the name of the engine
  46088. */
  46089. get name(): string;
  46090. /**
  46091. * Returns a string describing the current engine
  46092. */
  46093. get description(): string;
  46094. /**
  46095. * Returns the version of the engine
  46096. */
  46097. get version(): number;
  46098. /**
  46099. * Create a new instance of the gpu engine asynchronously
  46100. * @param canvas Defines the canvas to use to display the result
  46101. * @param options Defines the options passed to the engine to create the GPU context dependencies
  46102. * @returns a promise that resolves with the created engine
  46103. */
  46104. static CreateAsync(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions): Promise<WebGPUEngine>;
  46105. /**
  46106. * Create a new instance of the gpu engine.
  46107. * @param canvas Defines the canvas to use to display the result
  46108. * @param options Defines the options passed to the engine to create the GPU context dependencies
  46109. */
  46110. constructor(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions);
  46111. /**
  46112. * Initializes the WebGPU context and dependencies.
  46113. * @param glslangOptions Defines the GLSLang compiler options if necessary
  46114. * @returns a promise notifying the readiness of the engine.
  46115. */
  46116. initAsync(glslangOptions?: GlslangOptions): Promise<void>;
  46117. private _initGlslang;
  46118. private _initializeLimits;
  46119. private _initializeContextAndSwapChain;
  46120. private _initializeMainAttachments;
  46121. /**
  46122. * Force a specific size of the canvas
  46123. * @param width defines the new canvas' width
  46124. * @param height defines the new canvas' height
  46125. * @param forceSetSize true to force setting the sizes of the underlying canvas
  46126. * @returns true if the size was changed
  46127. */
  46128. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  46129. /**
  46130. * Gets a shader processor implementation fitting with the current engine type.
  46131. * @returns The shader processor implementation.
  46132. */
  46133. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  46134. /** @hidden */
  46135. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  46136. /**
  46137. * Force the entire cache to be cleared
  46138. * You should not have to use this function unless your engine needs to share the WebGPU context with another engine
  46139. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46140. */
  46141. wipeCaches(bruteForce?: boolean): void;
  46142. /**
  46143. * Enable or disable color writing
  46144. * @param enable defines the state to set
  46145. */
  46146. setColorWrite(enable: boolean): void;
  46147. /**
  46148. * Gets a boolean indicating if color writing is enabled
  46149. * @returns the current color writing state
  46150. */
  46151. getColorWrite(): boolean;
  46152. private _viewportsCurrent;
  46153. private _resetCurrentViewport;
  46154. private _applyViewport;
  46155. /** @hidden */
  46156. _viewport(x: number, y: number, width: number, height: number): void;
  46157. private _scissorsCurrent;
  46158. protected _scissorCached: {
  46159. x: number;
  46160. y: number;
  46161. z: number;
  46162. w: number;
  46163. };
  46164. private _resetCurrentScissor;
  46165. private _applyScissor;
  46166. private _scissorIsActive;
  46167. enableScissor(x: number, y: number, width: number, height: number): void;
  46168. disableScissor(): void;
  46169. /**
  46170. * Clear the current render buffer or the current render target (if any is set up)
  46171. * @param color defines the color to use
  46172. * @param backBuffer defines if the back buffer must be cleared
  46173. * @param depth defines if the depth buffer must be cleared
  46174. * @param stencil defines if the stencil buffer must be cleared
  46175. */
  46176. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46177. /**
  46178. * Clears a list of attachments
  46179. * @param attachments list of the attachments
  46180. * @param colorMain clear color for the main attachment (the first one)
  46181. * @param colorOthers clear color for the other attachments
  46182. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  46183. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  46184. */
  46185. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  46186. /**
  46187. * Creates a vertex buffer
  46188. * @param data the data for the vertex buffer
  46189. * @returns the new buffer
  46190. */
  46191. createVertexBuffer(data: DataArray): DataBuffer;
  46192. /**
  46193. * Creates a vertex buffer
  46194. * @param data the data for the dynamic vertex buffer
  46195. * @returns the new buffer
  46196. */
  46197. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46198. /**
  46199. * Updates a vertex buffer.
  46200. * @param vertexBuffer the vertex buffer to update
  46201. * @param data the data used to update the vertex buffer
  46202. * @param byteOffset the byte offset of the data
  46203. * @param byteLength the byte length of the data
  46204. */
  46205. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46206. /**
  46207. * Creates a new index buffer
  46208. * @param indices defines the content of the index buffer
  46209. * @param updatable defines if the index buffer must be updatable - not used in WebGPU
  46210. * @returns a new buffer
  46211. */
  46212. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  46213. /**
  46214. * Update an index buffer
  46215. * @param indexBuffer defines the target index buffer
  46216. * @param indices defines the data to update
  46217. * @param offset defines the offset in the target index buffer where update should start
  46218. */
  46219. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46220. /** @hidden */
  46221. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  46222. /** @hidden */
  46223. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  46224. /**
  46225. * Bind a list of vertex buffers with the engine
  46226. * @param vertexBuffers defines the list of vertex buffers to bind
  46227. * @param indexBuffer defines the index buffer to bind
  46228. * @param effect defines the effect associated with the vertex buffers
  46229. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  46230. */
  46231. bindBuffers(vertexBuffers: {
  46232. [key: string]: Nullable<VertexBuffer>;
  46233. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  46234. [kind: string]: Nullable<VertexBuffer>;
  46235. }): void;
  46236. /** @hidden */
  46237. _releaseBuffer(buffer: DataBuffer): boolean;
  46238. createUniformBuffer(elements: FloatArray): DataBuffer;
  46239. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  46240. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  46241. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  46242. /**
  46243. * Create a new effect (used to store vertex/fragment shaders)
  46244. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  46245. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  46246. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  46247. * @param samplers defines an array of string used to represent textures
  46248. * @param defines defines the string containing the defines to use to compile the shaders
  46249. * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails
  46250. * @param onCompiled defines a function to call when the effect creation is successful
  46251. * @param onError defines a function to call when the effect creation has failed
  46252. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  46253. * @returns the new Effect
  46254. */
  46255. 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;
  46256. private _compileRawShaderToSpirV;
  46257. private _compileShaderToSpirV;
  46258. private _createPipelineStageDescriptor;
  46259. private _compileRawPipelineStageDescriptor;
  46260. private _compilePipelineStageDescriptor;
  46261. /** @hidden */
  46262. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  46263. /** @hidden */
  46264. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  46265. /**
  46266. * Creates a new pipeline context
  46267. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  46268. * @returns the new pipeline
  46269. */
  46270. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  46271. /** @hidden */
  46272. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  46273. /**
  46274. * Gets the list of active attributes for a given WebGPU program
  46275. * @param pipelineContext defines the pipeline context to use
  46276. * @param attributesNames defines the list of attribute names to get
  46277. * @returns an array of indices indicating the offset of each attribute
  46278. */
  46279. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46280. /**
  46281. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46282. * @param effect defines the effect to activate
  46283. */
  46284. enableEffect(effect: Nullable<Effect>): void;
  46285. /** @hidden */
  46286. _releaseEffect(effect: Effect): void;
  46287. /**
  46288. * 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
  46289. */
  46290. releaseEffects(): void;
  46291. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46292. /**
  46293. * Gets a boolean indicating that only power of 2 textures are supported
  46294. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  46295. */
  46296. get needPOTTextures(): boolean;
  46297. /** @hidden */
  46298. _createHardwareTexture(): HardwareTextureWrapper;
  46299. /** @hidden */
  46300. _releaseTexture(texture: InternalTexture): void;
  46301. /** @hidden */
  46302. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  46303. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  46304. /**
  46305. * Usually called from Texture.ts.
  46306. * Passed information to create a hardware texture
  46307. * @param url defines a value which contains one of the following:
  46308. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46309. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46310. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46311. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46312. * @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)
  46313. * @param scene needed for loading to the correct scene
  46314. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46315. * @param onLoad optional callback to be called upon successful completion
  46316. * @param onError optional callback to be called upon failure
  46317. * @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
  46318. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46319. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46320. * @param forcedExtension defines the extension to use to pick the right loader
  46321. * @param mimeType defines an optional mime type
  46322. * @param loaderOptions options to be passed to the loader
  46323. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46324. */
  46325. 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;
  46326. /** @hidden */
  46327. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  46328. /**
  46329. * Creates a cube texture
  46330. * @param rootUrl defines the url where the files to load is located
  46331. * @param scene defines the current scene
  46332. * @param files defines the list of files to load (1 per face)
  46333. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46334. * @param onLoad defines an optional callback raised when the texture is loaded
  46335. * @param onError defines an optional callback raised if there is an issue to load the texture
  46336. * @param format defines the format of the data
  46337. * @param forcedExtension defines the extension to use to pick the right loader
  46338. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46339. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46340. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46341. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46342. * @param loaderOptions options to be passed to the loader
  46343. * @returns the cube texture as an InternalTexture
  46344. */
  46345. 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;
  46346. /**
  46347. * Creates a raw texture
  46348. * @param data defines the data to store in the texture
  46349. * @param width defines the width of the texture
  46350. * @param height defines the height of the texture
  46351. * @param format defines the format of the data
  46352. * @param generateMipMaps defines if the engine should generate the mip levels
  46353. * @param invertY defines if data must be stored with Y axis inverted
  46354. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  46355. * @param compression defines the compression used (null by default)
  46356. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  46357. * @returns the raw texture inside an InternalTexture
  46358. */
  46359. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  46360. /**
  46361. * Creates a new raw cube texture
  46362. * @param data defines the array of data to use to create each face
  46363. * @param size defines the size of the textures
  46364. * @param format defines the format of the data
  46365. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  46366. * @param generateMipMaps defines if the engine should generate the mip levels
  46367. * @param invertY defines if data must be stored with Y axis inverted
  46368. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  46369. * @param compression defines the compression used (null by default)
  46370. * @returns the cube texture as an InternalTexture
  46371. */
  46372. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  46373. /**
  46374. * Creates a new raw cube texture from a specified url
  46375. * @param url defines the url where the data is located
  46376. * @param scene defines the current scene
  46377. * @param size defines the size of the textures
  46378. * @param format defines the format of the data
  46379. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  46380. * @param noMipmap defines if the engine should avoid generating the mip levels
  46381. * @param callback defines a callback used to extract texture data from loaded data
  46382. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  46383. * @param onLoad defines a callback called when texture is loaded
  46384. * @param onError defines a callback called if there is an error
  46385. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  46386. * @param invertY defines if data must be stored with Y axis inverted
  46387. * @returns the cube texture as an InternalTexture
  46388. */
  46389. 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;
  46390. /**
  46391. * Creates a new raw 2D array texture
  46392. * @param data defines the data used to create the texture
  46393. * @param width defines the width of the texture
  46394. * @param height defines the height of the texture
  46395. * @param depth defines the number of layers of the texture
  46396. * @param format defines the format of the texture
  46397. * @param generateMipMaps defines if the engine must generate mip levels
  46398. * @param invertY defines if data must be stored with Y axis inverted
  46399. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  46400. * @param compression defines the compressed used (can be null)
  46401. * @param textureType defines the compressed used (can be null)
  46402. * @returns a new raw 2D array texture (stored in an InternalTexture)
  46403. */
  46404. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  46405. /**
  46406. * Creates a new raw 3D texture
  46407. * @param data defines the data used to create the texture
  46408. * @param width defines the width of the texture
  46409. * @param height defines the height of the texture
  46410. * @param depth defines the depth of the texture
  46411. * @param format defines the format of the texture
  46412. * @param generateMipMaps defines if the engine must generate mip levels
  46413. * @param invertY defines if data must be stored with Y axis inverted
  46414. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  46415. * @param compression defines the compressed used (can be null)
  46416. * @param textureType defines the compressed used (can be null)
  46417. * @returns a new raw 3D texture (stored in an InternalTexture)
  46418. */
  46419. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  46420. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  46421. /**
  46422. * Update the sampling mode of a given texture
  46423. * @param samplingMode defines the required sampling mode
  46424. * @param texture defines the texture to update
  46425. * @param generateMipMaps defines whether to generate mipmaps for the texture
  46426. */
  46427. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  46428. /**
  46429. * Update the sampling mode of a given texture
  46430. * @param texture defines the texture to update
  46431. * @param wrapU defines the texture wrap mode of the u coordinates
  46432. * @param wrapV defines the texture wrap mode of the v coordinates
  46433. * @param wrapR defines the texture wrap mode of the r coordinates
  46434. */
  46435. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  46436. /**
  46437. * Update the dimensions of a texture
  46438. * @param texture texture to update
  46439. * @param width new width of the texture
  46440. * @param height new height of the texture
  46441. * @param depth new depth of the texture
  46442. */
  46443. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  46444. private _setInternalTexture;
  46445. /**
  46446. * Sets a texture to the according uniform.
  46447. * @param channel The texture channel
  46448. * @param unused unused parameter
  46449. * @param texture The texture to apply
  46450. * @param name The name of the uniform in the effect
  46451. */
  46452. setTexture(channel: number, unused: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>, name: string): void;
  46453. /**
  46454. * Sets an array of texture to the WebGPU context
  46455. * @param channel defines the channel where the texture array must be set
  46456. * @param unused unused parameter
  46457. * @param textures defines the array of textures to bind
  46458. * @param name name of the channel
  46459. */
  46460. setTextureArray(channel: number, unused: Nullable<WebGLUniformLocation>, textures: BaseTexture[], name: string): void;
  46461. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string, baseName?: string, textureIndex?: number): boolean;
  46462. /** @hidden */
  46463. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  46464. /** @hidden */
  46465. _bindTexture(channel: number, texture: InternalTexture, name: string): void;
  46466. private _generateMipmaps;
  46467. /**
  46468. * Update the content of a texture
  46469. * @param texture defines the texture to update
  46470. * @param canvas defines the source containing the data
  46471. * @param invertY defines if data must be stored with Y axis inverted
  46472. * @param premulAlpha defines if alpha is stored as premultiplied
  46473. * @param format defines the format of the data
  46474. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46475. */
  46476. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  46477. /**
  46478. * Update a portion of an internal texture
  46479. * @param texture defines the texture to update
  46480. * @param imageData defines the data to store into the texture
  46481. * @param xOffset defines the x coordinates of the update rectangle
  46482. * @param yOffset defines the y coordinates of the update rectangle
  46483. * @param width defines the width of the update rectangle
  46484. * @param height defines the height of the update rectangle
  46485. * @param faceIndex defines the face index if texture is a cube (0 by default)
  46486. * @param lod defines the lod level to update (0 by default)
  46487. */
  46488. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  46489. /**
  46490. * Update a video texture
  46491. * @param texture defines the texture to update
  46492. * @param video defines the video element to use
  46493. * @param invertY defines if data must be stored with Y axis inverted
  46494. */
  46495. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  46496. /** @hidden */
  46497. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46498. /** @hidden */
  46499. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  46500. /** @hidden */
  46501. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46502. /** @hidden */
  46503. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  46504. /**
  46505. * Update a raw texture
  46506. * @param texture defines the texture to update
  46507. * @param bufferView defines the data to store in the texture
  46508. * @param format defines the format of the data
  46509. * @param invertY defines if data must be stored with Y axis inverted
  46510. * @param compression defines the compression used (null by default)
  46511. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  46512. */
  46513. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  46514. /**
  46515. * Update a raw cube texture
  46516. * @param texture defines the texture to update
  46517. * @param bufferView defines the data to store
  46518. * @param format defines the data format
  46519. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  46520. * @param invertY defines if data must be stored with Y axis inverted
  46521. * @param compression defines the compression used (null by default)
  46522. * @param level defines which level of the texture to update
  46523. */
  46524. updateRawCubeTexture(texture: InternalTexture, bufferView: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  46525. /**
  46526. * Update a raw 2D array texture
  46527. * @param texture defines the texture to update
  46528. * @param bufferView defines the data to store
  46529. * @param format defines the data format
  46530. * @param invertY defines if data must be stored with Y axis inverted
  46531. * @param compression defines the used compression (can be null)
  46532. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  46533. */
  46534. updateRawTexture2DArray(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  46535. /**
  46536. * Update a raw 3D texture
  46537. * @param texture defines the texture to update
  46538. * @param bufferView defines the data to store
  46539. * @param format defines the data format
  46540. * @param invertY defines if data must be stored with Y axis inverted
  46541. * @param compression defines the used compression (can be null)
  46542. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  46543. */
  46544. updateRawTexture3D(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  46545. /**
  46546. * Reads pixels from the current frame buffer. Please note that this function can be slow
  46547. * @param x defines the x coordinate of the rectangle where pixels must be read
  46548. * @param y defines the y coordinate of the rectangle where pixels must be read
  46549. * @param width defines the width of the rectangle where pixels must be read
  46550. * @param height defines the height of the rectangle where pixels must be read
  46551. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  46552. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  46553. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  46554. */
  46555. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  46556. /** @hidden */
  46557. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  46558. /** @hidden */
  46559. _readTexturePixelsSync(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): ArrayBufferView;
  46560. /**
  46561. * Creates a new render target texture
  46562. * @param size defines the size of the texture
  46563. * @param options defines the options used to create the texture
  46564. * @returns a new render target texture stored in an InternalTexture
  46565. */
  46566. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46567. /**
  46568. * Create a multi render target texture
  46569. * @param size defines the size of the texture
  46570. * @param options defines the creation options
  46571. * @returns the cube texture as an InternalTexture
  46572. */
  46573. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46574. /**
  46575. * Creates a new render target cube texture
  46576. * @param size defines the size of the texture
  46577. * @param options defines the options used to create the texture
  46578. * @returns a new render target cube texture stored in an InternalTexture
  46579. */
  46580. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  46581. /** @hidden */
  46582. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  46583. width: number;
  46584. height: number;
  46585. layers?: number;
  46586. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  46587. /** @hidden */
  46588. _createDepthStencilTexture(size: number | {
  46589. width: number;
  46590. height: number;
  46591. layers?: number;
  46592. }, options: DepthTextureCreationOptions): InternalTexture;
  46593. /** @hidden */
  46594. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  46595. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  46596. /**
  46597. * Update the sample count for a given multiple render target texture
  46598. * @param textures defines the textures to update
  46599. * @param samples defines the sample count to set
  46600. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46601. */
  46602. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46603. /**
  46604. * Begin a new frame
  46605. */
  46606. beginFrame(): void;
  46607. /**
  46608. * End the current frame
  46609. */
  46610. endFrame(): void;
  46611. /**
  46612. * Force a WebGPU flush (ie. a flush of all waiting commands)
  46613. */
  46614. flushFramebuffer(): void;
  46615. private _startRenderTargetRenderPass;
  46616. private _endRenderTargetRenderPass;
  46617. private _getCurrentRenderPass;
  46618. private _startMainRenderPass;
  46619. private _endMainRenderPass;
  46620. /**
  46621. * Restores the WebGPU state to only draw on the main color attachment
  46622. */
  46623. restoreSingleAttachment(): void;
  46624. /**
  46625. * Creates a layout object to draw/clear on specific textures in a MRT
  46626. * @param textureStatus textureStatus[i] indicates if the i-th is active
  46627. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  46628. */
  46629. buildTextureLayout(textureStatus: boolean[]): number[];
  46630. /**
  46631. * Select a subsets of attachments to draw to.
  46632. * @param attachments index of attachments
  46633. */
  46634. bindAttachments(attachments: number[]): void;
  46635. /**
  46636. * Binds the frame buffer to the specified texture.
  46637. * @param texture The texture to render to or null for the default canvas
  46638. * @param faceIndex The face of the texture to render to in case of cube texture
  46639. * @param requiredWidth The width of the target to render to
  46640. * @param requiredHeight The height of the target to render to
  46641. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46642. * @param lodLevel defines the lod level to bind to the frame buffer
  46643. * @param layer defines the 2d array index to bind to frame buffer to
  46644. */
  46645. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  46646. /**
  46647. * Unbind the current render target texture from the WebGPU context
  46648. * @param texture defines the render target texture to unbind
  46649. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46650. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46651. */
  46652. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46653. /**
  46654. * Unbind a list of render target textures from the WebGPU context
  46655. * @param textures defines the render target textures to unbind
  46656. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46657. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46658. */
  46659. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46660. /**
  46661. * Unbind the current render target and bind the default framebuffer
  46662. */
  46663. restoreDefaultFramebuffer(): void;
  46664. private _setColorFormat;
  46665. private _setDepthTextureFormat;
  46666. setDitheringState(value: boolean): void;
  46667. setRasterizerState(value: boolean): void;
  46668. /**
  46669. * Set various states to the context
  46670. * @param culling defines backface culling state
  46671. * @param zOffset defines the value to apply to zOffset (0 by default)
  46672. * @param force defines if states must be applied even if cache is up to date
  46673. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46674. */
  46675. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46676. /**
  46677. * Sets the current alpha mode
  46678. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46679. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46680. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46681. */
  46682. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46683. /**
  46684. * Sets the current alpha equation
  46685. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  46686. */
  46687. setAlphaEquation(equation: number): void;
  46688. private _getBindGroupsToRender;
  46689. private _bindVertexInputs;
  46690. private _setRenderBindGroups;
  46691. private _setRenderPipeline;
  46692. /**
  46693. * Draw a list of indexed primitives
  46694. * @param fillMode defines the primitive to use
  46695. * @param indexStart defines the starting index
  46696. * @param indexCount defines the number of index to draw
  46697. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  46698. */
  46699. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46700. /**
  46701. * Draw a list of unindexed primitives
  46702. * @param fillMode defines the primitive to use
  46703. * @param verticesStart defines the index of first vertex to draw
  46704. * @param verticesCount defines the count of vertices to draw
  46705. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  46706. */
  46707. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46708. private _bundleEncoder;
  46709. /**
  46710. * Start recording all the gpu calls into a bundle.
  46711. */
  46712. startRecordBundle(): void;
  46713. /**
  46714. * Stops recording the bundle.
  46715. * @returns the recorded bundle
  46716. */
  46717. stopRecordBundle(): GPURenderBundle;
  46718. /**
  46719. * Execute the previously recorded bundle.
  46720. * @param bundles defines the bundle to replay
  46721. */
  46722. executeBundles(bundles: GPURenderBundle[]): void;
  46723. /**
  46724. * Dispose and release all associated resources
  46725. */
  46726. dispose(): void;
  46727. /**
  46728. * Gets the current render width
  46729. * @param useScreen defines if screen size must be used (or the current render target if any)
  46730. * @returns a number defining the current render width
  46731. */
  46732. getRenderWidth(useScreen?: boolean): number;
  46733. /**
  46734. * Gets the current render height
  46735. * @param useScreen defines if screen size must be used (or the current render target if any)
  46736. * @returns a number defining the current render height
  46737. */
  46738. getRenderHeight(useScreen?: boolean): number;
  46739. /**
  46740. * Gets the HTML canvas attached with the current WebGPU context
  46741. * @returns a HTML canvas
  46742. */
  46743. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  46744. /** @hidden */
  46745. _debugPushGroup(groupName: string, targetObject?: number): void;
  46746. /** @hidden */
  46747. _debugPopGroup(targetObject?: number): void;
  46748. /** @hidden */
  46749. _debugInsertMarker(text: string, targetObject?: number): void;
  46750. private _debugFlushPendingCommands;
  46751. /**
  46752. * Get the current error code of the WebGPU context
  46753. * @returns the error code
  46754. */
  46755. getError(): number;
  46756. /** @hidden */
  46757. bindSamplers(effect: Effect): void;
  46758. /** @hidden */
  46759. _bindTextureDirectly(target: number, texture: InternalTexture, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  46760. /** @hidden */
  46761. _releaseFramebufferObjects(texture: InternalTexture): void;
  46762. /** @hidden */
  46763. applyStates(): void;
  46764. /**
  46765. * Gets a boolean indicating if all created effects are ready
  46766. * @returns always true - No parallel shader compilation
  46767. */
  46768. areAllEffectsReady(): boolean;
  46769. /** @hidden */
  46770. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46771. /** @hidden */
  46772. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46773. /** @hidden */
  46774. _getUnpackAlignement(): number;
  46775. /** @hidden */
  46776. _unpackFlipY(value: boolean): void;
  46777. /** @hidden */
  46778. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  46779. min: number;
  46780. mag: number;
  46781. };
  46782. /** @hidden */
  46783. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46784. /** @hidden */
  46785. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46786. /** @hidden */
  46787. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  46788. /** @hidden */
  46789. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  46790. /** @hidden */
  46791. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  46792. /** @hidden */
  46793. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  46794. /** @hidden */
  46795. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  46796. /** @hidden */
  46797. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  46798. /** @hidden */
  46799. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  46800. /** @hidden */
  46801. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  46802. /** @hidden */
  46803. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  46804. /** @hidden */
  46805. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  46806. /** @hidden */
  46807. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  46808. /** @hidden */
  46809. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  46810. /** @hidden */
  46811. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  46812. /** @hidden */
  46813. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  46814. /** @hidden */
  46815. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  46816. }
  46817. }
  46818. declare module BABYLON {
  46819. /**
  46820. * Define an interface for all classes that will hold resources
  46821. */
  46822. export interface IDisposable {
  46823. /**
  46824. * Releases all held resources
  46825. */
  46826. dispose(): void;
  46827. }
  46828. /** Interface defining initialization parameters for Scene class */
  46829. export interface SceneOptions {
  46830. /**
  46831. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  46832. * It will improve performance when the number of geometries becomes important.
  46833. */
  46834. useGeometryUniqueIdsMap?: boolean;
  46835. /**
  46836. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  46837. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  46838. */
  46839. useMaterialMeshMap?: boolean;
  46840. /**
  46841. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  46842. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  46843. */
  46844. useClonedMeshMap?: boolean;
  46845. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  46846. virtual?: boolean;
  46847. }
  46848. /**
  46849. * Represents a scene to be rendered by the engine.
  46850. * @see https://doc.babylonjs.com/features/scene
  46851. */
  46852. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  46853. /** The fog is deactivated */
  46854. static readonly FOGMODE_NONE: number;
  46855. /** The fog density is following an exponential function */
  46856. static readonly FOGMODE_EXP: number;
  46857. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  46858. static readonly FOGMODE_EXP2: number;
  46859. /** The fog density is following a linear function. */
  46860. static readonly FOGMODE_LINEAR: number;
  46861. /**
  46862. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  46863. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46864. */
  46865. static MinDeltaTime: number;
  46866. /**
  46867. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  46868. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46869. */
  46870. static MaxDeltaTime: number;
  46871. /**
  46872. * Factory used to create the default material.
  46873. * @param name The name of the material to create
  46874. * @param scene The scene to create the material for
  46875. * @returns The default material
  46876. */
  46877. static DefaultMaterialFactory(scene: Scene): Material;
  46878. /**
  46879. * Factory used to create the a collision coordinator.
  46880. * @returns The collision coordinator
  46881. */
  46882. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  46883. /** @hidden */
  46884. _inputManager: InputManager;
  46885. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  46886. cameraToUseForPointers: Nullable<Camera>;
  46887. /** @hidden */
  46888. readonly _isScene: boolean;
  46889. /** @hidden */
  46890. _blockEntityCollection: boolean;
  46891. /**
  46892. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  46893. */
  46894. autoClear: boolean;
  46895. /**
  46896. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  46897. */
  46898. autoClearDepthAndStencil: boolean;
  46899. /**
  46900. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  46901. */
  46902. clearColor: Color4;
  46903. /**
  46904. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  46905. */
  46906. ambientColor: Color3;
  46907. /**
  46908. * This is use to store the default BRDF lookup for PBR materials in your scene.
  46909. * It should only be one of the following (if not the default embedded one):
  46910. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46911. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  46912. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46913. * The material properties need to be setup according to the type of texture in use.
  46914. */
  46915. environmentBRDFTexture: BaseTexture;
  46916. /**
  46917. * Texture used in all pbr material as the reflection texture.
  46918. * As in the majority of the scene they are the same (exception for multi room and so on),
  46919. * this is easier to reference from here than from all the materials.
  46920. */
  46921. get environmentTexture(): Nullable<BaseTexture>;
  46922. /**
  46923. * Texture used in all pbr material as the reflection texture.
  46924. * As in the majority of the scene they are the same (exception for multi room and so on),
  46925. * this is easier to set here than in all the materials.
  46926. */
  46927. set environmentTexture(value: Nullable<BaseTexture>);
  46928. /** @hidden */
  46929. protected _environmentIntensity: number;
  46930. /**
  46931. * Intensity of the environment in all pbr material.
  46932. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  46933. * As in the majority of the scene they are the same (exception for multi room and so on),
  46934. * this is easier to reference from here than from all the materials.
  46935. */
  46936. get environmentIntensity(): number;
  46937. /**
  46938. * Intensity of the environment in all pbr material.
  46939. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  46940. * As in the majority of the scene they are the same (exception for multi room and so on),
  46941. * this is easier to set here than in all the materials.
  46942. */
  46943. set environmentIntensity(value: number);
  46944. /** @hidden */
  46945. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46946. /**
  46947. * Default image processing configuration used either in the rendering
  46948. * Forward main pass or through the imageProcessingPostProcess if present.
  46949. * As in the majority of the scene they are the same (exception for multi camera),
  46950. * this is easier to reference from here than from all the materials and post process.
  46951. *
  46952. * No setter as we it is a shared configuration, you can set the values instead.
  46953. */
  46954. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  46955. private _forceWireframe;
  46956. /**
  46957. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  46958. */
  46959. set forceWireframe(value: boolean);
  46960. get forceWireframe(): boolean;
  46961. private _skipFrustumClipping;
  46962. /**
  46963. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  46964. */
  46965. set skipFrustumClipping(value: boolean);
  46966. get skipFrustumClipping(): boolean;
  46967. private _forcePointsCloud;
  46968. /**
  46969. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  46970. */
  46971. set forcePointsCloud(value: boolean);
  46972. get forcePointsCloud(): boolean;
  46973. /**
  46974. * Gets or sets the active clipplane 1
  46975. */
  46976. clipPlane: Nullable<Plane>;
  46977. /**
  46978. * Gets or sets the active clipplane 2
  46979. */
  46980. clipPlane2: Nullable<Plane>;
  46981. /**
  46982. * Gets or sets the active clipplane 3
  46983. */
  46984. clipPlane3: Nullable<Plane>;
  46985. /**
  46986. * Gets or sets the active clipplane 4
  46987. */
  46988. clipPlane4: Nullable<Plane>;
  46989. /**
  46990. * Gets or sets the active clipplane 5
  46991. */
  46992. clipPlane5: Nullable<Plane>;
  46993. /**
  46994. * Gets or sets the active clipplane 6
  46995. */
  46996. clipPlane6: Nullable<Plane>;
  46997. /**
  46998. * Gets or sets a boolean indicating if animations are enabled
  46999. */
  47000. animationsEnabled: boolean;
  47001. private _animationPropertiesOverride;
  47002. /**
  47003. * Gets or sets the animation properties override
  47004. */
  47005. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  47006. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  47007. /**
  47008. * Gets or sets a boolean indicating if a constant deltatime has to be used
  47009. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  47010. */
  47011. useConstantAnimationDeltaTime: boolean;
  47012. /**
  47013. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  47014. * Please note that it requires to run a ray cast through the scene on every frame
  47015. */
  47016. constantlyUpdateMeshUnderPointer: boolean;
  47017. /**
  47018. * Defines the HTML cursor to use when hovering over interactive elements
  47019. */
  47020. hoverCursor: string;
  47021. /**
  47022. * Defines the HTML default cursor to use (empty by default)
  47023. */
  47024. defaultCursor: string;
  47025. /**
  47026. * Defines whether cursors are handled by the scene.
  47027. */
  47028. doNotHandleCursors: boolean;
  47029. /**
  47030. * This is used to call preventDefault() on pointer down
  47031. * in order to block unwanted artifacts like system double clicks
  47032. */
  47033. preventDefaultOnPointerDown: boolean;
  47034. /**
  47035. * This is used to call preventDefault() on pointer up
  47036. * in order to block unwanted artifacts like system double clicks
  47037. */
  47038. preventDefaultOnPointerUp: boolean;
  47039. /**
  47040. * Gets or sets user defined metadata
  47041. */
  47042. metadata: any;
  47043. /**
  47044. * For internal use only. Please do not use.
  47045. */
  47046. reservedDataStore: any;
  47047. /**
  47048. * Gets the name of the plugin used to load this scene (null by default)
  47049. */
  47050. loadingPluginName: string;
  47051. /**
  47052. * Use this array to add regular expressions used to disable offline support for specific urls
  47053. */
  47054. disableOfflineSupportExceptionRules: RegExp[];
  47055. /**
  47056. * An event triggered when the scene is disposed.
  47057. */
  47058. onDisposeObservable: Observable<Scene>;
  47059. private _onDisposeObserver;
  47060. /** Sets a function to be executed when this scene is disposed. */
  47061. set onDispose(callback: () => void);
  47062. /**
  47063. * An event triggered before rendering the scene (right after animations and physics)
  47064. */
  47065. onBeforeRenderObservable: Observable<Scene>;
  47066. private _onBeforeRenderObserver;
  47067. /** Sets a function to be executed before rendering this scene */
  47068. set beforeRender(callback: Nullable<() => void>);
  47069. /**
  47070. * An event triggered after rendering the scene
  47071. */
  47072. onAfterRenderObservable: Observable<Scene>;
  47073. /**
  47074. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  47075. */
  47076. onAfterRenderCameraObservable: Observable<Camera>;
  47077. private _onAfterRenderObserver;
  47078. /** Sets a function to be executed after rendering this scene */
  47079. set afterRender(callback: Nullable<() => void>);
  47080. /**
  47081. * An event triggered before animating the scene
  47082. */
  47083. onBeforeAnimationsObservable: Observable<Scene>;
  47084. /**
  47085. * An event triggered after animations processing
  47086. */
  47087. onAfterAnimationsObservable: Observable<Scene>;
  47088. /**
  47089. * An event triggered before draw calls are ready to be sent
  47090. */
  47091. onBeforeDrawPhaseObservable: Observable<Scene>;
  47092. /**
  47093. * An event triggered after draw calls have been sent
  47094. */
  47095. onAfterDrawPhaseObservable: Observable<Scene>;
  47096. /**
  47097. * An event triggered when the scene is ready
  47098. */
  47099. onReadyObservable: Observable<Scene>;
  47100. /**
  47101. * An event triggered before rendering a camera
  47102. */
  47103. onBeforeCameraRenderObservable: Observable<Camera>;
  47104. private _onBeforeCameraRenderObserver;
  47105. /** Sets a function to be executed before rendering a camera*/
  47106. set beforeCameraRender(callback: () => void);
  47107. /**
  47108. * An event triggered after rendering a camera
  47109. */
  47110. onAfterCameraRenderObservable: Observable<Camera>;
  47111. private _onAfterCameraRenderObserver;
  47112. /** Sets a function to be executed after rendering a camera*/
  47113. set afterCameraRender(callback: () => void);
  47114. /**
  47115. * An event triggered when active meshes evaluation is about to start
  47116. */
  47117. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  47118. /**
  47119. * An event triggered when active meshes evaluation is done
  47120. */
  47121. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  47122. /**
  47123. * An event triggered when particles rendering is about to start
  47124. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  47125. */
  47126. onBeforeParticlesRenderingObservable: Observable<Scene>;
  47127. /**
  47128. * An event triggered when particles rendering is done
  47129. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  47130. */
  47131. onAfterParticlesRenderingObservable: Observable<Scene>;
  47132. /**
  47133. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  47134. */
  47135. onDataLoadedObservable: Observable<Scene>;
  47136. /**
  47137. * An event triggered when a camera is created
  47138. */
  47139. onNewCameraAddedObservable: Observable<Camera>;
  47140. /**
  47141. * An event triggered when a camera is removed
  47142. */
  47143. onCameraRemovedObservable: Observable<Camera>;
  47144. /**
  47145. * An event triggered when a light is created
  47146. */
  47147. onNewLightAddedObservable: Observable<Light>;
  47148. /**
  47149. * An event triggered when a light is removed
  47150. */
  47151. onLightRemovedObservable: Observable<Light>;
  47152. /**
  47153. * An event triggered when a geometry is created
  47154. */
  47155. onNewGeometryAddedObservable: Observable<Geometry>;
  47156. /**
  47157. * An event triggered when a geometry is removed
  47158. */
  47159. onGeometryRemovedObservable: Observable<Geometry>;
  47160. /**
  47161. * An event triggered when a transform node is created
  47162. */
  47163. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  47164. /**
  47165. * An event triggered when a transform node is removed
  47166. */
  47167. onTransformNodeRemovedObservable: Observable<TransformNode>;
  47168. /**
  47169. * An event triggered when a mesh is created
  47170. */
  47171. onNewMeshAddedObservable: Observable<AbstractMesh>;
  47172. /**
  47173. * An event triggered when a mesh is removed
  47174. */
  47175. onMeshRemovedObservable: Observable<AbstractMesh>;
  47176. /**
  47177. * An event triggered when a skeleton is created
  47178. */
  47179. onNewSkeletonAddedObservable: Observable<Skeleton>;
  47180. /**
  47181. * An event triggered when a skeleton is removed
  47182. */
  47183. onSkeletonRemovedObservable: Observable<Skeleton>;
  47184. /**
  47185. * An event triggered when a material is created
  47186. */
  47187. onNewMaterialAddedObservable: Observable<Material>;
  47188. /**
  47189. * An event triggered when a multi material is created
  47190. */
  47191. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  47192. /**
  47193. * An event triggered when a material is removed
  47194. */
  47195. onMaterialRemovedObservable: Observable<Material>;
  47196. /**
  47197. * An event triggered when a multi material is removed
  47198. */
  47199. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  47200. /**
  47201. * An event triggered when a texture is created
  47202. */
  47203. onNewTextureAddedObservable: Observable<BaseTexture>;
  47204. /**
  47205. * An event triggered when a texture is removed
  47206. */
  47207. onTextureRemovedObservable: Observable<BaseTexture>;
  47208. /**
  47209. * An event triggered when render targets are about to be rendered
  47210. * Can happen multiple times per frame.
  47211. */
  47212. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  47213. /**
  47214. * An event triggered when render targets were rendered.
  47215. * Can happen multiple times per frame.
  47216. */
  47217. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  47218. /**
  47219. * An event triggered before calculating deterministic simulation step
  47220. */
  47221. onBeforeStepObservable: Observable<Scene>;
  47222. /**
  47223. * An event triggered after calculating deterministic simulation step
  47224. */
  47225. onAfterStepObservable: Observable<Scene>;
  47226. /**
  47227. * An event triggered when the activeCamera property is updated
  47228. */
  47229. onActiveCameraChanged: Observable<Scene>;
  47230. /**
  47231. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  47232. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  47233. * 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)
  47234. */
  47235. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  47236. /**
  47237. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  47238. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  47239. * 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)
  47240. */
  47241. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  47242. /**
  47243. * This Observable will when a mesh has been imported into the scene.
  47244. */
  47245. onMeshImportedObservable: Observable<AbstractMesh>;
  47246. /**
  47247. * This Observable will when an animation file has been imported into the scene.
  47248. */
  47249. onAnimationFileImportedObservable: Observable<Scene>;
  47250. /**
  47251. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  47252. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  47253. */
  47254. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  47255. /** @hidden */
  47256. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  47257. /**
  47258. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  47259. */
  47260. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  47261. /**
  47262. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  47263. */
  47264. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  47265. /**
  47266. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  47267. */
  47268. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  47269. /** Callback called when a pointer move is detected */
  47270. onPointerMove: (evt: IPointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  47271. /** Callback called when a pointer down is detected */
  47272. onPointerDown: (evt: IPointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  47273. /** Callback called when a pointer up is detected */
  47274. onPointerUp: (evt: IPointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  47275. /** Callback called when a pointer pick is detected */
  47276. onPointerPick: (evt: IPointerEvent, pickInfo: PickingInfo) => void;
  47277. /**
  47278. * 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).
  47279. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  47280. */
  47281. onPrePointerObservable: Observable<PointerInfoPre>;
  47282. /**
  47283. * Observable event triggered each time an input event is received from the rendering canvas
  47284. */
  47285. onPointerObservable: Observable<PointerInfo>;
  47286. /**
  47287. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  47288. */
  47289. get unTranslatedPointer(): Vector2;
  47290. /**
  47291. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  47292. */
  47293. static get DragMovementThreshold(): number;
  47294. static set DragMovementThreshold(value: number);
  47295. /**
  47296. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  47297. */
  47298. static get LongPressDelay(): number;
  47299. static set LongPressDelay(value: number);
  47300. /**
  47301. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  47302. */
  47303. static get DoubleClickDelay(): number;
  47304. static set DoubleClickDelay(value: number);
  47305. /** If you need to check double click without raising a single click at first click, enable this flag */
  47306. static get ExclusiveDoubleClickMode(): boolean;
  47307. static set ExclusiveDoubleClickMode(value: boolean);
  47308. /** @hidden */
  47309. _mirroredCameraPosition: Nullable<Vector3>;
  47310. /**
  47311. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  47312. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  47313. */
  47314. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  47315. /**
  47316. * Observable event triggered each time an keyboard event is received from the hosting window
  47317. */
  47318. onKeyboardObservable: Observable<KeyboardInfo>;
  47319. private _useRightHandedSystem;
  47320. /**
  47321. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  47322. */
  47323. set useRightHandedSystem(value: boolean);
  47324. get useRightHandedSystem(): boolean;
  47325. private _timeAccumulator;
  47326. private _currentStepId;
  47327. private _currentInternalStep;
  47328. /**
  47329. * Sets the step Id used by deterministic lock step
  47330. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47331. * @param newStepId defines the step Id
  47332. */
  47333. setStepId(newStepId: number): void;
  47334. /**
  47335. * Gets the step Id used by deterministic lock step
  47336. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47337. * @returns the step Id
  47338. */
  47339. getStepId(): number;
  47340. /**
  47341. * Gets the internal step used by deterministic lock step
  47342. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47343. * @returns the internal step
  47344. */
  47345. getInternalStep(): number;
  47346. private _fogEnabled;
  47347. /**
  47348. * Gets or sets a boolean indicating if fog is enabled on this scene
  47349. * @see https://doc.babylonjs.com/babylon101/environment#fog
  47350. * (Default is true)
  47351. */
  47352. set fogEnabled(value: boolean);
  47353. get fogEnabled(): boolean;
  47354. private _fogMode;
  47355. /**
  47356. * Gets or sets the fog mode to use
  47357. * @see https://doc.babylonjs.com/babylon101/environment#fog
  47358. * | mode | value |
  47359. * | --- | --- |
  47360. * | FOGMODE_NONE | 0 |
  47361. * | FOGMODE_EXP | 1 |
  47362. * | FOGMODE_EXP2 | 2 |
  47363. * | FOGMODE_LINEAR | 3 |
  47364. */
  47365. set fogMode(value: number);
  47366. get fogMode(): number;
  47367. /**
  47368. * Gets or sets the fog color to use
  47369. * @see https://doc.babylonjs.com/babylon101/environment#fog
  47370. * (Default is Color3(0.2, 0.2, 0.3))
  47371. */
  47372. fogColor: Color3;
  47373. /**
  47374. * Gets or sets the fog density to use
  47375. * @see https://doc.babylonjs.com/babylon101/environment#fog
  47376. * (Default is 0.1)
  47377. */
  47378. fogDensity: number;
  47379. /**
  47380. * Gets or sets the fog start distance to use
  47381. * @see https://doc.babylonjs.com/babylon101/environment#fog
  47382. * (Default is 0)
  47383. */
  47384. fogStart: number;
  47385. /**
  47386. * Gets or sets the fog end distance to use
  47387. * @see https://doc.babylonjs.com/babylon101/environment#fog
  47388. * (Default is 1000)
  47389. */
  47390. fogEnd: number;
  47391. /**
  47392. * Flag indicating that the frame buffer binding is handled by another component
  47393. */
  47394. get prePass(): boolean;
  47395. private _shadowsEnabled;
  47396. /**
  47397. * Gets or sets a boolean indicating if shadows are enabled on this scene
  47398. */
  47399. set shadowsEnabled(value: boolean);
  47400. get shadowsEnabled(): boolean;
  47401. private _lightsEnabled;
  47402. /**
  47403. * Gets or sets a boolean indicating if lights are enabled on this scene
  47404. */
  47405. set lightsEnabled(value: boolean);
  47406. get lightsEnabled(): boolean;
  47407. /** All of the active cameras added to this scene. */
  47408. activeCameras: Nullable<Camera[]>;
  47409. /** @hidden */
  47410. _activeCamera: Nullable<Camera>;
  47411. /** Gets or sets the current active camera */
  47412. get activeCamera(): Nullable<Camera>;
  47413. set activeCamera(value: Nullable<Camera>);
  47414. private _defaultMaterial;
  47415. /** The default material used on meshes when no material is affected */
  47416. get defaultMaterial(): Material;
  47417. /** The default material used on meshes when no material is affected */
  47418. set defaultMaterial(value: Material);
  47419. private _texturesEnabled;
  47420. /**
  47421. * Gets or sets a boolean indicating if textures are enabled on this scene
  47422. */
  47423. set texturesEnabled(value: boolean);
  47424. get texturesEnabled(): boolean;
  47425. /**
  47426. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  47427. */
  47428. physicsEnabled: boolean;
  47429. /**
  47430. * Gets or sets a boolean indicating if particles are enabled on this scene
  47431. */
  47432. particlesEnabled: boolean;
  47433. /**
  47434. * Gets or sets a boolean indicating if sprites are enabled on this scene
  47435. */
  47436. spritesEnabled: boolean;
  47437. private _skeletonsEnabled;
  47438. /**
  47439. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  47440. */
  47441. set skeletonsEnabled(value: boolean);
  47442. get skeletonsEnabled(): boolean;
  47443. /**
  47444. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  47445. */
  47446. lensFlaresEnabled: boolean;
  47447. /**
  47448. * Gets or sets a boolean indicating if collisions are enabled on this scene
  47449. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  47450. */
  47451. collisionsEnabled: boolean;
  47452. private _collisionCoordinator;
  47453. /** @hidden */
  47454. get collisionCoordinator(): ICollisionCoordinator;
  47455. /**
  47456. * Defines the gravity applied to this scene (used only for collisions)
  47457. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  47458. */
  47459. gravity: Vector3;
  47460. /**
  47461. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  47462. */
  47463. postProcessesEnabled: boolean;
  47464. /**
  47465. * Gets the current postprocess manager
  47466. */
  47467. postProcessManager: PostProcessManager;
  47468. /**
  47469. * Gets or sets a boolean indicating if render targets are enabled on this scene
  47470. */
  47471. renderTargetsEnabled: boolean;
  47472. /**
  47473. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  47474. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  47475. */
  47476. dumpNextRenderTargets: boolean;
  47477. /**
  47478. * The list of user defined render targets added to the scene
  47479. */
  47480. customRenderTargets: RenderTargetTexture[];
  47481. /**
  47482. * Defines if texture loading must be delayed
  47483. * If true, textures will only be loaded when they need to be rendered
  47484. */
  47485. useDelayedTextureLoading: boolean;
  47486. /**
  47487. * Gets the list of meshes imported to the scene through SceneLoader
  47488. */
  47489. importedMeshesFiles: String[];
  47490. /**
  47491. * Gets or sets a boolean indicating if probes are enabled on this scene
  47492. */
  47493. probesEnabled: boolean;
  47494. /**
  47495. * Gets or sets the current offline provider to use to store scene data
  47496. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  47497. */
  47498. offlineProvider: IOfflineProvider;
  47499. /**
  47500. * Gets or sets the action manager associated with the scene
  47501. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  47502. */
  47503. actionManager: AbstractActionManager;
  47504. private _meshesForIntersections;
  47505. /**
  47506. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  47507. */
  47508. proceduralTexturesEnabled: boolean;
  47509. private _engine;
  47510. private _totalVertices;
  47511. /** @hidden */
  47512. _activeIndices: PerfCounter;
  47513. /** @hidden */
  47514. _activeParticles: PerfCounter;
  47515. /** @hidden */
  47516. _activeBones: PerfCounter;
  47517. private _animationRatio;
  47518. /** @hidden */
  47519. _animationTimeLast: number;
  47520. /** @hidden */
  47521. _animationTime: number;
  47522. /**
  47523. * Gets or sets a general scale for animation speed
  47524. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  47525. */
  47526. animationTimeScale: number;
  47527. /** @hidden */
  47528. _cachedMaterial: Nullable<Material>;
  47529. /** @hidden */
  47530. _cachedEffect: Nullable<Effect>;
  47531. /** @hidden */
  47532. _cachedVisibility: Nullable<number>;
  47533. private _renderId;
  47534. private _frameId;
  47535. private _executeWhenReadyTimeoutId;
  47536. private _intermediateRendering;
  47537. private _viewUpdateFlag;
  47538. private _projectionUpdateFlag;
  47539. /** @hidden */
  47540. _toBeDisposed: Nullable<IDisposable>[];
  47541. private _activeRequests;
  47542. /** @hidden */
  47543. _pendingData: any[];
  47544. private _isDisposed;
  47545. /**
  47546. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  47547. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  47548. */
  47549. dispatchAllSubMeshesOfActiveMeshes: boolean;
  47550. private _activeMeshes;
  47551. private _processedMaterials;
  47552. private _renderTargets;
  47553. /** @hidden */
  47554. _activeParticleSystems: SmartArray<IParticleSystem>;
  47555. private _activeSkeletons;
  47556. private _softwareSkinnedMeshes;
  47557. private _renderingManager;
  47558. /** @hidden */
  47559. _activeAnimatables: Animatable[];
  47560. private _transformMatrix;
  47561. private _sceneUbo;
  47562. /** @hidden */
  47563. _viewMatrix: Matrix;
  47564. /** @hidden */
  47565. _projectionMatrix: Matrix;
  47566. /** @hidden */
  47567. _forcedViewPosition: Nullable<Vector3>;
  47568. /** @hidden */
  47569. _frustumPlanes: Plane[];
  47570. /**
  47571. * Gets the list of frustum planes (built from the active camera)
  47572. */
  47573. get frustumPlanes(): Plane[];
  47574. /**
  47575. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  47576. * This is useful if there are more lights that the maximum simulteanous authorized
  47577. */
  47578. requireLightSorting: boolean;
  47579. /** @hidden */
  47580. readonly useMaterialMeshMap: boolean;
  47581. /** @hidden */
  47582. readonly useClonedMeshMap: boolean;
  47583. private _externalData;
  47584. private _uid;
  47585. /**
  47586. * @hidden
  47587. * Backing store of defined scene components.
  47588. */
  47589. _components: ISceneComponent[];
  47590. /**
  47591. * @hidden
  47592. * Backing store of defined scene components.
  47593. */
  47594. _serializableComponents: ISceneSerializableComponent[];
  47595. /**
  47596. * List of components to register on the next registration step.
  47597. */
  47598. private _transientComponents;
  47599. /**
  47600. * Registers the transient components if needed.
  47601. */
  47602. private _registerTransientComponents;
  47603. /**
  47604. * @hidden
  47605. * Add a component to the scene.
  47606. * Note that the ccomponent could be registered on th next frame if this is called after
  47607. * the register component stage.
  47608. * @param component Defines the component to add to the scene
  47609. */
  47610. _addComponent(component: ISceneComponent): void;
  47611. /**
  47612. * @hidden
  47613. * Gets a component from the scene.
  47614. * @param name defines the name of the component to retrieve
  47615. * @returns the component or null if not present
  47616. */
  47617. _getComponent(name: string): Nullable<ISceneComponent>;
  47618. /**
  47619. * @hidden
  47620. * Defines the actions happening before camera updates.
  47621. */
  47622. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  47623. /**
  47624. * @hidden
  47625. * Defines the actions happening before clear the canvas.
  47626. */
  47627. _beforeClearStage: Stage<SimpleStageAction>;
  47628. /**
  47629. * @hidden
  47630. * Defines the actions happening before clear the canvas.
  47631. */
  47632. _beforeRenderTargetClearStage: Stage<RenderTargetStageAction>;
  47633. /**
  47634. * @hidden
  47635. * Defines the actions when collecting render targets for the frame.
  47636. */
  47637. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  47638. /**
  47639. * @hidden
  47640. * Defines the actions happening for one camera in the frame.
  47641. */
  47642. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  47643. /**
  47644. * @hidden
  47645. * Defines the actions happening during the per mesh ready checks.
  47646. */
  47647. _isReadyForMeshStage: Stage<MeshStageAction>;
  47648. /**
  47649. * @hidden
  47650. * Defines the actions happening before evaluate active mesh checks.
  47651. */
  47652. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  47653. /**
  47654. * @hidden
  47655. * Defines the actions happening during the evaluate sub mesh checks.
  47656. */
  47657. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  47658. /**
  47659. * @hidden
  47660. * Defines the actions happening during the active mesh stage.
  47661. */
  47662. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  47663. /**
  47664. * @hidden
  47665. * Defines the actions happening during the per camera render target step.
  47666. */
  47667. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  47668. /**
  47669. * @hidden
  47670. * Defines the actions happening just before the active camera is drawing.
  47671. */
  47672. _beforeCameraDrawStage: Stage<CameraStageAction>;
  47673. /**
  47674. * @hidden
  47675. * Defines the actions happening just before a render target is drawing.
  47676. */
  47677. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  47678. /**
  47679. * @hidden
  47680. * Defines the actions happening just before a rendering group is drawing.
  47681. */
  47682. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  47683. /**
  47684. * @hidden
  47685. * Defines the actions happening just before a mesh is drawing.
  47686. */
  47687. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  47688. /**
  47689. * @hidden
  47690. * Defines the actions happening just after a mesh has been drawn.
  47691. */
  47692. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  47693. /**
  47694. * @hidden
  47695. * Defines the actions happening just after a rendering group has been drawn.
  47696. */
  47697. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  47698. /**
  47699. * @hidden
  47700. * Defines the actions happening just after the active camera has been drawn.
  47701. */
  47702. _afterCameraDrawStage: Stage<CameraStageAction>;
  47703. /**
  47704. * @hidden
  47705. * Defines the actions happening just after a render target has been drawn.
  47706. */
  47707. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  47708. /**
  47709. * @hidden
  47710. * Defines the actions happening just after rendering all cameras and computing intersections.
  47711. */
  47712. _afterRenderStage: Stage<SimpleStageAction>;
  47713. /**
  47714. * @hidden
  47715. * Defines the actions happening when a pointer move event happens.
  47716. */
  47717. _pointerMoveStage: Stage<PointerMoveStageAction>;
  47718. /**
  47719. * @hidden
  47720. * Defines the actions happening when a pointer down event happens.
  47721. */
  47722. _pointerDownStage: Stage<PointerUpDownStageAction>;
  47723. /**
  47724. * @hidden
  47725. * Defines the actions happening when a pointer up event happens.
  47726. */
  47727. _pointerUpStage: Stage<PointerUpDownStageAction>;
  47728. /**
  47729. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  47730. */
  47731. private geometriesByUniqueId;
  47732. private _renderBundles;
  47733. /**
  47734. * Creates a new Scene
  47735. * @param engine defines the engine to use to render this scene
  47736. * @param options defines the scene options
  47737. */
  47738. constructor(engine: Engine, options?: SceneOptions);
  47739. /**
  47740. * Gets a string identifying the name of the class
  47741. * @returns "Scene" string
  47742. */
  47743. getClassName(): string;
  47744. private _defaultMeshCandidates;
  47745. /**
  47746. * @hidden
  47747. */
  47748. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47749. private _defaultSubMeshCandidates;
  47750. /**
  47751. * @hidden
  47752. */
  47753. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47754. /**
  47755. * Sets the default candidate providers for the scene.
  47756. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  47757. * and getCollidingSubMeshCandidates to their default function
  47758. */
  47759. setDefaultCandidateProviders(): void;
  47760. /**
  47761. * Gets the mesh that is currently under the pointer
  47762. */
  47763. get meshUnderPointer(): Nullable<AbstractMesh>;
  47764. /**
  47765. * Gets or sets the current on-screen X position of the pointer
  47766. */
  47767. get pointerX(): number;
  47768. set pointerX(value: number);
  47769. /**
  47770. * Gets or sets the current on-screen Y position of the pointer
  47771. */
  47772. get pointerY(): number;
  47773. set pointerY(value: number);
  47774. /**
  47775. * Gets the cached material (ie. the latest rendered one)
  47776. * @returns the cached material
  47777. */
  47778. getCachedMaterial(): Nullable<Material>;
  47779. /**
  47780. * Gets the cached effect (ie. the latest rendered one)
  47781. * @returns the cached effect
  47782. */
  47783. getCachedEffect(): Nullable<Effect>;
  47784. /**
  47785. * Gets the cached visibility state (ie. the latest rendered one)
  47786. * @returns the cached visibility state
  47787. */
  47788. getCachedVisibility(): Nullable<number>;
  47789. /**
  47790. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  47791. * @param material defines the current material
  47792. * @param effect defines the current effect
  47793. * @param visibility defines the current visibility state
  47794. * @returns true if one parameter is not cached
  47795. */
  47796. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  47797. /**
  47798. * Gets the engine associated with the scene
  47799. * @returns an Engine
  47800. */
  47801. getEngine(): Engine;
  47802. /**
  47803. * Gets the total number of vertices rendered per frame
  47804. * @returns the total number of vertices rendered per frame
  47805. */
  47806. getTotalVertices(): number;
  47807. /**
  47808. * Gets the performance counter for total vertices
  47809. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  47810. */
  47811. get totalVerticesPerfCounter(): PerfCounter;
  47812. /**
  47813. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  47814. * @returns the total number of active indices rendered per frame
  47815. */
  47816. getActiveIndices(): number;
  47817. /**
  47818. * Gets the performance counter for active indices
  47819. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  47820. */
  47821. get totalActiveIndicesPerfCounter(): PerfCounter;
  47822. /**
  47823. * Gets the total number of active particles rendered per frame
  47824. * @returns the total number of active particles rendered per frame
  47825. */
  47826. getActiveParticles(): number;
  47827. /**
  47828. * Gets the performance counter for active particles
  47829. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  47830. */
  47831. get activeParticlesPerfCounter(): PerfCounter;
  47832. /**
  47833. * Gets the total number of active bones rendered per frame
  47834. * @returns the total number of active bones rendered per frame
  47835. */
  47836. getActiveBones(): number;
  47837. /**
  47838. * Gets the performance counter for active bones
  47839. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  47840. */
  47841. get activeBonesPerfCounter(): PerfCounter;
  47842. /**
  47843. * Gets the array of active meshes
  47844. * @returns an array of AbstractMesh
  47845. */
  47846. getActiveMeshes(): SmartArray<AbstractMesh>;
  47847. /**
  47848. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  47849. * @returns a number
  47850. */
  47851. getAnimationRatio(): number;
  47852. /**
  47853. * Gets an unique Id for the current render phase
  47854. * @returns a number
  47855. */
  47856. getRenderId(): number;
  47857. /**
  47858. * Gets an unique Id for the current frame
  47859. * @returns a number
  47860. */
  47861. getFrameId(): number;
  47862. /** Call this function if you want to manually increment the render Id*/
  47863. incrementRenderId(): void;
  47864. private _createUbo;
  47865. /**
  47866. * Use this method to simulate a pointer move on a mesh
  47867. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  47868. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  47869. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  47870. * @returns the current scene
  47871. */
  47872. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  47873. /**
  47874. * Use this method to simulate a pointer down on a mesh
  47875. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  47876. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  47877. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  47878. * @returns the current scene
  47879. */
  47880. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  47881. /**
  47882. * Use this method to simulate a pointer up on a mesh
  47883. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  47884. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  47885. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  47886. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  47887. * @returns the current scene
  47888. */
  47889. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  47890. /**
  47891. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  47892. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  47893. * @returns true if the pointer was captured
  47894. */
  47895. isPointerCaptured(pointerId?: number): boolean;
  47896. /**
  47897. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  47898. * @param attachUp defines if you want to attach events to pointerup
  47899. * @param attachDown defines if you want to attach events to pointerdown
  47900. * @param attachMove defines if you want to attach events to pointermove
  47901. */
  47902. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  47903. /** Detaches all event handlers*/
  47904. detachControl(): void;
  47905. /**
  47906. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  47907. * Delay loaded resources are not taking in account
  47908. * @return true if all required resources are ready
  47909. */
  47910. isReady(): boolean;
  47911. /** Resets all cached information relative to material (including effect and visibility) */
  47912. resetCachedMaterial(): void;
  47913. /**
  47914. * Registers a function to be called before every frame render
  47915. * @param func defines the function to register
  47916. */
  47917. registerBeforeRender(func: () => void): void;
  47918. /**
  47919. * Unregisters a function called before every frame render
  47920. * @param func defines the function to unregister
  47921. */
  47922. unregisterBeforeRender(func: () => void): void;
  47923. /**
  47924. * Registers a function to be called after every frame render
  47925. * @param func defines the function to register
  47926. */
  47927. registerAfterRender(func: () => void): void;
  47928. /**
  47929. * Unregisters a function called after every frame render
  47930. * @param func defines the function to unregister
  47931. */
  47932. unregisterAfterRender(func: () => void): void;
  47933. private _executeOnceBeforeRender;
  47934. /**
  47935. * The provided function will run before render once and will be disposed afterwards.
  47936. * A timeout delay can be provided so that the function will be executed in N ms.
  47937. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  47938. * @param func The function to be executed.
  47939. * @param timeout optional delay in ms
  47940. */
  47941. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  47942. /** @hidden */
  47943. _addPendingData(data: any): void;
  47944. /** @hidden */
  47945. _removePendingData(data: any): void;
  47946. /**
  47947. * Returns the number of items waiting to be loaded
  47948. * @returns the number of items waiting to be loaded
  47949. */
  47950. getWaitingItemsCount(): number;
  47951. /**
  47952. * Returns a boolean indicating if the scene is still loading data
  47953. */
  47954. get isLoading(): boolean;
  47955. /**
  47956. * Registers a function to be executed when the scene is ready
  47957. * @param {Function} func - the function to be executed
  47958. */
  47959. executeWhenReady(func: () => void): void;
  47960. /**
  47961. * Returns a promise that resolves when the scene is ready
  47962. * @returns A promise that resolves when the scene is ready
  47963. */
  47964. whenReadyAsync(): Promise<void>;
  47965. /** @hidden */
  47966. _checkIsReady(): void;
  47967. /**
  47968. * Gets all animatable attached to the scene
  47969. */
  47970. get animatables(): Animatable[];
  47971. /**
  47972. * Resets the last animation time frame.
  47973. * Useful to override when animations start running when loading a scene for the first time.
  47974. */
  47975. resetLastAnimationTimeFrame(): void;
  47976. /**
  47977. * Gets the current view matrix
  47978. * @returns a Matrix
  47979. */
  47980. getViewMatrix(): Matrix;
  47981. /**
  47982. * Gets the current projection matrix
  47983. * @returns a Matrix
  47984. */
  47985. getProjectionMatrix(): Matrix;
  47986. /**
  47987. * Gets the current transform matrix
  47988. * @returns a Matrix made of View * Projection
  47989. */
  47990. getTransformMatrix(): Matrix;
  47991. /**
  47992. * Sets the current transform matrix
  47993. * @param viewL defines the View matrix to use
  47994. * @param projectionL defines the Projection matrix to use
  47995. * @param viewR defines the right View matrix to use (if provided)
  47996. * @param projectionR defines the right Projection matrix to use (if provided)
  47997. */
  47998. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  47999. /**
  48000. * Gets the uniform buffer used to store scene data
  48001. * @returns a UniformBuffer
  48002. */
  48003. getSceneUniformBuffer(): UniformBuffer;
  48004. /**
  48005. * Gets an unique (relatively to the current scene) Id
  48006. * @returns an unique number for the scene
  48007. */
  48008. getUniqueId(): number;
  48009. /**
  48010. * Add a mesh to the list of scene's meshes
  48011. * @param newMesh defines the mesh to add
  48012. * @param recursive if all child meshes should also be added to the scene
  48013. */
  48014. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  48015. /**
  48016. * Remove a mesh for the list of scene's meshes
  48017. * @param toRemove defines the mesh to remove
  48018. * @param recursive if all child meshes should also be removed from the scene
  48019. * @returns the index where the mesh was in the mesh list
  48020. */
  48021. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  48022. /**
  48023. * Add a transform node to the list of scene's transform nodes
  48024. * @param newTransformNode defines the transform node to add
  48025. */
  48026. addTransformNode(newTransformNode: TransformNode): void;
  48027. /**
  48028. * Remove a transform node for the list of scene's transform nodes
  48029. * @param toRemove defines the transform node to remove
  48030. * @returns the index where the transform node was in the transform node list
  48031. */
  48032. removeTransformNode(toRemove: TransformNode): number;
  48033. /**
  48034. * Remove a skeleton for the list of scene's skeletons
  48035. * @param toRemove defines the skeleton to remove
  48036. * @returns the index where the skeleton was in the skeleton list
  48037. */
  48038. removeSkeleton(toRemove: Skeleton): number;
  48039. /**
  48040. * Remove a morph target for the list of scene's morph targets
  48041. * @param toRemove defines the morph target to remove
  48042. * @returns the index where the morph target was in the morph target list
  48043. */
  48044. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  48045. /**
  48046. * Remove a light for the list of scene's lights
  48047. * @param toRemove defines the light to remove
  48048. * @returns the index where the light was in the light list
  48049. */
  48050. removeLight(toRemove: Light): number;
  48051. /**
  48052. * Remove a camera for the list of scene's cameras
  48053. * @param toRemove defines the camera to remove
  48054. * @returns the index where the camera was in the camera list
  48055. */
  48056. removeCamera(toRemove: Camera): number;
  48057. /**
  48058. * Remove a particle system for the list of scene's particle systems
  48059. * @param toRemove defines the particle system to remove
  48060. * @returns the index where the particle system was in the particle system list
  48061. */
  48062. removeParticleSystem(toRemove: IParticleSystem): number;
  48063. /**
  48064. * Remove a animation for the list of scene's animations
  48065. * @param toRemove defines the animation to remove
  48066. * @returns the index where the animation was in the animation list
  48067. */
  48068. removeAnimation(toRemove: Animation): number;
  48069. /**
  48070. * Will stop the animation of the given target
  48071. * @param target - the target
  48072. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  48073. * @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)
  48074. */
  48075. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  48076. /**
  48077. * Removes the given animation group from this scene.
  48078. * @param toRemove The animation group to remove
  48079. * @returns The index of the removed animation group
  48080. */
  48081. removeAnimationGroup(toRemove: AnimationGroup): number;
  48082. /**
  48083. * Removes the given multi-material from this scene.
  48084. * @param toRemove The multi-material to remove
  48085. * @returns The index of the removed multi-material
  48086. */
  48087. removeMultiMaterial(toRemove: MultiMaterial): number;
  48088. /**
  48089. * Removes the given material from this scene.
  48090. * @param toRemove The material to remove
  48091. * @returns The index of the removed material
  48092. */
  48093. removeMaterial(toRemove: Material): number;
  48094. /**
  48095. * Removes the given action manager from this scene.
  48096. * @param toRemove The action manager to remove
  48097. * @returns The index of the removed action manager
  48098. */
  48099. removeActionManager(toRemove: AbstractActionManager): number;
  48100. /**
  48101. * Removes the given texture from this scene.
  48102. * @param toRemove The texture to remove
  48103. * @returns The index of the removed texture
  48104. */
  48105. removeTexture(toRemove: BaseTexture): number;
  48106. /**
  48107. * Adds the given light to this scene
  48108. * @param newLight The light to add
  48109. */
  48110. addLight(newLight: Light): void;
  48111. /**
  48112. * Sorts the list list based on light priorities
  48113. */
  48114. sortLightsByPriority(): void;
  48115. /**
  48116. * Adds the given camera to this scene
  48117. * @param newCamera The camera to add
  48118. */
  48119. addCamera(newCamera: Camera): void;
  48120. /**
  48121. * Adds the given skeleton to this scene
  48122. * @param newSkeleton The skeleton to add
  48123. */
  48124. addSkeleton(newSkeleton: Skeleton): void;
  48125. /**
  48126. * Adds the given particle system to this scene
  48127. * @param newParticleSystem The particle system to add
  48128. */
  48129. addParticleSystem(newParticleSystem: IParticleSystem): void;
  48130. /**
  48131. * Adds the given animation to this scene
  48132. * @param newAnimation The animation to add
  48133. */
  48134. addAnimation(newAnimation: Animation): void;
  48135. /**
  48136. * Adds the given animation group to this scene.
  48137. * @param newAnimationGroup The animation group to add
  48138. */
  48139. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  48140. /**
  48141. * Adds the given multi-material to this scene
  48142. * @param newMultiMaterial The multi-material to add
  48143. */
  48144. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  48145. /**
  48146. * Adds the given material to this scene
  48147. * @param newMaterial The material to add
  48148. */
  48149. addMaterial(newMaterial: Material): void;
  48150. /**
  48151. * Adds the given morph target to this scene
  48152. * @param newMorphTargetManager The morph target to add
  48153. */
  48154. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  48155. /**
  48156. * Adds the given geometry to this scene
  48157. * @param newGeometry The geometry to add
  48158. */
  48159. addGeometry(newGeometry: Geometry): void;
  48160. /**
  48161. * Adds the given action manager to this scene
  48162. * @param newActionManager The action manager to add
  48163. */
  48164. addActionManager(newActionManager: AbstractActionManager): void;
  48165. /**
  48166. * Adds the given texture to this scene.
  48167. * @param newTexture The texture to add
  48168. */
  48169. addTexture(newTexture: BaseTexture): void;
  48170. /**
  48171. * Switch active camera
  48172. * @param newCamera defines the new active camera
  48173. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  48174. */
  48175. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  48176. /**
  48177. * sets the active camera of the scene using its ID
  48178. * @param id defines the camera's ID
  48179. * @return the new active camera or null if none found.
  48180. */
  48181. setActiveCameraByID(id: string): Nullable<Camera>;
  48182. /**
  48183. * sets the active camera of the scene using its name
  48184. * @param name defines the camera's name
  48185. * @returns the new active camera or null if none found.
  48186. */
  48187. setActiveCameraByName(name: string): Nullable<Camera>;
  48188. /**
  48189. * get an animation group using its name
  48190. * @param name defines the material's name
  48191. * @return the animation group or null if none found.
  48192. */
  48193. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  48194. /**
  48195. * Get a material using its unique id
  48196. * @param uniqueId defines the material's unique id
  48197. * @return the material or null if none found.
  48198. */
  48199. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  48200. /**
  48201. * get a material using its id
  48202. * @param id defines the material's ID
  48203. * @return the material or null if none found.
  48204. */
  48205. getMaterialByID(id: string): Nullable<Material>;
  48206. /**
  48207. * Gets a the last added material using a given id
  48208. * @param id defines the material's ID
  48209. * @return the last material with the given id or null if none found.
  48210. */
  48211. getLastMaterialByID(id: string): Nullable<Material>;
  48212. /**
  48213. * Gets a material using its name
  48214. * @param name defines the material's name
  48215. * @return the material or null if none found.
  48216. */
  48217. getMaterialByName(name: string): Nullable<Material>;
  48218. /**
  48219. * Get a texture using its unique id
  48220. * @param uniqueId defines the texture's unique id
  48221. * @return the texture or null if none found.
  48222. */
  48223. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  48224. /**
  48225. * Gets a camera using its id
  48226. * @param id defines the id to look for
  48227. * @returns the camera or null if not found
  48228. */
  48229. getCameraByID(id: string): Nullable<Camera>;
  48230. /**
  48231. * Gets a camera using its unique id
  48232. * @param uniqueId defines the unique id to look for
  48233. * @returns the camera or null if not found
  48234. */
  48235. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  48236. /**
  48237. * Gets a camera using its name
  48238. * @param name defines the camera's name
  48239. * @return the camera or null if none found.
  48240. */
  48241. getCameraByName(name: string): Nullable<Camera>;
  48242. /**
  48243. * Gets a bone using its id
  48244. * @param id defines the bone's id
  48245. * @return the bone or null if not found
  48246. */
  48247. getBoneByID(id: string): Nullable<Bone>;
  48248. /**
  48249. * Gets a bone using its id
  48250. * @param name defines the bone's name
  48251. * @return the bone or null if not found
  48252. */
  48253. getBoneByName(name: string): Nullable<Bone>;
  48254. /**
  48255. * Gets a light node using its name
  48256. * @param name defines the the light's name
  48257. * @return the light or null if none found.
  48258. */
  48259. getLightByName(name: string): Nullable<Light>;
  48260. /**
  48261. * Gets a light node using its id
  48262. * @param id defines the light's id
  48263. * @return the light or null if none found.
  48264. */
  48265. getLightByID(id: string): Nullable<Light>;
  48266. /**
  48267. * Gets a light node using its scene-generated unique ID
  48268. * @param uniqueId defines the light's unique id
  48269. * @return the light or null if none found.
  48270. */
  48271. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  48272. /**
  48273. * Gets a particle system by id
  48274. * @param id defines the particle system id
  48275. * @return the corresponding system or null if none found
  48276. */
  48277. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  48278. /**
  48279. * Gets a geometry using its ID
  48280. * @param id defines the geometry's id
  48281. * @return the geometry or null if none found.
  48282. */
  48283. getGeometryByID(id: string): Nullable<Geometry>;
  48284. private _getGeometryByUniqueID;
  48285. /**
  48286. * Add a new geometry to this scene
  48287. * @param geometry defines the geometry to be added to the scene.
  48288. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  48289. * @return a boolean defining if the geometry was added or not
  48290. */
  48291. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  48292. /**
  48293. * Removes an existing geometry
  48294. * @param geometry defines the geometry to be removed from the scene
  48295. * @return a boolean defining if the geometry was removed or not
  48296. */
  48297. removeGeometry(geometry: Geometry): boolean;
  48298. /**
  48299. * Gets the list of geometries attached to the scene
  48300. * @returns an array of Geometry
  48301. */
  48302. getGeometries(): Geometry[];
  48303. /**
  48304. * Gets the first added mesh found of a given ID
  48305. * @param id defines the id to search for
  48306. * @return the mesh found or null if not found at all
  48307. */
  48308. getMeshByID(id: string): Nullable<AbstractMesh>;
  48309. /**
  48310. * Gets a list of meshes using their id
  48311. * @param id defines the id to search for
  48312. * @returns a list of meshes
  48313. */
  48314. getMeshesByID(id: string): Array<AbstractMesh>;
  48315. /**
  48316. * Gets the first added transform node found of a given ID
  48317. * @param id defines the id to search for
  48318. * @return the found transform node or null if not found at all.
  48319. */
  48320. getTransformNodeByID(id: string): Nullable<TransformNode>;
  48321. /**
  48322. * Gets a transform node with its auto-generated unique id
  48323. * @param uniqueId efines the unique id to search for
  48324. * @return the found transform node or null if not found at all.
  48325. */
  48326. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  48327. /**
  48328. * Gets a list of transform nodes using their id
  48329. * @param id defines the id to search for
  48330. * @returns a list of transform nodes
  48331. */
  48332. getTransformNodesByID(id: string): Array<TransformNode>;
  48333. /**
  48334. * Gets a mesh with its auto-generated unique id
  48335. * @param uniqueId defines the unique id to search for
  48336. * @return the found mesh or null if not found at all.
  48337. */
  48338. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  48339. /**
  48340. * Gets a the last added mesh using a given id
  48341. * @param id defines the id to search for
  48342. * @return the found mesh or null if not found at all.
  48343. */
  48344. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  48345. /**
  48346. * Gets a the last added node (Mesh, Camera, Light) using a given id
  48347. * @param id defines the id to search for
  48348. * @return the found node or null if not found at all
  48349. */
  48350. getLastEntryByID(id: string): Nullable<Node>;
  48351. /**
  48352. * Gets a node (Mesh, Camera, Light) using a given id
  48353. * @param id defines the id to search for
  48354. * @return the found node or null if not found at all
  48355. */
  48356. getNodeByID(id: string): Nullable<Node>;
  48357. /**
  48358. * Gets a node (Mesh, Camera, Light) using a given name
  48359. * @param name defines the name to search for
  48360. * @return the found node or null if not found at all.
  48361. */
  48362. getNodeByName(name: string): Nullable<Node>;
  48363. /**
  48364. * Gets a mesh using a given name
  48365. * @param name defines the name to search for
  48366. * @return the found mesh or null if not found at all.
  48367. */
  48368. getMeshByName(name: string): Nullable<AbstractMesh>;
  48369. /**
  48370. * Gets a transform node using a given name
  48371. * @param name defines the name to search for
  48372. * @return the found transform node or null if not found at all.
  48373. */
  48374. getTransformNodeByName(name: string): Nullable<TransformNode>;
  48375. /**
  48376. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  48377. * @param id defines the id to search for
  48378. * @return the found skeleton or null if not found at all.
  48379. */
  48380. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  48381. /**
  48382. * Gets a skeleton using a given auto generated unique id
  48383. * @param uniqueId defines the unique id to search for
  48384. * @return the found skeleton or null if not found at all.
  48385. */
  48386. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  48387. /**
  48388. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  48389. * @param id defines the id to search for
  48390. * @return the found skeleton or null if not found at all.
  48391. */
  48392. getSkeletonById(id: string): Nullable<Skeleton>;
  48393. /**
  48394. * Gets a skeleton using a given name
  48395. * @param name defines the name to search for
  48396. * @return the found skeleton or null if not found at all.
  48397. */
  48398. getSkeletonByName(name: string): Nullable<Skeleton>;
  48399. /**
  48400. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  48401. * @param id defines the id to search for
  48402. * @return the found morph target manager or null if not found at all.
  48403. */
  48404. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  48405. /**
  48406. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  48407. * @param id defines the id to search for
  48408. * @return the found morph target or null if not found at all.
  48409. */
  48410. getMorphTargetById(id: string): Nullable<MorphTarget>;
  48411. /**
  48412. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  48413. * @param name defines the name to search for
  48414. * @return the found morph target or null if not found at all.
  48415. */
  48416. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  48417. /**
  48418. * Gets a post process using a given name (if many are found, this function will pick the first one)
  48419. * @param name defines the name to search for
  48420. * @return the found post process or null if not found at all.
  48421. */
  48422. getPostProcessByName(name: string): Nullable<PostProcess>;
  48423. /**
  48424. * Gets a boolean indicating if the given mesh is active
  48425. * @param mesh defines the mesh to look for
  48426. * @returns true if the mesh is in the active list
  48427. */
  48428. isActiveMesh(mesh: AbstractMesh): boolean;
  48429. /**
  48430. * Return a unique id as a string which can serve as an identifier for the scene
  48431. */
  48432. get uid(): string;
  48433. /**
  48434. * Add an externaly attached data from its key.
  48435. * This method call will fail and return false, if such key already exists.
  48436. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  48437. * @param key the unique key that identifies the data
  48438. * @param data the data object to associate to the key for this Engine instance
  48439. * @return true if no such key were already present and the data was added successfully, false otherwise
  48440. */
  48441. addExternalData<T>(key: string, data: T): boolean;
  48442. /**
  48443. * Get an externaly attached data from its key
  48444. * @param key the unique key that identifies the data
  48445. * @return the associated data, if present (can be null), or undefined if not present
  48446. */
  48447. getExternalData<T>(key: string): Nullable<T>;
  48448. /**
  48449. * Get an externaly attached data from its key, create it using a factory if it's not already present
  48450. * @param key the unique key that identifies the data
  48451. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  48452. * @return the associated data, can be null if the factory returned null.
  48453. */
  48454. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  48455. /**
  48456. * Remove an externaly attached data from the Engine instance
  48457. * @param key the unique key that identifies the data
  48458. * @return true if the data was successfully removed, false if it doesn't exist
  48459. */
  48460. removeExternalData(key: string): boolean;
  48461. private _evaluateSubMesh;
  48462. /**
  48463. * Clear the processed materials smart array preventing retention point in material dispose.
  48464. */
  48465. freeProcessedMaterials(): void;
  48466. private _preventFreeActiveMeshesAndRenderingGroups;
  48467. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  48468. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  48469. * when disposing several meshes in a row or a hierarchy of meshes.
  48470. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  48471. */
  48472. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  48473. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  48474. /**
  48475. * Clear the active meshes smart array preventing retention point in mesh dispose.
  48476. */
  48477. freeActiveMeshes(): void;
  48478. /**
  48479. * Clear the info related to rendering groups preventing retention points during dispose.
  48480. */
  48481. freeRenderingGroups(): void;
  48482. /** @hidden */
  48483. _isInIntermediateRendering(): boolean;
  48484. /**
  48485. * Lambda returning the list of potentially active meshes.
  48486. */
  48487. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  48488. /**
  48489. * Lambda returning the list of potentially active sub meshes.
  48490. */
  48491. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  48492. /**
  48493. * Lambda returning the list of potentially intersecting sub meshes.
  48494. */
  48495. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  48496. /**
  48497. * Lambda returning the list of potentially colliding sub meshes.
  48498. */
  48499. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  48500. /** @hidden */
  48501. _activeMeshesFrozen: boolean;
  48502. private _skipEvaluateActiveMeshesCompletely;
  48503. /**
  48504. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  48505. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  48506. * @param onSuccess optional success callback
  48507. * @param onError optional error callback
  48508. * @returns the current scene
  48509. */
  48510. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  48511. /**
  48512. * Use this function to restart evaluating active meshes on every frame
  48513. * @returns the current scene
  48514. */
  48515. unfreezeActiveMeshes(): Scene;
  48516. private _evaluateActiveMeshes;
  48517. private _activeMesh;
  48518. /**
  48519. * Update the transform matrix to update from the current active camera
  48520. * @param force defines a boolean used to force the update even if cache is up to date
  48521. */
  48522. updateTransformMatrix(force?: boolean): void;
  48523. private _bindFrameBuffer;
  48524. /** @hidden */
  48525. _allowPostProcessClearColor: boolean;
  48526. /** @hidden */
  48527. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  48528. private _processSubCameras;
  48529. private _checkIntersections;
  48530. /** @hidden */
  48531. _advancePhysicsEngineStep(step: number): void;
  48532. /**
  48533. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  48534. */
  48535. getDeterministicFrameTime: () => number;
  48536. /** @hidden */
  48537. _animate(): void;
  48538. /** Execute all animations (for a frame) */
  48539. animate(): void;
  48540. /**
  48541. * Render the scene
  48542. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  48543. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  48544. */
  48545. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  48546. /**
  48547. * Freeze all materials
  48548. * A frozen material will not be updatable but should be faster to render
  48549. */
  48550. freezeMaterials(): void;
  48551. /**
  48552. * Unfreeze all materials
  48553. * A frozen material will not be updatable but should be faster to render
  48554. */
  48555. unfreezeMaterials(): void;
  48556. /**
  48557. * Releases all held ressources
  48558. */
  48559. dispose(): void;
  48560. /**
  48561. * Gets if the scene is already disposed
  48562. */
  48563. get isDisposed(): boolean;
  48564. /**
  48565. * Call this function to reduce memory footprint of the scene.
  48566. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  48567. */
  48568. clearCachedVertexData(): void;
  48569. /**
  48570. * This function will remove the local cached buffer data from texture.
  48571. * It will save memory but will prevent the texture from being rebuilt
  48572. */
  48573. cleanCachedTextureBuffer(): void;
  48574. /**
  48575. * Get the world extend vectors with an optional filter
  48576. *
  48577. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  48578. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  48579. */
  48580. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  48581. min: Vector3;
  48582. max: Vector3;
  48583. };
  48584. /**
  48585. * Creates a ray that can be used to pick in the scene
  48586. * @param x defines the x coordinate of the origin (on-screen)
  48587. * @param y defines the y coordinate of the origin (on-screen)
  48588. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  48589. * @param camera defines the camera to use for the picking
  48590. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  48591. * @returns a Ray
  48592. */
  48593. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  48594. /**
  48595. * Creates a ray that can be used to pick in the scene
  48596. * @param x defines the x coordinate of the origin (on-screen)
  48597. * @param y defines the y coordinate of the origin (on-screen)
  48598. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  48599. * @param result defines the ray where to store the picking ray
  48600. * @param camera defines the camera to use for the picking
  48601. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  48602. * @returns the current scene
  48603. */
  48604. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  48605. /**
  48606. * Creates a ray that can be used to pick in the scene
  48607. * @param x defines the x coordinate of the origin (on-screen)
  48608. * @param y defines the y coordinate of the origin (on-screen)
  48609. * @param camera defines the camera to use for the picking
  48610. * @returns a Ray
  48611. */
  48612. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  48613. /**
  48614. * Creates a ray that can be used to pick in the scene
  48615. * @param x defines the x coordinate of the origin (on-screen)
  48616. * @param y defines the y coordinate of the origin (on-screen)
  48617. * @param result defines the ray where to store the picking ray
  48618. * @param camera defines the camera to use for the picking
  48619. * @returns the current scene
  48620. */
  48621. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  48622. /** Launch a ray to try to pick a mesh in the scene
  48623. * @param x position on screen
  48624. * @param y position on screen
  48625. * @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
  48626. * @param fastCheck defines if the first intersection will be used (and not the closest)
  48627. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  48628. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  48629. * @returns a PickingInfo
  48630. */
  48631. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  48632. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  48633. * @param x position on screen
  48634. * @param y position on screen
  48635. * @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
  48636. * @param fastCheck defines if the first intersection will be used (and not the closest)
  48637. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  48638. * @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)
  48639. */
  48640. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  48641. /** Use the given ray to pick a mesh in the scene
  48642. * @param ray The ray to use to pick meshes
  48643. * @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
  48644. * @param fastCheck defines if the first intersection will be used (and not the closest)
  48645. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  48646. * @returns a PickingInfo
  48647. */
  48648. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  48649. /**
  48650. * Launch a ray to try to pick a mesh in the scene
  48651. * @param x X position on screen
  48652. * @param y Y position on screen
  48653. * @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
  48654. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  48655. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  48656. * @returns an array of PickingInfo
  48657. */
  48658. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  48659. /**
  48660. * Launch a ray to try to pick a mesh in the scene
  48661. * @param ray Ray to use
  48662. * @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
  48663. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  48664. * @returns an array of PickingInfo
  48665. */
  48666. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  48667. /**
  48668. * Force the value of meshUnderPointer
  48669. * @param mesh defines the mesh to use
  48670. * @param pointerId optional pointer id when using more than one pointer
  48671. */
  48672. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  48673. /**
  48674. * Gets the mesh under the pointer
  48675. * @returns a Mesh or null if no mesh is under the pointer
  48676. */
  48677. getPointerOverMesh(): Nullable<AbstractMesh>;
  48678. /** @hidden */
  48679. _rebuildGeometries(): void;
  48680. /** @hidden */
  48681. _rebuildTextures(): void;
  48682. private _getByTags;
  48683. /**
  48684. * Get a list of meshes by tags
  48685. * @param tagsQuery defines the tags query to use
  48686. * @param forEach defines a predicate used to filter results
  48687. * @returns an array of Mesh
  48688. */
  48689. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  48690. /**
  48691. * Get a list of cameras by tags
  48692. * @param tagsQuery defines the tags query to use
  48693. * @param forEach defines a predicate used to filter results
  48694. * @returns an array of Camera
  48695. */
  48696. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  48697. /**
  48698. * Get a list of lights by tags
  48699. * @param tagsQuery defines the tags query to use
  48700. * @param forEach defines a predicate used to filter results
  48701. * @returns an array of Light
  48702. */
  48703. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  48704. /**
  48705. * Get a list of materials by tags
  48706. * @param tagsQuery defines the tags query to use
  48707. * @param forEach defines a predicate used to filter results
  48708. * @returns an array of Material
  48709. */
  48710. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  48711. /**
  48712. * Get a list of transform nodes by tags
  48713. * @param tagsQuery defines the tags query to use
  48714. * @param forEach defines a predicate used to filter results
  48715. * @returns an array of TransformNode
  48716. */
  48717. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  48718. /**
  48719. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  48720. * This allowed control for front to back rendering or reversly depending of the special needs.
  48721. *
  48722. * @param renderingGroupId The rendering group id corresponding to its index
  48723. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  48724. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  48725. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  48726. */
  48727. 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;
  48728. /**
  48729. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  48730. *
  48731. * @param renderingGroupId The rendering group id corresponding to its index
  48732. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48733. * @param depth Automatically clears depth between groups if true and autoClear is true.
  48734. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  48735. */
  48736. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  48737. /**
  48738. * Gets the current auto clear configuration for one rendering group of the rendering
  48739. * manager.
  48740. * @param index the rendering group index to get the information for
  48741. * @returns The auto clear setup for the requested rendering group
  48742. */
  48743. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  48744. private _blockMaterialDirtyMechanism;
  48745. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  48746. get blockMaterialDirtyMechanism(): boolean;
  48747. set blockMaterialDirtyMechanism(value: boolean);
  48748. /**
  48749. * Will flag all materials as dirty to trigger new shader compilation
  48750. * @param flag defines the flag used to specify which material part must be marked as dirty
  48751. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  48752. */
  48753. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  48754. /** @hidden */
  48755. _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;
  48756. /** @hidden */
  48757. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  48758. /** @hidden */
  48759. _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;
  48760. /** @hidden */
  48761. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  48762. /** @hidden */
  48763. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  48764. /** @hidden */
  48765. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  48766. }
  48767. }
  48768. declare module BABYLON {
  48769. /**
  48770. * Set of assets to keep when moving a scene into an asset container.
  48771. */
  48772. export class KeepAssets extends AbstractScene {
  48773. }
  48774. /**
  48775. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  48776. */
  48777. export class InstantiatedEntries {
  48778. /**
  48779. * List of new root nodes (eg. nodes with no parent)
  48780. */
  48781. rootNodes: TransformNode[];
  48782. /**
  48783. * List of new skeletons
  48784. */
  48785. skeletons: Skeleton[];
  48786. /**
  48787. * List of new animation groups
  48788. */
  48789. animationGroups: AnimationGroup[];
  48790. }
  48791. /**
  48792. * Container with a set of assets that can be added or removed from a scene.
  48793. */
  48794. export class AssetContainer extends AbstractScene {
  48795. private _wasAddedToScene;
  48796. /**
  48797. * The scene the AssetContainer belongs to.
  48798. */
  48799. scene: Scene;
  48800. /**
  48801. * Instantiates an AssetContainer.
  48802. * @param scene The scene the AssetContainer belongs to.
  48803. */
  48804. constructor(scene: Scene);
  48805. /**
  48806. * Instantiate or clone all meshes and add the new ones to the scene.
  48807. * Skeletons and animation groups will all be cloned
  48808. * @param nameFunction defines an optional function used to get new names for clones
  48809. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  48810. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  48811. */
  48812. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  48813. /**
  48814. * Adds all the assets from the container to the scene.
  48815. */
  48816. addAllToScene(): void;
  48817. /**
  48818. * Removes all the assets in the container from the scene
  48819. */
  48820. removeAllFromScene(): void;
  48821. /**
  48822. * Disposes all the assets in the container
  48823. */
  48824. dispose(): void;
  48825. private _moveAssets;
  48826. /**
  48827. * Removes all the assets contained in the scene and adds them to the container.
  48828. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  48829. */
  48830. moveAllFromScene(keepAssets?: KeepAssets): void;
  48831. /**
  48832. * 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.
  48833. * @returns the root mesh
  48834. */
  48835. createRootMesh(): Mesh;
  48836. /**
  48837. * Merge animations (direct and animation groups) from this asset container into a scene
  48838. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48839. * @param animatables set of animatables to retarget to a node from the scene
  48840. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  48841. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  48842. */
  48843. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  48844. }
  48845. }
  48846. declare module BABYLON {
  48847. /**
  48848. * Defines how the parser contract is defined.
  48849. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  48850. */
  48851. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  48852. /**
  48853. * Defines how the individual parser contract is defined.
  48854. * These parser can parse an individual asset
  48855. */
  48856. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  48857. /**
  48858. * Base class of the scene acting as a container for the different elements composing a scene.
  48859. * This class is dynamically extended by the different components of the scene increasing
  48860. * flexibility and reducing coupling
  48861. */
  48862. export abstract class AbstractScene {
  48863. /**
  48864. * Stores the list of available parsers in the application.
  48865. */
  48866. private static _BabylonFileParsers;
  48867. /**
  48868. * Stores the list of available individual parsers in the application.
  48869. */
  48870. private static _IndividualBabylonFileParsers;
  48871. /**
  48872. * Adds a parser in the list of available ones
  48873. * @param name Defines the name of the parser
  48874. * @param parser Defines the parser to add
  48875. */
  48876. static AddParser(name: string, parser: BabylonFileParser): void;
  48877. /**
  48878. * Gets a general parser from the list of avaialble ones
  48879. * @param name Defines the name of the parser
  48880. * @returns the requested parser or null
  48881. */
  48882. static GetParser(name: string): Nullable<BabylonFileParser>;
  48883. /**
  48884. * Adds n individual parser in the list of available ones
  48885. * @param name Defines the name of the parser
  48886. * @param parser Defines the parser to add
  48887. */
  48888. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  48889. /**
  48890. * Gets an individual parser from the list of avaialble ones
  48891. * @param name Defines the name of the parser
  48892. * @returns the requested parser or null
  48893. */
  48894. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  48895. /**
  48896. * Parser json data and populate both a scene and its associated container object
  48897. * @param jsonData Defines the data to parse
  48898. * @param scene Defines the scene to parse the data for
  48899. * @param container Defines the container attached to the parsing sequence
  48900. * @param rootUrl Defines the root url of the data
  48901. */
  48902. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  48903. /**
  48904. * Gets the list of root nodes (ie. nodes with no parent)
  48905. */
  48906. rootNodes: Node[];
  48907. /** All of the cameras added to this scene
  48908. * @see https://doc.babylonjs.com/babylon101/cameras
  48909. */
  48910. cameras: Camera[];
  48911. /**
  48912. * All of the lights added to this scene
  48913. * @see https://doc.babylonjs.com/babylon101/lights
  48914. */
  48915. lights: Light[];
  48916. /**
  48917. * All of the (abstract) meshes added to this scene
  48918. */
  48919. meshes: AbstractMesh[];
  48920. /**
  48921. * The list of skeletons added to the scene
  48922. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  48923. */
  48924. skeletons: Skeleton[];
  48925. /**
  48926. * All of the particle systems added to this scene
  48927. * @see https://doc.babylonjs.com/babylon101/particles
  48928. */
  48929. particleSystems: IParticleSystem[];
  48930. /**
  48931. * Gets a list of Animations associated with the scene
  48932. */
  48933. animations: Animation[];
  48934. /**
  48935. * All of the animation groups added to this scene
  48936. * @see https://doc.babylonjs.com/how_to/group
  48937. */
  48938. animationGroups: AnimationGroup[];
  48939. /**
  48940. * All of the multi-materials added to this scene
  48941. * @see https://doc.babylonjs.com/how_to/multi_materials
  48942. */
  48943. multiMaterials: MultiMaterial[];
  48944. /**
  48945. * All of the materials added to this scene
  48946. * In the context of a Scene, it is not supposed to be modified manually.
  48947. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  48948. * Note also that the order of the Material within the array is not significant and might change.
  48949. * @see https://doc.babylonjs.com/babylon101/materials
  48950. */
  48951. materials: Material[];
  48952. /**
  48953. * The list of morph target managers added to the scene
  48954. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  48955. */
  48956. morphTargetManagers: MorphTargetManager[];
  48957. /**
  48958. * The list of geometries used in the scene.
  48959. */
  48960. geometries: Geometry[];
  48961. /**
  48962. * All of the tranform nodes added to this scene
  48963. * In the context of a Scene, it is not supposed to be modified manually.
  48964. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  48965. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  48966. * @see https://doc.babylonjs.com/how_to/transformnode
  48967. */
  48968. transformNodes: TransformNode[];
  48969. /**
  48970. * ActionManagers available on the scene.
  48971. */
  48972. actionManagers: AbstractActionManager[];
  48973. /**
  48974. * Textures to keep.
  48975. */
  48976. textures: BaseTexture[];
  48977. /** @hidden */
  48978. protected _environmentTexture: Nullable<BaseTexture>;
  48979. /**
  48980. * Texture used in all pbr material as the reflection texture.
  48981. * As in the majority of the scene they are the same (exception for multi room and so on),
  48982. * this is easier to reference from here than from all the materials.
  48983. */
  48984. get environmentTexture(): Nullable<BaseTexture>;
  48985. set environmentTexture(value: Nullable<BaseTexture>);
  48986. /**
  48987. * The list of postprocesses added to the scene
  48988. */
  48989. postProcesses: PostProcess[];
  48990. /**
  48991. * @returns all meshes, lights, cameras, transformNodes and bones
  48992. */
  48993. getNodes(): Array<Node>;
  48994. }
  48995. }
  48996. declare module BABYLON {
  48997. /**
  48998. * Interface used to define options for Sound class
  48999. */
  49000. export interface ISoundOptions {
  49001. /**
  49002. * Does the sound autoplay once loaded.
  49003. */
  49004. autoplay?: boolean;
  49005. /**
  49006. * Does the sound loop after it finishes playing once.
  49007. */
  49008. loop?: boolean;
  49009. /**
  49010. * Sound's volume
  49011. */
  49012. volume?: number;
  49013. /**
  49014. * Is it a spatial sound?
  49015. */
  49016. spatialSound?: boolean;
  49017. /**
  49018. * Maximum distance to hear that sound
  49019. */
  49020. maxDistance?: number;
  49021. /**
  49022. * Uses user defined attenuation function
  49023. */
  49024. useCustomAttenuation?: boolean;
  49025. /**
  49026. * Define the roll off factor of spatial sounds.
  49027. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49028. */
  49029. rolloffFactor?: number;
  49030. /**
  49031. * Define the reference distance the sound should be heard perfectly.
  49032. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49033. */
  49034. refDistance?: number;
  49035. /**
  49036. * Define the distance attenuation model the sound will follow.
  49037. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49038. */
  49039. distanceModel?: string;
  49040. /**
  49041. * Defines the playback speed (1 by default)
  49042. */
  49043. playbackRate?: number;
  49044. /**
  49045. * Defines if the sound is from a streaming source
  49046. */
  49047. streaming?: boolean;
  49048. /**
  49049. * Defines an optional length (in seconds) inside the sound file
  49050. */
  49051. length?: number;
  49052. /**
  49053. * Defines an optional offset (in seconds) inside the sound file
  49054. */
  49055. offset?: number;
  49056. /**
  49057. * If true, URLs will not be required to state the audio file codec to use.
  49058. */
  49059. skipCodecCheck?: boolean;
  49060. }
  49061. }
  49062. declare module BABYLON {
  49063. /**
  49064. * Defines a sound that can be played in the application.
  49065. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  49066. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49067. */
  49068. export class Sound {
  49069. /**
  49070. * The name of the sound in the scene.
  49071. */
  49072. name: string;
  49073. /**
  49074. * Does the sound autoplay once loaded.
  49075. */
  49076. autoplay: boolean;
  49077. private _loop;
  49078. /**
  49079. * Does the sound loop after it finishes playing once.
  49080. */
  49081. get loop(): boolean;
  49082. set loop(value: boolean);
  49083. /**
  49084. * Does the sound use a custom attenuation curve to simulate the falloff
  49085. * happening when the source gets further away from the camera.
  49086. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  49087. */
  49088. useCustomAttenuation: boolean;
  49089. /**
  49090. * The sound track id this sound belongs to.
  49091. */
  49092. soundTrackId: number;
  49093. /**
  49094. * Is this sound currently played.
  49095. */
  49096. isPlaying: boolean;
  49097. /**
  49098. * Is this sound currently paused.
  49099. */
  49100. isPaused: boolean;
  49101. /**
  49102. * Does this sound enables spatial sound.
  49103. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49104. */
  49105. spatialSound: boolean;
  49106. /**
  49107. * Define the reference distance the sound should be heard perfectly.
  49108. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49109. */
  49110. refDistance: number;
  49111. /**
  49112. * Define the roll off factor of spatial sounds.
  49113. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49114. */
  49115. rolloffFactor: number;
  49116. /**
  49117. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  49118. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49119. */
  49120. maxDistance: number;
  49121. /**
  49122. * Define the distance attenuation model the sound will follow.
  49123. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49124. */
  49125. distanceModel: string;
  49126. /**
  49127. * @hidden
  49128. * Back Compat
  49129. **/
  49130. onended: () => any;
  49131. /**
  49132. * Gets or sets an object used to store user defined information for the sound.
  49133. */
  49134. metadata: any;
  49135. /**
  49136. * Observable event when the current playing sound finishes.
  49137. */
  49138. onEndedObservable: Observable<Sound>;
  49139. /**
  49140. * Gets the current time for the sound.
  49141. */
  49142. get currentTime(): number;
  49143. private _panningModel;
  49144. private _playbackRate;
  49145. private _streaming;
  49146. private _startTime;
  49147. private _startOffset;
  49148. private _position;
  49149. /** @hidden */
  49150. _positionInEmitterSpace: boolean;
  49151. private _localDirection;
  49152. private _volume;
  49153. private _isReadyToPlay;
  49154. private _isDirectional;
  49155. private _readyToPlayCallback;
  49156. private _audioBuffer;
  49157. private _soundSource;
  49158. private _streamingSource;
  49159. private _soundPanner;
  49160. private _soundGain;
  49161. private _inputAudioNode;
  49162. private _outputAudioNode;
  49163. private _coneInnerAngle;
  49164. private _coneOuterAngle;
  49165. private _coneOuterGain;
  49166. private _scene;
  49167. private _connectedTransformNode;
  49168. private _customAttenuationFunction;
  49169. private _registerFunc;
  49170. private _isOutputConnected;
  49171. private _htmlAudioElement;
  49172. private _urlType;
  49173. private _length?;
  49174. private _offset?;
  49175. /** @hidden */
  49176. static _SceneComponentInitialization: (scene: Scene) => void;
  49177. /**
  49178. * Create a sound and attach it to a scene
  49179. * @param name Name of your sound
  49180. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  49181. * @param scene defines the scene the sound belongs to
  49182. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  49183. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  49184. */
  49185. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  49186. /**
  49187. * Release the sound and its associated resources
  49188. */
  49189. dispose(): void;
  49190. /**
  49191. * Gets if the sounds is ready to be played or not.
  49192. * @returns true if ready, otherwise false
  49193. */
  49194. isReady(): boolean;
  49195. /**
  49196. * Get the current class name.
  49197. * @returns current class name
  49198. */
  49199. getClassName(): string;
  49200. private _soundLoaded;
  49201. /**
  49202. * Sets the data of the sound from an audiobuffer
  49203. * @param audioBuffer The audioBuffer containing the data
  49204. */
  49205. setAudioBuffer(audioBuffer: AudioBuffer): void;
  49206. /**
  49207. * Updates the current sounds options such as maxdistance, loop...
  49208. * @param options A JSON object containing values named as the object properties
  49209. */
  49210. updateOptions(options: ISoundOptions): void;
  49211. private _createSpatialParameters;
  49212. private _updateSpatialParameters;
  49213. /**
  49214. * Switch the panning model to HRTF:
  49215. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  49216. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49217. */
  49218. switchPanningModelToHRTF(): void;
  49219. /**
  49220. * Switch the panning model to Equal Power:
  49221. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  49222. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49223. */
  49224. switchPanningModelToEqualPower(): void;
  49225. private _switchPanningModel;
  49226. /**
  49227. * Connect this sound to a sound track audio node like gain...
  49228. * @param soundTrackAudioNode the sound track audio node to connect to
  49229. */
  49230. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  49231. /**
  49232. * Transform this sound into a directional source
  49233. * @param coneInnerAngle Size of the inner cone in degree
  49234. * @param coneOuterAngle Size of the outer cone in degree
  49235. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  49236. */
  49237. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  49238. /**
  49239. * Gets or sets the inner angle for the directional cone.
  49240. */
  49241. get directionalConeInnerAngle(): number;
  49242. /**
  49243. * Gets or sets the inner angle for the directional cone.
  49244. */
  49245. set directionalConeInnerAngle(value: number);
  49246. /**
  49247. * Gets or sets the outer angle for the directional cone.
  49248. */
  49249. get directionalConeOuterAngle(): number;
  49250. /**
  49251. * Gets or sets the outer angle for the directional cone.
  49252. */
  49253. set directionalConeOuterAngle(value: number);
  49254. /**
  49255. * Sets the position of the emitter if spatial sound is enabled
  49256. * @param newPosition Defines the new position
  49257. */
  49258. setPosition(newPosition: Vector3): void;
  49259. /**
  49260. * Sets the local direction of the emitter if spatial sound is enabled
  49261. * @param newLocalDirection Defines the new local direction
  49262. */
  49263. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  49264. private _updateDirection;
  49265. /** @hidden */
  49266. updateDistanceFromListener(): void;
  49267. /**
  49268. * Sets a new custom attenuation function for the sound.
  49269. * @param callback Defines the function used for the attenuation
  49270. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  49271. */
  49272. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  49273. /**
  49274. * Play the sound
  49275. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  49276. * @param offset (optional) Start the sound at a specific time in seconds
  49277. * @param length (optional) Sound duration (in seconds)
  49278. */
  49279. play(time?: number, offset?: number, length?: number): void;
  49280. private _onended;
  49281. /**
  49282. * Stop the sound
  49283. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  49284. */
  49285. stop(time?: number): void;
  49286. /**
  49287. * Put the sound in pause
  49288. */
  49289. pause(): void;
  49290. /**
  49291. * Sets a dedicated volume for this sounds
  49292. * @param newVolume Define the new volume of the sound
  49293. * @param time Define time for gradual change to new volume
  49294. */
  49295. setVolume(newVolume: number, time?: number): void;
  49296. /**
  49297. * Set the sound play back rate
  49298. * @param newPlaybackRate Define the playback rate the sound should be played at
  49299. */
  49300. setPlaybackRate(newPlaybackRate: number): void;
  49301. /**
  49302. * Gets the volume of the sound.
  49303. * @returns the volume of the sound
  49304. */
  49305. getVolume(): number;
  49306. /**
  49307. * Attach the sound to a dedicated mesh
  49308. * @param transformNode The transform node to connect the sound with
  49309. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  49310. */
  49311. attachToMesh(transformNode: TransformNode): void;
  49312. /**
  49313. * Detach the sound from the previously attached mesh
  49314. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  49315. */
  49316. detachFromMesh(): void;
  49317. private _onRegisterAfterWorldMatrixUpdate;
  49318. /**
  49319. * Clone the current sound in the scene.
  49320. * @returns the new sound clone
  49321. */
  49322. clone(): Nullable<Sound>;
  49323. /**
  49324. * Gets the current underlying audio buffer containing the data
  49325. * @returns the audio buffer
  49326. */
  49327. getAudioBuffer(): Nullable<AudioBuffer>;
  49328. /**
  49329. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  49330. * @returns the source node
  49331. */
  49332. getSoundSource(): Nullable<AudioBufferSourceNode>;
  49333. /**
  49334. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  49335. * @returns the gain node
  49336. */
  49337. getSoundGain(): Nullable<GainNode>;
  49338. /**
  49339. * Serializes the Sound in a JSON representation
  49340. * @returns the JSON representation of the sound
  49341. */
  49342. serialize(): any;
  49343. /**
  49344. * Parse a JSON representation of a sound to instantiate in a given scene
  49345. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  49346. * @param scene Define the scene the new parsed sound should be created in
  49347. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  49348. * @param sourceSound Define a sound place holder if do not need to instantiate a new one
  49349. * @returns the newly parsed sound
  49350. */
  49351. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  49352. }
  49353. }
  49354. declare module BABYLON {
  49355. /**
  49356. * This defines an action helpful to play a defined sound on a triggered action.
  49357. */
  49358. export class PlaySoundAction extends Action {
  49359. private _sound;
  49360. /**
  49361. * Instantiate the action
  49362. * @param triggerOptions defines the trigger options
  49363. * @param sound defines the sound to play
  49364. * @param condition defines the trigger related conditions
  49365. */
  49366. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  49367. /** @hidden */
  49368. _prepare(): void;
  49369. /**
  49370. * Execute the action and play the sound.
  49371. */
  49372. execute(): void;
  49373. /**
  49374. * Serializes the actions and its related information.
  49375. * @param parent defines the object to serialize in
  49376. * @returns the serialized object
  49377. */
  49378. serialize(parent: any): any;
  49379. }
  49380. /**
  49381. * This defines an action helpful to stop a defined sound on a triggered action.
  49382. */
  49383. export class StopSoundAction extends Action {
  49384. private _sound;
  49385. /**
  49386. * Instantiate the action
  49387. * @param triggerOptions defines the trigger options
  49388. * @param sound defines the sound to stop
  49389. * @param condition defines the trigger related conditions
  49390. */
  49391. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  49392. /** @hidden */
  49393. _prepare(): void;
  49394. /**
  49395. * Execute the action and stop the sound.
  49396. */
  49397. execute(): void;
  49398. /**
  49399. * Serializes the actions and its related information.
  49400. * @param parent defines the object to serialize in
  49401. * @returns the serialized object
  49402. */
  49403. serialize(parent: any): any;
  49404. }
  49405. }
  49406. declare module BABYLON {
  49407. /**
  49408. * This defines an action responsible to change the value of a property
  49409. * by interpolating between its current value and the newly set one once triggered.
  49410. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  49411. */
  49412. export class InterpolateValueAction extends Action {
  49413. /**
  49414. * Defines the path of the property where the value should be interpolated
  49415. */
  49416. propertyPath: string;
  49417. /**
  49418. * Defines the target value at the end of the interpolation.
  49419. */
  49420. value: any;
  49421. /**
  49422. * Defines the time it will take for the property to interpolate to the value.
  49423. */
  49424. duration: number;
  49425. /**
  49426. * Defines if the other scene animations should be stopped when the action has been triggered
  49427. */
  49428. stopOtherAnimations?: boolean;
  49429. /**
  49430. * Defines a callback raised once the interpolation animation has been done.
  49431. */
  49432. onInterpolationDone?: () => void;
  49433. /**
  49434. * Observable triggered once the interpolation animation has been done.
  49435. */
  49436. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  49437. private _target;
  49438. private _effectiveTarget;
  49439. private _property;
  49440. /**
  49441. * Instantiate the action
  49442. * @param triggerOptions defines the trigger options
  49443. * @param target defines the object containing the value to interpolate
  49444. * @param propertyPath defines the path to the property in the target object
  49445. * @param value defines the target value at the end of the interpolation
  49446. * @param duration defines the time it will take for the property to interpolate to the value.
  49447. * @param condition defines the trigger related conditions
  49448. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  49449. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  49450. */
  49451. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  49452. /** @hidden */
  49453. _prepare(): void;
  49454. /**
  49455. * Execute the action starts the value interpolation.
  49456. */
  49457. execute(): void;
  49458. /**
  49459. * Serializes the actions and its related information.
  49460. * @param parent defines the object to serialize in
  49461. * @returns the serialized object
  49462. */
  49463. serialize(parent: any): any;
  49464. }
  49465. }
  49466. declare module BABYLON {
  49467. /**
  49468. * A cursor which tracks a point on a path
  49469. */
  49470. export class PathCursor {
  49471. private path;
  49472. /**
  49473. * Stores path cursor callbacks for when an onchange event is triggered
  49474. */
  49475. private _onchange;
  49476. /**
  49477. * The value of the path cursor
  49478. */
  49479. value: number;
  49480. /**
  49481. * The animation array of the path cursor
  49482. */
  49483. animations: Animation[];
  49484. /**
  49485. * Initializes the path cursor
  49486. * @param path The path to track
  49487. */
  49488. constructor(path: Path2);
  49489. /**
  49490. * Gets the cursor point on the path
  49491. * @returns A point on the path cursor at the cursor location
  49492. */
  49493. getPoint(): Vector3;
  49494. /**
  49495. * Moves the cursor ahead by the step amount
  49496. * @param step The amount to move the cursor forward
  49497. * @returns This path cursor
  49498. */
  49499. moveAhead(step?: number): PathCursor;
  49500. /**
  49501. * Moves the cursor behind by the step amount
  49502. * @param step The amount to move the cursor back
  49503. * @returns This path cursor
  49504. */
  49505. moveBack(step?: number): PathCursor;
  49506. /**
  49507. * Moves the cursor by the step amount
  49508. * If the step amount is greater than one, an exception is thrown
  49509. * @param step The amount to move the cursor
  49510. * @returns This path cursor
  49511. */
  49512. move(step: number): PathCursor;
  49513. /**
  49514. * Ensures that the value is limited between zero and one
  49515. * @returns This path cursor
  49516. */
  49517. private ensureLimits;
  49518. /**
  49519. * Runs onchange callbacks on change (used by the animation engine)
  49520. * @returns This path cursor
  49521. */
  49522. private raiseOnChange;
  49523. /**
  49524. * Executes a function on change
  49525. * @param f A path cursor onchange callback
  49526. * @returns This path cursor
  49527. */
  49528. onchange(f: (cursor: PathCursor) => void): PathCursor;
  49529. }
  49530. }
  49531. declare module BABYLON {
  49532. /**
  49533. * This represents the default audio engine used in babylon.
  49534. * It is responsible to play, synchronize and analyse sounds throughout the application.
  49535. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49536. */
  49537. export class AudioEngine implements IAudioEngine {
  49538. private _audioContext;
  49539. private _audioContextInitialized;
  49540. private _muteButton;
  49541. private _hostElement;
  49542. /**
  49543. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  49544. */
  49545. canUseWebAudio: boolean;
  49546. /**
  49547. * The master gain node defines the global audio volume of your audio engine.
  49548. */
  49549. masterGain: GainNode;
  49550. /**
  49551. * Defines if Babylon should emit a warning if WebAudio is not supported.
  49552. * @ignoreNaming
  49553. */
  49554. WarnedWebAudioUnsupported: boolean;
  49555. /**
  49556. * Gets whether or not mp3 are supported by your browser.
  49557. */
  49558. isMP3supported: boolean;
  49559. /**
  49560. * Gets whether or not ogg are supported by your browser.
  49561. */
  49562. isOGGsupported: boolean;
  49563. /**
  49564. * Gets whether audio has been unlocked on the device.
  49565. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  49566. * a user interaction has happened.
  49567. */
  49568. unlocked: boolean;
  49569. /**
  49570. * Defines if the audio engine relies on a custom unlocked button.
  49571. * In this case, the embedded button will not be displayed.
  49572. */
  49573. useCustomUnlockedButton: boolean;
  49574. /**
  49575. * Event raised when audio has been unlocked on the browser.
  49576. */
  49577. onAudioUnlockedObservable: Observable<IAudioEngine>;
  49578. /**
  49579. * Event raised when audio has been locked on the browser.
  49580. */
  49581. onAudioLockedObservable: Observable<IAudioEngine>;
  49582. /**
  49583. * Gets the current AudioContext if available.
  49584. */
  49585. get audioContext(): Nullable<AudioContext>;
  49586. private _connectedAnalyser;
  49587. /**
  49588. * Instantiates a new audio engine.
  49589. *
  49590. * There should be only one per page as some browsers restrict the number
  49591. * of audio contexts you can create.
  49592. * @param hostElement defines the host element where to display the mute icon if necessary
  49593. */
  49594. constructor(hostElement?: Nullable<HTMLElement>);
  49595. /**
  49596. * Flags the audio engine in Locked state.
  49597. * This happens due to new browser policies preventing audio to autoplay.
  49598. */
  49599. lock(): void;
  49600. /**
  49601. * Unlocks the audio engine once a user action has been done on the dom.
  49602. * This is helpful to resume play once browser policies have been satisfied.
  49603. */
  49604. unlock(): void;
  49605. private _resumeAudioContext;
  49606. private _initializeAudioContext;
  49607. private _tryToRun;
  49608. private _triggerRunningState;
  49609. private _triggerSuspendedState;
  49610. private _displayMuteButton;
  49611. private _moveButtonToTopLeft;
  49612. private _onResize;
  49613. private _hideMuteButton;
  49614. /**
  49615. * Destroy and release the resources associated with the audio context.
  49616. */
  49617. dispose(): void;
  49618. /**
  49619. * Gets the global volume sets on the master gain.
  49620. * @returns the global volume if set or -1 otherwise
  49621. */
  49622. getGlobalVolume(): number;
  49623. /**
  49624. * Sets the global volume of your experience (sets on the master gain).
  49625. * @param newVolume Defines the new global volume of the application
  49626. */
  49627. setGlobalVolume(newVolume: number): void;
  49628. /**
  49629. * Connect the audio engine to an audio analyser allowing some amazing
  49630. * synchronization between the sounds/music and your visualization (VuMeter for instance).
  49631. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  49632. * @param analyser The analyser to connect to the engine
  49633. */
  49634. connectToAnalyser(analyser: Analyser): void;
  49635. }
  49636. }
  49637. declare module BABYLON {
  49638. /**
  49639. * Options allowed during the creation of a sound track.
  49640. */
  49641. export interface ISoundTrackOptions {
  49642. /**
  49643. * The volume the sound track should take during creation
  49644. */
  49645. volume?: number;
  49646. /**
  49647. * Define if the sound track is the main sound track of the scene
  49648. */
  49649. mainTrack?: boolean;
  49650. }
  49651. /**
  49652. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  49653. * It will be also used in a future release to apply effects on a specific track.
  49654. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  49655. */
  49656. export class SoundTrack {
  49657. /**
  49658. * The unique identifier of the sound track in the scene.
  49659. */
  49660. id: number;
  49661. /**
  49662. * The list of sounds included in the sound track.
  49663. */
  49664. soundCollection: Array<Sound>;
  49665. private _outputAudioNode;
  49666. private _scene;
  49667. private _connectedAnalyser;
  49668. private _options;
  49669. private _isInitialized;
  49670. /**
  49671. * Creates a new sound track.
  49672. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  49673. * @param scene Define the scene the sound track belongs to
  49674. * @param options
  49675. */
  49676. constructor(scene: Scene, options?: ISoundTrackOptions);
  49677. private _initializeSoundTrackAudioGraph;
  49678. /**
  49679. * Release the sound track and its associated resources
  49680. */
  49681. dispose(): void;
  49682. /**
  49683. * Adds a sound to this sound track
  49684. * @param sound define the sound to add
  49685. * @ignoreNaming
  49686. */
  49687. addSound(sound: Sound): void;
  49688. /**
  49689. * Removes a sound to this sound track
  49690. * @param sound define the sound to remove
  49691. * @ignoreNaming
  49692. */
  49693. removeSound(sound: Sound): void;
  49694. /**
  49695. * Set a global volume for the full sound track.
  49696. * @param newVolume Define the new volume of the sound track
  49697. */
  49698. setVolume(newVolume: number): void;
  49699. /**
  49700. * Switch the panning model to HRTF:
  49701. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  49702. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49703. */
  49704. switchPanningModelToHRTF(): void;
  49705. /**
  49706. * Switch the panning model to Equal Power:
  49707. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  49708. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49709. */
  49710. switchPanningModelToEqualPower(): void;
  49711. /**
  49712. * Connect the sound track to an audio analyser allowing some amazing
  49713. * synchronization between the sounds/music and your visualization (VuMeter for instance).
  49714. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  49715. * @param analyser The analyser to connect to the engine
  49716. */
  49717. connectToAnalyser(analyser: Analyser): void;
  49718. }
  49719. }
  49720. declare module BABYLON {
  49721. interface AbstractScene {
  49722. /**
  49723. * The list of sounds used in the scene.
  49724. */
  49725. sounds: Nullable<Array<Sound>>;
  49726. }
  49727. interface Scene {
  49728. /**
  49729. * @hidden
  49730. * Backing field
  49731. */
  49732. _mainSoundTrack: SoundTrack;
  49733. /**
  49734. * The main sound track played by the scene.
  49735. * It contains your primary collection of sounds.
  49736. */
  49737. mainSoundTrack: SoundTrack;
  49738. /**
  49739. * The list of sound tracks added to the scene
  49740. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49741. */
  49742. soundTracks: Nullable<Array<SoundTrack>>;
  49743. /**
  49744. * Gets a sound using a given name
  49745. * @param name defines the name to search for
  49746. * @return the found sound or null if not found at all.
  49747. */
  49748. getSoundByName(name: string): Nullable<Sound>;
  49749. /**
  49750. * Gets or sets if audio support is enabled
  49751. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49752. */
  49753. audioEnabled: boolean;
  49754. /**
  49755. * Gets or sets if audio will be output to headphones
  49756. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49757. */
  49758. headphone: boolean;
  49759. /**
  49760. * Gets or sets custom audio listener position provider
  49761. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49762. */
  49763. audioListenerPositionProvider: Nullable<() => Vector3>;
  49764. /**
  49765. * Gets or sets a refresh rate when using 3D audio positioning
  49766. */
  49767. audioPositioningRefreshRate: number;
  49768. }
  49769. /**
  49770. * Defines the sound scene component responsible to manage any sounds
  49771. * in a given scene.
  49772. */
  49773. export class AudioSceneComponent implements ISceneSerializableComponent {
  49774. private static _CameraDirectionLH;
  49775. private static _CameraDirectionRH;
  49776. /**
  49777. * The component name helpful to identify the component in the list of scene components.
  49778. */
  49779. readonly name: string;
  49780. /**
  49781. * The scene the component belongs to.
  49782. */
  49783. scene: Scene;
  49784. private _audioEnabled;
  49785. /**
  49786. * Gets whether audio is enabled or not.
  49787. * Please use related enable/disable method to switch state.
  49788. */
  49789. get audioEnabled(): boolean;
  49790. private _headphone;
  49791. /**
  49792. * Gets whether audio is outputting to headphone or not.
  49793. * Please use the according Switch methods to change output.
  49794. */
  49795. get headphone(): boolean;
  49796. /**
  49797. * Gets or sets a refresh rate when using 3D audio positioning
  49798. */
  49799. audioPositioningRefreshRate: number;
  49800. private _audioListenerPositionProvider;
  49801. /**
  49802. * Gets the current audio listener position provider
  49803. */
  49804. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  49805. /**
  49806. * Sets a custom listener position for all sounds in the scene
  49807. * By default, this is the position of the first active camera
  49808. */
  49809. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  49810. /**
  49811. * Creates a new instance of the component for the given scene
  49812. * @param scene Defines the scene to register the component in
  49813. */
  49814. constructor(scene: Scene);
  49815. /**
  49816. * Registers the component in a given scene
  49817. */
  49818. register(): void;
  49819. /**
  49820. * Rebuilds the elements related to this component in case of
  49821. * context lost for instance.
  49822. */
  49823. rebuild(): void;
  49824. /**
  49825. * Serializes the component data to the specified json object
  49826. * @param serializationObject The object to serialize to
  49827. */
  49828. serialize(serializationObject: any): void;
  49829. /**
  49830. * Adds all the elements from the container to the scene
  49831. * @param container the container holding the elements
  49832. */
  49833. addFromContainer(container: AbstractScene): void;
  49834. /**
  49835. * Removes all the elements in the container from the scene
  49836. * @param container contains the elements to remove
  49837. * @param dispose if the removed element should be disposed (default: false)
  49838. */
  49839. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49840. /**
  49841. * Disposes the component and the associated resources.
  49842. */
  49843. dispose(): void;
  49844. /**
  49845. * Disables audio in the associated scene.
  49846. */
  49847. disableAudio(): void;
  49848. /**
  49849. * Enables audio in the associated scene.
  49850. */
  49851. enableAudio(): void;
  49852. /**
  49853. * Switch audio to headphone output.
  49854. */
  49855. switchAudioModeForHeadphones(): void;
  49856. /**
  49857. * Switch audio to normal speakers.
  49858. */
  49859. switchAudioModeForNormalSpeakers(): void;
  49860. private _cachedCameraDirection;
  49861. private _cachedCameraPosition;
  49862. private _lastCheck;
  49863. private _afterRender;
  49864. }
  49865. }
  49866. declare module BABYLON {
  49867. /**
  49868. * Wraps one or more Sound objects and selects one with random weight for playback.
  49869. */
  49870. export class WeightedSound {
  49871. /** When true a Sound will be selected and played when the current playing Sound completes. */
  49872. loop: boolean;
  49873. private _coneInnerAngle;
  49874. private _coneOuterAngle;
  49875. private _volume;
  49876. /** A Sound is currently playing. */
  49877. isPlaying: boolean;
  49878. /** A Sound is currently paused. */
  49879. isPaused: boolean;
  49880. private _sounds;
  49881. private _weights;
  49882. private _currentIndex?;
  49883. /**
  49884. * Creates a new WeightedSound from the list of sounds given.
  49885. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  49886. * @param sounds Array of Sounds that will be selected from.
  49887. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  49888. */
  49889. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  49890. /**
  49891. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  49892. */
  49893. get directionalConeInnerAngle(): number;
  49894. /**
  49895. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  49896. */
  49897. set directionalConeInnerAngle(value: number);
  49898. /**
  49899. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  49900. * Listener angles between innerAngle and outerAngle will falloff linearly.
  49901. */
  49902. get directionalConeOuterAngle(): number;
  49903. /**
  49904. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  49905. * Listener angles between innerAngle and outerAngle will falloff linearly.
  49906. */
  49907. set directionalConeOuterAngle(value: number);
  49908. /**
  49909. * Playback volume.
  49910. */
  49911. get volume(): number;
  49912. /**
  49913. * Playback volume.
  49914. */
  49915. set volume(value: number);
  49916. private _onended;
  49917. /**
  49918. * Suspend playback
  49919. */
  49920. pause(): void;
  49921. /**
  49922. * Stop playback
  49923. */
  49924. stop(): void;
  49925. /**
  49926. * Start playback.
  49927. * @param startOffset Position the clip head at a specific time in seconds.
  49928. */
  49929. play(startOffset?: number): void;
  49930. }
  49931. }
  49932. declare module BABYLON {
  49933. /**
  49934. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  49935. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  49936. */
  49937. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  49938. /**
  49939. * Gets the name of the behavior.
  49940. */
  49941. get name(): string;
  49942. /**
  49943. * The easing function used by animations
  49944. */
  49945. static EasingFunction: BackEase;
  49946. /**
  49947. * The easing mode used by animations
  49948. */
  49949. static EasingMode: number;
  49950. /**
  49951. * The duration of the animation, in milliseconds
  49952. */
  49953. transitionDuration: number;
  49954. /**
  49955. * Length of the distance animated by the transition when lower radius is reached
  49956. */
  49957. lowerRadiusTransitionRange: number;
  49958. /**
  49959. * Length of the distance animated by the transition when upper radius is reached
  49960. */
  49961. upperRadiusTransitionRange: number;
  49962. private _autoTransitionRange;
  49963. /**
  49964. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  49965. */
  49966. get autoTransitionRange(): boolean;
  49967. /**
  49968. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  49969. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  49970. */
  49971. set autoTransitionRange(value: boolean);
  49972. private _attachedCamera;
  49973. private _onAfterCheckInputsObserver;
  49974. private _onMeshTargetChangedObserver;
  49975. /**
  49976. * Initializes the behavior.
  49977. */
  49978. init(): void;
  49979. /**
  49980. * Attaches the behavior to its arc rotate camera.
  49981. * @param camera Defines the camera to attach the behavior to
  49982. */
  49983. attach(camera: ArcRotateCamera): void;
  49984. /**
  49985. * Detaches the behavior from its current arc rotate camera.
  49986. */
  49987. detach(): void;
  49988. private _radiusIsAnimating;
  49989. private _radiusBounceTransition;
  49990. private _animatables;
  49991. private _cachedWheelPrecision;
  49992. /**
  49993. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  49994. * @param radiusLimit The limit to check against.
  49995. * @return Bool to indicate if at limit.
  49996. */
  49997. private _isRadiusAtLimit;
  49998. /**
  49999. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  50000. * @param radiusDelta The delta by which to animate to. Can be negative.
  50001. */
  50002. private _applyBoundRadiusAnimation;
  50003. /**
  50004. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  50005. */
  50006. protected _clearAnimationLocks(): void;
  50007. /**
  50008. * Stops and removes all animations that have been applied to the camera
  50009. */
  50010. stopAllAnimations(): void;
  50011. }
  50012. }
  50013. declare module BABYLON {
  50014. /**
  50015. * 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.
  50016. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  50017. */
  50018. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  50019. /**
  50020. * Gets the name of the behavior.
  50021. */
  50022. get name(): string;
  50023. private _mode;
  50024. private _radiusScale;
  50025. private _positionScale;
  50026. private _defaultElevation;
  50027. private _elevationReturnTime;
  50028. private _elevationReturnWaitTime;
  50029. private _zoomStopsAnimation;
  50030. private _framingTime;
  50031. /**
  50032. * The easing function used by animations
  50033. */
  50034. static EasingFunction: ExponentialEase;
  50035. /**
  50036. * The easing mode used by animations
  50037. */
  50038. static EasingMode: number;
  50039. /**
  50040. * Sets the current mode used by the behavior
  50041. */
  50042. set mode(mode: number);
  50043. /**
  50044. * Gets current mode used by the behavior.
  50045. */
  50046. get mode(): number;
  50047. /**
  50048. * Sets the scale applied to the radius (1 by default)
  50049. */
  50050. set radiusScale(radius: number);
  50051. /**
  50052. * Gets the scale applied to the radius
  50053. */
  50054. get radiusScale(): number;
  50055. /**
  50056. * Sets 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. set positionScale(scale: number);
  50059. /**
  50060. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  50061. */
  50062. get positionScale(): number;
  50063. /**
  50064. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  50065. * behaviour is triggered, in radians.
  50066. */
  50067. set defaultElevation(elevation: number);
  50068. /**
  50069. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  50070. * behaviour is triggered, in radians.
  50071. */
  50072. get defaultElevation(): number;
  50073. /**
  50074. * Sets the time (in milliseconds) taken to return to the default beta position.
  50075. * Negative value indicates camera should not return to default.
  50076. */
  50077. set elevationReturnTime(speed: number);
  50078. /**
  50079. * Gets the time (in milliseconds) taken to return to the default beta position.
  50080. * Negative value indicates camera should not return to default.
  50081. */
  50082. get elevationReturnTime(): number;
  50083. /**
  50084. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  50085. */
  50086. set elevationReturnWaitTime(time: number);
  50087. /**
  50088. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  50089. */
  50090. get elevationReturnWaitTime(): number;
  50091. /**
  50092. * Sets the flag that indicates if user zooming should stop animation.
  50093. */
  50094. set zoomStopsAnimation(flag: boolean);
  50095. /**
  50096. * Gets the flag that indicates if user zooming should stop animation.
  50097. */
  50098. get zoomStopsAnimation(): boolean;
  50099. /**
  50100. * Sets the transition time when framing the mesh, in milliseconds
  50101. */
  50102. set framingTime(time: number);
  50103. /**
  50104. * Gets the transition time when framing the mesh, in milliseconds
  50105. */
  50106. get framingTime(): number;
  50107. /**
  50108. * Define if the behavior should automatically change the configured
  50109. * camera limits and sensibilities.
  50110. */
  50111. autoCorrectCameraLimitsAndSensibility: boolean;
  50112. private _onPrePointerObservableObserver;
  50113. private _onAfterCheckInputsObserver;
  50114. private _onMeshTargetChangedObserver;
  50115. private _attachedCamera;
  50116. private _isPointerDown;
  50117. private _lastInteractionTime;
  50118. /**
  50119. * Initializes the behavior.
  50120. */
  50121. init(): void;
  50122. /**
  50123. * Attaches the behavior to its arc rotate camera.
  50124. * @param camera Defines the camera to attach the behavior to
  50125. */
  50126. attach(camera: ArcRotateCamera): void;
  50127. /**
  50128. * Detaches the behavior from its current arc rotate camera.
  50129. */
  50130. detach(): void;
  50131. private _animatables;
  50132. private _betaIsAnimating;
  50133. private _betaTransition;
  50134. private _radiusTransition;
  50135. private _vectorTransition;
  50136. /**
  50137. * Targets the given mesh and updates zoom level accordingly.
  50138. * @param mesh The mesh to target.
  50139. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  50140. * @param onAnimationEnd Callback triggered at the end of the framing animation
  50141. */
  50142. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  50143. /**
  50144. * Targets the given mesh with its children and updates zoom level accordingly.
  50145. * @param mesh The mesh to target.
  50146. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  50147. * @param onAnimationEnd Callback triggered at the end of the framing animation
  50148. */
  50149. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  50150. /**
  50151. * Targets the given meshes with their children and updates zoom level accordingly.
  50152. * @param meshes The mesh to target.
  50153. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  50154. * @param onAnimationEnd Callback triggered at the end of the framing animation
  50155. */
  50156. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  50157. /**
  50158. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  50159. * @param minimumWorld Determines the smaller position of the bounding box extend
  50160. * @param maximumWorld Determines the bigger position of the bounding box extend
  50161. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  50162. * @param onAnimationEnd Callback triggered at the end of the framing animation
  50163. */
  50164. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  50165. /**
  50166. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  50167. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  50168. * frustum width.
  50169. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  50170. * to fully enclose the mesh in the viewing frustum.
  50171. */
  50172. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  50173. /**
  50174. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  50175. * is automatically returned to its default position (expected to be above ground plane).
  50176. */
  50177. private _maintainCameraAboveGround;
  50178. /**
  50179. * Returns the frustum slope based on the canvas ratio and camera FOV
  50180. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  50181. */
  50182. private _getFrustumSlope;
  50183. /**
  50184. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  50185. */
  50186. private _clearAnimationLocks;
  50187. /**
  50188. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  50189. */
  50190. private _applyUserInteraction;
  50191. /**
  50192. * Stops and removes all animations that have been applied to the camera
  50193. */
  50194. stopAllAnimations(): void;
  50195. /**
  50196. * Gets a value indicating if the user is moving the camera
  50197. */
  50198. get isUserIsMoving(): boolean;
  50199. /**
  50200. * The camera can move all the way towards the mesh.
  50201. */
  50202. static IgnoreBoundsSizeMode: number;
  50203. /**
  50204. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  50205. */
  50206. static FitFrustumSidesMode: number;
  50207. }
  50208. }
  50209. declare module BABYLON {
  50210. /**
  50211. * Base class for Camera Pointer Inputs.
  50212. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  50213. * for example usage.
  50214. */
  50215. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  50216. /**
  50217. * Defines the camera the input is attached to.
  50218. */
  50219. abstract camera: Camera;
  50220. /**
  50221. * Whether keyboard modifier keys are pressed at time of last mouse event.
  50222. */
  50223. protected _altKey: boolean;
  50224. protected _ctrlKey: boolean;
  50225. protected _metaKey: boolean;
  50226. protected _shiftKey: boolean;
  50227. /**
  50228. * Which mouse buttons were pressed at time of last mouse event.
  50229. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  50230. */
  50231. protected _buttonsPressed: number;
  50232. /**
  50233. * Defines the buttons associated with the input to handle camera move.
  50234. */
  50235. buttons: number[];
  50236. /**
  50237. * Attach the input controls to a specific dom element to get the input from.
  50238. * @param element Defines the element the controls should be listened from
  50239. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50240. */
  50241. attachControl(noPreventDefault?: boolean): void;
  50242. /**
  50243. * Detach the current controls from the specified dom element.
  50244. */
  50245. detachControl(): void;
  50246. /**
  50247. * Gets the class name of the current input.
  50248. * @returns the class name
  50249. */
  50250. getClassName(): string;
  50251. /**
  50252. * Get the friendly name associated with the input class.
  50253. * @returns the input friendly name
  50254. */
  50255. getSimpleName(): string;
  50256. /**
  50257. * Called on pointer POINTERDOUBLETAP event.
  50258. * Override this method to provide functionality on POINTERDOUBLETAP event.
  50259. */
  50260. protected onDoubleTap(type: string): void;
  50261. /**
  50262. * Called on pointer POINTERMOVE event if only a single touch is active.
  50263. * Override this method to provide functionality.
  50264. */
  50265. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  50266. /**
  50267. * Called on pointer POINTERMOVE event if multiple touches are active.
  50268. * Override this method to provide functionality.
  50269. */
  50270. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  50271. /**
  50272. * Called on JS contextmenu event.
  50273. * Override this method to provide functionality.
  50274. */
  50275. protected onContextMenu(evt: PointerEvent): void;
  50276. /**
  50277. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  50278. * press.
  50279. * Override this method to provide functionality.
  50280. */
  50281. protected onButtonDown(evt: IPointerEvent): void;
  50282. /**
  50283. * Called each time a new POINTERUP event occurs. Ie, for each button
  50284. * release.
  50285. * Override this method to provide functionality.
  50286. */
  50287. protected onButtonUp(evt: IPointerEvent): void;
  50288. /**
  50289. * Called when window becomes inactive.
  50290. * Override this method to provide functionality.
  50291. */
  50292. protected onLostFocus(): void;
  50293. private _pointerInput;
  50294. private _observer;
  50295. private _onLostFocus;
  50296. private pointA;
  50297. private pointB;
  50298. }
  50299. }
  50300. declare module BABYLON {
  50301. /**
  50302. * Manage the pointers inputs to control an arc rotate camera.
  50303. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50304. */
  50305. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  50306. /**
  50307. * Defines the camera the input is attached to.
  50308. */
  50309. camera: ArcRotateCamera;
  50310. /**
  50311. * Gets the class name of the current input.
  50312. * @returns the class name
  50313. */
  50314. getClassName(): string;
  50315. /**
  50316. * Defines the buttons associated with the input to handle camera move.
  50317. */
  50318. buttons: number[];
  50319. /**
  50320. * Defines the pointer angular sensibility along the X axis or how fast is
  50321. * the camera rotating.
  50322. */
  50323. angularSensibilityX: number;
  50324. /**
  50325. * Defines the pointer angular sensibility along the Y axis or how fast is
  50326. * the camera rotating.
  50327. */
  50328. angularSensibilityY: number;
  50329. /**
  50330. * Defines the pointer pinch precision or how fast is the camera zooming.
  50331. */
  50332. pinchPrecision: number;
  50333. /**
  50334. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  50335. * from 0.
  50336. * It defines the percentage of current camera.radius to use as delta when
  50337. * pinch zoom is used.
  50338. */
  50339. pinchDeltaPercentage: number;
  50340. /**
  50341. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  50342. * that any object in the plane at the camera's target point will scale
  50343. * perfectly with finger motion.
  50344. * Overrides pinchDeltaPercentage and pinchPrecision.
  50345. */
  50346. useNaturalPinchZoom: boolean;
  50347. /**
  50348. * Defines whether zoom (2 fingers pinch) is enabled through multitouch
  50349. */
  50350. pinchZoom: boolean;
  50351. /**
  50352. * Defines the pointer panning sensibility or how fast is the camera moving.
  50353. */
  50354. panningSensibility: number;
  50355. /**
  50356. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  50357. */
  50358. multiTouchPanning: boolean;
  50359. /**
  50360. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  50361. * zoom (pinch) through multitouch.
  50362. */
  50363. multiTouchPanAndZoom: boolean;
  50364. /**
  50365. * Revers pinch action direction.
  50366. */
  50367. pinchInwards: boolean;
  50368. private _isPanClick;
  50369. private _twoFingerActivityCount;
  50370. private _isPinching;
  50371. /**
  50372. * Move camera from multi touch panning positions.
  50373. */
  50374. private _computeMultiTouchPanning;
  50375. /**
  50376. * Move camera from pinch zoom distances.
  50377. */
  50378. private _computePinchZoom;
  50379. /**
  50380. * Called on pointer POINTERMOVE event if only a single touch is active.
  50381. */
  50382. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  50383. /**
  50384. * Called on pointer POINTERDOUBLETAP event.
  50385. */
  50386. protected onDoubleTap(type: string): void;
  50387. /**
  50388. * Called on pointer POINTERMOVE event if multiple touches are active.
  50389. */
  50390. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  50391. /**
  50392. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  50393. * press.
  50394. */
  50395. protected onButtonDown(evt: IPointerEvent): void;
  50396. /**
  50397. * Called each time a new POINTERUP event occurs. Ie, for each button
  50398. * release.
  50399. */
  50400. protected onButtonUp(evt: IPointerEvent): void;
  50401. /**
  50402. * Called when window becomes inactive.
  50403. */
  50404. protected onLostFocus(): void;
  50405. }
  50406. }
  50407. declare module BABYLON {
  50408. /**
  50409. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  50410. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50411. */
  50412. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  50413. /**
  50414. * Defines the camera the input is attached to.
  50415. */
  50416. camera: ArcRotateCamera;
  50417. /**
  50418. * Defines the list of key codes associated with the up action (increase alpha)
  50419. */
  50420. keysUp: number[];
  50421. /**
  50422. * Defines the list of key codes associated with the down action (decrease alpha)
  50423. */
  50424. keysDown: number[];
  50425. /**
  50426. * Defines the list of key codes associated with the left action (increase beta)
  50427. */
  50428. keysLeft: number[];
  50429. /**
  50430. * Defines the list of key codes associated with the right action (decrease beta)
  50431. */
  50432. keysRight: number[];
  50433. /**
  50434. * Defines the list of key codes associated with the reset action.
  50435. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  50436. */
  50437. keysReset: number[];
  50438. /**
  50439. * Defines the panning sensibility of the inputs.
  50440. * (How fast is the camera panning)
  50441. */
  50442. panningSensibility: number;
  50443. /**
  50444. * Defines the zooming sensibility of the inputs.
  50445. * (How fast is the camera zooming)
  50446. */
  50447. zoomingSensibility: number;
  50448. /**
  50449. * Defines whether maintaining the alt key down switch the movement mode from
  50450. * orientation to zoom.
  50451. */
  50452. useAltToZoom: boolean;
  50453. /**
  50454. * Rotation speed of the camera
  50455. */
  50456. angularSpeed: number;
  50457. private _keys;
  50458. private _ctrlPressed;
  50459. private _altPressed;
  50460. private _onCanvasBlurObserver;
  50461. private _onKeyboardObserver;
  50462. private _engine;
  50463. private _scene;
  50464. /**
  50465. * Attach the input controls to a specific dom element to get the input from.
  50466. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50467. */
  50468. attachControl(noPreventDefault?: boolean): void;
  50469. /**
  50470. * Detach the current controls from the specified dom element.
  50471. */
  50472. detachControl(): void;
  50473. /**
  50474. * Update the current camera state depending on the inputs that have been used this frame.
  50475. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50476. */
  50477. checkInputs(): void;
  50478. /**
  50479. * Gets the class name of the current input.
  50480. * @returns the class name
  50481. */
  50482. getClassName(): string;
  50483. /**
  50484. * Get the friendly name associated with the input class.
  50485. * @returns the input friendly name
  50486. */
  50487. getSimpleName(): string;
  50488. }
  50489. }
  50490. declare module BABYLON {
  50491. /**
  50492. * Manage the mouse wheel inputs to control an arc rotate camera.
  50493. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50494. */
  50495. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  50496. /**
  50497. * Defines the camera the input is attached to.
  50498. */
  50499. camera: ArcRotateCamera;
  50500. /**
  50501. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  50502. */
  50503. wheelPrecision: number;
  50504. /**
  50505. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  50506. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  50507. */
  50508. wheelDeltaPercentage: number;
  50509. private _wheel;
  50510. private _observer;
  50511. private computeDeltaFromMouseWheelLegacyEvent;
  50512. /**
  50513. * Attach the input controls to a specific dom element to get the input from.
  50514. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50515. */
  50516. attachControl(noPreventDefault?: boolean): void;
  50517. /**
  50518. * Detach the current controls from the specified dom element.
  50519. */
  50520. detachControl(): void;
  50521. /**
  50522. * Gets the class name of the current input.
  50523. * @returns the class name
  50524. */
  50525. getClassName(): string;
  50526. /**
  50527. * Get the friendly name associated with the input class.
  50528. * @returns the input friendly name
  50529. */
  50530. getSimpleName(): string;
  50531. }
  50532. }
  50533. declare module BABYLON {
  50534. /**
  50535. * Default Inputs manager for the ArcRotateCamera.
  50536. * It groups all the default supported inputs for ease of use.
  50537. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50538. */
  50539. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  50540. /**
  50541. * Instantiates a new ArcRotateCameraInputsManager.
  50542. * @param camera Defines the camera the inputs belong to
  50543. */
  50544. constructor(camera: ArcRotateCamera);
  50545. /**
  50546. * Add mouse wheel input support to the input manager.
  50547. * @returns the current input manager
  50548. */
  50549. addMouseWheel(): ArcRotateCameraInputsManager;
  50550. /**
  50551. * Add pointers input support to the input manager.
  50552. * @returns the current input manager
  50553. */
  50554. addPointers(): ArcRotateCameraInputsManager;
  50555. /**
  50556. * Add keyboard input support to the input manager.
  50557. * @returns the current input manager
  50558. */
  50559. addKeyboard(): ArcRotateCameraInputsManager;
  50560. }
  50561. }
  50562. declare module BABYLON {
  50563. /**
  50564. * This represents an orbital type of camera.
  50565. *
  50566. * 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.
  50567. * 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.
  50568. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  50569. */
  50570. export class ArcRotateCamera extends TargetCamera {
  50571. /**
  50572. * Defines the rotation angle of the camera along the longitudinal axis.
  50573. */
  50574. alpha: number;
  50575. /**
  50576. * Defines the rotation angle of the camera along the latitudinal axis.
  50577. */
  50578. beta: number;
  50579. /**
  50580. * Defines the radius of the camera from it s target point.
  50581. */
  50582. radius: number;
  50583. protected _target: Vector3;
  50584. protected _targetHost: Nullable<AbstractMesh>;
  50585. /**
  50586. * Defines the target point of the camera.
  50587. * The camera looks towards it form the radius distance.
  50588. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  50589. */
  50590. get target(): Vector3;
  50591. set target(value: Vector3);
  50592. /**
  50593. * Define the current local position of the camera in the scene
  50594. */
  50595. get position(): Vector3;
  50596. set position(newPosition: Vector3);
  50597. protected _upToYMatrix: Matrix;
  50598. protected _YToUpMatrix: Matrix;
  50599. /**
  50600. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  50601. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  50602. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  50603. */
  50604. set upVector(vec: Vector3);
  50605. get upVector(): Vector3;
  50606. /**
  50607. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  50608. */
  50609. setMatUp(): void;
  50610. /**
  50611. * Current inertia value on the longitudinal axis.
  50612. * The bigger this number the longer it will take for the camera to stop.
  50613. */
  50614. inertialAlphaOffset: number;
  50615. /**
  50616. * Current inertia value on the latitudinal axis.
  50617. * The bigger this number the longer it will take for the camera to stop.
  50618. */
  50619. inertialBetaOffset: number;
  50620. /**
  50621. * Current inertia value on the radius axis.
  50622. * The bigger this number the longer it will take for the camera to stop.
  50623. */
  50624. inertialRadiusOffset: number;
  50625. /**
  50626. * Minimum allowed angle on the longitudinal axis.
  50627. * This can help limiting how the Camera is able to move in the scene.
  50628. */
  50629. lowerAlphaLimit: Nullable<number>;
  50630. /**
  50631. * Maximum allowed angle on the longitudinal axis.
  50632. * This can help limiting how the Camera is able to move in the scene.
  50633. */
  50634. upperAlphaLimit: Nullable<number>;
  50635. /**
  50636. * Minimum allowed angle on the latitudinal axis.
  50637. * This can help limiting how the Camera is able to move in the scene.
  50638. */
  50639. lowerBetaLimit: number;
  50640. /**
  50641. * Maximum allowed angle on the latitudinal axis.
  50642. * This can help limiting how the Camera is able to move in the scene.
  50643. */
  50644. upperBetaLimit: number;
  50645. /**
  50646. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  50647. * This can help limiting how the Camera is able to move in the scene.
  50648. */
  50649. lowerRadiusLimit: Nullable<number>;
  50650. /**
  50651. * Maximum allowed distance of the camera to the target (The camera can not get further).
  50652. * This can help limiting how the Camera is able to move in the scene.
  50653. */
  50654. upperRadiusLimit: Nullable<number>;
  50655. /**
  50656. * Defines the current inertia value used during panning of the camera along the X axis.
  50657. */
  50658. inertialPanningX: number;
  50659. /**
  50660. * Defines the current inertia value used during panning of the camera along the Y axis.
  50661. */
  50662. inertialPanningY: number;
  50663. /**
  50664. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  50665. * Basically if your fingers moves away from more than this distance you will be considered
  50666. * in pinch mode.
  50667. */
  50668. pinchToPanMaxDistance: number;
  50669. /**
  50670. * Defines the maximum distance the camera can pan.
  50671. * This could help keeping the camera always in your scene.
  50672. */
  50673. panningDistanceLimit: Nullable<number>;
  50674. /**
  50675. * Defines the target of the camera before panning.
  50676. */
  50677. panningOriginTarget: Vector3;
  50678. /**
  50679. * Defines the value of the inertia used during panning.
  50680. * 0 would mean stop inertia and one would mean no decelleration at all.
  50681. */
  50682. panningInertia: number;
  50683. /**
  50684. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  50685. */
  50686. get angularSensibilityX(): number;
  50687. set angularSensibilityX(value: number);
  50688. /**
  50689. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  50690. */
  50691. get angularSensibilityY(): number;
  50692. set angularSensibilityY(value: number);
  50693. /**
  50694. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  50695. */
  50696. get pinchPrecision(): number;
  50697. set pinchPrecision(value: number);
  50698. /**
  50699. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  50700. * It will be used instead of pinchDeltaPrecision if different from 0.
  50701. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  50702. */
  50703. get pinchDeltaPercentage(): number;
  50704. set pinchDeltaPercentage(value: number);
  50705. /**
  50706. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  50707. * and pinch delta percentage.
  50708. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  50709. * that any object in the plane at the camera's target point will scale
  50710. * perfectly with finger motion.
  50711. */
  50712. get useNaturalPinchZoom(): boolean;
  50713. set useNaturalPinchZoom(value: boolean);
  50714. /**
  50715. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  50716. */
  50717. get panningSensibility(): number;
  50718. set panningSensibility(value: number);
  50719. /**
  50720. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  50721. */
  50722. get keysUp(): number[];
  50723. set keysUp(value: number[]);
  50724. /**
  50725. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  50726. */
  50727. get keysDown(): number[];
  50728. set keysDown(value: number[]);
  50729. /**
  50730. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  50731. */
  50732. get keysLeft(): number[];
  50733. set keysLeft(value: number[]);
  50734. /**
  50735. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  50736. */
  50737. get keysRight(): number[];
  50738. set keysRight(value: number[]);
  50739. /**
  50740. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  50741. */
  50742. get wheelPrecision(): number;
  50743. set wheelPrecision(value: number);
  50744. /**
  50745. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  50746. * It will be used instead of pinchDeltaPrecision if different from 0.
  50747. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  50748. */
  50749. get wheelDeltaPercentage(): number;
  50750. set wheelDeltaPercentage(value: number);
  50751. /**
  50752. * Defines how much the radius should be scaled while zooming on a particular mesh (through the zoomOn function)
  50753. */
  50754. zoomOnFactor: number;
  50755. /**
  50756. * Defines a screen offset for the camera position.
  50757. */
  50758. targetScreenOffset: Vector2;
  50759. /**
  50760. * Allows the camera to be completely reversed.
  50761. * If false the camera can not arrive upside down.
  50762. */
  50763. allowUpsideDown: boolean;
  50764. /**
  50765. * Define if double tap/click is used to restore the previously saved state of the camera.
  50766. */
  50767. useInputToRestoreState: boolean;
  50768. /** @hidden */
  50769. _viewMatrix: Matrix;
  50770. /** @hidden */
  50771. _useCtrlForPanning: boolean;
  50772. /** @hidden */
  50773. _panningMouseButton: number;
  50774. /**
  50775. * Defines the input associated to the camera.
  50776. */
  50777. inputs: ArcRotateCameraInputsManager;
  50778. /** @hidden */
  50779. _reset: () => void;
  50780. /**
  50781. * Defines the allowed panning axis.
  50782. */
  50783. panningAxis: Vector3;
  50784. protected _transformedDirection: Vector3;
  50785. private _bouncingBehavior;
  50786. /**
  50787. * Gets the bouncing behavior of the camera if it has been enabled.
  50788. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  50789. */
  50790. get bouncingBehavior(): Nullable<BouncingBehavior>;
  50791. /**
  50792. * Defines if the bouncing behavior of the camera is enabled on the camera.
  50793. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  50794. */
  50795. get useBouncingBehavior(): boolean;
  50796. set useBouncingBehavior(value: boolean);
  50797. private _framingBehavior;
  50798. /**
  50799. * Gets the framing behavior of the camera if it has been enabled.
  50800. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  50801. */
  50802. get framingBehavior(): Nullable<FramingBehavior>;
  50803. /**
  50804. * Defines if the framing behavior of the camera is enabled on the camera.
  50805. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  50806. */
  50807. get useFramingBehavior(): boolean;
  50808. set useFramingBehavior(value: boolean);
  50809. private _autoRotationBehavior;
  50810. /**
  50811. * Gets the auto rotation behavior of the camera if it has been enabled.
  50812. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  50813. */
  50814. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  50815. /**
  50816. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  50817. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  50818. */
  50819. get useAutoRotationBehavior(): boolean;
  50820. set useAutoRotationBehavior(value: boolean);
  50821. /**
  50822. * Observable triggered when the mesh target has been changed on the camera.
  50823. */
  50824. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  50825. /**
  50826. * Event raised when the camera is colliding with a mesh.
  50827. */
  50828. onCollide: (collidedMesh: AbstractMesh) => void;
  50829. /**
  50830. * Defines whether the camera should check collision with the objects oh the scene.
  50831. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  50832. */
  50833. checkCollisions: boolean;
  50834. /**
  50835. * Defines the collision radius of the camera.
  50836. * This simulates a sphere around the camera.
  50837. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  50838. */
  50839. collisionRadius: Vector3;
  50840. protected _collider: Collider;
  50841. protected _previousPosition: Vector3;
  50842. protected _collisionVelocity: Vector3;
  50843. protected _newPosition: Vector3;
  50844. protected _previousAlpha: number;
  50845. protected _previousBeta: number;
  50846. protected _previousRadius: number;
  50847. protected _collisionTriggered: boolean;
  50848. protected _targetBoundingCenter: Nullable<Vector3>;
  50849. private _computationVector;
  50850. /**
  50851. * Instantiates a new ArcRotateCamera in a given scene
  50852. * @param name Defines the name of the camera
  50853. * @param alpha Defines the camera rotation along the longitudinal axis
  50854. * @param beta Defines the camera rotation along the latitudinal axis
  50855. * @param radius Defines the camera distance from its target
  50856. * @param target Defines the camera target
  50857. * @param scene Defines the scene the camera belongs to
  50858. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active if not other active cameras have been defined
  50859. */
  50860. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  50861. /** @hidden */
  50862. _initCache(): void;
  50863. /** @hidden */
  50864. _updateCache(ignoreParentClass?: boolean): void;
  50865. protected _getTargetPosition(): Vector3;
  50866. private _storedAlpha;
  50867. private _storedBeta;
  50868. private _storedRadius;
  50869. private _storedTarget;
  50870. private _storedTargetScreenOffset;
  50871. /**
  50872. * Stores the current state of the camera (alpha, beta, radius and target)
  50873. * @returns the camera itself
  50874. */
  50875. storeState(): Camera;
  50876. /**
  50877. * @hidden
  50878. * Restored camera state. You must call storeState() first
  50879. */
  50880. _restoreStateValues(): boolean;
  50881. /** @hidden */
  50882. _isSynchronizedViewMatrix(): boolean;
  50883. /**
  50884. * Attach the input controls to a specific dom element to get the input from.
  50885. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50886. */
  50887. attachControl(noPreventDefault?: boolean): void;
  50888. /**
  50889. * Attach the input controls to a specific dom element to get the input from.
  50890. * @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
  50891. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50892. */
  50893. attachControl(ignored: any, noPreventDefault?: boolean): void;
  50894. /**
  50895. * Attached controls to the current camera.
  50896. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50897. * @param useCtrlForPanning Defines whether ctrl is used for panning within the controls
  50898. */
  50899. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  50900. /**
  50901. * Attached controls to the current camera.
  50902. * @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
  50903. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50904. * @param useCtrlForPanning Defines whether ctrl is used for panning within the controls
  50905. */
  50906. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  50907. /**
  50908. * Attached controls to the current camera.
  50909. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50910. * @param useCtrlForPanning Defines whether ctrl is used for panning within the controls
  50911. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  50912. */
  50913. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  50914. /**
  50915. * Detach the current controls from the specified dom element.
  50916. */
  50917. detachControl(): void;
  50918. /**
  50919. * Detach the current controls from the specified dom element.
  50920. * @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
  50921. */
  50922. detachControl(ignored: any): void;
  50923. /** @hidden */
  50924. _checkInputs(): void;
  50925. protected _checkLimits(): void;
  50926. /**
  50927. * Rebuilds angles (alpha, beta) and radius from the give position and target
  50928. */
  50929. rebuildAnglesAndRadius(): void;
  50930. /**
  50931. * Use a position to define the current camera related information like alpha, beta and radius
  50932. * @param position Defines the position to set the camera at
  50933. */
  50934. setPosition(position: Vector3): void;
  50935. /**
  50936. * Defines the target the camera should look at.
  50937. * This will automatically adapt alpha beta and radius to fit within the new target.
  50938. * @param target Defines the new target as a Vector or a mesh
  50939. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  50940. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  50941. */
  50942. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  50943. /** @hidden */
  50944. _getViewMatrix(): Matrix;
  50945. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  50946. /**
  50947. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  50948. * @param meshes Defines the mesh to zoom on
  50949. * @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)
  50950. */
  50951. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  50952. /**
  50953. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  50954. * The target will be changed but the radius
  50955. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  50956. * @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)
  50957. */
  50958. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  50959. min: Vector3;
  50960. max: Vector3;
  50961. distance: number;
  50962. }, doNotUpdateMaxZ?: boolean): void;
  50963. /**
  50964. * @override
  50965. * Override Camera.createRigCamera
  50966. */
  50967. createRigCamera(name: string, cameraIndex: number): Camera;
  50968. /**
  50969. * @hidden
  50970. * @override
  50971. * Override Camera._updateRigCameras
  50972. */
  50973. _updateRigCameras(): void;
  50974. /**
  50975. * Destroy the camera and release the current resources hold by it.
  50976. */
  50977. dispose(): void;
  50978. /**
  50979. * Gets the current object class name.
  50980. * @return the class name
  50981. */
  50982. getClassName(): string;
  50983. }
  50984. }
  50985. declare module BABYLON {
  50986. /**
  50987. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  50988. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  50989. */
  50990. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  50991. /**
  50992. * Gets the name of the behavior.
  50993. */
  50994. get name(): string;
  50995. private _zoomStopsAnimation;
  50996. private _idleRotationSpeed;
  50997. private _idleRotationWaitTime;
  50998. private _idleRotationSpinupTime;
  50999. /**
  51000. * Sets the flag that indicates if user zooming should stop animation.
  51001. */
  51002. set zoomStopsAnimation(flag: boolean);
  51003. /**
  51004. * Gets the flag that indicates if user zooming should stop animation.
  51005. */
  51006. get zoomStopsAnimation(): boolean;
  51007. /**
  51008. * Sets the default speed at which the camera rotates around the model.
  51009. */
  51010. set idleRotationSpeed(speed: number);
  51011. /**
  51012. * Gets the default speed at which the camera rotates around the model.
  51013. */
  51014. get idleRotationSpeed(): number;
  51015. /**
  51016. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  51017. */
  51018. set idleRotationWaitTime(time: number);
  51019. /**
  51020. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  51021. */
  51022. get idleRotationWaitTime(): number;
  51023. /**
  51024. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  51025. */
  51026. set idleRotationSpinupTime(time: number);
  51027. /**
  51028. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  51029. */
  51030. get idleRotationSpinupTime(): number;
  51031. /**
  51032. * Gets a value indicating if the camera is currently rotating because of this behavior
  51033. */
  51034. get rotationInProgress(): boolean;
  51035. private _onPrePointerObservableObserver;
  51036. private _onAfterCheckInputsObserver;
  51037. private _attachedCamera;
  51038. private _isPointerDown;
  51039. private _lastFrameTime;
  51040. private _lastInteractionTime;
  51041. private _cameraRotationSpeed;
  51042. /**
  51043. * Initializes the behavior.
  51044. */
  51045. init(): void;
  51046. /**
  51047. * Attaches the behavior to its arc rotate camera.
  51048. * @param camera Defines the camera to attach the behavior to
  51049. */
  51050. attach(camera: ArcRotateCamera): void;
  51051. /**
  51052. * Detaches the behavior from its current arc rotate camera.
  51053. */
  51054. detach(): void;
  51055. /**
  51056. * Returns true if user is scrolling.
  51057. * @return true if user is scrolling.
  51058. */
  51059. private _userIsZooming;
  51060. private _lastFrameRadius;
  51061. private _shouldAnimationStopForInteraction;
  51062. /**
  51063. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  51064. */
  51065. private _applyUserInteraction;
  51066. private _userIsMoving;
  51067. }
  51068. }
  51069. declare module BABYLON {
  51070. /**
  51071. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  51072. */
  51073. export class AttachToBoxBehavior implements Behavior<Mesh> {
  51074. private ui;
  51075. /**
  51076. * The name of the behavior
  51077. */
  51078. name: string;
  51079. /**
  51080. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  51081. */
  51082. distanceAwayFromFace: number;
  51083. /**
  51084. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  51085. */
  51086. distanceAwayFromBottomOfFace: number;
  51087. private _faceVectors;
  51088. private _target;
  51089. private _scene;
  51090. private _onRenderObserver;
  51091. private _tmpMatrix;
  51092. private _tmpVector;
  51093. /**
  51094. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  51095. * @param ui The transform node that should be attached to the mesh
  51096. */
  51097. constructor(ui: TransformNode);
  51098. /**
  51099. * Initializes the behavior
  51100. */
  51101. init(): void;
  51102. private _closestFace;
  51103. private _zeroVector;
  51104. private _lookAtTmpMatrix;
  51105. private _lookAtToRef;
  51106. /**
  51107. * Attaches the AttachToBoxBehavior to the passed in mesh
  51108. * @param target The mesh that the specified node will be attached to
  51109. */
  51110. attach(target: Mesh): void;
  51111. /**
  51112. * Detaches the behavior from the mesh
  51113. */
  51114. detach(): void;
  51115. }
  51116. }
  51117. declare module BABYLON {
  51118. /**
  51119. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  51120. */
  51121. export class FadeInOutBehavior implements Behavior<Mesh> {
  51122. /**
  51123. * Time in milliseconds to delay before fading in (Default: 0)
  51124. */
  51125. delay: number;
  51126. /**
  51127. * Time in milliseconds for the mesh to fade in (Default: 300)
  51128. */
  51129. fadeInTime: number;
  51130. private _millisecondsPerFrame;
  51131. private _hovered;
  51132. private _hoverValue;
  51133. private _ownerNode;
  51134. /**
  51135. * Instantiates the FadeInOutBehavior
  51136. */
  51137. constructor();
  51138. /**
  51139. * The name of the behavior
  51140. */
  51141. get name(): string;
  51142. /**
  51143. * Initializes the behavior
  51144. */
  51145. init(): void;
  51146. /**
  51147. * Attaches the fade behavior on the passed in mesh
  51148. * @param ownerNode The mesh that will be faded in/out once attached
  51149. */
  51150. attach(ownerNode: Mesh): void;
  51151. /**
  51152. * Detaches the behavior from the mesh
  51153. */
  51154. detach(): void;
  51155. /**
  51156. * Triggers the mesh to begin fading in or out
  51157. * @param value if the object should fade in or out (true to fade in)
  51158. */
  51159. fadeIn(value: boolean): void;
  51160. private _update;
  51161. private _setAllVisibility;
  51162. }
  51163. }
  51164. declare module BABYLON {
  51165. /**
  51166. * Class containing a set of static utilities functions for managing Pivots
  51167. * @hidden
  51168. */
  51169. export class PivotTools {
  51170. private static _PivotCached;
  51171. private static _OldPivotPoint;
  51172. private static _PivotTranslation;
  51173. private static _PivotTmpVector;
  51174. private static _PivotPostMultiplyPivotMatrix;
  51175. /** @hidden */
  51176. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  51177. /** @hidden */
  51178. static _RestorePivotPoint(mesh: AbstractMesh): void;
  51179. }
  51180. }
  51181. declare module BABYLON {
  51182. /**
  51183. * Class containing static functions to help procedurally build meshes
  51184. */
  51185. export class PlaneBuilder {
  51186. /**
  51187. * Creates a plane mesh
  51188. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  51189. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  51190. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  51191. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51192. * * 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
  51193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51194. * @param name defines the name of the mesh
  51195. * @param options defines the options used to create the mesh
  51196. * @param scene defines the hosting scene
  51197. * @returns the plane mesh
  51198. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  51199. */
  51200. static CreatePlane(name: string, options: {
  51201. size?: number;
  51202. width?: number;
  51203. height?: number;
  51204. sideOrientation?: number;
  51205. frontUVs?: Vector4;
  51206. backUVs?: Vector4;
  51207. updatable?: boolean;
  51208. sourcePlane?: Plane;
  51209. }, scene?: Nullable<Scene>): Mesh;
  51210. }
  51211. }
  51212. declare module BABYLON {
  51213. /**
  51214. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  51215. */
  51216. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  51217. private static _AnyMouseID;
  51218. /**
  51219. * Abstract mesh the behavior is set on
  51220. */
  51221. attachedNode: AbstractMesh;
  51222. private _dragPlane;
  51223. private _scene;
  51224. private _pointerObserver;
  51225. private _beforeRenderObserver;
  51226. private static _planeScene;
  51227. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  51228. /**
  51229. * 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)
  51230. */
  51231. maxDragAngle: number;
  51232. /**
  51233. * @hidden
  51234. */
  51235. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  51236. /**
  51237. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  51238. */
  51239. currentDraggingPointerID: number;
  51240. /**
  51241. * The last position where the pointer hit the drag plane in world space
  51242. */
  51243. lastDragPosition: Vector3;
  51244. /**
  51245. * If the behavior is currently in a dragging state
  51246. */
  51247. dragging: boolean;
  51248. /**
  51249. * 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)
  51250. */
  51251. dragDeltaRatio: number;
  51252. /**
  51253. * If the drag plane orientation should be updated during the dragging (Default: true)
  51254. */
  51255. updateDragPlane: boolean;
  51256. private _debugMode;
  51257. private _moving;
  51258. /**
  51259. * Fires each time the attached mesh is dragged with the pointer
  51260. * * delta between last drag position and current drag position in world space
  51261. * * dragDistance along the drag axis
  51262. * * dragPlaneNormal normal of the current drag plane used during the drag
  51263. * * dragPlanePoint in world space where the drag intersects the drag plane
  51264. */
  51265. onDragObservable: Observable<{
  51266. delta: Vector3;
  51267. dragPlanePoint: Vector3;
  51268. dragPlaneNormal: Vector3;
  51269. dragDistance: number;
  51270. pointerId: number;
  51271. }>;
  51272. /**
  51273. * Fires each time a drag begins (eg. mouse down on mesh)
  51274. */
  51275. onDragStartObservable: Observable<{
  51276. dragPlanePoint: Vector3;
  51277. pointerId: number;
  51278. }>;
  51279. /**
  51280. * Fires each time a drag ends (eg. mouse release after drag)
  51281. */
  51282. onDragEndObservable: Observable<{
  51283. dragPlanePoint: Vector3;
  51284. pointerId: number;
  51285. }>;
  51286. /**
  51287. * If the attached mesh should be moved when dragged
  51288. */
  51289. moveAttached: boolean;
  51290. /**
  51291. * If the drag behavior will react to drag events (Default: true)
  51292. */
  51293. enabled: boolean;
  51294. /**
  51295. * If pointer events should start and release the drag (Default: true)
  51296. */
  51297. startAndReleaseDragOnPointerEvents: boolean;
  51298. /**
  51299. * If camera controls should be detached during the drag
  51300. */
  51301. detachCameraControls: boolean;
  51302. /**
  51303. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  51304. */
  51305. useObjectOrientationForDragging: boolean;
  51306. private _options;
  51307. /**
  51308. * Gets the options used by the behavior
  51309. */
  51310. get options(): {
  51311. dragAxis?: Vector3;
  51312. dragPlaneNormal?: Vector3;
  51313. };
  51314. /**
  51315. * Sets the options used by the behavior
  51316. */
  51317. set options(options: {
  51318. dragAxis?: Vector3;
  51319. dragPlaneNormal?: Vector3;
  51320. });
  51321. /**
  51322. * Creates a pointer drag behavior that can be attached to a mesh
  51323. * @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)
  51324. */
  51325. constructor(options?: {
  51326. dragAxis?: Vector3;
  51327. dragPlaneNormal?: Vector3;
  51328. });
  51329. /**
  51330. * Predicate to determine if it is valid to move the object to a new position when it is moved
  51331. */
  51332. validateDrag: (targetPosition: Vector3) => boolean;
  51333. /**
  51334. * The name of the behavior
  51335. */
  51336. get name(): string;
  51337. /**
  51338. * Initializes the behavior
  51339. */
  51340. init(): void;
  51341. private _tmpVector;
  51342. private _alternatePickedPoint;
  51343. private _worldDragAxis;
  51344. private _targetPosition;
  51345. private _attachedToElement;
  51346. /**
  51347. * Attaches the drag behavior the passed in mesh
  51348. * @param ownerNode The mesh that will be dragged around once attached
  51349. * @param predicate Predicate to use for pick filtering
  51350. */
  51351. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  51352. /**
  51353. * Force release the drag action by code.
  51354. */
  51355. releaseDrag(): void;
  51356. private _startDragRay;
  51357. private _lastPointerRay;
  51358. /**
  51359. * Simulates the start of a pointer drag event on the behavior
  51360. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  51361. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  51362. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  51363. */
  51364. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  51365. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  51366. private _dragDelta;
  51367. protected _moveDrag(ray: Ray): void;
  51368. private _pickWithRayOnDragPlane;
  51369. private _pointA;
  51370. private _pointC;
  51371. private _localAxis;
  51372. private _lookAt;
  51373. private _updateDragPlanePosition;
  51374. /**
  51375. * Detaches the behavior from the mesh
  51376. */
  51377. detach(): void;
  51378. }
  51379. }
  51380. declare module BABYLON {
  51381. /**
  51382. * A behavior that when attached to a mesh will allow the mesh to be scaled
  51383. */
  51384. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  51385. private _dragBehaviorA;
  51386. private _dragBehaviorB;
  51387. private _startDistance;
  51388. private _initialScale;
  51389. private _targetScale;
  51390. private _ownerNode;
  51391. private _sceneRenderObserver;
  51392. /**
  51393. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  51394. */
  51395. constructor();
  51396. /**
  51397. * The name of the behavior
  51398. */
  51399. get name(): string;
  51400. /**
  51401. * Initializes the behavior
  51402. */
  51403. init(): void;
  51404. private _getCurrentDistance;
  51405. /**
  51406. * Attaches the scale behavior the passed in mesh
  51407. * @param ownerNode The mesh that will be scaled around once attached
  51408. */
  51409. attach(ownerNode: Mesh): void;
  51410. /**
  51411. * Detaches the behavior from the mesh
  51412. */
  51413. detach(): void;
  51414. }
  51415. }
  51416. declare module BABYLON {
  51417. /**
  51418. * 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
  51419. */
  51420. export class SixDofDragBehavior implements Behavior<Mesh> {
  51421. private static _virtualScene;
  51422. private _ownerNode;
  51423. private _sceneRenderObserver;
  51424. private _scene;
  51425. private _targetPosition;
  51426. private _virtualOriginMesh;
  51427. private _virtualDragMesh;
  51428. private _pointerObserver;
  51429. private _moving;
  51430. private _startingOrientation;
  51431. private _attachedToElement;
  51432. /**
  51433. * 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)
  51434. */
  51435. private zDragFactor;
  51436. /**
  51437. * If the object should rotate to face the drag origin
  51438. */
  51439. rotateDraggedObject: boolean;
  51440. /**
  51441. * If the behavior is currently in a dragging state
  51442. */
  51443. dragging: boolean;
  51444. /**
  51445. * 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)
  51446. */
  51447. dragDeltaRatio: number;
  51448. /**
  51449. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  51450. */
  51451. currentDraggingPointerID: number;
  51452. /**
  51453. * If camera controls should be detached during the drag
  51454. */
  51455. detachCameraControls: boolean;
  51456. /**
  51457. * Fires each time a drag starts
  51458. */
  51459. onDragStartObservable: Observable<{}>;
  51460. /**
  51461. * Fires each time a drag happens
  51462. */
  51463. onDragObservable: Observable<void>;
  51464. /**
  51465. * Fires each time a drag ends (eg. mouse release after drag)
  51466. */
  51467. onDragEndObservable: Observable<{}>;
  51468. /**
  51469. * 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
  51470. */
  51471. constructor();
  51472. /**
  51473. * The name of the behavior
  51474. */
  51475. get name(): string;
  51476. /**
  51477. * Initializes the behavior
  51478. */
  51479. init(): void;
  51480. /**
  51481. * In the case of multiple active cameras, the cameraToUseForPointers should be used if set instead of active camera
  51482. */
  51483. private get _pointerCamera();
  51484. /**
  51485. * Attaches the scale behavior the passed in mesh
  51486. * @param ownerNode The mesh that will be scaled around once attached
  51487. */
  51488. attach(ownerNode: Mesh): void;
  51489. /**
  51490. * Detaches the behavior from the mesh
  51491. */
  51492. detach(): void;
  51493. }
  51494. }
  51495. declare module BABYLON {
  51496. /**
  51497. * Class used to apply inverse kinematics to bones
  51498. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  51499. */
  51500. export class BoneIKController {
  51501. private static _tmpVecs;
  51502. private static _tmpQuat;
  51503. private static _tmpMats;
  51504. /**
  51505. * Gets or sets the target mesh
  51506. */
  51507. targetMesh: AbstractMesh;
  51508. /** Gets or sets the mesh used as pole */
  51509. poleTargetMesh: AbstractMesh;
  51510. /**
  51511. * Gets or sets the bone used as pole
  51512. */
  51513. poleTargetBone: Nullable<Bone>;
  51514. /**
  51515. * Gets or sets the target position
  51516. */
  51517. targetPosition: Vector3;
  51518. /**
  51519. * Gets or sets the pole target position
  51520. */
  51521. poleTargetPosition: Vector3;
  51522. /**
  51523. * Gets or sets the pole target local offset
  51524. */
  51525. poleTargetLocalOffset: Vector3;
  51526. /**
  51527. * Gets or sets the pole angle
  51528. */
  51529. poleAngle: number;
  51530. /**
  51531. * Gets or sets the mesh associated with the controller
  51532. */
  51533. mesh: AbstractMesh;
  51534. /**
  51535. * 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)
  51536. */
  51537. slerpAmount: number;
  51538. private _bone1Quat;
  51539. private _bone1Mat;
  51540. private _bone2Ang;
  51541. private _bone1;
  51542. private _bone2;
  51543. private _bone1Length;
  51544. private _bone2Length;
  51545. private _maxAngle;
  51546. private _maxReach;
  51547. private _rightHandedSystem;
  51548. private _bendAxis;
  51549. private _slerping;
  51550. private _adjustRoll;
  51551. /**
  51552. * Gets or sets maximum allowed angle
  51553. */
  51554. get maxAngle(): number;
  51555. set maxAngle(value: number);
  51556. /**
  51557. * Creates a new BoneIKController
  51558. * @param mesh defines the mesh to control
  51559. * @param bone defines the bone to control
  51560. * @param options defines options to set up the controller
  51561. */
  51562. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  51563. targetMesh?: AbstractMesh;
  51564. poleTargetMesh?: AbstractMesh;
  51565. poleTargetBone?: Bone;
  51566. poleTargetLocalOffset?: Vector3;
  51567. poleAngle?: number;
  51568. bendAxis?: Vector3;
  51569. maxAngle?: number;
  51570. slerpAmount?: number;
  51571. });
  51572. private _setMaxAngle;
  51573. /**
  51574. * Force the controller to update the bones
  51575. */
  51576. update(): void;
  51577. }
  51578. }
  51579. declare module BABYLON {
  51580. /**
  51581. * Class used to make a bone look toward a point in space
  51582. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  51583. */
  51584. export class BoneLookController {
  51585. private static _tmpVecs;
  51586. private static _tmpQuat;
  51587. private static _tmpMats;
  51588. /**
  51589. * The target Vector3 that the bone will look at
  51590. */
  51591. target: Vector3;
  51592. /**
  51593. * The mesh that the bone is attached to
  51594. */
  51595. mesh: AbstractMesh;
  51596. /**
  51597. * The bone that will be looking to the target
  51598. */
  51599. bone: Bone;
  51600. /**
  51601. * The up axis of the coordinate system that is used when the bone is rotated
  51602. */
  51603. upAxis: Vector3;
  51604. /**
  51605. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  51606. */
  51607. upAxisSpace: Space;
  51608. /**
  51609. * Used to make an adjustment to the yaw of the bone
  51610. */
  51611. adjustYaw: number;
  51612. /**
  51613. * Used to make an adjustment to the pitch of the bone
  51614. */
  51615. adjustPitch: number;
  51616. /**
  51617. * Used to make an adjustment to the roll of the bone
  51618. */
  51619. adjustRoll: number;
  51620. /**
  51621. * 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)
  51622. */
  51623. slerpAmount: number;
  51624. private _minYaw;
  51625. private _maxYaw;
  51626. private _minPitch;
  51627. private _maxPitch;
  51628. private _minYawSin;
  51629. private _minYawCos;
  51630. private _maxYawSin;
  51631. private _maxYawCos;
  51632. private _midYawConstraint;
  51633. private _minPitchTan;
  51634. private _maxPitchTan;
  51635. private _boneQuat;
  51636. private _slerping;
  51637. private _transformYawPitch;
  51638. private _transformYawPitchInv;
  51639. private _firstFrameSkipped;
  51640. private _yawRange;
  51641. private _fowardAxis;
  51642. /**
  51643. * Gets or sets the minimum yaw angle that the bone can look to
  51644. */
  51645. get minYaw(): number;
  51646. set minYaw(value: number);
  51647. /**
  51648. * Gets or sets the maximum yaw angle that the bone can look to
  51649. */
  51650. get maxYaw(): number;
  51651. set maxYaw(value: number);
  51652. /**
  51653. * Gets or sets the minimum pitch angle that the bone can look to
  51654. */
  51655. get minPitch(): number;
  51656. set minPitch(value: number);
  51657. /**
  51658. * Gets or sets the maximum pitch angle that the bone can look to
  51659. */
  51660. get maxPitch(): number;
  51661. set maxPitch(value: number);
  51662. /**
  51663. * Create a BoneLookController
  51664. * @param mesh the mesh that the bone belongs to
  51665. * @param bone the bone that will be looking to the target
  51666. * @param target the target Vector3 to look at
  51667. * @param options optional settings:
  51668. * * maxYaw: the maximum angle the bone will yaw to
  51669. * * minYaw: the minimum angle the bone will yaw to
  51670. * * maxPitch: the maximum angle the bone will pitch to
  51671. * * minPitch: the minimum angle the bone will yaw to
  51672. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  51673. * * upAxis: the up axis of the coordinate system
  51674. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  51675. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  51676. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  51677. * * adjustYaw: used to make an adjustment to the yaw of the bone
  51678. * * adjustPitch: used to make an adjustment to the pitch of the bone
  51679. * * adjustRoll: used to make an adjustment to the roll of the bone
  51680. **/
  51681. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  51682. maxYaw?: number;
  51683. minYaw?: number;
  51684. maxPitch?: number;
  51685. minPitch?: number;
  51686. slerpAmount?: number;
  51687. upAxis?: Vector3;
  51688. upAxisSpace?: Space;
  51689. yawAxis?: Vector3;
  51690. pitchAxis?: Vector3;
  51691. adjustYaw?: number;
  51692. adjustPitch?: number;
  51693. adjustRoll?: number;
  51694. });
  51695. /**
  51696. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  51697. */
  51698. update(): void;
  51699. private _getAngleDiff;
  51700. private _getAngleBetween;
  51701. private _isAngleBetween;
  51702. }
  51703. }
  51704. declare module BABYLON {
  51705. /**
  51706. * Manage the gamepad inputs to control an arc rotate camera.
  51707. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51708. */
  51709. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  51710. /**
  51711. * Defines the camera the input is attached to.
  51712. */
  51713. camera: ArcRotateCamera;
  51714. /**
  51715. * Defines the gamepad the input is gathering event from.
  51716. */
  51717. gamepad: Nullable<Gamepad>;
  51718. /**
  51719. * Defines the gamepad rotation sensiblity.
  51720. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  51721. */
  51722. gamepadRotationSensibility: number;
  51723. /**
  51724. * Defines the gamepad move sensiblity.
  51725. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  51726. */
  51727. gamepadMoveSensibility: number;
  51728. private _yAxisScale;
  51729. /**
  51730. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  51731. */
  51732. get invertYAxis(): boolean;
  51733. set invertYAxis(value: boolean);
  51734. private _onGamepadConnectedObserver;
  51735. private _onGamepadDisconnectedObserver;
  51736. /**
  51737. * Attach the input controls to a specific dom element to get the input from.
  51738. */
  51739. attachControl(): void;
  51740. /**
  51741. * Detach the current controls from the specified dom element.
  51742. */
  51743. detachControl(): void;
  51744. /**
  51745. * Update the current camera state depending on the inputs that have been used this frame.
  51746. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51747. */
  51748. checkInputs(): void;
  51749. /**
  51750. * Gets the class name of the current intput.
  51751. * @returns the class name
  51752. */
  51753. getClassName(): string;
  51754. /**
  51755. * Get the friendly name associated with the input class.
  51756. * @returns the input friendly name
  51757. */
  51758. getSimpleName(): string;
  51759. }
  51760. }
  51761. declare module BABYLON {
  51762. interface ArcRotateCameraInputsManager {
  51763. /**
  51764. * Add orientation input support to the input manager.
  51765. * @returns the current input manager
  51766. */
  51767. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  51768. }
  51769. /**
  51770. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  51771. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51772. */
  51773. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  51774. /**
  51775. * Defines the camera the input is attached to.
  51776. */
  51777. camera: ArcRotateCamera;
  51778. /**
  51779. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  51780. */
  51781. alphaCorrection: number;
  51782. /**
  51783. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  51784. */
  51785. gammaCorrection: number;
  51786. private _alpha;
  51787. private _gamma;
  51788. private _dirty;
  51789. private _deviceOrientationHandler;
  51790. /**
  51791. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  51792. */
  51793. constructor();
  51794. /**
  51795. * Attach the input controls to a specific dom element to get the input from.
  51796. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51797. */
  51798. attachControl(noPreventDefault?: boolean): void;
  51799. /** @hidden */
  51800. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  51801. /**
  51802. * Update the current camera state depending on the inputs that have been used this frame.
  51803. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51804. */
  51805. checkInputs(): void;
  51806. /**
  51807. * Detach the current controls from the specified dom element.
  51808. */
  51809. detachControl(): void;
  51810. /**
  51811. * Gets the class name of the current input.
  51812. * @returns the class name
  51813. */
  51814. getClassName(): string;
  51815. /**
  51816. * Get the friendly name associated with the input class.
  51817. * @returns the input friendly name
  51818. */
  51819. getSimpleName(): string;
  51820. }
  51821. }
  51822. declare module BABYLON {
  51823. /**
  51824. * Listen to mouse events to control the camera.
  51825. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51826. */
  51827. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  51828. /**
  51829. * Defines the camera the input is attached to.
  51830. */
  51831. camera: FlyCamera;
  51832. /**
  51833. * Defines if touch is enabled. (Default is true.)
  51834. */
  51835. touchEnabled: boolean;
  51836. /**
  51837. * Defines the buttons associated with the input to handle camera rotation.
  51838. */
  51839. buttons: number[];
  51840. /**
  51841. * Assign buttons for Yaw control.
  51842. */
  51843. buttonsYaw: number[];
  51844. /**
  51845. * Assign buttons for Pitch control.
  51846. */
  51847. buttonsPitch: number[];
  51848. /**
  51849. * Assign buttons for Roll control.
  51850. */
  51851. buttonsRoll: number[];
  51852. /**
  51853. * Detect if any button is being pressed while mouse is moved.
  51854. * -1 = Mouse locked.
  51855. * 0 = Left button.
  51856. * 1 = Middle Button.
  51857. * 2 = Right Button.
  51858. */
  51859. activeButton: number;
  51860. /**
  51861. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  51862. * Higher values reduce its sensitivity.
  51863. */
  51864. angularSensibility: number;
  51865. private _observer;
  51866. private _rollObserver;
  51867. private previousPosition;
  51868. private noPreventDefault;
  51869. private element;
  51870. /**
  51871. * Listen to mouse events to control the camera.
  51872. * @param touchEnabled Define if touch is enabled. (Default is true.)
  51873. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51874. */
  51875. constructor(touchEnabled?: boolean);
  51876. /**
  51877. * Attach the mouse control to the HTML DOM element.
  51878. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  51879. */
  51880. attachControl(noPreventDefault?: boolean): void;
  51881. /**
  51882. * Detach the current controls from the specified dom element.
  51883. */
  51884. detachControl(): void;
  51885. /**
  51886. * Gets the class name of the current input.
  51887. * @returns the class name.
  51888. */
  51889. getClassName(): string;
  51890. /**
  51891. * Get the friendly name associated with the input class.
  51892. * @returns the input's friendly name.
  51893. */
  51894. getSimpleName(): string;
  51895. private _pointerInput;
  51896. private _onMouseMove;
  51897. /**
  51898. * Rotate camera by mouse offset.
  51899. */
  51900. private rotateCamera;
  51901. }
  51902. }
  51903. declare module BABYLON {
  51904. /**
  51905. * Default Inputs manager for the FlyCamera.
  51906. * It groups all the default supported inputs for ease of use.
  51907. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51908. */
  51909. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  51910. /**
  51911. * Instantiates a new FlyCameraInputsManager.
  51912. * @param camera Defines the camera the inputs belong to.
  51913. */
  51914. constructor(camera: FlyCamera);
  51915. /**
  51916. * Add keyboard input support to the input manager.
  51917. * @returns the new FlyCameraKeyboardMoveInput().
  51918. */
  51919. addKeyboard(): FlyCameraInputsManager;
  51920. /**
  51921. * Add mouse input support to the input manager.
  51922. * @param touchEnabled Enable touch screen support.
  51923. * @returns the new FlyCameraMouseInput().
  51924. */
  51925. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  51926. }
  51927. }
  51928. declare module BABYLON {
  51929. /**
  51930. * This is a flying camera, designed for 3D movement and rotation in all directions,
  51931. * such as in a 3D Space Shooter or a Flight Simulator.
  51932. */
  51933. export class FlyCamera extends TargetCamera {
  51934. /**
  51935. * Define the collision ellipsoid of the camera.
  51936. * This is helpful for simulating a camera body, like a player's body.
  51937. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  51938. */
  51939. ellipsoid: Vector3;
  51940. /**
  51941. * Define an offset for the position of the ellipsoid around the camera.
  51942. * This can be helpful if the camera is attached away from the player's body center,
  51943. * such as at its head.
  51944. */
  51945. ellipsoidOffset: Vector3;
  51946. /**
  51947. * Enable or disable collisions of the camera with the rest of the scene objects.
  51948. */
  51949. checkCollisions: boolean;
  51950. /**
  51951. * Enable or disable gravity on the camera.
  51952. */
  51953. applyGravity: boolean;
  51954. /**
  51955. * Define the current direction the camera is moving to.
  51956. */
  51957. cameraDirection: Vector3;
  51958. /**
  51959. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  51960. * This overrides and empties cameraRotation.
  51961. */
  51962. rotationQuaternion: Quaternion;
  51963. /**
  51964. * Track Roll to maintain the wanted Rolling when looking around.
  51965. */
  51966. _trackRoll: number;
  51967. /**
  51968. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  51969. */
  51970. rollCorrect: number;
  51971. /**
  51972. * Mimic a banked turn, Rolling the camera when Yawing.
  51973. * It's recommended to use rollCorrect = 10 for faster banking correction.
  51974. */
  51975. bankedTurn: boolean;
  51976. /**
  51977. * Limit in radians for how much Roll banking will add. (Default: 90°)
  51978. */
  51979. bankedTurnLimit: number;
  51980. /**
  51981. * Value of 0 disables the banked Roll.
  51982. * Value of 1 is equal to the Yaw angle in radians.
  51983. */
  51984. bankedTurnMultiplier: number;
  51985. /**
  51986. * The inputs manager loads all the input sources, such as keyboard and mouse.
  51987. */
  51988. inputs: FlyCameraInputsManager;
  51989. /**
  51990. * Gets the input sensibility for mouse input.
  51991. * Higher values reduce sensitivity.
  51992. */
  51993. get angularSensibility(): number;
  51994. /**
  51995. * Sets the input sensibility for a mouse input.
  51996. * Higher values reduce sensitivity.
  51997. */
  51998. set angularSensibility(value: number);
  51999. /**
  52000. * Get the keys for camera movement forward.
  52001. */
  52002. get keysForward(): number[];
  52003. /**
  52004. * Set the keys for camera movement forward.
  52005. */
  52006. set keysForward(value: number[]);
  52007. /**
  52008. * Get the keys for camera movement backward.
  52009. */
  52010. get keysBackward(): number[];
  52011. set keysBackward(value: number[]);
  52012. /**
  52013. * Get the keys for camera movement up.
  52014. */
  52015. get keysUp(): number[];
  52016. /**
  52017. * Set the keys for camera movement up.
  52018. */
  52019. set keysUp(value: number[]);
  52020. /**
  52021. * Get the keys for camera movement down.
  52022. */
  52023. get keysDown(): number[];
  52024. /**
  52025. * Set the keys for camera movement down.
  52026. */
  52027. set keysDown(value: number[]);
  52028. /**
  52029. * Get the keys for camera movement left.
  52030. */
  52031. get keysLeft(): number[];
  52032. /**
  52033. * Set the keys for camera movement left.
  52034. */
  52035. set keysLeft(value: number[]);
  52036. /**
  52037. * Set the keys for camera movement right.
  52038. */
  52039. get keysRight(): number[];
  52040. /**
  52041. * Set the keys for camera movement right.
  52042. */
  52043. set keysRight(value: number[]);
  52044. /**
  52045. * Event raised when the camera collides with a mesh in the scene.
  52046. */
  52047. onCollide: (collidedMesh: AbstractMesh) => void;
  52048. private _collider;
  52049. private _needMoveForGravity;
  52050. private _oldPosition;
  52051. private _diffPosition;
  52052. private _newPosition;
  52053. /** @hidden */
  52054. _localDirection: Vector3;
  52055. /** @hidden */
  52056. _transformedDirection: Vector3;
  52057. /**
  52058. * Instantiates a FlyCamera.
  52059. * This is a flying camera, designed for 3D movement and rotation in all directions,
  52060. * such as in a 3D Space Shooter or a Flight Simulator.
  52061. * @param name Define the name of the camera in the scene.
  52062. * @param position Define the starting position of the camera in the scene.
  52063. * @param scene Define the scene the camera belongs to.
  52064. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active, if no other camera has been defined as active.
  52065. */
  52066. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  52067. /**
  52068. * Attach the input controls to a specific dom element to get the input from.
  52069. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  52070. */
  52071. attachControl(noPreventDefault?: boolean): void;
  52072. /**
  52073. * Detach a control from the HTML DOM element.
  52074. * The camera will stop reacting to that input.
  52075. */
  52076. detachControl(): void;
  52077. private _collisionMask;
  52078. /**
  52079. * Get the mask that the camera ignores in collision events.
  52080. */
  52081. get collisionMask(): number;
  52082. /**
  52083. * Set the mask that the camera ignores in collision events.
  52084. */
  52085. set collisionMask(mask: number);
  52086. /** @hidden */
  52087. _collideWithWorld(displacement: Vector3): void;
  52088. /** @hidden */
  52089. private _onCollisionPositionChange;
  52090. /** @hidden */
  52091. _checkInputs(): void;
  52092. /** @hidden */
  52093. _decideIfNeedsToMove(): boolean;
  52094. /** @hidden */
  52095. _updatePosition(): void;
  52096. /**
  52097. * Restore the Roll to its target value at the rate specified.
  52098. * @param rate - Higher means slower restoring.
  52099. * @hidden
  52100. */
  52101. restoreRoll(rate: number): void;
  52102. /**
  52103. * Destroy the camera and release the current resources held by it.
  52104. */
  52105. dispose(): void;
  52106. /**
  52107. * Get the current object class name.
  52108. * @returns the class name.
  52109. */
  52110. getClassName(): string;
  52111. }
  52112. }
  52113. declare module BABYLON {
  52114. /**
  52115. * Listen to keyboard events to control the camera.
  52116. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52117. */
  52118. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  52119. /**
  52120. * Defines the camera the input is attached to.
  52121. */
  52122. camera: FlyCamera;
  52123. /**
  52124. * The list of keyboard keys used to control the forward move of the camera.
  52125. */
  52126. keysForward: number[];
  52127. /**
  52128. * The list of keyboard keys used to control the backward move of the camera.
  52129. */
  52130. keysBackward: number[];
  52131. /**
  52132. * The list of keyboard keys used to control the forward move of the camera.
  52133. */
  52134. keysUp: number[];
  52135. /**
  52136. * The list of keyboard keys used to control the backward move of the camera.
  52137. */
  52138. keysDown: number[];
  52139. /**
  52140. * The list of keyboard keys used to control the right strafe move of the camera.
  52141. */
  52142. keysRight: number[];
  52143. /**
  52144. * The list of keyboard keys used to control the left strafe move of the camera.
  52145. */
  52146. keysLeft: number[];
  52147. private _keys;
  52148. private _onCanvasBlurObserver;
  52149. private _onKeyboardObserver;
  52150. private _engine;
  52151. private _scene;
  52152. /**
  52153. * Attach the input controls to a specific dom element to get the input from.
  52154. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  52155. */
  52156. attachControl(noPreventDefault?: boolean): void;
  52157. /**
  52158. * Detach the current controls from the specified dom element.
  52159. */
  52160. detachControl(): void;
  52161. /**
  52162. * Gets the class name of the current intput.
  52163. * @returns the class name
  52164. */
  52165. getClassName(): string;
  52166. /** @hidden */
  52167. _onLostFocus(e: FocusEvent): void;
  52168. /**
  52169. * Get the friendly name associated with the input class.
  52170. * @returns the input friendly name
  52171. */
  52172. getSimpleName(): string;
  52173. /**
  52174. * Update the current camera state depending on the inputs that have been used this frame.
  52175. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52176. */
  52177. checkInputs(): void;
  52178. }
  52179. }
  52180. declare module BABYLON {
  52181. /**
  52182. * Manage the mouse wheel inputs to control a follow camera.
  52183. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52184. */
  52185. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  52186. /**
  52187. * Defines the camera the input is attached to.
  52188. */
  52189. camera: FollowCamera;
  52190. /**
  52191. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  52192. */
  52193. axisControlRadius: boolean;
  52194. /**
  52195. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  52196. */
  52197. axisControlHeight: boolean;
  52198. /**
  52199. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  52200. */
  52201. axisControlRotation: boolean;
  52202. /**
  52203. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  52204. * relation to mouseWheel events.
  52205. */
  52206. wheelPrecision: number;
  52207. /**
  52208. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  52209. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  52210. */
  52211. wheelDeltaPercentage: number;
  52212. private _wheel;
  52213. private _observer;
  52214. /**
  52215. * Attach the input controls to a specific dom element to get the input from.
  52216. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  52217. */
  52218. attachControl(noPreventDefault?: boolean): void;
  52219. /**
  52220. * Detach the current controls from the specified dom element.
  52221. */
  52222. detachControl(): void;
  52223. /**
  52224. * Gets the class name of the current input.
  52225. * @returns the class name
  52226. */
  52227. getClassName(): string;
  52228. /**
  52229. * Get the friendly name associated with the input class.
  52230. * @returns the input friendly name
  52231. */
  52232. getSimpleName(): string;
  52233. }
  52234. }
  52235. declare module BABYLON {
  52236. /**
  52237. * Manage the pointers inputs to control an follow camera.
  52238. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52239. */
  52240. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  52241. /**
  52242. * Defines the camera the input is attached to.
  52243. */
  52244. camera: FollowCamera;
  52245. /**
  52246. * Gets the class name of the current input.
  52247. * @returns the class name
  52248. */
  52249. getClassName(): string;
  52250. /**
  52251. * Defines the pointer angular sensibility along the X axis or how fast is
  52252. * the camera rotating.
  52253. * A negative number will reverse the axis direction.
  52254. */
  52255. angularSensibilityX: number;
  52256. /**
  52257. * Defines the pointer angular sensibility along the Y axis or how fast is
  52258. * the camera rotating.
  52259. * A negative number will reverse the axis direction.
  52260. */
  52261. angularSensibilityY: number;
  52262. /**
  52263. * Defines the pointer pinch precision or how fast is the camera zooming.
  52264. * A negative number will reverse the axis direction.
  52265. */
  52266. pinchPrecision: number;
  52267. /**
  52268. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  52269. * from 0.
  52270. * It defines the percentage of current camera.radius to use as delta when
  52271. * pinch zoom is used.
  52272. */
  52273. pinchDeltaPercentage: number;
  52274. /**
  52275. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  52276. */
  52277. axisXControlRadius: boolean;
  52278. /**
  52279. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  52280. */
  52281. axisXControlHeight: boolean;
  52282. /**
  52283. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  52284. */
  52285. axisXControlRotation: boolean;
  52286. /**
  52287. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  52288. */
  52289. axisYControlRadius: boolean;
  52290. /**
  52291. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  52292. */
  52293. axisYControlHeight: boolean;
  52294. /**
  52295. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  52296. */
  52297. axisYControlRotation: boolean;
  52298. /**
  52299. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  52300. */
  52301. axisPinchControlRadius: boolean;
  52302. /**
  52303. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  52304. */
  52305. axisPinchControlHeight: boolean;
  52306. /**
  52307. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  52308. */
  52309. axisPinchControlRotation: boolean;
  52310. /**
  52311. * Log error messages if basic misconfiguration has occurred.
  52312. */
  52313. warningEnable: boolean;
  52314. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  52315. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  52316. private _warningCounter;
  52317. private _warning;
  52318. }
  52319. }
  52320. declare module BABYLON {
  52321. /**
  52322. * Default Inputs manager for the FollowCamera.
  52323. * It groups all the default supported inputs for ease of use.
  52324. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52325. */
  52326. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  52327. /**
  52328. * Instantiates a new FollowCameraInputsManager.
  52329. * @param camera Defines the camera the inputs belong to
  52330. */
  52331. constructor(camera: FollowCamera);
  52332. /**
  52333. * Add keyboard input support to the input manager.
  52334. * @returns the current input manager
  52335. */
  52336. addKeyboard(): FollowCameraInputsManager;
  52337. /**
  52338. * Add mouse wheel input support to the input manager.
  52339. * @returns the current input manager
  52340. */
  52341. addMouseWheel(): FollowCameraInputsManager;
  52342. /**
  52343. * Add pointers input support to the input manager.
  52344. * @returns the current input manager
  52345. */
  52346. addPointers(): FollowCameraInputsManager;
  52347. /**
  52348. * Add orientation input support to the input manager.
  52349. * @returns the current input manager
  52350. */
  52351. addVRDeviceOrientation(): FollowCameraInputsManager;
  52352. }
  52353. }
  52354. declare module BABYLON {
  52355. /**
  52356. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  52357. * an arc rotate version arcFollowCamera are available.
  52358. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  52359. */
  52360. export class FollowCamera extends TargetCamera {
  52361. /**
  52362. * Distance the follow camera should follow an object at
  52363. */
  52364. radius: number;
  52365. /**
  52366. * Minimum allowed distance of the camera to the axis of rotation
  52367. * (The camera can not get closer).
  52368. * This can help limiting how the Camera is able to move in the scene.
  52369. */
  52370. lowerRadiusLimit: Nullable<number>;
  52371. /**
  52372. * Maximum allowed distance of the camera to the axis of rotation
  52373. * (The camera can not get further).
  52374. * This can help limiting how the Camera is able to move in the scene.
  52375. */
  52376. upperRadiusLimit: Nullable<number>;
  52377. /**
  52378. * Define a rotation offset between the camera and the object it follows
  52379. */
  52380. rotationOffset: number;
  52381. /**
  52382. * Minimum allowed angle to camera position relative to target object.
  52383. * This can help limiting how the Camera is able to move in the scene.
  52384. */
  52385. lowerRotationOffsetLimit: Nullable<number>;
  52386. /**
  52387. * Maximum allowed angle to camera position relative to target object.
  52388. * This can help limiting how the Camera is able to move in the scene.
  52389. */
  52390. upperRotationOffsetLimit: Nullable<number>;
  52391. /**
  52392. * Define a height offset between the camera and the object it follows.
  52393. * It can help following an object from the top (like a car chasing a plane)
  52394. */
  52395. heightOffset: number;
  52396. /**
  52397. * Minimum allowed height of camera position relative to target object.
  52398. * This can help limiting how the Camera is able to move in the scene.
  52399. */
  52400. lowerHeightOffsetLimit: Nullable<number>;
  52401. /**
  52402. * Maximum allowed height of camera position relative to target object.
  52403. * This can help limiting how the Camera is able to move in the scene.
  52404. */
  52405. upperHeightOffsetLimit: Nullable<number>;
  52406. /**
  52407. * Define how fast the camera can accelerate to follow it s target.
  52408. */
  52409. cameraAcceleration: number;
  52410. /**
  52411. * Define the speed limit of the camera following an object.
  52412. */
  52413. maxCameraSpeed: number;
  52414. /**
  52415. * Define the target of the camera.
  52416. */
  52417. lockedTarget: Nullable<AbstractMesh>;
  52418. /**
  52419. * Defines the input associated with the camera.
  52420. */
  52421. inputs: FollowCameraInputsManager;
  52422. /**
  52423. * Instantiates the follow camera.
  52424. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  52425. * @param name Define the name of the camera in the scene
  52426. * @param position Define the position of the camera
  52427. * @param scene Define the scene the camera belong to
  52428. * @param lockedTarget Define the target of the camera
  52429. */
  52430. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  52431. private _follow;
  52432. /**
  52433. * Attach the input controls to a specific dom element to get the input from.
  52434. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  52435. */
  52436. attachControl(noPreventDefault?: boolean): void;
  52437. /**
  52438. * Detach the current controls from the specified dom element.
  52439. */
  52440. detachControl(): void;
  52441. /** @hidden */
  52442. _checkInputs(): void;
  52443. private _checkLimits;
  52444. /**
  52445. * Gets the camera class name.
  52446. * @returns the class name
  52447. */
  52448. getClassName(): string;
  52449. }
  52450. /**
  52451. * Arc Rotate version of the follow camera.
  52452. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  52453. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  52454. */
  52455. export class ArcFollowCamera extends TargetCamera {
  52456. /** The longitudinal angle of the camera */
  52457. alpha: number;
  52458. /** The latitudinal angle of the camera */
  52459. beta: number;
  52460. /** The radius of the camera from its target */
  52461. radius: number;
  52462. private _cartesianCoordinates;
  52463. /** Define the camera target (the mesh it should follow) */
  52464. private _meshTarget;
  52465. /**
  52466. * Instantiates a new ArcFollowCamera
  52467. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  52468. * @param name Define the name of the camera
  52469. * @param alpha Define the rotation angle of the camera around the longitudinal axis
  52470. * @param beta Define the rotation angle of the camera around the elevation axis
  52471. * @param radius Define the radius of the camera from its target point
  52472. * @param target Define the target of the camera
  52473. * @param scene Define the scene the camera belongs to
  52474. */
  52475. constructor(name: string,
  52476. /** The longitudinal angle of the camera */
  52477. alpha: number,
  52478. /** The latitudinal angle of the camera */
  52479. beta: number,
  52480. /** The radius of the camera from its target */
  52481. radius: number,
  52482. /** Define the camera target (the mesh it should follow) */
  52483. target: Nullable<AbstractMesh>, scene: Scene);
  52484. private _follow;
  52485. /** @hidden */
  52486. _checkInputs(): void;
  52487. /**
  52488. * Returns the class name of the object.
  52489. * It is mostly used internally for serialization purposes.
  52490. */
  52491. getClassName(): string;
  52492. }
  52493. }
  52494. declare module BABYLON {
  52495. /**
  52496. * Manage the keyboard inputs to control the movement of a follow camera.
  52497. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52498. */
  52499. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  52500. /**
  52501. * Defines the camera the input is attached to.
  52502. */
  52503. camera: FollowCamera;
  52504. /**
  52505. * Defines the list of key codes associated with the up action (increase heightOffset)
  52506. */
  52507. keysHeightOffsetIncr: number[];
  52508. /**
  52509. * Defines the list of key codes associated with the down action (decrease heightOffset)
  52510. */
  52511. keysHeightOffsetDecr: number[];
  52512. /**
  52513. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  52514. */
  52515. keysHeightOffsetModifierAlt: boolean;
  52516. /**
  52517. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  52518. */
  52519. keysHeightOffsetModifierCtrl: boolean;
  52520. /**
  52521. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  52522. */
  52523. keysHeightOffsetModifierShift: boolean;
  52524. /**
  52525. * Defines the list of key codes associated with the left action (increase rotationOffset)
  52526. */
  52527. keysRotationOffsetIncr: number[];
  52528. /**
  52529. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  52530. */
  52531. keysRotationOffsetDecr: number[];
  52532. /**
  52533. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  52534. */
  52535. keysRotationOffsetModifierAlt: boolean;
  52536. /**
  52537. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  52538. */
  52539. keysRotationOffsetModifierCtrl: boolean;
  52540. /**
  52541. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  52542. */
  52543. keysRotationOffsetModifierShift: boolean;
  52544. /**
  52545. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  52546. */
  52547. keysRadiusIncr: number[];
  52548. /**
  52549. * Defines the list of key codes associated with the zoom-out action (increase radius)
  52550. */
  52551. keysRadiusDecr: number[];
  52552. /**
  52553. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  52554. */
  52555. keysRadiusModifierAlt: boolean;
  52556. /**
  52557. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  52558. */
  52559. keysRadiusModifierCtrl: boolean;
  52560. /**
  52561. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  52562. */
  52563. keysRadiusModifierShift: boolean;
  52564. /**
  52565. * Defines the rate of change of heightOffset.
  52566. */
  52567. heightSensibility: number;
  52568. /**
  52569. * Defines the rate of change of rotationOffset.
  52570. */
  52571. rotationSensibility: number;
  52572. /**
  52573. * Defines the rate of change of radius.
  52574. */
  52575. radiusSensibility: number;
  52576. private _keys;
  52577. private _ctrlPressed;
  52578. private _altPressed;
  52579. private _shiftPressed;
  52580. private _onCanvasBlurObserver;
  52581. private _onKeyboardObserver;
  52582. private _engine;
  52583. private _scene;
  52584. /**
  52585. * Attach the input controls to a specific dom element to get the input from.
  52586. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  52587. */
  52588. attachControl(noPreventDefault?: boolean): void;
  52589. /**
  52590. * Detach the current controls from the specified dom element.
  52591. */
  52592. detachControl(): void;
  52593. /**
  52594. * Update the current camera state depending on the inputs that have been used this frame.
  52595. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52596. */
  52597. checkInputs(): void;
  52598. /**
  52599. * Gets the class name of the current input.
  52600. * @returns the class name
  52601. */
  52602. getClassName(): string;
  52603. /**
  52604. * Get the friendly name associated with the input class.
  52605. * @returns the input friendly name
  52606. */
  52607. getSimpleName(): string;
  52608. /**
  52609. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  52610. * allow modification of the heightOffset value.
  52611. */
  52612. private _modifierHeightOffset;
  52613. /**
  52614. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  52615. * allow modification of the rotationOffset value.
  52616. */
  52617. private _modifierRotationOffset;
  52618. /**
  52619. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  52620. * allow modification of the radius value.
  52621. */
  52622. private _modifierRadius;
  52623. }
  52624. }
  52625. declare module BABYLON {
  52626. interface FreeCameraInputsManager {
  52627. /**
  52628. * @hidden
  52629. */
  52630. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  52631. /**
  52632. * Add orientation input support to the input manager.
  52633. * @returns the current input manager
  52634. */
  52635. addDeviceOrientation(): FreeCameraInputsManager;
  52636. }
  52637. /**
  52638. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  52639. * Screen rotation is taken into account.
  52640. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52641. */
  52642. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  52643. private _camera;
  52644. private _screenOrientationAngle;
  52645. private _constantTranform;
  52646. private _screenQuaternion;
  52647. private _alpha;
  52648. private _beta;
  52649. private _gamma;
  52650. /**
  52651. * Can be used to detect if a device orientation sensor is available on a device
  52652. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  52653. * @returns a promise that will resolve on orientation change
  52654. */
  52655. static WaitForOrientationChangeAsync(timeout?: number): Promise<void>;
  52656. /**
  52657. * @hidden
  52658. */
  52659. _onDeviceOrientationChangedObservable: Observable<void>;
  52660. /**
  52661. * Instantiates a new input
  52662. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52663. */
  52664. constructor();
  52665. /**
  52666. * Define the camera controlled by the input.
  52667. */
  52668. get camera(): FreeCamera;
  52669. set camera(camera: FreeCamera);
  52670. /**
  52671. * Attach the input controls to a specific dom element to get the input from.
  52672. */
  52673. attachControl(): void;
  52674. private _orientationChanged;
  52675. private _deviceOrientation;
  52676. /**
  52677. * Detach the current controls from the specified dom element.
  52678. */
  52679. detachControl(): void;
  52680. /**
  52681. * Update the current camera state depending on the inputs that have been used this frame.
  52682. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52683. */
  52684. checkInputs(): void;
  52685. /**
  52686. * Gets the class name of the current input.
  52687. * @returns the class name
  52688. */
  52689. getClassName(): string;
  52690. /**
  52691. * Get the friendly name associated with the input class.
  52692. * @returns the input friendly name
  52693. */
  52694. getSimpleName(): string;
  52695. }
  52696. }
  52697. declare module BABYLON {
  52698. /**
  52699. * Manage the gamepad inputs to control a free camera.
  52700. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52701. */
  52702. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  52703. /**
  52704. * Define the camera the input is attached to.
  52705. */
  52706. camera: FreeCamera;
  52707. /**
  52708. * Define the Gamepad controlling the input
  52709. */
  52710. gamepad: Nullable<Gamepad>;
  52711. /**
  52712. * Defines the gamepad rotation sensiblity.
  52713. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  52714. */
  52715. gamepadAngularSensibility: number;
  52716. /**
  52717. * Defines the gamepad move sensiblity.
  52718. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  52719. */
  52720. gamepadMoveSensibility: number;
  52721. private _yAxisScale;
  52722. /**
  52723. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  52724. */
  52725. get invertYAxis(): boolean;
  52726. set invertYAxis(value: boolean);
  52727. private _onGamepadConnectedObserver;
  52728. private _onGamepadDisconnectedObserver;
  52729. private _cameraTransform;
  52730. private _deltaTransform;
  52731. private _vector3;
  52732. private _vector2;
  52733. /**
  52734. * Attach the input controls to a specific dom element to get the input from.
  52735. */
  52736. attachControl(): void;
  52737. /**
  52738. * Detach the current controls from the specified dom element.
  52739. */
  52740. detachControl(): void;
  52741. /**
  52742. * Update the current camera state depending on the inputs that have been used this frame.
  52743. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52744. */
  52745. checkInputs(): void;
  52746. /**
  52747. * Gets the class name of the current input.
  52748. * @returns the class name
  52749. */
  52750. getClassName(): string;
  52751. /**
  52752. * Get the friendly name associated with the input class.
  52753. * @returns the input friendly name
  52754. */
  52755. getSimpleName(): string;
  52756. }
  52757. }
  52758. declare module BABYLON {
  52759. /**
  52760. * Defines the potential axis of a Joystick
  52761. */
  52762. export enum JoystickAxis {
  52763. /** X axis */
  52764. X = 0,
  52765. /** Y axis */
  52766. Y = 1,
  52767. /** Z axis */
  52768. Z = 2
  52769. }
  52770. /**
  52771. * Represents the different customization options available
  52772. * for VirtualJoystick
  52773. */
  52774. interface VirtualJoystickCustomizations {
  52775. /**
  52776. * Size of the joystick's puck
  52777. */
  52778. puckSize: number;
  52779. /**
  52780. * Size of the joystick's container
  52781. */
  52782. containerSize: number;
  52783. /**
  52784. * Color of the joystick && puck
  52785. */
  52786. color: string;
  52787. /**
  52788. * Image URL for the joystick's puck
  52789. */
  52790. puckImage?: string;
  52791. /**
  52792. * Image URL for the joystick's container
  52793. */
  52794. containerImage?: string;
  52795. /**
  52796. * Defines the unmoving position of the joystick container
  52797. */
  52798. position?: {
  52799. x: number;
  52800. y: number;
  52801. };
  52802. /**
  52803. * Defines whether or not the joystick container is always visible
  52804. */
  52805. alwaysVisible: boolean;
  52806. /**
  52807. * Defines whether or not to limit the movement of the puck to the joystick's container
  52808. */
  52809. limitToContainer: boolean;
  52810. }
  52811. /**
  52812. * Class used to define virtual joystick (used in touch mode)
  52813. */
  52814. export class VirtualJoystick {
  52815. /**
  52816. * Gets or sets a boolean indicating that left and right values must be inverted
  52817. */
  52818. reverseLeftRight: boolean;
  52819. /**
  52820. * Gets or sets a boolean indicating that up and down values must be inverted
  52821. */
  52822. reverseUpDown: boolean;
  52823. /**
  52824. * Gets the offset value for the position (ie. the change of the position value)
  52825. */
  52826. deltaPosition: Vector3;
  52827. /**
  52828. * Gets a boolean indicating if the virtual joystick was pressed
  52829. */
  52830. pressed: boolean;
  52831. /**
  52832. * Canvas the virtual joystick will render onto, default z-index of this is 5
  52833. */
  52834. static Canvas: Nullable<HTMLCanvasElement>;
  52835. /**
  52836. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  52837. */
  52838. limitToContainer: boolean;
  52839. private static _globalJoystickIndex;
  52840. private static _alwaysVisibleSticks;
  52841. private static vjCanvasContext;
  52842. private static vjCanvasWidth;
  52843. private static vjCanvasHeight;
  52844. private static halfWidth;
  52845. private static _GetDefaultOptions;
  52846. private _action;
  52847. private _axisTargetedByLeftAndRight;
  52848. private _axisTargetedByUpAndDown;
  52849. private _joystickSensibility;
  52850. private _inversedSensibility;
  52851. private _joystickPointerID;
  52852. private _joystickColor;
  52853. private _joystickPointerPos;
  52854. private _joystickPreviousPointerPos;
  52855. private _joystickPointerStartPos;
  52856. private _deltaJoystickVector;
  52857. private _leftJoystick;
  52858. private _touches;
  52859. private _joystickPosition;
  52860. private _alwaysVisible;
  52861. private _puckImage;
  52862. private _containerImage;
  52863. private _joystickPuckSize;
  52864. private _joystickContainerSize;
  52865. private _clearPuckSize;
  52866. private _clearContainerSize;
  52867. private _clearPuckSizeOffset;
  52868. private _clearContainerSizeOffset;
  52869. private _onPointerDownHandlerRef;
  52870. private _onPointerMoveHandlerRef;
  52871. private _onPointerUpHandlerRef;
  52872. private _onResize;
  52873. /**
  52874. * Creates a new virtual joystick
  52875. * @param leftJoystick defines that the joystick is for left hand (false by default)
  52876. * @param customizations Defines the options we want to customize the VirtualJoystick
  52877. */
  52878. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  52879. /**
  52880. * Defines joystick sensibility (ie. the ratio between a physical move and virtual joystick position change)
  52881. * @param newJoystickSensibility defines the new sensibility
  52882. */
  52883. setJoystickSensibility(newJoystickSensibility: number): void;
  52884. private _onPointerDown;
  52885. private _onPointerMove;
  52886. private _onPointerUp;
  52887. /**
  52888. * Change the color of the virtual joystick
  52889. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  52890. */
  52891. setJoystickColor(newColor: string): void;
  52892. /**
  52893. * Size of the joystick's container
  52894. */
  52895. set containerSize(newSize: number);
  52896. get containerSize(): number;
  52897. /**
  52898. * Size of the joystick's puck
  52899. */
  52900. set puckSize(newSize: number);
  52901. get puckSize(): number;
  52902. /**
  52903. * Clears the set position of the joystick
  52904. */
  52905. clearPosition(): void;
  52906. /**
  52907. * Defines whether or not the joystick container is always visible
  52908. */
  52909. set alwaysVisible(value: boolean);
  52910. get alwaysVisible(): boolean;
  52911. /**
  52912. * Sets the constant position of the Joystick container
  52913. * @param x X axis coordinate
  52914. * @param y Y axis coordinate
  52915. */
  52916. setPosition(x: number, y: number): void;
  52917. /**
  52918. * Defines a callback to call when the joystick is touched
  52919. * @param action defines the callback
  52920. */
  52921. setActionOnTouch(action: () => any): void;
  52922. /**
  52923. * Defines which axis you'd like to control for left & right
  52924. * @param axis defines the axis to use
  52925. */
  52926. setAxisForLeftRight(axis: JoystickAxis): void;
  52927. /**
  52928. * Defines which axis you'd like to control for up & down
  52929. * @param axis defines the axis to use
  52930. */
  52931. setAxisForUpDown(axis: JoystickAxis): void;
  52932. /**
  52933. * Clears the canvas from the previous puck / container draw
  52934. */
  52935. private _clearPreviousDraw;
  52936. /**
  52937. * Loads `urlPath` to be used for the container's image
  52938. * @param urlPath defines the urlPath of an image to use
  52939. */
  52940. setContainerImage(urlPath: string): void;
  52941. /**
  52942. * Loads `urlPath` to be used for the puck's image
  52943. * @param urlPath defines the urlPath of an image to use
  52944. */
  52945. setPuckImage(urlPath: string): void;
  52946. /**
  52947. * Draws the Virtual Joystick's container
  52948. */
  52949. private _drawContainer;
  52950. /**
  52951. * Draws the Virtual Joystick's puck
  52952. */
  52953. private _drawPuck;
  52954. private _drawVirtualJoystick;
  52955. /**
  52956. * Release internal HTML canvas
  52957. */
  52958. releaseCanvas(): void;
  52959. }
  52960. }
  52961. declare module BABYLON {
  52962. interface FreeCameraInputsManager {
  52963. /**
  52964. * Add virtual joystick input support to the input manager.
  52965. * @returns the current input manager
  52966. */
  52967. addVirtualJoystick(): FreeCameraInputsManager;
  52968. }
  52969. /**
  52970. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  52971. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52972. */
  52973. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  52974. /**
  52975. * Defines the camera the input is attached to.
  52976. */
  52977. camera: FreeCamera;
  52978. private _leftjoystick;
  52979. private _rightjoystick;
  52980. /**
  52981. * Gets the left stick of the virtual joystick.
  52982. * @returns The virtual Joystick
  52983. */
  52984. getLeftJoystick(): VirtualJoystick;
  52985. /**
  52986. * Gets the right stick of the virtual joystick.
  52987. * @returns The virtual Joystick
  52988. */
  52989. getRightJoystick(): VirtualJoystick;
  52990. /**
  52991. * Update the current camera state depending on the inputs that have been used this frame.
  52992. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52993. */
  52994. checkInputs(): void;
  52995. /**
  52996. * Attach the input controls to a specific dom element to get the input from.
  52997. */
  52998. attachControl(): void;
  52999. /**
  53000. * Detach the current controls from the specified dom element.
  53001. */
  53002. detachControl(): void;
  53003. /**
  53004. * Gets the class name of the current input.
  53005. * @returns the class name
  53006. */
  53007. getClassName(): string;
  53008. /**
  53009. * Get the friendly name associated with the input class.
  53010. * @returns the input friendly name
  53011. */
  53012. getSimpleName(): string;
  53013. }
  53014. }
  53015. declare module BABYLON {
  53016. /**
  53017. * This represents a FPS type of camera controlled by touch.
  53018. * This is like a universal camera minus the Gamepad controls.
  53019. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53020. */
  53021. export class TouchCamera extends FreeCamera {
  53022. /**
  53023. * Defines the touch sensibility for rotation.
  53024. * The higher the faster.
  53025. */
  53026. get touchAngularSensibility(): number;
  53027. set touchAngularSensibility(value: number);
  53028. /**
  53029. * Defines the touch sensibility for move.
  53030. * The higher the faster.
  53031. */
  53032. get touchMoveSensibility(): number;
  53033. set touchMoveSensibility(value: number);
  53034. /**
  53035. * Instantiates a new touch camera.
  53036. * This represents a FPS type of camera controlled by touch.
  53037. * This is like a universal camera minus the Gamepad controls.
  53038. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53039. * @param name Define the name of the camera in the scene
  53040. * @param position Define the start position of the camera in the scene
  53041. * @param scene Define the scene the camera belongs to
  53042. */
  53043. constructor(name: string, position: Vector3, scene: Scene);
  53044. /**
  53045. * Gets the current object class name.
  53046. * @return the class name
  53047. */
  53048. getClassName(): string;
  53049. /** @hidden */
  53050. _setupInputs(): void;
  53051. }
  53052. }
  53053. declare module BABYLON {
  53054. /**
  53055. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  53056. * being tilted forward or back and left or right.
  53057. */
  53058. export class DeviceOrientationCamera extends FreeCamera {
  53059. private _initialQuaternion;
  53060. private _quaternionCache;
  53061. private _tmpDragQuaternion;
  53062. private _disablePointerInputWhenUsingDeviceOrientation;
  53063. /**
  53064. * Creates a new device orientation camera
  53065. * @param name The name of the camera
  53066. * @param position The start position camera
  53067. * @param scene The scene the camera belongs to
  53068. */
  53069. constructor(name: string, position: Vector3, scene: Scene);
  53070. /**
  53071. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  53072. */
  53073. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  53074. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  53075. private _dragFactor;
  53076. /**
  53077. * Enabled turning on the y axis when the orientation sensor is active
  53078. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  53079. */
  53080. enableHorizontalDragging(dragFactor?: number): void;
  53081. /**
  53082. * Gets the current instance class name ("DeviceOrientationCamera").
  53083. * This helps avoiding instanceof at run time.
  53084. * @returns the class name
  53085. */
  53086. getClassName(): string;
  53087. /**
  53088. * @hidden
  53089. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  53090. */
  53091. _checkInputs(): void;
  53092. /**
  53093. * Reset the camera to its default orientation on the specified axis only.
  53094. * @param axis The axis to reset
  53095. */
  53096. resetToCurrentRotation(axis?: Axis): void;
  53097. }
  53098. }
  53099. declare module BABYLON {
  53100. /**
  53101. * Defines supported buttons for XBox360 compatible gamepads
  53102. */
  53103. export enum Xbox360Button {
  53104. /** A */
  53105. A = 0,
  53106. /** B */
  53107. B = 1,
  53108. /** X */
  53109. X = 2,
  53110. /** Y */
  53111. Y = 3,
  53112. /** Left button */
  53113. LB = 4,
  53114. /** Right button */
  53115. RB = 5,
  53116. /** Back */
  53117. Back = 8,
  53118. /** Start */
  53119. Start = 9,
  53120. /** Left stick */
  53121. LeftStick = 10,
  53122. /** Right stick */
  53123. RightStick = 11
  53124. }
  53125. /** Defines values for XBox360 DPad */
  53126. export enum Xbox360Dpad {
  53127. /** Up */
  53128. Up = 12,
  53129. /** Down */
  53130. Down = 13,
  53131. /** Left */
  53132. Left = 14,
  53133. /** Right */
  53134. Right = 15
  53135. }
  53136. /**
  53137. * Defines a XBox360 gamepad
  53138. */
  53139. export class Xbox360Pad extends Gamepad {
  53140. private _leftTrigger;
  53141. private _rightTrigger;
  53142. private _onlefttriggerchanged;
  53143. private _onrighttriggerchanged;
  53144. private _onbuttondown;
  53145. private _onbuttonup;
  53146. private _ondpaddown;
  53147. private _ondpadup;
  53148. /** Observable raised when a button is pressed */
  53149. onButtonDownObservable: Observable<Xbox360Button>;
  53150. /** Observable raised when a button is released */
  53151. onButtonUpObservable: Observable<Xbox360Button>;
  53152. /** Observable raised when a pad is pressed */
  53153. onPadDownObservable: Observable<Xbox360Dpad>;
  53154. /** Observable raised when a pad is released */
  53155. onPadUpObservable: Observable<Xbox360Dpad>;
  53156. private _buttonA;
  53157. private _buttonB;
  53158. private _buttonX;
  53159. private _buttonY;
  53160. private _buttonBack;
  53161. private _buttonStart;
  53162. private _buttonLB;
  53163. private _buttonRB;
  53164. private _buttonLeftStick;
  53165. private _buttonRightStick;
  53166. private _dPadUp;
  53167. private _dPadDown;
  53168. private _dPadLeft;
  53169. private _dPadRight;
  53170. private _isXboxOnePad;
  53171. /**
  53172. * Creates a new XBox360 gamepad object
  53173. * @param id defines the id of this gamepad
  53174. * @param index defines its index
  53175. * @param gamepad defines the internal HTML gamepad object
  53176. * @param xboxOne defines if it is a XBox One gamepad
  53177. */
  53178. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  53179. /**
  53180. * Defines the callback to call when left trigger is pressed
  53181. * @param callback defines the callback to use
  53182. */
  53183. onlefttriggerchanged(callback: (value: number) => void): void;
  53184. /**
  53185. * Defines the callback to call when right trigger is pressed
  53186. * @param callback defines the callback to use
  53187. */
  53188. onrighttriggerchanged(callback: (value: number) => void): void;
  53189. /**
  53190. * Gets the left trigger value
  53191. */
  53192. get leftTrigger(): number;
  53193. /**
  53194. * Sets the left trigger value
  53195. */
  53196. set leftTrigger(newValue: number);
  53197. /**
  53198. * Gets the right trigger value
  53199. */
  53200. get rightTrigger(): number;
  53201. /**
  53202. * Sets the right trigger value
  53203. */
  53204. set rightTrigger(newValue: number);
  53205. /**
  53206. * Defines the callback to call when a button is pressed
  53207. * @param callback defines the callback to use
  53208. */
  53209. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  53210. /**
  53211. * Defines the callback to call when a button is released
  53212. * @param callback defines the callback to use
  53213. */
  53214. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  53215. /**
  53216. * Defines the callback to call when a pad is pressed
  53217. * @param callback defines the callback to use
  53218. */
  53219. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  53220. /**
  53221. * Defines the callback to call when a pad is released
  53222. * @param callback defines the callback to use
  53223. */
  53224. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  53225. private _setButtonValue;
  53226. private _setDPadValue;
  53227. /**
  53228. * Gets the value of the `A` button
  53229. */
  53230. get buttonA(): number;
  53231. /**
  53232. * Sets the value of the `A` button
  53233. */
  53234. set buttonA(value: number);
  53235. /**
  53236. * Gets the value of the `B` button
  53237. */
  53238. get buttonB(): number;
  53239. /**
  53240. * Sets the value of the `B` button
  53241. */
  53242. set buttonB(value: number);
  53243. /**
  53244. * Gets the value of the `X` button
  53245. */
  53246. get buttonX(): number;
  53247. /**
  53248. * Sets the value of the `X` button
  53249. */
  53250. set buttonX(value: number);
  53251. /**
  53252. * Gets the value of the `Y` button
  53253. */
  53254. get buttonY(): number;
  53255. /**
  53256. * Sets the value of the `Y` button
  53257. */
  53258. set buttonY(value: number);
  53259. /**
  53260. * Gets the value of the `Start` button
  53261. */
  53262. get buttonStart(): number;
  53263. /**
  53264. * Sets the value of the `Start` button
  53265. */
  53266. set buttonStart(value: number);
  53267. /**
  53268. * Gets the value of the `Back` button
  53269. */
  53270. get buttonBack(): number;
  53271. /**
  53272. * Sets the value of the `Back` button
  53273. */
  53274. set buttonBack(value: number);
  53275. /**
  53276. * Gets the value of the `Left` button
  53277. */
  53278. get buttonLB(): number;
  53279. /**
  53280. * Sets the value of the `Left` button
  53281. */
  53282. set buttonLB(value: number);
  53283. /**
  53284. * Gets the value of the `Right` button
  53285. */
  53286. get buttonRB(): number;
  53287. /**
  53288. * Sets the value of the `Right` button
  53289. */
  53290. set buttonRB(value: number);
  53291. /**
  53292. * Gets the value of the Left joystick
  53293. */
  53294. get buttonLeftStick(): number;
  53295. /**
  53296. * Sets the value of the Left joystick
  53297. */
  53298. set buttonLeftStick(value: number);
  53299. /**
  53300. * Gets the value of the Right joystick
  53301. */
  53302. get buttonRightStick(): number;
  53303. /**
  53304. * Sets the value of the Right joystick
  53305. */
  53306. set buttonRightStick(value: number);
  53307. /**
  53308. * Gets the value of D-pad up
  53309. */
  53310. get dPadUp(): number;
  53311. /**
  53312. * Sets the value of D-pad up
  53313. */
  53314. set dPadUp(value: number);
  53315. /**
  53316. * Gets the value of D-pad down
  53317. */
  53318. get dPadDown(): number;
  53319. /**
  53320. * Sets the value of D-pad down
  53321. */
  53322. set dPadDown(value: number);
  53323. /**
  53324. * Gets the value of D-pad left
  53325. */
  53326. get dPadLeft(): number;
  53327. /**
  53328. * Sets the value of D-pad left
  53329. */
  53330. set dPadLeft(value: number);
  53331. /**
  53332. * Gets the value of D-pad right
  53333. */
  53334. get dPadRight(): number;
  53335. /**
  53336. * Sets the value of D-pad right
  53337. */
  53338. set dPadRight(value: number);
  53339. /**
  53340. * Force the gamepad to synchronize with device values
  53341. */
  53342. update(): void;
  53343. /**
  53344. * Disposes the gamepad
  53345. */
  53346. dispose(): void;
  53347. }
  53348. }
  53349. declare module BABYLON {
  53350. /**
  53351. * Defines supported buttons for DualShock compatible gamepads
  53352. */
  53353. export enum DualShockButton {
  53354. /** Cross */
  53355. Cross = 0,
  53356. /** Circle */
  53357. Circle = 1,
  53358. /** Square */
  53359. Square = 2,
  53360. /** Triangle */
  53361. Triangle = 3,
  53362. /** L1 */
  53363. L1 = 4,
  53364. /** R1 */
  53365. R1 = 5,
  53366. /** Share */
  53367. Share = 8,
  53368. /** Options */
  53369. Options = 9,
  53370. /** Left stick */
  53371. LeftStick = 10,
  53372. /** Right stick */
  53373. RightStick = 11
  53374. }
  53375. /** Defines values for DualShock DPad */
  53376. export enum DualShockDpad {
  53377. /** Up */
  53378. Up = 12,
  53379. /** Down */
  53380. Down = 13,
  53381. /** Left */
  53382. Left = 14,
  53383. /** Right */
  53384. Right = 15
  53385. }
  53386. /**
  53387. * Defines a DualShock gamepad
  53388. */
  53389. export class DualShockPad extends Gamepad {
  53390. private _leftTrigger;
  53391. private _rightTrigger;
  53392. private _onlefttriggerchanged;
  53393. private _onrighttriggerchanged;
  53394. private _onbuttondown;
  53395. private _onbuttonup;
  53396. private _ondpaddown;
  53397. private _ondpadup;
  53398. /** Observable raised when a button is pressed */
  53399. onButtonDownObservable: Observable<DualShockButton>;
  53400. /** Observable raised when a button is released */
  53401. onButtonUpObservable: Observable<DualShockButton>;
  53402. /** Observable raised when a pad is pressed */
  53403. onPadDownObservable: Observable<DualShockDpad>;
  53404. /** Observable raised when a pad is released */
  53405. onPadUpObservable: Observable<DualShockDpad>;
  53406. private _buttonCross;
  53407. private _buttonCircle;
  53408. private _buttonSquare;
  53409. private _buttonTriangle;
  53410. private _buttonShare;
  53411. private _buttonOptions;
  53412. private _buttonL1;
  53413. private _buttonR1;
  53414. private _buttonLeftStick;
  53415. private _buttonRightStick;
  53416. private _dPadUp;
  53417. private _dPadDown;
  53418. private _dPadLeft;
  53419. private _dPadRight;
  53420. /**
  53421. * Creates a new DualShock gamepad object
  53422. * @param id defines the id of this gamepad
  53423. * @param index defines its index
  53424. * @param gamepad defines the internal HTML gamepad object
  53425. */
  53426. constructor(id: string, index: number, gamepad: any);
  53427. /**
  53428. * Defines the callback to call when left trigger is pressed
  53429. * @param callback defines the callback to use
  53430. */
  53431. onlefttriggerchanged(callback: (value: number) => void): void;
  53432. /**
  53433. * Defines the callback to call when right trigger is pressed
  53434. * @param callback defines the callback to use
  53435. */
  53436. onrighttriggerchanged(callback: (value: number) => void): void;
  53437. /**
  53438. * Gets the left trigger value
  53439. */
  53440. get leftTrigger(): number;
  53441. /**
  53442. * Sets the left trigger value
  53443. */
  53444. set leftTrigger(newValue: number);
  53445. /**
  53446. * Gets the right trigger value
  53447. */
  53448. get rightTrigger(): number;
  53449. /**
  53450. * Sets the right trigger value
  53451. */
  53452. set rightTrigger(newValue: number);
  53453. /**
  53454. * Defines the callback to call when a button is pressed
  53455. * @param callback defines the callback to use
  53456. */
  53457. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  53458. /**
  53459. * Defines the callback to call when a button is released
  53460. * @param callback defines the callback to use
  53461. */
  53462. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  53463. /**
  53464. * Defines the callback to call when a pad is pressed
  53465. * @param callback defines the callback to use
  53466. */
  53467. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  53468. /**
  53469. * Defines the callback to call when a pad is released
  53470. * @param callback defines the callback to use
  53471. */
  53472. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  53473. private _setButtonValue;
  53474. private _setDPadValue;
  53475. /**
  53476. * Gets the value of the `Cross` button
  53477. */
  53478. get buttonCross(): number;
  53479. /**
  53480. * Sets the value of the `Cross` button
  53481. */
  53482. set buttonCross(value: number);
  53483. /**
  53484. * Gets the value of the `Circle` button
  53485. */
  53486. get buttonCircle(): number;
  53487. /**
  53488. * Sets the value of the `Circle` button
  53489. */
  53490. set buttonCircle(value: number);
  53491. /**
  53492. * Gets the value of the `Square` button
  53493. */
  53494. get buttonSquare(): number;
  53495. /**
  53496. * Sets the value of the `Square` button
  53497. */
  53498. set buttonSquare(value: number);
  53499. /**
  53500. * Gets the value of the `Triangle` button
  53501. */
  53502. get buttonTriangle(): number;
  53503. /**
  53504. * Sets the value of the `Triangle` button
  53505. */
  53506. set buttonTriangle(value: number);
  53507. /**
  53508. * Gets the value of the `Options` button
  53509. */
  53510. get buttonOptions(): number;
  53511. /**
  53512. * Sets the value of the `Options` button
  53513. */
  53514. set buttonOptions(value: number);
  53515. /**
  53516. * Gets the value of the `Share` button
  53517. */
  53518. get buttonShare(): number;
  53519. /**
  53520. * Sets the value of the `Share` button
  53521. */
  53522. set buttonShare(value: number);
  53523. /**
  53524. * Gets the value of the `L1` button
  53525. */
  53526. get buttonL1(): number;
  53527. /**
  53528. * Sets the value of the `L1` button
  53529. */
  53530. set buttonL1(value: number);
  53531. /**
  53532. * Gets the value of the `R1` button
  53533. */
  53534. get buttonR1(): number;
  53535. /**
  53536. * Sets the value of the `R1` button
  53537. */
  53538. set buttonR1(value: number);
  53539. /**
  53540. * Gets the value of the Left joystick
  53541. */
  53542. get buttonLeftStick(): number;
  53543. /**
  53544. * Sets the value of the Left joystick
  53545. */
  53546. set buttonLeftStick(value: number);
  53547. /**
  53548. * Gets the value of the Right joystick
  53549. */
  53550. get buttonRightStick(): number;
  53551. /**
  53552. * Sets the value of the Right joystick
  53553. */
  53554. set buttonRightStick(value: number);
  53555. /**
  53556. * Gets the value of D-pad up
  53557. */
  53558. get dPadUp(): number;
  53559. /**
  53560. * Sets the value of D-pad up
  53561. */
  53562. set dPadUp(value: number);
  53563. /**
  53564. * Gets the value of D-pad down
  53565. */
  53566. get dPadDown(): number;
  53567. /**
  53568. * Sets the value of D-pad down
  53569. */
  53570. set dPadDown(value: number);
  53571. /**
  53572. * Gets the value of D-pad left
  53573. */
  53574. get dPadLeft(): number;
  53575. /**
  53576. * Sets the value of D-pad left
  53577. */
  53578. set dPadLeft(value: number);
  53579. /**
  53580. * Gets the value of D-pad right
  53581. */
  53582. get dPadRight(): number;
  53583. /**
  53584. * Sets the value of D-pad right
  53585. */
  53586. set dPadRight(value: number);
  53587. /**
  53588. * Force the gamepad to synchronize with device values
  53589. */
  53590. update(): void;
  53591. /**
  53592. * Disposes the gamepad
  53593. */
  53594. dispose(): void;
  53595. }
  53596. }
  53597. declare module BABYLON {
  53598. /**
  53599. * Manager for handling gamepads
  53600. */
  53601. export class GamepadManager {
  53602. private _scene?;
  53603. private _babylonGamepads;
  53604. private _oneGamepadConnected;
  53605. /** @hidden */
  53606. _isMonitoring: boolean;
  53607. private _gamepadEventSupported;
  53608. private _gamepadSupport?;
  53609. /**
  53610. * observable to be triggered when the gamepad controller has been connected
  53611. */
  53612. onGamepadConnectedObservable: Observable<Gamepad>;
  53613. /**
  53614. * observable to be triggered when the gamepad controller has been disconnected
  53615. */
  53616. onGamepadDisconnectedObservable: Observable<Gamepad>;
  53617. private _onGamepadConnectedEvent;
  53618. private _onGamepadDisconnectedEvent;
  53619. /**
  53620. * Initializes the gamepad manager
  53621. * @param _scene BabylonJS scene
  53622. */
  53623. constructor(_scene?: Scene | undefined);
  53624. /**
  53625. * The gamepads in the game pad manager
  53626. */
  53627. get gamepads(): Gamepad[];
  53628. /**
  53629. * Get the gamepad controllers based on type
  53630. * @param type The type of gamepad controller
  53631. * @returns Nullable gamepad
  53632. */
  53633. getGamepadByType(type?: number): Nullable<Gamepad>;
  53634. /**
  53635. * Disposes the gamepad manager
  53636. */
  53637. dispose(): void;
  53638. private _addNewGamepad;
  53639. private _startMonitoringGamepads;
  53640. private _stopMonitoringGamepads;
  53641. /** @hidden */
  53642. _checkGamepadsStatus(): void;
  53643. private _updateGamepadObjects;
  53644. }
  53645. }
  53646. declare module BABYLON {
  53647. interface Scene {
  53648. /** @hidden */
  53649. _gamepadManager: Nullable<GamepadManager>;
  53650. /**
  53651. * Gets the gamepad manager associated with the scene
  53652. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  53653. */
  53654. gamepadManager: GamepadManager;
  53655. }
  53656. /**
  53657. * Interface representing a free camera inputs manager
  53658. */
  53659. interface FreeCameraInputsManager {
  53660. /**
  53661. * Adds gamepad input support to the FreeCameraInputsManager.
  53662. * @returns the FreeCameraInputsManager
  53663. */
  53664. addGamepad(): FreeCameraInputsManager;
  53665. }
  53666. /**
  53667. * Interface representing an arc rotate camera inputs manager
  53668. */
  53669. interface ArcRotateCameraInputsManager {
  53670. /**
  53671. * Adds gamepad input support to the ArcRotateCamera InputManager.
  53672. * @returns the camera inputs manager
  53673. */
  53674. addGamepad(): ArcRotateCameraInputsManager;
  53675. }
  53676. /**
  53677. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  53678. */
  53679. export class GamepadSystemSceneComponent implements ISceneComponent {
  53680. /**
  53681. * The component name helpfull to identify the component in the list of scene components.
  53682. */
  53683. readonly name: string;
  53684. /**
  53685. * The scene the component belongs to.
  53686. */
  53687. scene: Scene;
  53688. /**
  53689. * Creates a new instance of the component for the given scene
  53690. * @param scene Defines the scene to register the component in
  53691. */
  53692. constructor(scene: Scene);
  53693. /**
  53694. * Registers the component in a given scene
  53695. */
  53696. register(): void;
  53697. /**
  53698. * Rebuilds the elements related to this component in case of
  53699. * context lost for instance.
  53700. */
  53701. rebuild(): void;
  53702. /**
  53703. * Disposes the component and the associated ressources
  53704. */
  53705. dispose(): void;
  53706. private _beforeCameraUpdate;
  53707. }
  53708. }
  53709. declare module BABYLON {
  53710. /**
  53711. * 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,
  53712. * which still works and will still be found in many Playgrounds.
  53713. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53714. */
  53715. export class UniversalCamera extends TouchCamera {
  53716. /**
  53717. * Defines the gamepad rotation sensiblity.
  53718. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  53719. */
  53720. get gamepadAngularSensibility(): number;
  53721. set gamepadAngularSensibility(value: number);
  53722. /**
  53723. * Defines the gamepad move sensiblity.
  53724. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  53725. */
  53726. get gamepadMoveSensibility(): number;
  53727. set gamepadMoveSensibility(value: number);
  53728. /**
  53729. * 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,
  53730. * which still works and will still be found in many Playgrounds.
  53731. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53732. * @param name Define the name of the camera in the scene
  53733. * @param position Define the start position of the camera in the scene
  53734. * @param scene Define the scene the camera belongs to
  53735. */
  53736. constructor(name: string, position: Vector3, scene: Scene);
  53737. /**
  53738. * Gets the current object class name.
  53739. * @return the class name
  53740. */
  53741. getClassName(): string;
  53742. }
  53743. }
  53744. declare module BABYLON {
  53745. /**
  53746. * This represents a FPS type of camera. This is only here for back compat purpose.
  53747. * Please use the UniversalCamera instead as both are identical.
  53748. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53749. */
  53750. export class GamepadCamera extends UniversalCamera {
  53751. /**
  53752. * Instantiates a new Gamepad Camera
  53753. * This represents a FPS type of camera. This is only here for back compat purpose.
  53754. * Please use the UniversalCamera instead as both are identical.
  53755. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53756. * @param name Define the name of the camera in the scene
  53757. * @param position Define the start position of the camera in the scene
  53758. * @param scene Define the scene the camera belongs to
  53759. */
  53760. constructor(name: string, position: Vector3, scene: Scene);
  53761. /**
  53762. * Gets the current object class name.
  53763. * @return the class name
  53764. */
  53765. getClassName(): string;
  53766. }
  53767. }
  53768. declare module BABYLON {
  53769. /** @hidden */
  53770. export var anaglyphPixelShader: {
  53771. name: string;
  53772. shader: string;
  53773. };
  53774. }
  53775. declare module BABYLON {
  53776. /**
  53777. * Postprocess used to generate anaglyphic rendering
  53778. */
  53779. export class AnaglyphPostProcess extends PostProcess {
  53780. private _passedProcess;
  53781. /**
  53782. * Gets a string identifying the name of the class
  53783. * @returns "AnaglyphPostProcess" string
  53784. */
  53785. getClassName(): string;
  53786. /**
  53787. * Creates a new AnaglyphPostProcess
  53788. * @param name defines postprocess name
  53789. * @param options defines creation options or target ratio scale
  53790. * @param rigCameras defines cameras using this postprocess
  53791. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  53792. * @param engine defines hosting engine
  53793. * @param reusable defines if the postprocess will be reused multiple times per frame
  53794. */
  53795. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  53796. }
  53797. }
  53798. declare module BABYLON {
  53799. /**
  53800. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  53801. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  53802. */
  53803. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  53804. /**
  53805. * Creates a new AnaglyphArcRotateCamera
  53806. * @param name defines camera name
  53807. * @param alpha defines alpha angle (in radians)
  53808. * @param beta defines beta angle (in radians)
  53809. * @param radius defines radius
  53810. * @param target defines camera target
  53811. * @param interaxialDistance defines distance between each color axis
  53812. * @param scene defines the hosting scene
  53813. */
  53814. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  53815. /**
  53816. * Gets camera class name
  53817. * @returns AnaglyphArcRotateCamera
  53818. */
  53819. getClassName(): string;
  53820. }
  53821. }
  53822. declare module BABYLON {
  53823. /**
  53824. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  53825. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  53826. */
  53827. export class AnaglyphFreeCamera extends FreeCamera {
  53828. /**
  53829. * Creates a new AnaglyphFreeCamera
  53830. * @param name defines camera name
  53831. * @param position defines initial position
  53832. * @param interaxialDistance defines distance between each color axis
  53833. * @param scene defines the hosting scene
  53834. */
  53835. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  53836. /**
  53837. * Gets camera class name
  53838. * @returns AnaglyphFreeCamera
  53839. */
  53840. getClassName(): string;
  53841. }
  53842. }
  53843. declare module BABYLON {
  53844. /**
  53845. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  53846. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  53847. */
  53848. export class AnaglyphGamepadCamera extends GamepadCamera {
  53849. /**
  53850. * Creates a new AnaglyphGamepadCamera
  53851. * @param name defines camera name
  53852. * @param position defines initial position
  53853. * @param interaxialDistance defines distance between each color axis
  53854. * @param scene defines the hosting scene
  53855. */
  53856. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  53857. /**
  53858. * Gets camera class name
  53859. * @returns AnaglyphGamepadCamera
  53860. */
  53861. getClassName(): string;
  53862. }
  53863. }
  53864. declare module BABYLON {
  53865. /**
  53866. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  53867. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  53868. */
  53869. export class AnaglyphUniversalCamera extends UniversalCamera {
  53870. /**
  53871. * Creates a new AnaglyphUniversalCamera
  53872. * @param name defines camera name
  53873. * @param position defines initial position
  53874. * @param interaxialDistance defines distance between each color axis
  53875. * @param scene defines the hosting scene
  53876. */
  53877. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  53878. /**
  53879. * Gets camera class name
  53880. * @returns AnaglyphUniversalCamera
  53881. */
  53882. getClassName(): string;
  53883. }
  53884. }
  53885. declare module BABYLON {
  53886. /** @hidden */
  53887. export var stereoscopicInterlacePixelShader: {
  53888. name: string;
  53889. shader: string;
  53890. };
  53891. }
  53892. declare module BABYLON {
  53893. /**
  53894. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  53895. */
  53896. export class StereoscopicInterlacePostProcessI extends PostProcess {
  53897. private _stepSize;
  53898. private _passedProcess;
  53899. /**
  53900. * Gets a string identifying the name of the class
  53901. * @returns "StereoscopicInterlacePostProcessI" string
  53902. */
  53903. getClassName(): string;
  53904. /**
  53905. * Initializes a StereoscopicInterlacePostProcessI
  53906. * @param name The name of the effect.
  53907. * @param rigCameras The rig cameras to be applied to the post process
  53908. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  53909. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  53910. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53911. * @param engine The engine which the post process will be applied. (default: current engine)
  53912. * @param reusable If the post process can be reused on the same frame. (default: false)
  53913. */
  53914. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53915. }
  53916. /**
  53917. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  53918. */
  53919. export class StereoscopicInterlacePostProcess extends PostProcess {
  53920. private _stepSize;
  53921. private _passedProcess;
  53922. /**
  53923. * Gets a string identifying the name of the class
  53924. * @returns "StereoscopicInterlacePostProcess" string
  53925. */
  53926. getClassName(): string;
  53927. /**
  53928. * Initializes a StereoscopicInterlacePostProcess
  53929. * @param name The name of the effect.
  53930. * @param rigCameras The rig cameras to be applied to the post process
  53931. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  53932. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53933. * @param engine The engine which the post process will be applied. (default: current engine)
  53934. * @param reusable If the post process can be reused on the same frame. (default: false)
  53935. */
  53936. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53937. }
  53938. }
  53939. declare module BABYLON {
  53940. /**
  53941. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  53942. * @see https://doc.babylonjs.com/features/cameras
  53943. */
  53944. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  53945. /**
  53946. * Creates a new StereoscopicArcRotateCamera
  53947. * @param name defines camera name
  53948. * @param alpha defines alpha angle (in radians)
  53949. * @param beta defines beta angle (in radians)
  53950. * @param radius defines radius
  53951. * @param target defines camera target
  53952. * @param interaxialDistance defines distance between each color axis
  53953. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  53954. * @param scene defines the hosting scene
  53955. */
  53956. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  53957. /**
  53958. * Gets camera class name
  53959. * @returns StereoscopicArcRotateCamera
  53960. */
  53961. getClassName(): string;
  53962. }
  53963. }
  53964. declare module BABYLON {
  53965. /**
  53966. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  53967. * @see https://doc.babylonjs.com/features/cameras
  53968. */
  53969. export class StereoscopicFreeCamera extends FreeCamera {
  53970. /**
  53971. * Creates a new StereoscopicFreeCamera
  53972. * @param name defines camera name
  53973. * @param position defines initial position
  53974. * @param interaxialDistance defines distance between each color axis
  53975. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  53976. * @param scene defines the hosting scene
  53977. */
  53978. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  53979. /**
  53980. * Gets camera class name
  53981. * @returns StereoscopicFreeCamera
  53982. */
  53983. getClassName(): string;
  53984. }
  53985. }
  53986. declare module BABYLON {
  53987. /**
  53988. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  53989. * @see https://doc.babylonjs.com/features/cameras
  53990. */
  53991. export class StereoscopicGamepadCamera extends GamepadCamera {
  53992. /**
  53993. * Creates a new StereoscopicGamepadCamera
  53994. * @param name defines camera name
  53995. * @param position defines initial position
  53996. * @param interaxialDistance defines distance between each color axis
  53997. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  53998. * @param scene defines the hosting scene
  53999. */
  54000. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  54001. /**
  54002. * Gets camera class name
  54003. * @returns StereoscopicGamepadCamera
  54004. */
  54005. getClassName(): string;
  54006. }
  54007. }
  54008. declare module BABYLON {
  54009. /**
  54010. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  54011. * @see https://doc.babylonjs.com/features/cameras
  54012. */
  54013. export class StereoscopicUniversalCamera extends UniversalCamera {
  54014. /**
  54015. * Creates a new StereoscopicUniversalCamera
  54016. * @param name defines camera name
  54017. * @param position defines initial position
  54018. * @param interaxialDistance defines distance between each color axis
  54019. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  54020. * @param scene defines the hosting scene
  54021. */
  54022. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  54023. /**
  54024. * Gets camera class name
  54025. * @returns StereoscopicUniversalCamera
  54026. */
  54027. getClassName(): string;
  54028. }
  54029. }
  54030. declare module BABYLON {
  54031. /**
  54032. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  54033. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  54034. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  54035. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  54036. */
  54037. export class VirtualJoysticksCamera extends FreeCamera {
  54038. /**
  54039. * Instantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  54040. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  54041. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  54042. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  54043. * @param name Define the name of the camera in the scene
  54044. * @param position Define the start position of the camera in the scene
  54045. * @param scene Define the scene the camera belongs to
  54046. */
  54047. constructor(name: string, position: Vector3, scene: Scene);
  54048. /**
  54049. * Gets the current object class name.
  54050. * @return the class name
  54051. */
  54052. getClassName(): string;
  54053. }
  54054. }
  54055. declare module BABYLON {
  54056. /**
  54057. * This represents all the required metrics to create a VR camera.
  54058. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  54059. */
  54060. export class VRCameraMetrics {
  54061. /**
  54062. * Define the horizontal resolution off the screen.
  54063. */
  54064. hResolution: number;
  54065. /**
  54066. * Define the vertical resolution off the screen.
  54067. */
  54068. vResolution: number;
  54069. /**
  54070. * Define the horizontal screen size.
  54071. */
  54072. hScreenSize: number;
  54073. /**
  54074. * Define the vertical screen size.
  54075. */
  54076. vScreenSize: number;
  54077. /**
  54078. * Define the vertical screen center position.
  54079. */
  54080. vScreenCenter: number;
  54081. /**
  54082. * Define the distance of the eyes to the screen.
  54083. */
  54084. eyeToScreenDistance: number;
  54085. /**
  54086. * Define the distance between both lenses
  54087. */
  54088. lensSeparationDistance: number;
  54089. /**
  54090. * Define the distance between both viewer's eyes.
  54091. */
  54092. interpupillaryDistance: number;
  54093. /**
  54094. * Define the distortion factor of the VR postprocess.
  54095. * Please, touch with care.
  54096. */
  54097. distortionK: number[];
  54098. /**
  54099. * Define the chromatic aberration correction factors for the VR post process.
  54100. */
  54101. chromaAbCorrection: number[];
  54102. /**
  54103. * Define the scale factor of the post process.
  54104. * The smaller the better but the slower.
  54105. */
  54106. postProcessScaleFactor: number;
  54107. /**
  54108. * Define an offset for the lens center.
  54109. */
  54110. lensCenterOffset: number;
  54111. /**
  54112. * Define if the current vr camera should compensate the distortion of the lens or not.
  54113. */
  54114. compensateDistortion: boolean;
  54115. /**
  54116. * Defines if multiview should be enabled when rendering (Default: false)
  54117. */
  54118. multiviewEnabled: boolean;
  54119. /**
  54120. * Gets the rendering aspect ratio based on the provided resolutions.
  54121. */
  54122. get aspectRatio(): number;
  54123. /**
  54124. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  54125. */
  54126. get aspectRatioFov(): number;
  54127. /**
  54128. * @hidden
  54129. */
  54130. get leftHMatrix(): Matrix;
  54131. /**
  54132. * @hidden
  54133. */
  54134. get rightHMatrix(): Matrix;
  54135. /**
  54136. * @hidden
  54137. */
  54138. get leftPreViewMatrix(): Matrix;
  54139. /**
  54140. * @hidden
  54141. */
  54142. get rightPreViewMatrix(): Matrix;
  54143. /**
  54144. * Get the default VRMetrics based on the most generic setup.
  54145. * @returns the default vr metrics
  54146. */
  54147. static GetDefault(): VRCameraMetrics;
  54148. }
  54149. }
  54150. declare module BABYLON {
  54151. /** @hidden */
  54152. export var vrDistortionCorrectionPixelShader: {
  54153. name: string;
  54154. shader: string;
  54155. };
  54156. }
  54157. declare module BABYLON {
  54158. /**
  54159. * VRDistortionCorrectionPostProcess used for mobile VR
  54160. */
  54161. export class VRDistortionCorrectionPostProcess extends PostProcess {
  54162. private _isRightEye;
  54163. private _distortionFactors;
  54164. private _postProcessScaleFactor;
  54165. private _lensCenterOffset;
  54166. private _scaleIn;
  54167. private _scaleFactor;
  54168. private _lensCenter;
  54169. /**
  54170. * Gets a string identifying the name of the class
  54171. * @returns "VRDistortionCorrectionPostProcess" string
  54172. */
  54173. getClassName(): string;
  54174. /**
  54175. * Initializes the VRDistortionCorrectionPostProcess
  54176. * @param name The name of the effect.
  54177. * @param camera The camera to apply the render pass to.
  54178. * @param isRightEye If this is for the right eye distortion
  54179. * @param vrMetrics All the required metrics for the VR camera
  54180. */
  54181. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  54182. }
  54183. }
  54184. declare module BABYLON {
  54185. /**
  54186. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  54187. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  54188. */
  54189. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  54190. /**
  54191. * Creates a new VRDeviceOrientationArcRotateCamera
  54192. * @param name defines camera name
  54193. * @param alpha defines the camera rotation along the longitudinal axis
  54194. * @param beta defines the camera rotation along the latitudinal axis
  54195. * @param radius defines the camera distance from its target
  54196. * @param target defines the camera target
  54197. * @param scene defines the scene the camera belongs to
  54198. * @param compensateDistortion defines if the camera needs to compensate the lens distortion
  54199. * @param vrCameraMetrics defines the vr metrics associated to the camera
  54200. */
  54201. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  54202. /**
  54203. * Gets camera class name
  54204. * @returns VRDeviceOrientationArcRotateCamera
  54205. */
  54206. getClassName(): string;
  54207. }
  54208. }
  54209. declare module BABYLON {
  54210. /**
  54211. * Camera used to simulate VR rendering (based on FreeCamera)
  54212. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  54213. */
  54214. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  54215. /**
  54216. * Creates a new VRDeviceOrientationFreeCamera
  54217. * @param name defines camera name
  54218. * @param position defines the start position of the camera
  54219. * @param scene defines the scene the camera belongs to
  54220. * @param compensateDistortion defines if the camera needs to compensate the lens distortion
  54221. * @param vrCameraMetrics defines the vr metrics associated to the camera
  54222. */
  54223. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  54224. /**
  54225. * Gets camera class name
  54226. * @returns VRDeviceOrientationFreeCamera
  54227. */
  54228. getClassName(): string;
  54229. }
  54230. }
  54231. declare module BABYLON {
  54232. /**
  54233. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  54234. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  54235. */
  54236. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  54237. /**
  54238. * Creates a new VRDeviceOrientationGamepadCamera
  54239. * @param name defines camera name
  54240. * @param position defines the start position of the camera
  54241. * @param scene defines the scene the camera belongs to
  54242. * @param compensateDistortion defines if the camera needs to compensate the lens distortion
  54243. * @param vrCameraMetrics defines the vr metrics associated to the camera
  54244. */
  54245. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  54246. /**
  54247. * Gets camera class name
  54248. * @returns VRDeviceOrientationGamepadCamera
  54249. */
  54250. getClassName(): string;
  54251. }
  54252. }
  54253. declare module BABYLON {
  54254. /**
  54255. * A class extending Texture allowing drawing on a texture
  54256. * @see https://doc.babylonjs.com/how_to/dynamictexture
  54257. */
  54258. export class DynamicTexture extends Texture {
  54259. private _generateMipMaps;
  54260. private _canvas;
  54261. private _context;
  54262. /**
  54263. * Creates a DynamicTexture
  54264. * @param name defines the name of the texture
  54265. * @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
  54266. * @param scene defines the scene where you want the texture
  54267. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  54268. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54269. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  54270. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  54271. */
  54272. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  54273. /**
  54274. * Get the current class name of the texture useful for serialization or dynamic coding.
  54275. * @returns "DynamicTexture"
  54276. */
  54277. getClassName(): string;
  54278. /**
  54279. * Gets the current state of canRescale
  54280. */
  54281. get canRescale(): boolean;
  54282. private _recreate;
  54283. /**
  54284. * Scales the texture
  54285. * @param ratio the scale factor to apply to both width and height
  54286. */
  54287. scale(ratio: number): void;
  54288. /**
  54289. * Resizes the texture
  54290. * @param width the new width
  54291. * @param height the new height
  54292. */
  54293. scaleTo(width: number, height: number): void;
  54294. /**
  54295. * Gets the context of the canvas used by the texture
  54296. * @returns the canvas context of the dynamic texture
  54297. */
  54298. getContext(): CanvasRenderingContext2D;
  54299. /**
  54300. * Clears the texture
  54301. */
  54302. clear(): void;
  54303. /**
  54304. * Updates the texture
  54305. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  54306. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  54307. */
  54308. update(invertY?: boolean, premulAlpha?: boolean): void;
  54309. /**
  54310. * Draws text onto the texture
  54311. * @param text defines the text to be drawn
  54312. * @param x defines the placement of the text from the left
  54313. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  54314. * @param font defines the font to be used with font-style, font-size, font-name
  54315. * @param color defines the color used for the text
  54316. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  54317. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  54318. * @param update defines whether texture is immediately update (default is true)
  54319. */
  54320. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  54321. /**
  54322. * Clones the texture
  54323. * @returns the clone of the texture.
  54324. */
  54325. clone(): DynamicTexture;
  54326. /**
  54327. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  54328. * @returns a serialized dynamic texture object
  54329. */
  54330. serialize(): any;
  54331. private _IsCanvasElement;
  54332. /** @hidden */
  54333. _rebuild(): void;
  54334. }
  54335. }
  54336. declare module BABYLON {
  54337. /**
  54338. * Class containing static functions to help procedurally build meshes
  54339. */
  54340. export class GroundBuilder {
  54341. /**
  54342. * Creates a ground mesh
  54343. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  54344. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  54345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54346. * @param name defines the name of the mesh
  54347. * @param options defines the options used to create the mesh
  54348. * @param scene defines the hosting scene
  54349. * @returns the ground mesh
  54350. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  54351. */
  54352. static CreateGround(name: string, options: {
  54353. width?: number;
  54354. height?: number;
  54355. subdivisions?: number;
  54356. subdivisionsX?: number;
  54357. subdivisionsY?: number;
  54358. updatable?: boolean;
  54359. }, scene: any): Mesh;
  54360. /**
  54361. * Creates a tiled ground mesh
  54362. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  54363. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  54364. * * 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
  54365. * * 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
  54366. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54367. * @param name defines the name of the mesh
  54368. * @param options defines the options used to create the mesh
  54369. * @param scene defines the hosting scene
  54370. * @returns the tiled ground mesh
  54371. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  54372. */
  54373. static CreateTiledGround(name: string, options: {
  54374. xmin: number;
  54375. zmin: number;
  54376. xmax: number;
  54377. zmax: number;
  54378. subdivisions?: {
  54379. w: number;
  54380. h: number;
  54381. };
  54382. precision?: {
  54383. w: number;
  54384. h: number;
  54385. };
  54386. updatable?: boolean;
  54387. }, scene?: Nullable<Scene>): Mesh;
  54388. /**
  54389. * Creates a ground mesh from a height map
  54390. * * The parameter `url` sets the URL of the height map image resource.
  54391. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  54392. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  54393. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  54394. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  54395. * * 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.
  54396. * * 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).
  54397. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  54398. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54399. * @param name defines the name of the mesh
  54400. * @param url defines the url to the height map
  54401. * @param options defines the options used to create the mesh
  54402. * @param scene defines the hosting scene
  54403. * @returns the ground mesh
  54404. * @see https://doc.babylonjs.com/babylon101/height_map
  54405. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  54406. */
  54407. static CreateGroundFromHeightMap(name: string, url: string, options: {
  54408. width?: number;
  54409. height?: number;
  54410. subdivisions?: number;
  54411. minHeight?: number;
  54412. maxHeight?: number;
  54413. colorFilter?: Color3;
  54414. alphaFilter?: number;
  54415. updatable?: boolean;
  54416. onReady?: (mesh: GroundMesh) => void;
  54417. }, scene?: Nullable<Scene>): GroundMesh;
  54418. }
  54419. }
  54420. declare module BABYLON {
  54421. /**
  54422. * Class containing static functions to help procedurally build meshes
  54423. */
  54424. export class TorusBuilder {
  54425. /**
  54426. * Creates a torus mesh
  54427. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  54428. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  54429. * * The parameter `tessellation` sets the number of torus sides (positive integer, default 16)
  54430. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54431. * * 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
  54432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54433. * @param name defines the name of the mesh
  54434. * @param options defines the options used to create the mesh
  54435. * @param scene defines the hosting scene
  54436. * @returns the torus mesh
  54437. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  54438. */
  54439. static CreateTorus(name: string, options: {
  54440. diameter?: number;
  54441. thickness?: number;
  54442. tessellation?: number;
  54443. updatable?: boolean;
  54444. sideOrientation?: number;
  54445. frontUVs?: Vector4;
  54446. backUVs?: Vector4;
  54447. }, scene: any): Mesh;
  54448. }
  54449. }
  54450. declare module BABYLON {
  54451. /**
  54452. * Class containing static functions to help procedurally build meshes
  54453. */
  54454. export class CylinderBuilder {
  54455. /**
  54456. * Creates a cylinder or a cone mesh
  54457. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  54458. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  54459. * * 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.
  54460. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  54461. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  54462. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  54463. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  54464. * * 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).
  54465. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  54466. * * 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).
  54467. * * 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
  54468. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  54469. * * 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
  54470. * * 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.
  54471. * * If `enclose` is false, a ring surface is one element.
  54472. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  54473. * * 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
  54474. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54475. * * 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
  54476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54477. * @param name defines the name of the mesh
  54478. * @param options defines the options used to create the mesh
  54479. * @param scene defines the hosting scene
  54480. * @returns the cylinder mesh
  54481. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  54482. */
  54483. static CreateCylinder(name: string, options: {
  54484. height?: number;
  54485. diameterTop?: number;
  54486. diameterBottom?: number;
  54487. diameter?: number;
  54488. tessellation?: number;
  54489. subdivisions?: number;
  54490. arc?: number;
  54491. faceColors?: Color4[];
  54492. faceUV?: Vector4[];
  54493. updatable?: boolean;
  54494. hasRings?: boolean;
  54495. enclose?: boolean;
  54496. cap?: number;
  54497. sideOrientation?: number;
  54498. frontUVs?: Vector4;
  54499. backUVs?: Vector4;
  54500. }, scene: any): Mesh;
  54501. }
  54502. }
  54503. declare module BABYLON {
  54504. /**
  54505. * States of the webXR experience
  54506. */
  54507. export enum WebXRState {
  54508. /**
  54509. * Transitioning to being in XR mode
  54510. */
  54511. ENTERING_XR = 0,
  54512. /**
  54513. * Transitioning to non XR mode
  54514. */
  54515. EXITING_XR = 1,
  54516. /**
  54517. * In XR mode and presenting
  54518. */
  54519. IN_XR = 2,
  54520. /**
  54521. * Not entered XR mode
  54522. */
  54523. NOT_IN_XR = 3
  54524. }
  54525. /**
  54526. * The state of the XR camera's tracking
  54527. */
  54528. export enum WebXRTrackingState {
  54529. /**
  54530. * No transformation received, device is not being tracked
  54531. */
  54532. NOT_TRACKING = 0,
  54533. /**
  54534. * Tracking lost - using emulated position
  54535. */
  54536. TRACKING_LOST = 1,
  54537. /**
  54538. * Transformation tracking works normally
  54539. */
  54540. TRACKING = 2
  54541. }
  54542. /**
  54543. * Abstraction of the XR render target
  54544. */
  54545. export interface WebXRRenderTarget extends IDisposable {
  54546. /**
  54547. * xrpresent context of the canvas which can be used to display/mirror xr content
  54548. */
  54549. canvasContext: WebGLRenderingContext;
  54550. /**
  54551. * xr layer for the canvas
  54552. */
  54553. xrLayer: Nullable<XRWebGLLayer>;
  54554. /**
  54555. * Initializes the xr layer for the session
  54556. * @param xrSession xr session
  54557. * @returns a promise that will resolve once the XR Layer has been created
  54558. */
  54559. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  54560. }
  54561. }
  54562. declare module BABYLON {
  54563. /**
  54564. * Configuration object for WebXR output canvas
  54565. */
  54566. export class WebXRManagedOutputCanvasOptions {
  54567. /**
  54568. * An optional canvas in case you wish to create it yourself and provide it here.
  54569. * If not provided, a new canvas will be created
  54570. */
  54571. canvasElement?: HTMLCanvasElement;
  54572. /**
  54573. * Options for this XR Layer output
  54574. */
  54575. canvasOptions?: XRWebGLLayerInit;
  54576. /**
  54577. * CSS styling for a newly created canvas (if not provided)
  54578. */
  54579. newCanvasCssStyle?: string;
  54580. /**
  54581. * Get the default values of the configuration object
  54582. * @param engine defines the engine to use (can be null)
  54583. * @returns default values of this configuration object
  54584. */
  54585. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  54586. }
  54587. /**
  54588. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  54589. */
  54590. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  54591. private _options;
  54592. private _canvas;
  54593. private _engine;
  54594. private _originalCanvasSize;
  54595. /**
  54596. * Rendering context of the canvas which can be used to display/mirror xr content
  54597. */
  54598. canvasContext: WebGLRenderingContext;
  54599. /**
  54600. * xr layer for the canvas
  54601. */
  54602. xrLayer: Nullable<XRWebGLLayer>;
  54603. /**
  54604. * Observers registered here will be triggered when the xr layer was initialized
  54605. */
  54606. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  54607. /**
  54608. * Initializes the canvas to be added/removed upon entering/exiting xr
  54609. * @param _xrSessionManager The XR Session manager
  54610. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  54611. */
  54612. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  54613. /**
  54614. * Disposes of the object
  54615. */
  54616. dispose(): void;
  54617. /**
  54618. * Initializes the xr layer for the session
  54619. * @param xrSession xr session
  54620. * @returns a promise that will resolve once the XR Layer has been created
  54621. */
  54622. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  54623. private _addCanvas;
  54624. private _removeCanvas;
  54625. private _setCanvasSize;
  54626. private _setManagedOutputCanvas;
  54627. }
  54628. }
  54629. declare module BABYLON {
  54630. /**
  54631. * Manages an XRSession to work with Babylon's engine
  54632. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  54633. */
  54634. export class WebXRSessionManager implements IDisposable {
  54635. /** The scene which the session should be created for */
  54636. scene: Scene;
  54637. private _referenceSpace;
  54638. private _rttProvider;
  54639. private _sessionEnded;
  54640. private _xrNavigator;
  54641. private baseLayer;
  54642. /**
  54643. * The base reference space from which the session started. good if you want to reset your
  54644. * reference space
  54645. */
  54646. baseReferenceSpace: XRReferenceSpace;
  54647. /**
  54648. * Current XR frame
  54649. */
  54650. currentFrame: Nullable<XRFrame>;
  54651. /** WebXR timestamp updated every frame */
  54652. currentTimestamp: number;
  54653. /**
  54654. * Used just in case of a failure to initialize an immersive session.
  54655. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  54656. */
  54657. defaultHeightCompensation: number;
  54658. /**
  54659. * Fires every time a new xrFrame arrives which can be used to update the camera
  54660. */
  54661. onXRFrameObservable: Observable<XRFrame>;
  54662. /**
  54663. * Fires when the reference space changed
  54664. */
  54665. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  54666. /**
  54667. * Fires when the xr session is ended either by the device or manually done
  54668. */
  54669. onXRSessionEnded: Observable<any>;
  54670. /**
  54671. * Fires when the xr session is ended either by the device or manually done
  54672. */
  54673. onXRSessionInit: Observable<XRSession>;
  54674. /**
  54675. * Underlying xr session
  54676. */
  54677. session: XRSession;
  54678. /**
  54679. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  54680. * or get the offset the player is currently at.
  54681. */
  54682. viewerReferenceSpace: XRReferenceSpace;
  54683. /**
  54684. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  54685. * @param scene The scene which the session should be created for
  54686. */
  54687. constructor(
  54688. /** The scene which the session should be created for */
  54689. scene: Scene);
  54690. /**
  54691. * The current reference space used in this session. This reference space can constantly change!
  54692. * It is mainly used to offset the camera's position.
  54693. */
  54694. get referenceSpace(): XRReferenceSpace;
  54695. /**
  54696. * Set a new reference space and triggers the observable
  54697. */
  54698. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  54699. /**
  54700. * Disposes of the session manager
  54701. */
  54702. dispose(): void;
  54703. /**
  54704. * Stops the xrSession and restores the render loop
  54705. * @returns Promise which resolves after it exits XR
  54706. */
  54707. exitXRAsync(): Promise<void>;
  54708. /**
  54709. * Gets the correct render target texture to be rendered this frame for this eye
  54710. * @param eye the eye for which to get the render target
  54711. * @returns the render target for the specified eye
  54712. */
  54713. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  54714. /**
  54715. * Creates a WebXRRenderTarget object for the XR session
  54716. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  54717. * @param options optional options to provide when creating a new render target
  54718. * @returns a WebXR render target to which the session can render
  54719. */
  54720. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  54721. /**
  54722. * Initializes the manager
  54723. * After initialization enterXR can be called to start an XR session
  54724. * @returns Promise which resolves after it is initialized
  54725. */
  54726. initializeAsync(): Promise<void>;
  54727. /**
  54728. * Initializes an xr session
  54729. * @param xrSessionMode mode to initialize
  54730. * @param xrSessionInit defines optional and required values to pass to the session builder
  54731. * @returns a promise which will resolve once the session has been initialized
  54732. */
  54733. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  54734. /**
  54735. * Checks if a session would be supported for the creation options specified
  54736. * @param sessionMode session mode to check if supported eg. immersive-vr
  54737. * @returns A Promise that resolves to true if supported and false if not
  54738. */
  54739. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  54740. /**
  54741. * Resets the reference space to the one started the session
  54742. */
  54743. resetReferenceSpace(): void;
  54744. /**
  54745. * Starts rendering to the xr layer
  54746. */
  54747. runXRRenderLoop(): void;
  54748. /**
  54749. * Sets the reference space on the xr session
  54750. * @param referenceSpaceType space to set
  54751. * @returns a promise that will resolve once the reference space has been set
  54752. */
  54753. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  54754. /**
  54755. * Updates the render state of the session
  54756. * @param state state to set
  54757. * @returns a promise that resolves once the render state has been updated
  54758. */
  54759. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  54760. /**
  54761. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  54762. * @param sessionMode defines the session to test
  54763. * @returns a promise with boolean as final value
  54764. */
  54765. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  54766. /**
  54767. * Returns true if Babylon.js is using the BabylonNative backend, otherwise false
  54768. */
  54769. get isNative(): boolean;
  54770. private _createRenderTargetTexture;
  54771. }
  54772. }
  54773. declare module BABYLON {
  54774. /**
  54775. * WebXR Camera which holds the views for the xrSession
  54776. * @see https://doc.babylonjs.com/how_to/webxr_camera
  54777. */
  54778. export class WebXRCamera extends FreeCamera {
  54779. private _xrSessionManager;
  54780. private _firstFrame;
  54781. private _referenceQuaternion;
  54782. private _referencedPosition;
  54783. private _xrInvPositionCache;
  54784. private _xrInvQuaternionCache;
  54785. private _trackingState;
  54786. /**
  54787. * Observable raised before camera teleportation
  54788. */
  54789. onBeforeCameraTeleport: Observable<Vector3>;
  54790. /**
  54791. * Observable raised after camera teleportation
  54792. */
  54793. onAfterCameraTeleport: Observable<Vector3>;
  54794. /**
  54795. * Notifies when the camera's tracking state has changed.
  54796. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  54797. */
  54798. onTrackingStateChanged: Observable<WebXRTrackingState>;
  54799. /**
  54800. * Should position compensation execute on first frame.
  54801. * This is used when copying the position from a native (non XR) camera
  54802. */
  54803. compensateOnFirstFrame: boolean;
  54804. /**
  54805. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  54806. * @param name the name of the camera
  54807. * @param scene the scene to add the camera to
  54808. * @param _xrSessionManager a constructed xr session manager
  54809. */
  54810. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  54811. /**
  54812. * Get the current XR tracking state of the camera
  54813. */
  54814. get trackingState(): WebXRTrackingState;
  54815. private _setTrackingState;
  54816. /**
  54817. * Return the user's height, unrelated to the current ground.
  54818. * This will be the y position of this camera, when ground level is 0.
  54819. */
  54820. get realWorldHeight(): number;
  54821. /** @hidden */
  54822. _updateForDualEyeDebugging(): void;
  54823. /**
  54824. * Sets this camera's transformation based on a non-vr camera
  54825. * @param otherCamera the non-vr camera to copy the transformation from
  54826. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  54827. */
  54828. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  54829. /**
  54830. * Gets the current instance class name ("WebXRCamera").
  54831. * @returns the class name
  54832. */
  54833. getClassName(): string;
  54834. private _rotate180;
  54835. private _updateFromXRSession;
  54836. private _updateNumberOfRigCameras;
  54837. private _updateReferenceSpace;
  54838. private _updateReferenceSpaceOffset;
  54839. }
  54840. }
  54841. declare module BABYLON {
  54842. /**
  54843. * Defining the interface required for a (webxr) feature
  54844. */
  54845. export interface IWebXRFeature extends IDisposable {
  54846. /**
  54847. * Is this feature attached
  54848. */
  54849. attached: boolean;
  54850. /**
  54851. * Should auto-attach be disabled?
  54852. */
  54853. disableAutoAttach: boolean;
  54854. /**
  54855. * Attach the feature to the session
  54856. * Will usually be called by the features manager
  54857. *
  54858. * @param force should attachment be forced (even when already attached)
  54859. * @returns true if successful.
  54860. */
  54861. attach(force?: boolean): boolean;
  54862. /**
  54863. * Detach the feature from the session
  54864. * Will usually be called by the features manager
  54865. *
  54866. * @returns true if successful.
  54867. */
  54868. detach(): boolean;
  54869. /**
  54870. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  54871. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  54872. *
  54873. * @returns whether or not the feature is compatible in this environment
  54874. */
  54875. isCompatible(): boolean;
  54876. /**
  54877. * Was this feature disposed;
  54878. */
  54879. isDisposed: boolean;
  54880. /**
  54881. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  54882. */
  54883. xrNativeFeatureName?: string;
  54884. /**
  54885. * A list of (Babylon WebXR) features this feature depends on
  54886. */
  54887. dependsOn?: string[];
  54888. /**
  54889. * If this feature requires to extend the XRSessionInit object, this function will return the partial XR session init object
  54890. */
  54891. getXRSessionInitExtension?: () => Promise<Partial<XRSessionInit>>;
  54892. }
  54893. /**
  54894. * A list of the currently available features without referencing them
  54895. */
  54896. export class WebXRFeatureName {
  54897. /**
  54898. * The name of the anchor system feature
  54899. */
  54900. static readonly ANCHOR_SYSTEM: string;
  54901. /**
  54902. * The name of the background remover feature
  54903. */
  54904. static readonly BACKGROUND_REMOVER: string;
  54905. /**
  54906. * The name of the hit test feature
  54907. */
  54908. static readonly HIT_TEST: string;
  54909. /**
  54910. * The name of the mesh detection feature
  54911. */
  54912. static readonly MESH_DETECTION: string;
  54913. /**
  54914. * physics impostors for xr controllers feature
  54915. */
  54916. static readonly PHYSICS_CONTROLLERS: string;
  54917. /**
  54918. * The name of the plane detection feature
  54919. */
  54920. static readonly PLANE_DETECTION: string;
  54921. /**
  54922. * The name of the pointer selection feature
  54923. */
  54924. static readonly POINTER_SELECTION: string;
  54925. /**
  54926. * The name of the teleportation feature
  54927. */
  54928. static readonly TELEPORTATION: string;
  54929. /**
  54930. * The name of the feature points feature.
  54931. */
  54932. static readonly FEATURE_POINTS: string;
  54933. /**
  54934. * The name of the hand tracking feature.
  54935. */
  54936. static readonly HAND_TRACKING: string;
  54937. /**
  54938. * The name of the image tracking feature
  54939. */
  54940. static readonly IMAGE_TRACKING: string;
  54941. }
  54942. /**
  54943. * Defining the constructor of a feature. Used to register the modules.
  54944. */
  54945. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  54946. /**
  54947. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  54948. * It is mainly used in AR sessions.
  54949. *
  54950. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  54951. */
  54952. export class WebXRFeaturesManager implements IDisposable {
  54953. private _xrSessionManager;
  54954. private static readonly _AvailableFeatures;
  54955. private _features;
  54956. /**
  54957. * constructs a new features manages.
  54958. *
  54959. * @param _xrSessionManager an instance of WebXRSessionManager
  54960. */
  54961. constructor(_xrSessionManager: WebXRSessionManager);
  54962. /**
  54963. * Used to register a module. After calling this function a developer can use this feature in the scene.
  54964. * Mainly used internally.
  54965. *
  54966. * @param featureName the name of the feature to register
  54967. * @param constructorFunction the function used to construct the module
  54968. * @param version the (babylon) version of the module
  54969. * @param stable is that a stable version of this module
  54970. */
  54971. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  54972. /**
  54973. * Returns a constructor of a specific feature.
  54974. *
  54975. * @param featureName the name of the feature to construct
  54976. * @param version the version of the feature to load
  54977. * @param xrSessionManager the xrSessionManager. Used to construct the module
  54978. * @param options optional options provided to the module.
  54979. * @returns a function that, when called, will return a new instance of this feature
  54980. */
  54981. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  54982. /**
  54983. * Can be used to return the list of features currently registered
  54984. *
  54985. * @returns an Array of available features
  54986. */
  54987. static GetAvailableFeatures(): string[];
  54988. /**
  54989. * Gets the versions available for a specific feature
  54990. * @param featureName the name of the feature
  54991. * @returns an array with the available versions
  54992. */
  54993. static GetAvailableVersions(featureName: string): string[];
  54994. /**
  54995. * Return the latest unstable version of this feature
  54996. * @param featureName the name of the feature to search
  54997. * @returns the version number. if not found will return -1
  54998. */
  54999. static GetLatestVersionOfFeature(featureName: string): number;
  55000. /**
  55001. * Return the latest stable version of this feature
  55002. * @param featureName the name of the feature to search
  55003. * @returns the version number. if not found will return -1
  55004. */
  55005. static GetStableVersionOfFeature(featureName: string): number;
  55006. /**
  55007. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  55008. * Can be used during a session to start a feature
  55009. * @param featureName the name of feature to attach
  55010. */
  55011. attachFeature(featureName: string): void;
  55012. /**
  55013. * Can be used inside a session or when the session ends to detach a specific feature
  55014. * @param featureName the name of the feature to detach
  55015. */
  55016. detachFeature(featureName: string): void;
  55017. /**
  55018. * Used to disable an already-enabled feature
  55019. * The feature will be disposed and will be recreated once enabled.
  55020. * @param featureName the feature to disable
  55021. * @returns true if disable was successful
  55022. */
  55023. disableFeature(featureName: string | {
  55024. Name: string;
  55025. }): boolean;
  55026. /**
  55027. * dispose this features manager
  55028. */
  55029. dispose(): void;
  55030. /**
  55031. * 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.
  55032. * 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.
  55033. *
  55034. * @param featureName the name of the feature to load or the class of the feature
  55035. * @param version optional version to load. if not provided the latest version will be enabled
  55036. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  55037. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  55038. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  55039. * @returns a new constructed feature or throws an error if feature not found.
  55040. */
  55041. enableFeature(featureName: string | {
  55042. Name: string;
  55043. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  55044. /**
  55045. * get the implementation of an enabled feature.
  55046. * @param featureName the name of the feature to load
  55047. * @returns the feature class, if found
  55048. */
  55049. getEnabledFeature(featureName: string): IWebXRFeature;
  55050. /**
  55051. * Get the list of enabled features
  55052. * @returns an array of enabled features
  55053. */
  55054. getEnabledFeatures(): string[];
  55055. /**
  55056. * This function will extend the session creation configuration object with enabled features.
  55057. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  55058. * according to the defined "required" variable, provided during enableFeature call
  55059. * @param xrSessionInit the xr Session init object to extend
  55060. *
  55061. * @returns an extended XRSessionInit object
  55062. */
  55063. _extendXRSessionInitObject(xrSessionInit: XRSessionInit): Promise<XRSessionInit>;
  55064. }
  55065. }
  55066. declare module BABYLON {
  55067. /**
  55068. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  55069. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  55070. */
  55071. export class WebXRExperienceHelper implements IDisposable {
  55072. private scene;
  55073. private _nonVRCamera;
  55074. private _originalSceneAutoClear;
  55075. private _supported;
  55076. /**
  55077. * Camera used to render xr content
  55078. */
  55079. camera: WebXRCamera;
  55080. /** A features manager for this xr session */
  55081. featuresManager: WebXRFeaturesManager;
  55082. /**
  55083. * Observers registered here will be triggered after the camera's initial transformation is set
  55084. * This can be used to set a different ground level or an extra rotation.
  55085. *
  55086. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  55087. * to the position set after this observable is done executing.
  55088. */
  55089. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  55090. /**
  55091. * Fires when the state of the experience helper has changed
  55092. */
  55093. onStateChangedObservable: Observable<WebXRState>;
  55094. /** Session manager used to keep track of xr session */
  55095. sessionManager: WebXRSessionManager;
  55096. /**
  55097. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  55098. */
  55099. state: WebXRState;
  55100. /**
  55101. * Creates a WebXRExperienceHelper
  55102. * @param scene The scene the helper should be created in
  55103. */
  55104. private constructor();
  55105. /**
  55106. * Creates the experience helper
  55107. * @param scene the scene to attach the experience helper to
  55108. * @returns a promise for the experience helper
  55109. */
  55110. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  55111. /**
  55112. * Disposes of the experience helper
  55113. */
  55114. dispose(): void;
  55115. /**
  55116. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  55117. * @param sessionMode options for the XR session
  55118. * @param referenceSpaceType frame of reference of the XR session
  55119. * @param renderTarget the output canvas that will be used to enter XR mode
  55120. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  55121. * @returns promise that resolves after xr mode has entered
  55122. */
  55123. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  55124. /**
  55125. * Exits XR mode and returns the scene to its original state
  55126. * @returns promise that resolves after xr mode has exited
  55127. */
  55128. exitXRAsync(): Promise<void>;
  55129. private _nonXRToXRCamera;
  55130. private _setState;
  55131. }
  55132. }
  55133. declare module BABYLON {
  55134. /**
  55135. * X-Y values for axes in WebXR
  55136. */
  55137. export interface IWebXRMotionControllerAxesValue {
  55138. /**
  55139. * The value of the x axis
  55140. */
  55141. x: number;
  55142. /**
  55143. * The value of the y-axis
  55144. */
  55145. y: number;
  55146. }
  55147. /**
  55148. * changed / previous values for the values of this component
  55149. */
  55150. export interface IWebXRMotionControllerComponentChangesValues<T> {
  55151. /**
  55152. * current (this frame) value
  55153. */
  55154. current: T;
  55155. /**
  55156. * previous (last change) value
  55157. */
  55158. previous: T;
  55159. }
  55160. /**
  55161. * Represents changes in the component between current frame and last values recorded
  55162. */
  55163. export interface IWebXRMotionControllerComponentChanges {
  55164. /**
  55165. * will be populated with previous and current values if axes changed
  55166. */
  55167. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  55168. /**
  55169. * will be populated with previous and current values if pressed changed
  55170. */
  55171. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  55172. /**
  55173. * will be populated with previous and current values if touched changed
  55174. */
  55175. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  55176. /**
  55177. * will be populated with previous and current values if value changed
  55178. */
  55179. value?: IWebXRMotionControllerComponentChangesValues<number>;
  55180. }
  55181. /**
  55182. * This class represents a single component (for example button or thumbstick) of a motion controller
  55183. */
  55184. export class WebXRControllerComponent implements IDisposable {
  55185. /**
  55186. * the id of this component
  55187. */
  55188. id: string;
  55189. /**
  55190. * the type of the component
  55191. */
  55192. type: MotionControllerComponentType;
  55193. private _buttonIndex;
  55194. private _axesIndices;
  55195. private _axes;
  55196. private _changes;
  55197. private _currentValue;
  55198. private _hasChanges;
  55199. private _pressed;
  55200. private _touched;
  55201. /**
  55202. * button component type
  55203. */
  55204. static BUTTON_TYPE: MotionControllerComponentType;
  55205. /**
  55206. * squeeze component type
  55207. */
  55208. static SQUEEZE_TYPE: MotionControllerComponentType;
  55209. /**
  55210. * Thumbstick component type
  55211. */
  55212. static THUMBSTICK_TYPE: MotionControllerComponentType;
  55213. /**
  55214. * Touchpad component type
  55215. */
  55216. static TOUCHPAD_TYPE: MotionControllerComponentType;
  55217. /**
  55218. * trigger component type
  55219. */
  55220. static TRIGGER_TYPE: MotionControllerComponentType;
  55221. /**
  55222. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  55223. * the axes data changes
  55224. */
  55225. onAxisValueChangedObservable: Observable<{
  55226. x: number;
  55227. y: number;
  55228. }>;
  55229. /**
  55230. * Observers registered here will be triggered when the state of a button changes
  55231. * State change is either pressed / touched / value
  55232. */
  55233. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  55234. /**
  55235. * Creates a new component for a motion controller.
  55236. * It is created by the motion controller itself
  55237. *
  55238. * @param id the id of this component
  55239. * @param type the type of the component
  55240. * @param _buttonIndex index in the buttons array of the gamepad
  55241. * @param _axesIndices indices of the values in the axes array of the gamepad
  55242. */
  55243. constructor(
  55244. /**
  55245. * the id of this component
  55246. */
  55247. id: string,
  55248. /**
  55249. * the type of the component
  55250. */
  55251. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  55252. /**
  55253. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  55254. */
  55255. get axes(): IWebXRMotionControllerAxesValue;
  55256. /**
  55257. * Get the changes. Elements will be populated only if they changed with their previous and current value
  55258. */
  55259. get changes(): IWebXRMotionControllerComponentChanges;
  55260. /**
  55261. * Return whether or not the component changed the last frame
  55262. */
  55263. get hasChanges(): boolean;
  55264. /**
  55265. * is the button currently pressed
  55266. */
  55267. get pressed(): boolean;
  55268. /**
  55269. * is the button currently touched
  55270. */
  55271. get touched(): boolean;
  55272. /**
  55273. * Get the current value of this component
  55274. */
  55275. get value(): number;
  55276. /**
  55277. * Dispose this component
  55278. */
  55279. dispose(): void;
  55280. /**
  55281. * Are there axes correlating to this component
  55282. * @return true is axes data is available
  55283. */
  55284. isAxes(): boolean;
  55285. /**
  55286. * Is this component a button (hence - pressable)
  55287. * @returns true if can be pressed
  55288. */
  55289. isButton(): boolean;
  55290. /**
  55291. * update this component using the gamepad object it is in. Called on every frame
  55292. * @param nativeController the native gamepad controller object
  55293. */
  55294. update(nativeController: IMinimalMotionControllerObject): void;
  55295. }
  55296. }
  55297. declare module BABYLON {
  55298. /**
  55299. * Type used for the success callback of ImportMesh
  55300. */
  55301. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  55302. /**
  55303. * Interface used for the result of ImportMeshAsync
  55304. */
  55305. export interface ISceneLoaderAsyncResult {
  55306. /**
  55307. * The array of loaded meshes
  55308. */
  55309. readonly meshes: AbstractMesh[];
  55310. /**
  55311. * The array of loaded particle systems
  55312. */
  55313. readonly particleSystems: IParticleSystem[];
  55314. /**
  55315. * The array of loaded skeletons
  55316. */
  55317. readonly skeletons: Skeleton[];
  55318. /**
  55319. * The array of loaded animation groups
  55320. */
  55321. readonly animationGroups: AnimationGroup[];
  55322. /**
  55323. * The array of loaded transform nodes
  55324. */
  55325. readonly transformNodes: TransformNode[];
  55326. /**
  55327. * The array of loaded geometries
  55328. */
  55329. readonly geometries: Geometry[];
  55330. /**
  55331. * The array of loaded lights
  55332. */
  55333. readonly lights: Light[];
  55334. }
  55335. /**
  55336. * Interface used to represent data loading progression
  55337. */
  55338. export interface ISceneLoaderProgressEvent {
  55339. /**
  55340. * Defines if data length to load can be evaluated
  55341. */
  55342. readonly lengthComputable: boolean;
  55343. /**
  55344. * Defines the loaded data length
  55345. */
  55346. readonly loaded: number;
  55347. /**
  55348. * Defines the data length to load
  55349. */
  55350. readonly total: number;
  55351. }
  55352. /**
  55353. * Interface used by SceneLoader plugins to define supported file extensions
  55354. */
  55355. export interface ISceneLoaderPluginExtensions {
  55356. /**
  55357. * Defines the list of supported extensions
  55358. */
  55359. [extension: string]: {
  55360. isBinary: boolean;
  55361. };
  55362. }
  55363. /**
  55364. * Interface used by SceneLoader plugin factory
  55365. */
  55366. export interface ISceneLoaderPluginFactory {
  55367. /**
  55368. * Defines the name of the factory
  55369. */
  55370. name: string;
  55371. /**
  55372. * Function called to create a new plugin
  55373. * @return the new plugin
  55374. */
  55375. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  55376. /**
  55377. * The callback that returns true if the data can be directly loaded.
  55378. * @param data string containing the file data
  55379. * @returns if the data can be loaded directly
  55380. */
  55381. canDirectLoad?(data: string): boolean;
  55382. }
  55383. /**
  55384. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  55385. */
  55386. export interface ISceneLoaderPluginBase {
  55387. /**
  55388. * The friendly name of this plugin.
  55389. */
  55390. name: string;
  55391. /**
  55392. * The file extensions supported by this plugin.
  55393. */
  55394. extensions: string | ISceneLoaderPluginExtensions;
  55395. /**
  55396. * The callback called when loading from a url.
  55397. * @param scene scene loading this url
  55398. * @param url url to load
  55399. * @param onSuccess callback called when the file successfully loads
  55400. * @param onProgress callback called while file is loading (if the server supports this mode)
  55401. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  55402. * @param onError callback called when the file fails to load
  55403. * @returns a file request object
  55404. */
  55405. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  55406. /**
  55407. * The callback called when loading from a file object.
  55408. * @param scene scene loading this file
  55409. * @param file defines the file to load
  55410. * @param onSuccess defines the callback to call when data is loaded
  55411. * @param onProgress defines the callback to call during loading process
  55412. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  55413. * @param onError defines the callback to call when an error occurs
  55414. * @returns a file request object
  55415. */
  55416. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  55417. /**
  55418. * The callback that returns true if the data can be directly loaded.
  55419. * @param data string containing the file data
  55420. * @returns if the data can be loaded directly
  55421. */
  55422. canDirectLoad?(data: string): boolean;
  55423. /**
  55424. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  55425. * @param scene scene loading this data
  55426. * @param data string containing the data
  55427. * @returns data to pass to the plugin
  55428. */
  55429. directLoad?(scene: Scene, data: string): any;
  55430. /**
  55431. * The callback that allows custom handling of the root url based on the response url.
  55432. * @param rootUrl the original root url
  55433. * @param responseURL the response url if available
  55434. * @returns the new root url
  55435. */
  55436. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  55437. }
  55438. /**
  55439. * Interface used to define a SceneLoader plugin
  55440. */
  55441. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  55442. /**
  55443. * Import meshes into a scene.
  55444. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  55445. * @param scene The scene to import into
  55446. * @param data The data to import
  55447. * @param rootUrl The root url for scene and resources
  55448. * @param meshes The meshes array to import into
  55449. * @param particleSystems The particle systems array to import into
  55450. * @param skeletons The skeletons array to import into
  55451. * @param onError The callback when import fails
  55452. * @returns True if successful or false otherwise
  55453. */
  55454. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  55455. /**
  55456. * Load into a scene.
  55457. * @param scene The scene to load into
  55458. * @param data The data to import
  55459. * @param rootUrl The root url for scene and resources
  55460. * @param onError The callback when import fails
  55461. * @returns True if successful or false otherwise
  55462. */
  55463. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  55464. /**
  55465. * Load into an asset container.
  55466. * @param scene The scene to load into
  55467. * @param data The data to import
  55468. * @param rootUrl The root url for scene and resources
  55469. * @param onError The callback when import fails
  55470. * @returns The loaded asset container
  55471. */
  55472. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  55473. }
  55474. /**
  55475. * Interface used to define an async SceneLoader plugin
  55476. */
  55477. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  55478. /**
  55479. * Import meshes into a scene.
  55480. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  55481. * @param scene The scene to import into
  55482. * @param data The data to import
  55483. * @param rootUrl The root url for scene and resources
  55484. * @param onProgress The callback when the load progresses
  55485. * @param fileName Defines the name of the file to load
  55486. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  55487. */
  55488. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  55489. /**
  55490. * Load into a scene.
  55491. * @param scene The scene to load into
  55492. * @param data The data to import
  55493. * @param rootUrl The root url for scene and resources
  55494. * @param onProgress The callback when the load progresses
  55495. * @param fileName Defines the name of the file to load
  55496. * @returns Nothing
  55497. */
  55498. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  55499. /**
  55500. * Load into an asset container.
  55501. * @param scene The scene to load into
  55502. * @param data The data to import
  55503. * @param rootUrl The root url for scene and resources
  55504. * @param onProgress The callback when the load progresses
  55505. * @param fileName Defines the name of the file to load
  55506. * @returns The loaded asset container
  55507. */
  55508. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  55509. }
  55510. /**
  55511. * Mode that determines how to handle old animation groups before loading new ones.
  55512. */
  55513. export enum SceneLoaderAnimationGroupLoadingMode {
  55514. /**
  55515. * Reset all old animations to initial state then dispose them.
  55516. */
  55517. Clean = 0,
  55518. /**
  55519. * Stop all old animations.
  55520. */
  55521. Stop = 1,
  55522. /**
  55523. * Restart old animations from first frame.
  55524. */
  55525. Sync = 2,
  55526. /**
  55527. * Old animations remains untouched.
  55528. */
  55529. NoSync = 3
  55530. }
  55531. /**
  55532. * Defines a plugin registered by the SceneLoader
  55533. */
  55534. interface IRegisteredPlugin {
  55535. /**
  55536. * Defines the plugin to use
  55537. */
  55538. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  55539. /**
  55540. * Defines if the plugin supports binary data
  55541. */
  55542. isBinary: boolean;
  55543. }
  55544. /**
  55545. * Class used to load scene from various file formats using registered plugins
  55546. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  55547. */
  55548. export class SceneLoader {
  55549. /**
  55550. * No logging while loading
  55551. */
  55552. static readonly NO_LOGGING: number;
  55553. /**
  55554. * Minimal logging while loading
  55555. */
  55556. static readonly MINIMAL_LOGGING: number;
  55557. /**
  55558. * Summary logging while loading
  55559. */
  55560. static readonly SUMMARY_LOGGING: number;
  55561. /**
  55562. * Detailed logging while loading
  55563. */
  55564. static readonly DETAILED_LOGGING: number;
  55565. /**
  55566. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  55567. */
  55568. static get ForceFullSceneLoadingForIncremental(): boolean;
  55569. static set ForceFullSceneLoadingForIncremental(value: boolean);
  55570. /**
  55571. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  55572. */
  55573. static get ShowLoadingScreen(): boolean;
  55574. static set ShowLoadingScreen(value: boolean);
  55575. /**
  55576. * Defines the current logging level (while loading the scene)
  55577. * @ignorenaming
  55578. */
  55579. static get loggingLevel(): number;
  55580. static set loggingLevel(value: number);
  55581. /**
  55582. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  55583. */
  55584. static get CleanBoneMatrixWeights(): boolean;
  55585. static set CleanBoneMatrixWeights(value: boolean);
  55586. /**
  55587. * Event raised when a plugin is used to load a scene
  55588. */
  55589. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  55590. private static _registeredPlugins;
  55591. private static _showingLoadingScreen;
  55592. /**
  55593. * Gets the default plugin (used to load Babylon files)
  55594. * @returns the .babylon plugin
  55595. */
  55596. static GetDefaultPlugin(): IRegisteredPlugin;
  55597. private static _GetPluginForExtension;
  55598. private static _GetPluginForDirectLoad;
  55599. private static _GetPluginForFilename;
  55600. private static _GetDirectLoad;
  55601. private static _LoadData;
  55602. private static _GetFileInfo;
  55603. /**
  55604. * Gets a plugin that can load the given extension
  55605. * @param extension defines the extension to load
  55606. * @returns a plugin or null if none works
  55607. */
  55608. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  55609. /**
  55610. * Gets a boolean indicating that the given extension can be loaded
  55611. * @param extension defines the extension to load
  55612. * @returns true if the extension is supported
  55613. */
  55614. static IsPluginForExtensionAvailable(extension: string): boolean;
  55615. /**
  55616. * Adds a new plugin to the list of registered plugins
  55617. * @param plugin defines the plugin to add
  55618. */
  55619. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  55620. /**
  55621. * Import meshes into a scene
  55622. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  55623. * @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)
  55624. * @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)
  55625. * @param scene the instance of BABYLON.Scene to append to
  55626. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  55627. * @param onProgress a callback with a progress event for each file being loaded
  55628. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  55629. * @param pluginExtension the extension used to determine the plugin
  55630. * @returns The loaded plugin
  55631. */
  55632. 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>;
  55633. /**
  55634. * Import meshes into a scene
  55635. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  55636. * @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)
  55637. * @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)
  55638. * @param scene the instance of BABYLON.Scene to append to
  55639. * @param onProgress a callback with a progress event for each file being loaded
  55640. * @param pluginExtension the extension used to determine the plugin
  55641. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  55642. */
  55643. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  55644. /**
  55645. * Load a scene
  55646. * @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)
  55647. * @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)
  55648. * @param engine is the instance of BABYLON.Engine to use to create the scene
  55649. * @param onSuccess a callback with the scene when import succeeds
  55650. * @param onProgress a callback with a progress event for each file being loaded
  55651. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  55652. * @param pluginExtension the extension used to determine the plugin
  55653. * @returns The loaded plugin
  55654. */
  55655. 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>;
  55656. /**
  55657. * Load a scene
  55658. * @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)
  55659. * @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)
  55660. * @param engine is the instance of BABYLON.Engine to use to create the scene
  55661. * @param onProgress a callback with a progress event for each file being loaded
  55662. * @param pluginExtension the extension used to determine the plugin
  55663. * @returns The loaded scene
  55664. */
  55665. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  55666. /**
  55667. * Append a scene
  55668. * @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)
  55669. * @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)
  55670. * @param scene is the instance of BABYLON.Scene to append to
  55671. * @param onSuccess a callback with the scene when import succeeds
  55672. * @param onProgress a callback with a progress event for each file being loaded
  55673. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  55674. * @param pluginExtension the extension used to determine the plugin
  55675. * @returns The loaded plugin
  55676. */
  55677. 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>;
  55678. /**
  55679. * Append a scene
  55680. * @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)
  55681. * @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)
  55682. * @param scene is the instance of BABYLON.Scene to append to
  55683. * @param onProgress a callback with a progress event for each file being loaded
  55684. * @param pluginExtension the extension used to determine the plugin
  55685. * @returns The given scene
  55686. */
  55687. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  55688. /**
  55689. * Load a scene into an asset container
  55690. * @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)
  55691. * @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)
  55692. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  55693. * @param onSuccess a callback with the scene when import succeeds
  55694. * @param onProgress a callback with a progress event for each file being loaded
  55695. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  55696. * @param pluginExtension the extension used to determine the plugin
  55697. * @returns The loaded plugin
  55698. */
  55699. 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>;
  55700. /**
  55701. * Load a scene into an asset container
  55702. * @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)
  55703. * @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)
  55704. * @param scene is the instance of Scene to append to
  55705. * @param onProgress a callback with a progress event for each file being loaded
  55706. * @param pluginExtension the extension used to determine the plugin
  55707. * @returns The loaded asset container
  55708. */
  55709. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  55710. /**
  55711. * Import animations from a file into a scene
  55712. * @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)
  55713. * @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)
  55714. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  55715. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  55716. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  55717. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  55718. * @param onSuccess a callback with the scene when import succeeds
  55719. * @param onProgress a callback with a progress event for each file being loaded
  55720. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  55721. * @param pluginExtension the extension used to determine the plugin
  55722. */
  55723. 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;
  55724. /**
  55725. * Import animations from a file into a scene
  55726. * @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)
  55727. * @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)
  55728. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  55729. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  55730. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  55731. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  55732. * @param onSuccess a callback with the scene when import succeeds
  55733. * @param onProgress a callback with a progress event for each file being loaded
  55734. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  55735. * @param pluginExtension the extension used to determine the plugin
  55736. * @returns the updated scene with imported animations
  55737. */
  55738. 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>;
  55739. }
  55740. }
  55741. declare module BABYLON {
  55742. /**
  55743. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  55744. */
  55745. export type MotionControllerHandedness = "none" | "left" | "right";
  55746. /**
  55747. * The type of components available in motion controllers.
  55748. * This is not the name of the component.
  55749. */
  55750. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  55751. /**
  55752. * The state of a controller component
  55753. */
  55754. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  55755. /**
  55756. * The schema of motion controller layout.
  55757. * No object will be initialized using this interface
  55758. * This is used just to define the profile.
  55759. */
  55760. export interface IMotionControllerLayout {
  55761. /**
  55762. * Path to load the assets. Usually relative to the base path
  55763. */
  55764. assetPath: string;
  55765. /**
  55766. * Available components (unsorted)
  55767. */
  55768. components: {
  55769. /**
  55770. * A map of component Ids
  55771. */
  55772. [componentId: string]: {
  55773. /**
  55774. * The type of input the component outputs
  55775. */
  55776. type: MotionControllerComponentType;
  55777. /**
  55778. * The indices of this component in the gamepad object
  55779. */
  55780. gamepadIndices: {
  55781. /**
  55782. * Index of button
  55783. */
  55784. button?: number;
  55785. /**
  55786. * If available, index of x-axis
  55787. */
  55788. xAxis?: number;
  55789. /**
  55790. * If available, index of y-axis
  55791. */
  55792. yAxis?: number;
  55793. };
  55794. /**
  55795. * The mesh's root node name
  55796. */
  55797. rootNodeName: string;
  55798. /**
  55799. * Animation definitions for this model
  55800. */
  55801. visualResponses: {
  55802. [stateKey: string]: {
  55803. /**
  55804. * What property will be animated
  55805. */
  55806. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  55807. /**
  55808. * What states influence this visual response
  55809. */
  55810. states: MotionControllerComponentStateType[];
  55811. /**
  55812. * Type of animation - movement or visibility
  55813. */
  55814. valueNodeProperty: "transform" | "visibility";
  55815. /**
  55816. * Base node name to move. Its position will be calculated according to the min and max nodes
  55817. */
  55818. valueNodeName?: string;
  55819. /**
  55820. * Minimum movement node
  55821. */
  55822. minNodeName?: string;
  55823. /**
  55824. * Max movement node
  55825. */
  55826. maxNodeName?: string;
  55827. };
  55828. };
  55829. /**
  55830. * If touch enabled, what is the name of node to display user feedback
  55831. */
  55832. touchPointNodeName?: string;
  55833. };
  55834. };
  55835. /**
  55836. * Is it xr standard mapping or not
  55837. */
  55838. gamepadMapping: "" | "xr-standard";
  55839. /**
  55840. * Base root node of this entire model
  55841. */
  55842. rootNodeName: string;
  55843. /**
  55844. * Defines the main button component id
  55845. */
  55846. selectComponentId: string;
  55847. }
  55848. /**
  55849. * A definition for the layout map in the input profile
  55850. */
  55851. export interface IMotionControllerLayoutMap {
  55852. /**
  55853. * Layouts with handedness type as a key
  55854. */
  55855. [handedness: string]: IMotionControllerLayout;
  55856. }
  55857. /**
  55858. * The XR Input profile schema
  55859. * Profiles can be found here:
  55860. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  55861. */
  55862. export interface IMotionControllerProfile {
  55863. /**
  55864. * fallback profiles for this profileId
  55865. */
  55866. fallbackProfileIds: string[];
  55867. /**
  55868. * The layout map, with handedness as key
  55869. */
  55870. layouts: IMotionControllerLayoutMap;
  55871. /**
  55872. * The id of this profile
  55873. * correlates to the profile(s) in the xrInput.profiles array
  55874. */
  55875. profileId: string;
  55876. }
  55877. /**
  55878. * A helper-interface for the 3 meshes needed for controller button animation
  55879. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  55880. */
  55881. export interface IMotionControllerButtonMeshMap {
  55882. /**
  55883. * the mesh that defines the pressed value mesh position.
  55884. * This is used to find the max-position of this button
  55885. */
  55886. pressedMesh: AbstractMesh;
  55887. /**
  55888. * the mesh that defines the unpressed value mesh position.
  55889. * This is used to find the min (or initial) position of this button
  55890. */
  55891. unpressedMesh: AbstractMesh;
  55892. /**
  55893. * The mesh that will be changed when value changes
  55894. */
  55895. valueMesh: AbstractMesh;
  55896. }
  55897. /**
  55898. * A helper-interface for the 3 meshes needed for controller axis animation.
  55899. * This will be expanded when touchpad animations are fully supported
  55900. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  55901. */
  55902. export interface IMotionControllerMeshMap {
  55903. /**
  55904. * the mesh that defines the maximum value mesh position.
  55905. */
  55906. maxMesh?: AbstractMesh;
  55907. /**
  55908. * the mesh that defines the minimum value mesh position.
  55909. */
  55910. minMesh?: AbstractMesh;
  55911. /**
  55912. * The mesh that will be changed when axis value changes
  55913. */
  55914. valueMesh?: AbstractMesh;
  55915. }
  55916. /**
  55917. * The elements needed for change-detection of the gamepad objects in motion controllers
  55918. */
  55919. export interface IMinimalMotionControllerObject {
  55920. /**
  55921. * Available axes of this controller
  55922. */
  55923. axes: number[];
  55924. /**
  55925. * An array of available buttons
  55926. */
  55927. buttons: Array<{
  55928. /**
  55929. * Value of the button/trigger
  55930. */
  55931. value: number;
  55932. /**
  55933. * If the button/trigger is currently touched
  55934. */
  55935. touched: boolean;
  55936. /**
  55937. * If the button/trigger is currently pressed
  55938. */
  55939. pressed: boolean;
  55940. }>;
  55941. /**
  55942. * EXPERIMENTAL haptic support.
  55943. */
  55944. hapticActuators?: Array<{
  55945. pulse: (value: number, duration: number) => Promise<boolean>;
  55946. }>;
  55947. }
  55948. /**
  55949. * An Abstract Motion controller
  55950. * This class receives an xrInput and a profile layout and uses those to initialize the components
  55951. * Each component has an observable to check for changes in value and state
  55952. */
  55953. export abstract class WebXRAbstractMotionController implements IDisposable {
  55954. protected scene: Scene;
  55955. protected layout: IMotionControllerLayout;
  55956. /**
  55957. * The gamepad object correlating to this controller
  55958. */
  55959. gamepadObject: IMinimalMotionControllerObject;
  55960. /**
  55961. * handedness (left/right/none) of this controller
  55962. */
  55963. handedness: MotionControllerHandedness;
  55964. private _initComponent;
  55965. private _modelReady;
  55966. /**
  55967. * A map of components (WebXRControllerComponent) in this motion controller
  55968. * Components have a ComponentType and can also have both button and axis definitions
  55969. */
  55970. readonly components: {
  55971. [id: string]: WebXRControllerComponent;
  55972. };
  55973. /**
  55974. * Disable the model's animation. Can be set at any time.
  55975. */
  55976. disableAnimation: boolean;
  55977. /**
  55978. * Observers registered here will be triggered when the model of this controller is done loading
  55979. */
  55980. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  55981. /**
  55982. * The profile id of this motion controller
  55983. */
  55984. abstract profileId: string;
  55985. /**
  55986. * The root mesh of the model. It is null if the model was not yet initialized
  55987. */
  55988. rootMesh: Nullable<AbstractMesh>;
  55989. /**
  55990. * constructs a new abstract motion controller
  55991. * @param scene the scene to which the model of the controller will be added
  55992. * @param layout The profile layout to load
  55993. * @param gamepadObject The gamepad object correlating to this controller
  55994. * @param handedness handedness (left/right/none) of this controller
  55995. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  55996. */
  55997. constructor(scene: Scene, layout: IMotionControllerLayout,
  55998. /**
  55999. * The gamepad object correlating to this controller
  56000. */
  56001. gamepadObject: IMinimalMotionControllerObject,
  56002. /**
  56003. * handedness (left/right/none) of this controller
  56004. */
  56005. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  56006. /**
  56007. * Dispose this controller, the model mesh and all its components
  56008. */
  56009. dispose(): void;
  56010. /**
  56011. * Returns all components of specific type
  56012. * @param type the type to search for
  56013. * @return an array of components with this type
  56014. */
  56015. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  56016. /**
  56017. * get a component based an its component id as defined in layout.components
  56018. * @param id the id of the component
  56019. * @returns the component correlates to the id or undefined if not found
  56020. */
  56021. getComponent(id: string): WebXRControllerComponent;
  56022. /**
  56023. * Get the list of components available in this motion controller
  56024. * @returns an array of strings correlating to available components
  56025. */
  56026. getComponentIds(): string[];
  56027. /**
  56028. * Get the first component of specific type
  56029. * @param type type of component to find
  56030. * @return a controller component or null if not found
  56031. */
  56032. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  56033. /**
  56034. * Get the main (Select) component of this controller as defined in the layout
  56035. * @returns the main component of this controller
  56036. */
  56037. getMainComponent(): WebXRControllerComponent;
  56038. /**
  56039. * Loads the model correlating to this controller
  56040. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  56041. * @returns A promise fulfilled with the result of the model loading
  56042. */
  56043. loadModel(): Promise<boolean>;
  56044. /**
  56045. * Update this model using the current XRFrame
  56046. * @param xrFrame the current xr frame to use and update the model
  56047. */
  56048. updateFromXRFrame(xrFrame: XRFrame): void;
  56049. /**
  56050. * Backwards compatibility due to a deeply-integrated typo
  56051. */
  56052. get handness(): XREye;
  56053. /**
  56054. * Pulse (vibrate) this controller
  56055. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  56056. * Consecutive calls to this function will cancel the last pulse call
  56057. *
  56058. * @param value the strength of the pulse in 0.0...1.0 range
  56059. * @param duration Duration of the pulse in milliseconds
  56060. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  56061. * @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
  56062. */
  56063. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  56064. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  56065. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  56066. /**
  56067. * Moves the axis on the controller mesh based on its current state
  56068. * @param axis the index of the axis
  56069. * @param axisValue the value of the axis which determines the meshes new position
  56070. * @hidden
  56071. */
  56072. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  56073. /**
  56074. * Update the model itself with the current frame data
  56075. * @param xrFrame the frame to use for updating the model mesh
  56076. */
  56077. protected updateModel(xrFrame: XRFrame): void;
  56078. /**
  56079. * Get the filename and path for this controller's model
  56080. * @returns a map of filename and path
  56081. */
  56082. protected abstract _getFilenameAndPath(): {
  56083. filename: string;
  56084. path: string;
  56085. };
  56086. /**
  56087. * This function is called before the mesh is loaded. It checks for loading constraints.
  56088. * For example, this function can check if the GLB loader is available
  56089. * If this function returns false, the generic controller will be loaded instead
  56090. * @returns Is the client ready to load the mesh
  56091. */
  56092. protected abstract _getModelLoadingConstraints(): boolean;
  56093. /**
  56094. * This function will be called after the model was successfully loaded and can be used
  56095. * for mesh transformations before it is available for the user
  56096. * @param meshes the loaded meshes
  56097. */
  56098. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  56099. /**
  56100. * Set the root mesh for this controller. Important for the WebXR controller class
  56101. * @param meshes the loaded meshes
  56102. */
  56103. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  56104. /**
  56105. * A function executed each frame that updates the mesh (if needed)
  56106. * @param xrFrame the current xrFrame
  56107. */
  56108. protected abstract _updateModel(xrFrame: XRFrame): void;
  56109. private _getGenericFilenameAndPath;
  56110. private _getGenericParentMesh;
  56111. }
  56112. }
  56113. declare module BABYLON {
  56114. /**
  56115. * A generic trigger-only motion controller for WebXR
  56116. */
  56117. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  56118. /**
  56119. * Static version of the profile id of this controller
  56120. */
  56121. static ProfileId: string;
  56122. profileId: string;
  56123. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  56124. protected _getFilenameAndPath(): {
  56125. filename: string;
  56126. path: string;
  56127. };
  56128. protected _getModelLoadingConstraints(): boolean;
  56129. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  56130. protected _setRootMesh(meshes: AbstractMesh[]): void;
  56131. protected _updateModel(): void;
  56132. }
  56133. }
  56134. declare module BABYLON {
  56135. /**
  56136. * Class containing static functions to help procedurally build meshes
  56137. */
  56138. export class SphereBuilder {
  56139. /**
  56140. * Creates a sphere mesh
  56141. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  56142. * * 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`)
  56143. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  56144. * * 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
  56145. * * 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)
  56146. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56147. * * 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
  56148. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56149. * @param name defines the name of the mesh
  56150. * @param options defines the options used to create the mesh
  56151. * @param scene defines the hosting scene
  56152. * @returns the sphere mesh
  56153. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  56154. */
  56155. static CreateSphere(name: string, options: {
  56156. segments?: number;
  56157. diameter?: number;
  56158. diameterX?: number;
  56159. diameterY?: number;
  56160. diameterZ?: number;
  56161. arc?: number;
  56162. slice?: number;
  56163. sideOrientation?: number;
  56164. frontUVs?: Vector4;
  56165. backUVs?: Vector4;
  56166. updatable?: boolean;
  56167. }, scene?: Nullable<Scene>): Mesh;
  56168. }
  56169. }
  56170. declare module BABYLON {
  56171. /**
  56172. * A profiled motion controller has its profile loaded from an online repository.
  56173. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  56174. */
  56175. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  56176. private _repositoryUrl;
  56177. private _buttonMeshMapping;
  56178. private _touchDots;
  56179. /**
  56180. * The profile ID of this controller. Will be populated when the controller initializes.
  56181. */
  56182. profileId: string;
  56183. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  56184. dispose(): void;
  56185. protected _getFilenameAndPath(): {
  56186. filename: string;
  56187. path: string;
  56188. };
  56189. protected _getModelLoadingConstraints(): boolean;
  56190. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  56191. protected _setRootMesh(meshes: AbstractMesh[]): void;
  56192. protected _updateModel(_xrFrame: XRFrame): void;
  56193. }
  56194. }
  56195. declare module BABYLON {
  56196. /**
  56197. * A construction function type to create a new controller based on an xrInput object
  56198. */
  56199. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  56200. /**
  56201. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  56202. *
  56203. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  56204. * it should be replaced with auto-loaded controllers.
  56205. *
  56206. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  56207. */
  56208. export class WebXRMotionControllerManager {
  56209. private static _AvailableControllers;
  56210. private static _Fallbacks;
  56211. private static _ProfileLoadingPromises;
  56212. private static _ProfilesList;
  56213. /**
  56214. * The base URL of the online controller repository. Can be changed at any time.
  56215. */
  56216. static BaseRepositoryUrl: string;
  56217. /**
  56218. * Which repository gets priority - local or online
  56219. */
  56220. static PrioritizeOnlineRepository: boolean;
  56221. /**
  56222. * Use the online repository, or use only locally-defined controllers
  56223. */
  56224. static UseOnlineRepository: boolean;
  56225. /**
  56226. * Clear the cache used for profile loading and reload when requested again
  56227. */
  56228. static ClearProfilesCache(): void;
  56229. /**
  56230. * Register the default fallbacks.
  56231. * This function is called automatically when this file is imported.
  56232. */
  56233. static DefaultFallbacks(): void;
  56234. /**
  56235. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  56236. * @param profileId the profile to which a fallback needs to be found
  56237. * @return an array with corresponding fallback profiles
  56238. */
  56239. static FindFallbackWithProfileId(profileId: string): string[];
  56240. /**
  56241. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  56242. * The order of search:
  56243. *
  56244. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  56245. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  56246. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  56247. * 4) return the generic trigger controller if none were found
  56248. *
  56249. * @param xrInput the xrInput to which a new controller is initialized
  56250. * @param scene the scene to which the model will be added
  56251. * @param forceProfile force a certain profile for this controller
  56252. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  56253. */
  56254. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  56255. /**
  56256. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  56257. *
  56258. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  56259. *
  56260. * @param type the profile type to register
  56261. * @param constructFunction the function to be called when loading this profile
  56262. */
  56263. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  56264. /**
  56265. * Register a fallback to a specific profile.
  56266. * @param profileId the profileId that will receive the fallbacks
  56267. * @param fallbacks A list of fallback profiles
  56268. */
  56269. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  56270. /**
  56271. * Will update the list of profiles available in the repository
  56272. * @return a promise that resolves to a map of profiles available online
  56273. */
  56274. static UpdateProfilesList(): Promise<{
  56275. [profile: string]: string;
  56276. }>;
  56277. private static _LoadProfileFromRepository;
  56278. private static _LoadProfilesFromAvailableControllers;
  56279. }
  56280. }
  56281. declare module BABYLON {
  56282. /**
  56283. * Configuration options for the WebXR controller creation
  56284. */
  56285. export interface IWebXRControllerOptions {
  56286. /**
  56287. * Should the controller mesh be animated when a user interacts with it
  56288. * The pressed buttons / thumbstick and touchpad animations will be disabled
  56289. */
  56290. disableMotionControllerAnimation?: boolean;
  56291. /**
  56292. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  56293. */
  56294. doNotLoadControllerMesh?: boolean;
  56295. /**
  56296. * Force a specific controller type for this controller.
  56297. * This can be used when creating your own profile or when testing different controllers
  56298. */
  56299. forceControllerProfile?: string;
  56300. /**
  56301. * Defines a rendering group ID for meshes that will be loaded.
  56302. * This is for the default controllers only.
  56303. */
  56304. renderingGroupId?: number;
  56305. }
  56306. /**
  56307. * Represents an XR controller
  56308. */
  56309. export class WebXRInputSource {
  56310. private _scene;
  56311. /** The underlying input source for the controller */
  56312. inputSource: XRInputSource;
  56313. private _options;
  56314. private _tmpVector;
  56315. private _uniqueId;
  56316. private _disposed;
  56317. /**
  56318. * 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
  56319. */
  56320. grip?: AbstractMesh;
  56321. /**
  56322. * If available, this is the gamepad object related to this controller.
  56323. * Using this object it is possible to get click events and trackpad changes of the
  56324. * webxr controller that is currently being used.
  56325. */
  56326. motionController?: WebXRAbstractMotionController;
  56327. /**
  56328. * Event that fires when the controller is removed/disposed.
  56329. * The object provided as event data is this controller, after associated assets were disposed.
  56330. * uniqueId is still available.
  56331. */
  56332. onDisposeObservable: Observable<WebXRInputSource>;
  56333. /**
  56334. * Will be triggered when the mesh associated with the motion controller is done loading.
  56335. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  56336. * A shortened version of controller -> motion controller -> on mesh loaded.
  56337. */
  56338. onMeshLoadedObservable: Observable<AbstractMesh>;
  56339. /**
  56340. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  56341. */
  56342. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  56343. /**
  56344. * Pointer which can be used to select objects or attach a visible laser to
  56345. */
  56346. pointer: AbstractMesh;
  56347. /**
  56348. * Creates the input source object
  56349. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  56350. * @param _scene the scene which the controller should be associated to
  56351. * @param inputSource the underlying input source for the controller
  56352. * @param _options options for this controller creation
  56353. */
  56354. constructor(_scene: Scene,
  56355. /** The underlying input source for the controller */
  56356. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  56357. /**
  56358. * Get this controllers unique id
  56359. */
  56360. get uniqueId(): string;
  56361. /**
  56362. * Disposes of the object
  56363. */
  56364. dispose(): void;
  56365. /**
  56366. * Gets a world space ray coming from the pointer or grip
  56367. * @param result the resulting ray
  56368. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  56369. */
  56370. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  56371. /**
  56372. * Updates the controller pose based on the given XRFrame
  56373. * @param xrFrame xr frame to update the pose with
  56374. * @param referenceSpace reference space to use
  56375. */
  56376. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  56377. }
  56378. }
  56379. declare module BABYLON {
  56380. /**
  56381. * The schema for initialization options of the XR Input class
  56382. */
  56383. export interface IWebXRInputOptions {
  56384. /**
  56385. * If set to true no model will be automatically loaded
  56386. */
  56387. doNotLoadControllerMeshes?: boolean;
  56388. /**
  56389. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  56390. * If not found, the xr input profile data will be used.
  56391. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  56392. */
  56393. forceInputProfile?: string;
  56394. /**
  56395. * Do not send a request to the controller repository to load the profile.
  56396. *
  56397. * Instead, use the controllers available in babylon itself.
  56398. */
  56399. disableOnlineControllerRepository?: boolean;
  56400. /**
  56401. * A custom URL for the controllers repository
  56402. */
  56403. customControllersRepositoryURL?: string;
  56404. /**
  56405. * Should the controller model's components not move according to the user input
  56406. */
  56407. disableControllerAnimation?: boolean;
  56408. /**
  56409. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  56410. */
  56411. controllerOptions?: IWebXRControllerOptions;
  56412. }
  56413. /**
  56414. * XR input used to track XR inputs such as controllers/rays
  56415. */
  56416. export class WebXRInput implements IDisposable {
  56417. /**
  56418. * the xr session manager for this session
  56419. */
  56420. xrSessionManager: WebXRSessionManager;
  56421. /**
  56422. * the WebXR camera for this session. Mainly used for teleportation
  56423. */
  56424. xrCamera: WebXRCamera;
  56425. private readonly options;
  56426. /**
  56427. * XR controllers being tracked
  56428. */
  56429. controllers: Array<WebXRInputSource>;
  56430. private _frameObserver;
  56431. private _sessionEndedObserver;
  56432. private _sessionInitObserver;
  56433. /**
  56434. * Event when a controller has been connected/added
  56435. */
  56436. onControllerAddedObservable: Observable<WebXRInputSource>;
  56437. /**
  56438. * Event when a controller has been removed/disconnected
  56439. */
  56440. onControllerRemovedObservable: Observable<WebXRInputSource>;
  56441. /**
  56442. * Initializes the WebXRInput
  56443. * @param xrSessionManager the xr session manager for this session
  56444. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  56445. * @param options = initialization options for this xr input
  56446. */
  56447. constructor(
  56448. /**
  56449. * the xr session manager for this session
  56450. */
  56451. xrSessionManager: WebXRSessionManager,
  56452. /**
  56453. * the WebXR camera for this session. Mainly used for teleportation
  56454. */
  56455. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  56456. private _onInputSourcesChange;
  56457. private _addAndRemoveControllers;
  56458. /**
  56459. * Disposes of the object
  56460. */
  56461. dispose(): void;
  56462. }
  56463. }
  56464. declare module BABYLON {
  56465. /**
  56466. * This is the base class for all WebXR features.
  56467. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  56468. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  56469. */
  56470. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  56471. protected _xrSessionManager: WebXRSessionManager;
  56472. private _attached;
  56473. private _removeOnDetach;
  56474. /**
  56475. * Is this feature disposed?
  56476. */
  56477. isDisposed: boolean;
  56478. /**
  56479. * Should auto-attach be disabled?
  56480. */
  56481. disableAutoAttach: boolean;
  56482. /**
  56483. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  56484. */
  56485. xrNativeFeatureName: string;
  56486. /**
  56487. * Construct a new (abstract) WebXR feature
  56488. * @param _xrSessionManager the xr session manager for this feature
  56489. */
  56490. constructor(_xrSessionManager: WebXRSessionManager);
  56491. /**
  56492. * Is this feature attached
  56493. */
  56494. get attached(): boolean;
  56495. /**
  56496. * attach this feature
  56497. *
  56498. * @param force should attachment be forced (even when already attached)
  56499. * @returns true if successful, false is failed or already attached
  56500. */
  56501. attach(force?: boolean): boolean;
  56502. /**
  56503. * detach this feature.
  56504. *
  56505. * @returns true if successful, false if failed or already detached
  56506. */
  56507. detach(): boolean;
  56508. /**
  56509. * Dispose this feature and all of the resources attached
  56510. */
  56511. dispose(): void;
  56512. /**
  56513. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  56514. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  56515. *
  56516. * @returns whether or not the feature is compatible in this environment
  56517. */
  56518. isCompatible(): boolean;
  56519. /**
  56520. * This is used to register callbacks that will automatically be removed when detach is called.
  56521. * @param observable the observable to which the observer will be attached
  56522. * @param callback the callback to register
  56523. */
  56524. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  56525. /**
  56526. * Code in this function will be executed on each xrFrame received from the browser.
  56527. * This function will not execute after the feature is detached.
  56528. * @param _xrFrame the current frame
  56529. */
  56530. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  56531. }
  56532. }
  56533. declare module BABYLON {
  56534. /**
  56535. * Renders a layer on top of an existing scene
  56536. */
  56537. export class UtilityLayerRenderer implements IDisposable {
  56538. /** the original scene that will be rendered on top of */
  56539. originalScene: Scene;
  56540. private _pointerCaptures;
  56541. private _lastPointerEvents;
  56542. private static _DefaultUtilityLayer;
  56543. private static _DefaultKeepDepthUtilityLayer;
  56544. private _sharedGizmoLight;
  56545. private _renderCamera;
  56546. /**
  56547. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  56548. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  56549. * @returns the camera that is used when rendering the utility layer
  56550. */
  56551. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  56552. /**
  56553. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  56554. * @param cam the camera that should be used when rendering the utility layer
  56555. */
  56556. setRenderCamera(cam: Nullable<Camera>): void;
  56557. /**
  56558. * @hidden
  56559. * Light which used by gizmos to get light shading
  56560. */
  56561. _getSharedGizmoLight(): HemisphericLight;
  56562. /**
  56563. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  56564. */
  56565. pickUtilitySceneFirst: boolean;
  56566. /**
  56567. * 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)
  56568. */
  56569. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  56570. /**
  56571. * 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)
  56572. */
  56573. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  56574. /**
  56575. * The scene that is rendered on top of the original scene
  56576. */
  56577. utilityLayerScene: Scene;
  56578. /**
  56579. * If the utility layer should automatically be rendered on top of existing scene
  56580. */
  56581. shouldRender: boolean;
  56582. /**
  56583. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  56584. */
  56585. onlyCheckPointerDownEvents: boolean;
  56586. /**
  56587. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  56588. */
  56589. processAllEvents: boolean;
  56590. /**
  56591. * Observable raised when the pointer move from the utility layer scene to the main scene
  56592. */
  56593. onPointerOutObservable: Observable<number>;
  56594. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  56595. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  56596. private _afterRenderObserver;
  56597. private _sceneDisposeObserver;
  56598. private _originalPointerObserver;
  56599. /**
  56600. * Instantiates a UtilityLayerRenderer
  56601. * @param originalScene the original scene that will be rendered on top of
  56602. * @param handleEvents boolean indicating if the utility layer should handle events
  56603. */
  56604. constructor(
  56605. /** the original scene that will be rendered on top of */
  56606. originalScene: Scene, handleEvents?: boolean);
  56607. private _notifyObservers;
  56608. /**
  56609. * Renders the utility layers scene on top of the original scene
  56610. */
  56611. render(): void;
  56612. /**
  56613. * Disposes of the renderer
  56614. */
  56615. dispose(): void;
  56616. private _updateCamera;
  56617. }
  56618. }
  56619. declare module BABYLON {
  56620. /**
  56621. * Options interface for the pointer selection module
  56622. */
  56623. export interface IWebXRControllerPointerSelectionOptions {
  56624. /**
  56625. * if provided, this scene will be used to render meshes.
  56626. */
  56627. customUtilityLayerScene?: Scene;
  56628. /**
  56629. * 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)
  56630. * If not disabled, the last picked point will be used to execute a pointer up event
  56631. * If disabled, pointer up event will be triggered right after the pointer down event.
  56632. * Used in screen and gaze target ray mode only
  56633. */
  56634. disablePointerUpOnTouchOut: boolean;
  56635. /**
  56636. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  56637. */
  56638. forceGazeMode: boolean;
  56639. /**
  56640. * 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
  56641. * to start a new countdown to the pointer down event.
  56642. * Defaults to 1.
  56643. */
  56644. gazeModePointerMovedFactor?: number;
  56645. /**
  56646. * Different button type to use instead of the main component
  56647. */
  56648. overrideButtonId?: string;
  56649. /**
  56650. * use this rendering group id for the meshes (optional)
  56651. */
  56652. renderingGroupId?: number;
  56653. /**
  56654. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  56655. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  56656. * 3000 means 3 seconds between pointing at something and selecting it
  56657. */
  56658. timeToSelect?: number;
  56659. /**
  56660. * Should meshes created here be added to a utility layer or the main scene
  56661. */
  56662. useUtilityLayer?: boolean;
  56663. /**
  56664. * Optional WebXR camera to be used for gaze selection
  56665. */
  56666. gazeCamera?: WebXRCamera;
  56667. /**
  56668. * the xr input to use with this pointer selection
  56669. */
  56670. xrInput: WebXRInput;
  56671. /**
  56672. * Should the scene pointerX and pointerY update be disabled
  56673. * This is required for fullscreen AR GUI, but might slow down other experiences.
  56674. * Disable in VR, if not needed.
  56675. * The first rig camera (left eye) will be used to calculate the projection
  56676. */
  56677. disableScenePointerVectorUpdate: boolean;
  56678. /**
  56679. * Enable pointer selection on all controllers instead of switching between them
  56680. */
  56681. enablePointerSelectionOnAllControllers?: boolean;
  56682. /**
  56683. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  56684. * If switch is enabled, it will still allow the user to switch between the different controllers
  56685. */
  56686. preferredHandedness?: XRHandedness;
  56687. /**
  56688. * Disable switching the pointer selection from one controller to the other.
  56689. * 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
  56690. */
  56691. disableSwitchOnClick?: boolean;
  56692. /**
  56693. * The maximum distance of the pointer selection feature. Defaults to 100.
  56694. */
  56695. maxPointerDistance?: number;
  56696. }
  56697. /**
  56698. * A module that will enable pointer selection for motion controllers of XR Input Sources
  56699. */
  56700. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  56701. private readonly _options;
  56702. private static _idCounter;
  56703. private _attachController;
  56704. private _controllers;
  56705. private _scene;
  56706. private _tmpVectorForPickCompare;
  56707. private _attachedController;
  56708. /**
  56709. * The module's name
  56710. */
  56711. static readonly Name: string;
  56712. /**
  56713. * The (Babylon) version of this module.
  56714. * This is an integer representing the implementation version.
  56715. * This number does not correspond to the WebXR specs version
  56716. */
  56717. static readonly Version: number;
  56718. /**
  56719. * Disable lighting on the laser pointer (so it will always be visible)
  56720. */
  56721. disablePointerLighting: boolean;
  56722. /**
  56723. * Disable lighting on the selection mesh (so it will always be visible)
  56724. */
  56725. disableSelectionMeshLighting: boolean;
  56726. /**
  56727. * Should the laser pointer be displayed
  56728. */
  56729. displayLaserPointer: boolean;
  56730. /**
  56731. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  56732. */
  56733. displaySelectionMesh: boolean;
  56734. /**
  56735. * This color will be set to the laser pointer when selection is triggered
  56736. */
  56737. laserPointerPickedColor: Color3;
  56738. /**
  56739. * Default color of the laser pointer
  56740. */
  56741. laserPointerDefaultColor: Color3;
  56742. /**
  56743. * default color of the selection ring
  56744. */
  56745. selectionMeshDefaultColor: Color3;
  56746. /**
  56747. * This color will be applied to the selection ring when selection is triggered
  56748. */
  56749. selectionMeshPickedColor: Color3;
  56750. /**
  56751. * Optional filter to be used for ray selection. This predicate shares behavior with
  56752. * scene.pointerMovePredicate which takes priority if it is also assigned.
  56753. */
  56754. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  56755. /**
  56756. * constructs a new background remover module
  56757. * @param _xrSessionManager the session manager for this module
  56758. * @param _options read-only options to be used in this module
  56759. */
  56760. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  56761. /**
  56762. * attach this feature
  56763. * Will usually be called by the features manager
  56764. *
  56765. * @returns true if successful.
  56766. */
  56767. attach(): boolean;
  56768. /**
  56769. * detach this feature.
  56770. * Will usually be called by the features manager
  56771. *
  56772. * @returns true if successful.
  56773. */
  56774. detach(): boolean;
  56775. /**
  56776. * Will get the mesh under a specific pointer.
  56777. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  56778. * @param controllerId the controllerId to check
  56779. * @returns The mesh under pointer or null if no mesh is under the pointer
  56780. */
  56781. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  56782. /**
  56783. * Get the xr controller that correlates to the pointer id in the pointer event
  56784. *
  56785. * @param id the pointer id to search for
  56786. * @returns the controller that correlates to this id or null if not found
  56787. */
  56788. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  56789. private _identityMatrix;
  56790. private _screenCoordinatesRef;
  56791. private _viewportRef;
  56792. protected _onXRFrame(_xrFrame: XRFrame): void;
  56793. private _attachGazeMode;
  56794. private _attachScreenRayMode;
  56795. private _attachTrackedPointerRayMode;
  56796. private _convertNormalToDirectionOfRay;
  56797. private _detachController;
  56798. private _generateNewMeshPair;
  56799. private _pickingMoved;
  56800. private _updatePointerDistance;
  56801. /** @hidden */
  56802. get lasterPointerDefaultColor(): Color3;
  56803. }
  56804. }
  56805. declare module BABYLON {
  56806. /**
  56807. * Button which can be used to enter a different mode of XR
  56808. */
  56809. export class WebXREnterExitUIButton {
  56810. /** button element */
  56811. element: HTMLElement;
  56812. /** XR initialization options for the button */
  56813. sessionMode: XRSessionMode;
  56814. /** Reference space type */
  56815. referenceSpaceType: XRReferenceSpaceType;
  56816. /**
  56817. * Creates a WebXREnterExitUIButton
  56818. * @param element button element
  56819. * @param sessionMode XR initialization session mode
  56820. * @param referenceSpaceType the type of reference space to be used
  56821. */
  56822. constructor(
  56823. /** button element */
  56824. element: HTMLElement,
  56825. /** XR initialization options for the button */
  56826. sessionMode: XRSessionMode,
  56827. /** Reference space type */
  56828. referenceSpaceType: XRReferenceSpaceType);
  56829. /**
  56830. * Extendable function which can be used to update the button's visuals when the state changes
  56831. * @param activeButton the current active button in the UI
  56832. */
  56833. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  56834. }
  56835. /**
  56836. * Options to create the webXR UI
  56837. */
  56838. export class WebXREnterExitUIOptions {
  56839. /**
  56840. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  56841. */
  56842. customButtons?: Array<WebXREnterExitUIButton>;
  56843. /**
  56844. * A reference space type to use when creating the default button.
  56845. * Default is local-floor
  56846. */
  56847. referenceSpaceType?: XRReferenceSpaceType;
  56848. /**
  56849. * Context to enter xr with
  56850. */
  56851. renderTarget?: Nullable<WebXRRenderTarget>;
  56852. /**
  56853. * A session mode to use when creating the default button.
  56854. * Default is immersive-vr
  56855. */
  56856. sessionMode?: XRSessionMode;
  56857. /**
  56858. * A list of optional features to init the session with
  56859. */
  56860. optionalFeatures?: string[];
  56861. /**
  56862. * A list of optional features to init the session with
  56863. */
  56864. requiredFeatures?: string[];
  56865. /**
  56866. * If defined, this function will be executed if the UI encounters an error when entering XR
  56867. */
  56868. onError?: (error: any) => void;
  56869. }
  56870. /**
  56871. * UI to allow the user to enter/exit XR mode
  56872. */
  56873. export class WebXREnterExitUI implements IDisposable {
  56874. private scene;
  56875. /** version of the options passed to this UI */
  56876. options: WebXREnterExitUIOptions;
  56877. private _activeButton;
  56878. private _buttons;
  56879. /**
  56880. * The HTML Div Element to which buttons are added.
  56881. */
  56882. readonly overlay: HTMLDivElement;
  56883. /**
  56884. * Fired every time the active button is changed.
  56885. *
  56886. * When xr is entered via a button that launches xr that button will be the callback parameter
  56887. *
  56888. * When exiting xr the callback parameter will be null)
  56889. */
  56890. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  56891. /**
  56892. *
  56893. * @param scene babylon scene object to use
  56894. * @param options (read-only) version of the options passed to this UI
  56895. */
  56896. private constructor();
  56897. /**
  56898. * Creates UI to allow the user to enter/exit XR mode
  56899. * @param scene the scene to add the ui to
  56900. * @param helper the xr experience helper to enter/exit xr with
  56901. * @param options options to configure the UI
  56902. * @returns the created ui
  56903. */
  56904. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  56905. /**
  56906. * Disposes of the XR UI component
  56907. */
  56908. dispose(): void;
  56909. private _updateButtons;
  56910. }
  56911. }
  56912. declare module BABYLON {
  56913. /**
  56914. * Class containing static functions to help procedurally build meshes
  56915. */
  56916. export class LinesBuilder {
  56917. /**
  56918. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  56919. * * 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
  56920. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  56921. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  56922. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  56923. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  56924. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56925. * * 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
  56926. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  56927. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56928. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  56929. * @param name defines the name of the new line system
  56930. * @param options defines the options used to create the line system
  56931. * @param scene defines the hosting scene
  56932. * @returns a new line system mesh
  56933. */
  56934. static CreateLineSystem(name: string, options: {
  56935. lines: Vector3[][];
  56936. updatable?: boolean;
  56937. instance?: Nullable<LinesMesh>;
  56938. colors?: Nullable<Color4[][]>;
  56939. useVertexAlpha?: boolean;
  56940. }, scene: Nullable<Scene>): LinesMesh;
  56941. /**
  56942. * Creates a line mesh
  56943. * 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
  56944. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56945. * * The parameter `points` is an array successive Vector3
  56946. * * 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
  56947. * * The optional parameter `colors` is an array of successive Color4, one per line point
  56948. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  56949. * * When updating an instance, remember that only point positions can change, not the number of points
  56950. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56951. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  56952. * @param name defines the name of the new line system
  56953. * @param options defines the options used to create the line system
  56954. * @param scene defines the hosting scene
  56955. * @returns a new line mesh
  56956. */
  56957. static CreateLines(name: string, options: {
  56958. points: Vector3[];
  56959. updatable?: boolean;
  56960. instance?: Nullable<LinesMesh>;
  56961. colors?: Color4[];
  56962. useVertexAlpha?: boolean;
  56963. }, scene?: Nullable<Scene>): LinesMesh;
  56964. /**
  56965. * Creates a dashed line mesh
  56966. * * 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
  56967. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56968. * * The parameter `points` is an array successive Vector3
  56969. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  56970. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  56971. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  56972. * * 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
  56973. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56974. * * When updating an instance, remember that only point positions can change, not the number of points
  56975. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56976. * @param name defines the name of the mesh
  56977. * @param options defines the options used to create the mesh
  56978. * @param scene defines the hosting scene
  56979. * @returns the dashed line mesh
  56980. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  56981. */
  56982. static CreateDashedLines(name: string, options: {
  56983. points: Vector3[];
  56984. dashSize?: number;
  56985. gapSize?: number;
  56986. dashNb?: number;
  56987. updatable?: boolean;
  56988. instance?: LinesMesh;
  56989. useVertexAlpha?: boolean;
  56990. }, scene?: Nullable<Scene>): LinesMesh;
  56991. }
  56992. }
  56993. declare module BABYLON {
  56994. /**
  56995. * Construction options for a timer
  56996. */
  56997. export interface ITimerOptions<T> {
  56998. /**
  56999. * Time-to-end
  57000. */
  57001. timeout: number;
  57002. /**
  57003. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  57004. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  57005. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  57006. */
  57007. contextObservable: Observable<T>;
  57008. /**
  57009. * Optional parameters when adding an observer to the observable
  57010. */
  57011. observableParameters?: {
  57012. mask?: number;
  57013. insertFirst?: boolean;
  57014. scope?: any;
  57015. };
  57016. /**
  57017. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  57018. */
  57019. breakCondition?: (data?: ITimerData<T>) => boolean;
  57020. /**
  57021. * Will be triggered when the time condition has met
  57022. */
  57023. onEnded?: (data: ITimerData<any>) => void;
  57024. /**
  57025. * Will be triggered when the break condition has met (prematurely ended)
  57026. */
  57027. onAborted?: (data: ITimerData<any>) => void;
  57028. /**
  57029. * Optional function to execute on each tick (or count)
  57030. */
  57031. onTick?: (data: ITimerData<any>) => void;
  57032. }
  57033. /**
  57034. * An interface defining the data sent by the timer
  57035. */
  57036. export interface ITimerData<T> {
  57037. /**
  57038. * When did it start
  57039. */
  57040. startTime: number;
  57041. /**
  57042. * Time now
  57043. */
  57044. currentTime: number;
  57045. /**
  57046. * Time passed since started
  57047. */
  57048. deltaTime: number;
  57049. /**
  57050. * How much is completed, in [0.0...1.0].
  57051. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  57052. */
  57053. completeRate: number;
  57054. /**
  57055. * What the registered observable sent in the last count
  57056. */
  57057. payload: T;
  57058. }
  57059. /**
  57060. * The current state of the timer
  57061. */
  57062. export enum TimerState {
  57063. /**
  57064. * Timer initialized, not yet started
  57065. */
  57066. INIT = 0,
  57067. /**
  57068. * Timer started and counting
  57069. */
  57070. STARTED = 1,
  57071. /**
  57072. * Timer ended (whether aborted or time reached)
  57073. */
  57074. ENDED = 2
  57075. }
  57076. /**
  57077. * A simple version of the timer. Will take options and start the timer immediately after calling it
  57078. *
  57079. * @param options options with which to initialize this timer
  57080. */
  57081. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  57082. /**
  57083. * An advanced implementation of a timer class
  57084. */
  57085. export class AdvancedTimer<T = any> implements IDisposable {
  57086. /**
  57087. * Will notify each time the timer calculates the remaining time
  57088. */
  57089. onEachCountObservable: Observable<ITimerData<T>>;
  57090. /**
  57091. * Will trigger when the timer was aborted due to the break condition
  57092. */
  57093. onTimerAbortedObservable: Observable<ITimerData<T>>;
  57094. /**
  57095. * Will trigger when the timer ended successfully
  57096. */
  57097. onTimerEndedObservable: Observable<ITimerData<T>>;
  57098. /**
  57099. * Will trigger when the timer state has changed
  57100. */
  57101. onStateChangedObservable: Observable<TimerState>;
  57102. private _observer;
  57103. private _contextObservable;
  57104. private _observableParameters;
  57105. private _startTime;
  57106. private _timer;
  57107. private _state;
  57108. private _breakCondition;
  57109. private _timeToEnd;
  57110. private _breakOnNextTick;
  57111. /**
  57112. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  57113. * @param options construction options for this advanced timer
  57114. */
  57115. constructor(options: ITimerOptions<T>);
  57116. /**
  57117. * set a breaking condition for this timer. Default is to never break during count
  57118. * @param predicate the new break condition. Returns true to break, false otherwise
  57119. */
  57120. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  57121. /**
  57122. * Reset ALL associated observables in this advanced timer
  57123. */
  57124. clearObservables(): void;
  57125. /**
  57126. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  57127. *
  57128. * @param timeToEnd how much time to measure until timer ended
  57129. */
  57130. start(timeToEnd?: number): void;
  57131. /**
  57132. * Will force a stop on the next tick.
  57133. */
  57134. stop(): void;
  57135. /**
  57136. * Dispose this timer, clearing all resources
  57137. */
  57138. dispose(): void;
  57139. private _setState;
  57140. private _tick;
  57141. private _stop;
  57142. }
  57143. }
  57144. declare module BABYLON {
  57145. /**
  57146. * The options container for the teleportation module
  57147. */
  57148. export interface IWebXRTeleportationOptions {
  57149. /**
  57150. * if provided, this scene will be used to render meshes.
  57151. */
  57152. customUtilityLayerScene?: Scene;
  57153. /**
  57154. * Values to configure the default target mesh
  57155. */
  57156. defaultTargetMeshOptions?: {
  57157. /**
  57158. * Fill color of the teleportation area
  57159. */
  57160. teleportationFillColor?: string;
  57161. /**
  57162. * Border color for the teleportation area
  57163. */
  57164. teleportationBorderColor?: string;
  57165. /**
  57166. * Disable the mesh's animation sequence
  57167. */
  57168. disableAnimation?: boolean;
  57169. /**
  57170. * Disable lighting on the material or the ring and arrow
  57171. */
  57172. disableLighting?: boolean;
  57173. /**
  57174. * Override the default material of the torus and arrow
  57175. */
  57176. torusArrowMaterial?: Material;
  57177. };
  57178. /**
  57179. * A list of meshes to use as floor meshes.
  57180. * Meshes can be added and removed after initializing the feature using the
  57181. * addFloorMesh and removeFloorMesh functions
  57182. * If empty, rotation will still work
  57183. */
  57184. floorMeshes?: AbstractMesh[];
  57185. /**
  57186. * use this rendering group id for the meshes (optional)
  57187. */
  57188. renderingGroupId?: number;
  57189. /**
  57190. * Should teleportation move only to snap points
  57191. */
  57192. snapPointsOnly?: boolean;
  57193. /**
  57194. * An array of points to which the teleportation will snap to.
  57195. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  57196. */
  57197. snapPositions?: Vector3[];
  57198. /**
  57199. * How close should the teleportation ray be in order to snap to position.
  57200. * Default to 0.8 units (meters)
  57201. */
  57202. snapToPositionRadius?: number;
  57203. /**
  57204. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  57205. * If you want to support rotation, make sure your mesh has a direction indicator.
  57206. *
  57207. * When left untouched, the default mesh will be initialized.
  57208. */
  57209. teleportationTargetMesh?: AbstractMesh;
  57210. /**
  57211. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  57212. */
  57213. timeToTeleport?: number;
  57214. /**
  57215. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  57216. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  57217. */
  57218. useMainComponentOnly?: boolean;
  57219. /**
  57220. * Should meshes created here be added to a utility layer or the main scene
  57221. */
  57222. useUtilityLayer?: boolean;
  57223. /**
  57224. * Babylon XR Input class for controller
  57225. */
  57226. xrInput: WebXRInput;
  57227. /**
  57228. * Meshes that the teleportation ray cannot go through
  57229. */
  57230. pickBlockerMeshes?: AbstractMesh[];
  57231. /**
  57232. * Should teleport work only on a specific hand?
  57233. */
  57234. forceHandedness?: XRHandedness;
  57235. /**
  57236. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  57237. */
  57238. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  57239. }
  57240. /**
  57241. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  57242. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  57243. * the input of the attached controllers.
  57244. */
  57245. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  57246. private _options;
  57247. private _controllers;
  57248. private _currentTeleportationControllerId;
  57249. private _floorMeshes;
  57250. private _quadraticBezierCurve;
  57251. private _selectionFeature;
  57252. private _snapToPositions;
  57253. private _snappedToPoint;
  57254. private _teleportationRingMaterial?;
  57255. private _tmpRay;
  57256. private _tmpVector;
  57257. private _tmpQuaternion;
  57258. /**
  57259. * The module's name
  57260. */
  57261. static readonly Name: string;
  57262. /**
  57263. * The (Babylon) version of this module.
  57264. * This is an integer representing the implementation version.
  57265. * This number does not correspond to the webxr specs version
  57266. */
  57267. static readonly Version: number;
  57268. /**
  57269. * Is movement backwards enabled
  57270. */
  57271. backwardsMovementEnabled: boolean;
  57272. /**
  57273. * Distance to travel when moving backwards
  57274. */
  57275. backwardsTeleportationDistance: number;
  57276. /**
  57277. * The distance from the user to the inspection point in the direction of the controller
  57278. * A higher number will allow the user to move further
  57279. * defaults to 5 (meters, in xr units)
  57280. */
  57281. parabolicCheckRadius: number;
  57282. /**
  57283. * Should the module support parabolic ray on top of direct ray
  57284. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  57285. * Very helpful when moving between floors / different heights
  57286. */
  57287. parabolicRayEnabled: boolean;
  57288. /**
  57289. * The second type of ray - straight line.
  57290. * Should it be enabled or should the parabolic line be the only one.
  57291. */
  57292. straightRayEnabled: boolean;
  57293. /**
  57294. * How much rotation should be applied when rotating right and left
  57295. */
  57296. rotationAngle: number;
  57297. private _rotationEnabled;
  57298. /**
  57299. * Is rotation enabled when moving forward?
  57300. * Disabling this feature will prevent the user from deciding the direction when teleporting
  57301. */
  57302. get rotationEnabled(): boolean;
  57303. /**
  57304. * Sets whether rotation is enabled or not
  57305. * @param enabled is rotation enabled when teleportation is shown
  57306. */
  57307. set rotationEnabled(enabled: boolean);
  57308. /**
  57309. * Exposes the currently set teleportation target mesh.
  57310. */
  57311. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  57312. /**
  57313. * constructs a new anchor system
  57314. * @param _xrSessionManager an instance of WebXRSessionManager
  57315. * @param _options configuration object for this feature
  57316. */
  57317. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  57318. /**
  57319. * Get the snapPointsOnly flag
  57320. */
  57321. get snapPointsOnly(): boolean;
  57322. /**
  57323. * Sets the snapPointsOnly flag
  57324. * @param snapToPoints should teleportation be exclusively to snap points
  57325. */
  57326. set snapPointsOnly(snapToPoints: boolean);
  57327. /**
  57328. * Add a new mesh to the floor meshes array
  57329. * @param mesh the mesh to use as floor mesh
  57330. */
  57331. addFloorMesh(mesh: AbstractMesh): void;
  57332. /**
  57333. * Add a new snap-to point to fix teleportation to this position
  57334. * @param newSnapPoint The new Snap-To point
  57335. */
  57336. addSnapPoint(newSnapPoint: Vector3): void;
  57337. attach(): boolean;
  57338. detach(): boolean;
  57339. dispose(): void;
  57340. /**
  57341. * Remove a mesh from the floor meshes array
  57342. * @param mesh the mesh to remove
  57343. */
  57344. removeFloorMesh(mesh: AbstractMesh): void;
  57345. /**
  57346. * Remove a mesh from the floor meshes array using its name
  57347. * @param name the mesh name to remove
  57348. */
  57349. removeFloorMeshByName(name: string): void;
  57350. /**
  57351. * 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
  57352. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  57353. * @returns was the point found and removed or not
  57354. */
  57355. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  57356. /**
  57357. * This function sets a selection feature that will be disabled when
  57358. * the forward ray is shown and will be reattached when hidden.
  57359. * This is used to remove the selection rays when moving.
  57360. * @param selectionFeature the feature to disable when forward movement is enabled
  57361. */
  57362. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  57363. protected _onXRFrame(_xrFrame: XRFrame): void;
  57364. private _attachController;
  57365. private _createDefaultTargetMesh;
  57366. private _detachController;
  57367. private _findClosestSnapPointWithRadius;
  57368. private _setTargetMeshPosition;
  57369. private _setTargetMeshVisibility;
  57370. private _showParabolicPath;
  57371. private _teleportForward;
  57372. }
  57373. }
  57374. declare module BABYLON {
  57375. /**
  57376. * Options for the default xr helper
  57377. */
  57378. export class WebXRDefaultExperienceOptions {
  57379. /**
  57380. * Enable or disable default UI to enter XR
  57381. */
  57382. disableDefaultUI?: boolean;
  57383. /**
  57384. * Should pointer selection not initialize.
  57385. * Note that disabling pointer selection also disables teleportation.
  57386. * Defaults to false.
  57387. */
  57388. disablePointerSelection?: boolean;
  57389. /**
  57390. * Should teleportation not initialize. Defaults to false.
  57391. */
  57392. disableTeleportation?: boolean;
  57393. /**
  57394. * Floor meshes that will be used for teleport
  57395. */
  57396. floorMeshes?: Array<AbstractMesh>;
  57397. /**
  57398. * If set to true, the first frame will not be used to reset position
  57399. * The first frame is mainly used when copying transformation from the old camera
  57400. * Mainly used in AR
  57401. */
  57402. ignoreNativeCameraTransformation?: boolean;
  57403. /**
  57404. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  57405. */
  57406. inputOptions?: IWebXRInputOptions;
  57407. /**
  57408. * optional configuration for the output canvas
  57409. */
  57410. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  57411. /**
  57412. * optional UI options. This can be used among other to change session mode and reference space type
  57413. */
  57414. uiOptions?: WebXREnterExitUIOptions;
  57415. /**
  57416. * When loading teleportation and pointer select, use stable versions instead of latest.
  57417. */
  57418. useStablePlugins?: boolean;
  57419. /**
  57420. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  57421. */
  57422. renderingGroupId?: number;
  57423. /**
  57424. * A list of optional features to init the session with
  57425. * If set to true, all features we support will be added
  57426. */
  57427. optionalFeatures?: boolean | string[];
  57428. }
  57429. /**
  57430. * Default experience which provides a similar setup to the previous webVRExperience
  57431. */
  57432. export class WebXRDefaultExperience {
  57433. /**
  57434. * Base experience
  57435. */
  57436. baseExperience: WebXRExperienceHelper;
  57437. /**
  57438. * Enables ui for entering/exiting xr
  57439. */
  57440. enterExitUI: WebXREnterExitUI;
  57441. /**
  57442. * Input experience extension
  57443. */
  57444. input: WebXRInput;
  57445. /**
  57446. * Enables laser pointer and selection
  57447. */
  57448. pointerSelection: WebXRControllerPointerSelection;
  57449. /**
  57450. * Default target xr should render to
  57451. */
  57452. renderTarget: WebXRRenderTarget;
  57453. /**
  57454. * Enables teleportation
  57455. */
  57456. teleportation: WebXRMotionControllerTeleportation;
  57457. private constructor();
  57458. /**
  57459. * Creates the default xr experience
  57460. * @param scene scene
  57461. * @param options options for basic configuration
  57462. * @returns resulting WebXRDefaultExperience
  57463. */
  57464. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  57465. /**
  57466. * Disposes of the experience helper
  57467. */
  57468. dispose(): void;
  57469. }
  57470. }
  57471. declare module BABYLON {
  57472. /**
  57473. * Options to modify the vr teleportation behavior.
  57474. */
  57475. export interface VRTeleportationOptions {
  57476. /**
  57477. * The name of the mesh which should be used as the teleportation floor. (default: null)
  57478. */
  57479. floorMeshName?: string;
  57480. /**
  57481. * A list of meshes to be used as the teleportation floor. (default: empty)
  57482. */
  57483. floorMeshes?: Mesh[];
  57484. /**
  57485. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  57486. */
  57487. teleportationMode?: number;
  57488. /**
  57489. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  57490. */
  57491. teleportationTime?: number;
  57492. /**
  57493. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  57494. */
  57495. teleportationSpeed?: number;
  57496. /**
  57497. * The easing function used in the animation or null for Linear. (default CircleEase)
  57498. */
  57499. easingFunction?: EasingFunction;
  57500. }
  57501. /**
  57502. * Options to modify the vr experience helper's behavior.
  57503. */
  57504. export interface VRExperienceHelperOptions extends WebVROptions {
  57505. /**
  57506. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  57507. */
  57508. createDeviceOrientationCamera?: boolean;
  57509. /**
  57510. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  57511. */
  57512. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  57513. /**
  57514. * Uses the main button on the controller to toggle the laser casted. (default: true)
  57515. */
  57516. laserToggle?: boolean;
  57517. /**
  57518. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  57519. */
  57520. floorMeshes?: Mesh[];
  57521. /**
  57522. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  57523. */
  57524. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  57525. /**
  57526. * Defines if WebXR should be used instead of WebVR (if available)
  57527. */
  57528. useXR?: boolean;
  57529. }
  57530. /**
  57531. * Event containing information after VR has been entered
  57532. */
  57533. export class OnAfterEnteringVRObservableEvent {
  57534. /**
  57535. * If entering vr was successful
  57536. */
  57537. success: boolean;
  57538. }
  57539. /**
  57540. * Helps to quickly add VR support to an existing scene.
  57541. * See https://doc.babylonjs.com/how_to/webvr_helper
  57542. */
  57543. export class VRExperienceHelper {
  57544. /** Options to modify the vr experience helper's behavior. */
  57545. webVROptions: VRExperienceHelperOptions;
  57546. private _scene;
  57547. private _position;
  57548. private _btnVR;
  57549. private _btnVRDisplayed;
  57550. private _webVRsupported;
  57551. private _webVRready;
  57552. private _webVRrequesting;
  57553. private _webVRpresenting;
  57554. private _hasEnteredVR;
  57555. private _fullscreenVRpresenting;
  57556. private _inputElement;
  57557. private _webVRCamera;
  57558. private _vrDeviceOrientationCamera;
  57559. private _deviceOrientationCamera;
  57560. private _existingCamera;
  57561. private _onKeyDown;
  57562. private _onVrDisplayPresentChange;
  57563. private _onVRDisplayChanged;
  57564. private _onVRRequestPresentStart;
  57565. private _onVRRequestPresentComplete;
  57566. /**
  57567. * 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)
  57568. */
  57569. enableGazeEvenWhenNoPointerLock: boolean;
  57570. /**
  57571. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  57572. */
  57573. exitVROnDoubleTap: boolean;
  57574. /**
  57575. * Observable raised right before entering VR.
  57576. */
  57577. onEnteringVRObservable: Observable<VRExperienceHelper>;
  57578. /**
  57579. * Observable raised when entering VR has completed.
  57580. */
  57581. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  57582. /**
  57583. * Observable raised when exiting VR.
  57584. */
  57585. onExitingVRObservable: Observable<VRExperienceHelper>;
  57586. /**
  57587. * Observable raised when controller mesh is loaded.
  57588. */
  57589. onControllerMeshLoadedObservable: Observable<WebVRController>;
  57590. /** Return this.onEnteringVRObservable
  57591. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  57592. */
  57593. get onEnteringVR(): Observable<VRExperienceHelper>;
  57594. /** Return this.onExitingVRObservable
  57595. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  57596. */
  57597. get onExitingVR(): Observable<VRExperienceHelper>;
  57598. /** Return this.onControllerMeshLoadedObservable
  57599. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  57600. */
  57601. get onControllerMeshLoaded(): Observable<WebVRController>;
  57602. private _rayLength;
  57603. private _useCustomVRButton;
  57604. private _teleportationRequested;
  57605. private _teleportActive;
  57606. private _floorMeshName;
  57607. private _floorMeshesCollection;
  57608. private _teleportationMode;
  57609. private _teleportationTime;
  57610. private _teleportationSpeed;
  57611. private _teleportationEasing;
  57612. private _rotationAllowed;
  57613. private _teleportBackwardsVector;
  57614. private _teleportationTarget;
  57615. private _isDefaultTeleportationTarget;
  57616. private _postProcessMove;
  57617. private _teleportationFillColor;
  57618. private _teleportationBorderColor;
  57619. private _rotationAngle;
  57620. private _haloCenter;
  57621. private _cameraGazer;
  57622. private _padSensibilityUp;
  57623. private _padSensibilityDown;
  57624. private _leftController;
  57625. private _rightController;
  57626. private _gazeColor;
  57627. private _laserColor;
  57628. private _pickedLaserColor;
  57629. private _pickedGazeColor;
  57630. /**
  57631. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  57632. */
  57633. onNewMeshSelected: Observable<AbstractMesh>;
  57634. /**
  57635. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  57636. * This observable will provide the mesh and the controller used to select the mesh
  57637. */
  57638. onMeshSelectedWithController: Observable<{
  57639. mesh: AbstractMesh;
  57640. controller: WebVRController;
  57641. }>;
  57642. /**
  57643. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  57644. */
  57645. onNewMeshPicked: Observable<PickingInfo>;
  57646. private _circleEase;
  57647. /**
  57648. * Observable raised before camera teleportation
  57649. */
  57650. onBeforeCameraTeleport: Observable<Vector3>;
  57651. /**
  57652. * Observable raised after camera teleportation
  57653. */
  57654. onAfterCameraTeleport: Observable<Vector3>;
  57655. /**
  57656. * Observable raised when current selected mesh gets unselected
  57657. */
  57658. onSelectedMeshUnselected: Observable<AbstractMesh>;
  57659. private _raySelectionPredicate;
  57660. /**
  57661. * To be optionally changed by user to define custom ray selection
  57662. */
  57663. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  57664. /**
  57665. * To be optionally changed by user to define custom selection logic (after ray selection)
  57666. */
  57667. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  57668. /**
  57669. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  57670. */
  57671. teleportationEnabled: boolean;
  57672. private _defaultHeight;
  57673. private _teleportationInitialized;
  57674. private _interactionsEnabled;
  57675. private _interactionsRequested;
  57676. private _displayGaze;
  57677. private _displayLaserPointer;
  57678. /**
  57679. * The mesh used to display where the user is going to teleport.
  57680. */
  57681. get teleportationTarget(): Mesh;
  57682. /**
  57683. * Sets the mesh to be used to display where the user is going to teleport.
  57684. */
  57685. set teleportationTarget(value: Mesh);
  57686. /**
  57687. * 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
  57688. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  57689. * See https://doc.babylonjs.com/resources/baking_transformations
  57690. */
  57691. get gazeTrackerMesh(): Mesh;
  57692. set gazeTrackerMesh(value: Mesh);
  57693. /**
  57694. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  57695. */
  57696. updateGazeTrackerScale: boolean;
  57697. /**
  57698. * If the gaze trackers color should be updated when selecting meshes
  57699. */
  57700. updateGazeTrackerColor: boolean;
  57701. /**
  57702. * If the controller laser color should be updated when selecting meshes
  57703. */
  57704. updateControllerLaserColor: boolean;
  57705. /**
  57706. * The gaze tracking mesh corresponding to the left controller
  57707. */
  57708. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  57709. /**
  57710. * The gaze tracking mesh corresponding to the right controller
  57711. */
  57712. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  57713. /**
  57714. * If the ray of the gaze should be displayed.
  57715. */
  57716. get displayGaze(): boolean;
  57717. /**
  57718. * Sets if the ray of the gaze should be displayed.
  57719. */
  57720. set displayGaze(value: boolean);
  57721. /**
  57722. * If the ray of the LaserPointer should be displayed.
  57723. */
  57724. get displayLaserPointer(): boolean;
  57725. /**
  57726. * Sets if the ray of the LaserPointer should be displayed.
  57727. */
  57728. set displayLaserPointer(value: boolean);
  57729. /**
  57730. * The deviceOrientationCamera used as the camera when not in VR.
  57731. */
  57732. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  57733. /**
  57734. * Based on the current WebVR support, returns the current VR camera used.
  57735. */
  57736. get currentVRCamera(): Nullable<Camera>;
  57737. /**
  57738. * The webVRCamera which is used when in VR.
  57739. */
  57740. get webVRCamera(): WebVRFreeCamera;
  57741. /**
  57742. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  57743. */
  57744. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  57745. /**
  57746. * The html button that is used to trigger entering into VR.
  57747. */
  57748. get vrButton(): Nullable<HTMLButtonElement>;
  57749. private get _teleportationRequestInitiated();
  57750. /**
  57751. * Defines whether or not Pointer lock should be requested when switching to
  57752. * full screen.
  57753. */
  57754. requestPointerLockOnFullScreen: boolean;
  57755. /**
  57756. * If asking to force XR, this will be populated with the default xr experience
  57757. */
  57758. xr: WebXRDefaultExperience;
  57759. /**
  57760. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  57761. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  57762. */
  57763. xrTestDone: boolean;
  57764. /**
  57765. * Instantiates a VRExperienceHelper.
  57766. * Helps to quickly add VR support to an existing scene.
  57767. * @param scene The scene the VRExperienceHelper belongs to.
  57768. * @param webVROptions Options to modify the vr experience helper's behavior.
  57769. */
  57770. constructor(scene: Scene,
  57771. /** Options to modify the vr experience helper's behavior. */
  57772. webVROptions?: VRExperienceHelperOptions);
  57773. private completeVRInit;
  57774. private _onDefaultMeshLoaded;
  57775. private _onResize;
  57776. private _onFullscreenChange;
  57777. /**
  57778. * Gets a value indicating if we are currently in VR mode.
  57779. */
  57780. get isInVRMode(): boolean;
  57781. private onVrDisplayPresentChange;
  57782. private onVRDisplayChanged;
  57783. private moveButtonToBottomRight;
  57784. private displayVRButton;
  57785. private updateButtonVisibility;
  57786. private _cachedAngularSensibility;
  57787. /**
  57788. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  57789. * Otherwise, will use the fullscreen API.
  57790. */
  57791. enterVR(): void;
  57792. /**
  57793. * Attempt to exit VR, or fullscreen.
  57794. */
  57795. exitVR(): void;
  57796. /**
  57797. * The position of the vr experience helper.
  57798. */
  57799. get position(): Vector3;
  57800. /**
  57801. * Sets the position of the vr experience helper.
  57802. */
  57803. set position(value: Vector3);
  57804. /**
  57805. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  57806. */
  57807. enableInteractions(): void;
  57808. private get _noControllerIsActive();
  57809. private beforeRender;
  57810. private _isTeleportationFloor;
  57811. /**
  57812. * Adds a floor mesh to be used for teleportation.
  57813. * @param floorMesh the mesh to be used for teleportation.
  57814. */
  57815. addFloorMesh(floorMesh: Mesh): void;
  57816. /**
  57817. * Removes a floor mesh from being used for teleportation.
  57818. * @param floorMesh the mesh to be removed.
  57819. */
  57820. removeFloorMesh(floorMesh: Mesh): void;
  57821. /**
  57822. * Enables interactions and teleportation using the VR controllers and gaze.
  57823. * @param vrTeleportationOptions options to modify teleportation behavior.
  57824. */
  57825. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  57826. private _onNewGamepadConnected;
  57827. private _tryEnableInteractionOnController;
  57828. private _onNewGamepadDisconnected;
  57829. private _enableInteractionOnController;
  57830. private _checkTeleportWithRay;
  57831. private _checkRotate;
  57832. private _checkTeleportBackwards;
  57833. private _enableTeleportationOnController;
  57834. private _createTeleportationCircles;
  57835. private _displayTeleportationTarget;
  57836. private _hideTeleportationTarget;
  57837. private _rotateCamera;
  57838. private _moveTeleportationSelectorTo;
  57839. private _workingVector;
  57840. private _workingQuaternion;
  57841. private _workingMatrix;
  57842. /**
  57843. * Time Constant Teleportation Mode
  57844. */
  57845. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  57846. /**
  57847. * Speed Constant Teleportation Mode
  57848. */
  57849. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  57850. /**
  57851. * Teleports the users feet to the desired location
  57852. * @param location The location where the user's feet should be placed
  57853. */
  57854. teleportCamera(location: Vector3): void;
  57855. private _convertNormalToDirectionOfRay;
  57856. private _castRayAndSelectObject;
  57857. private _notifySelectedMeshUnselected;
  57858. /**
  57859. * Permanently set new colors for the laser pointer
  57860. * @param color the new laser color
  57861. * @param pickedColor the new laser color when picked mesh detected
  57862. */
  57863. setLaserColor(color: Color3, pickedColor?: Color3): void;
  57864. /**
  57865. * Set lighting enabled / disabled on the laser pointer of both controllers
  57866. * @param enabled should the lighting be enabled on the laser pointer
  57867. */
  57868. setLaserLightingState(enabled?: boolean): void;
  57869. /**
  57870. * Permanently set new colors for the gaze pointer
  57871. * @param color the new gaze color
  57872. * @param pickedColor the new gaze color when picked mesh detected
  57873. */
  57874. setGazeColor(color: Color3, pickedColor?: Color3): void;
  57875. /**
  57876. * Sets the color of the laser ray from the vr controllers.
  57877. * @param color new color for the ray.
  57878. */
  57879. changeLaserColor(color: Color3): void;
  57880. /**
  57881. * Sets the color of the ray from the vr headsets gaze.
  57882. * @param color new color for the ray.
  57883. */
  57884. changeGazeColor(color: Color3): void;
  57885. /**
  57886. * Exits VR and disposes of the vr experience helper
  57887. */
  57888. dispose(): void;
  57889. /**
  57890. * Gets the name of the VRExperienceHelper class
  57891. * @returns "VRExperienceHelper"
  57892. */
  57893. getClassName(): string;
  57894. }
  57895. }
  57896. declare module BABYLON {
  57897. /**
  57898. * Contains an array of blocks representing the octree
  57899. */
  57900. export interface IOctreeContainer<T> {
  57901. /**
  57902. * Blocks within the octree
  57903. */
  57904. blocks: Array<OctreeBlock<T>>;
  57905. }
  57906. /**
  57907. * Class used to store a cell in an octree
  57908. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57909. */
  57910. export class OctreeBlock<T> {
  57911. /**
  57912. * Gets the content of the current block
  57913. */
  57914. entries: T[];
  57915. /**
  57916. * Gets the list of block children
  57917. */
  57918. blocks: Array<OctreeBlock<T>>;
  57919. private _depth;
  57920. private _maxDepth;
  57921. private _capacity;
  57922. private _minPoint;
  57923. private _maxPoint;
  57924. private _boundingVectors;
  57925. private _creationFunc;
  57926. /**
  57927. * Creates a new block
  57928. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  57929. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  57930. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  57931. * @param depth defines the current depth of this block in the octree
  57932. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  57933. * @param creationFunc defines a callback to call when an element is added to the block
  57934. */
  57935. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  57936. /**
  57937. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  57938. */
  57939. get capacity(): number;
  57940. /**
  57941. * Gets the minimum vector (in world space) of the block's bounding box
  57942. */
  57943. get minPoint(): Vector3;
  57944. /**
  57945. * Gets the maximum vector (in world space) of the block's bounding box
  57946. */
  57947. get maxPoint(): Vector3;
  57948. /**
  57949. * Add a new element to this block
  57950. * @param entry defines the element to add
  57951. */
  57952. addEntry(entry: T): void;
  57953. /**
  57954. * Remove an element from this block
  57955. * @param entry defines the element to remove
  57956. */
  57957. removeEntry(entry: T): void;
  57958. /**
  57959. * Add an array of elements to this block
  57960. * @param entries defines the array of elements to add
  57961. */
  57962. addEntries(entries: T[]): void;
  57963. /**
  57964. * Test if the current block intersects the frustum planes and if yes, then add its content to the selection array
  57965. * @param frustumPlanes defines the frustum planes to test
  57966. * @param selection defines the array to store current content if selection is positive
  57967. * @param allowDuplicate defines if the selection array can contains duplicated entries
  57968. */
  57969. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  57970. /**
  57971. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  57972. * @param sphereCenter defines the bounding sphere center
  57973. * @param sphereRadius defines the bounding sphere radius
  57974. * @param selection defines the array to store current content if selection is positive
  57975. * @param allowDuplicate defines if the selection array can contains duplicated entries
  57976. */
  57977. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  57978. /**
  57979. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  57980. * @param ray defines the ray to test with
  57981. * @param selection defines the array to store current content if selection is positive
  57982. */
  57983. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  57984. /**
  57985. * Subdivide the content into child blocks (this block will then be empty)
  57986. */
  57987. createInnerBlocks(): void;
  57988. /**
  57989. * @hidden
  57990. */
  57991. 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;
  57992. }
  57993. }
  57994. declare module BABYLON {
  57995. /**
  57996. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  57997. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57998. */
  57999. export class Octree<T> {
  58000. /** 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.) */
  58001. maxDepth: number;
  58002. /**
  58003. * Blocks within the octree containing objects
  58004. */
  58005. blocks: Array<OctreeBlock<T>>;
  58006. /**
  58007. * Content stored in the octree
  58008. */
  58009. dynamicContent: T[];
  58010. private _maxBlockCapacity;
  58011. private _selectionContent;
  58012. private _creationFunc;
  58013. /**
  58014. * Creates a octree
  58015. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  58016. * @param creationFunc function to be used to instantiate the octree
  58017. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  58018. * @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.)
  58019. */
  58020. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  58021. /** 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.) */
  58022. maxDepth?: number);
  58023. /**
  58024. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  58025. * @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);
  58026. * @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);
  58027. * @param entries meshes to be added to the octree blocks
  58028. */
  58029. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  58030. /**
  58031. * Adds a mesh to the octree
  58032. * @param entry Mesh to add to the octree
  58033. */
  58034. addMesh(entry: T): void;
  58035. /**
  58036. * Remove an element from the octree
  58037. * @param entry defines the element to remove
  58038. */
  58039. removeMesh(entry: T): void;
  58040. /**
  58041. * Selects an array of meshes within the frustum
  58042. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  58043. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  58044. * @returns array of meshes within the frustum
  58045. */
  58046. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  58047. /**
  58048. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  58049. * @param sphereCenter defines the bounding sphere center
  58050. * @param sphereRadius defines the bounding sphere radius
  58051. * @param allowDuplicate defines if the selection array can contains duplicated entries
  58052. * @returns an array of objects that intersect the sphere
  58053. */
  58054. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  58055. /**
  58056. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  58057. * @param ray defines the ray to test with
  58058. * @returns array of intersected objects
  58059. */
  58060. intersectsRay(ray: Ray): SmartArray<T>;
  58061. /**
  58062. * Adds a mesh into the octree block if it intersects the block
  58063. */
  58064. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  58065. /**
  58066. * Adds a submesh into the octree block if it intersects the block
  58067. */
  58068. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  58069. }
  58070. }
  58071. declare module BABYLON {
  58072. interface Scene {
  58073. /**
  58074. * @hidden
  58075. * Backing Filed
  58076. */
  58077. _selectionOctree: Octree<AbstractMesh>;
  58078. /**
  58079. * Gets the octree used to boost mesh selection (picking)
  58080. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  58081. */
  58082. selectionOctree: Octree<AbstractMesh>;
  58083. /**
  58084. * Creates or updates the octree used to boost selection (picking)
  58085. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  58086. * @param maxCapacity defines the maximum capacity per leaf
  58087. * @param maxDepth defines the maximum depth of the octree
  58088. * @returns an octree of AbstractMesh
  58089. */
  58090. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  58091. }
  58092. interface AbstractMesh {
  58093. /**
  58094. * @hidden
  58095. * Backing Field
  58096. */
  58097. _submeshesOctree: Octree<SubMesh>;
  58098. /**
  58099. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  58100. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  58101. * @param maxCapacity defines the maximum size of each block (64 by default)
  58102. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  58103. * @returns the new octree
  58104. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  58105. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  58106. */
  58107. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  58108. }
  58109. /**
  58110. * Defines the octree scene component responsible to manage any octrees
  58111. * in a given scene.
  58112. */
  58113. export class OctreeSceneComponent {
  58114. /**
  58115. * The component name help to identify the component in the list of scene components.
  58116. */
  58117. readonly name: string;
  58118. /**
  58119. * The scene the component belongs to.
  58120. */
  58121. scene: Scene;
  58122. /**
  58123. * Indicates if the meshes have been checked to make sure they are isEnabled()
  58124. */
  58125. readonly checksIsEnabled: boolean;
  58126. /**
  58127. * Creates a new instance of the component for the given scene
  58128. * @param scene Defines the scene to register the component in
  58129. */
  58130. constructor(scene: Scene);
  58131. /**
  58132. * Registers the component in a given scene
  58133. */
  58134. register(): void;
  58135. /**
  58136. * Return the list of active meshes
  58137. * @returns the list of active meshes
  58138. */
  58139. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  58140. /**
  58141. * Return the list of active sub meshes
  58142. * @param mesh The mesh to get the candidates sub meshes from
  58143. * @returns the list of active sub meshes
  58144. */
  58145. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  58146. private _tempRay;
  58147. /**
  58148. * Return the list of sub meshes intersecting with a given local ray
  58149. * @param mesh defines the mesh to find the submesh for
  58150. * @param localRay defines the ray in local space
  58151. * @returns the list of intersecting sub meshes
  58152. */
  58153. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  58154. /**
  58155. * Return the list of sub meshes colliding with a collider
  58156. * @param mesh defines the mesh to find the submesh for
  58157. * @param collider defines the collider to evaluate the collision against
  58158. * @returns the list of colliding sub meshes
  58159. */
  58160. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  58161. /**
  58162. * Rebuilds the elements related to this component in case of
  58163. * context lost for instance.
  58164. */
  58165. rebuild(): void;
  58166. /**
  58167. * Disposes the component and the associated resources.
  58168. */
  58169. dispose(): void;
  58170. }
  58171. }
  58172. declare module BABYLON {
  58173. /**
  58174. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  58175. */
  58176. export interface GizmoAxisCache {
  58177. /** Mesh used to render the Gizmo */
  58178. gizmoMeshes: Mesh[];
  58179. /** Mesh used to detect user interaction with Gizmo */
  58180. colliderMeshes: Mesh[];
  58181. /** Material used to indicate color of gizmo mesh */
  58182. material: StandardMaterial;
  58183. /** Material used to indicate hover state of the Gizmo */
  58184. hoverMaterial: StandardMaterial;
  58185. /** Material used to indicate disabled state of the Gizmo */
  58186. disableMaterial: StandardMaterial;
  58187. /** Used to indicate Active state of the Gizmo */
  58188. active: boolean;
  58189. }
  58190. /**
  58191. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  58192. */
  58193. export class Gizmo implements IDisposable {
  58194. /** The utility layer the gizmo will be added to */
  58195. gizmoLayer: UtilityLayerRenderer;
  58196. /**
  58197. * The root mesh of the gizmo
  58198. */
  58199. _rootMesh: Mesh;
  58200. private _attachedMesh;
  58201. private _attachedNode;
  58202. /**
  58203. * Ratio for the scale of the gizmo (Default: 1)
  58204. */
  58205. protected _scaleRatio: number;
  58206. /**
  58207. * boolean updated by pointermove when a gizmo mesh is hovered
  58208. */
  58209. protected _isHovered: boolean;
  58210. /**
  58211. * Ratio for the scale of the gizmo (Default: 1)
  58212. */
  58213. set scaleRatio(value: number);
  58214. get scaleRatio(): number;
  58215. /**
  58216. * True when the mouse pointer is hovered a gizmo mesh
  58217. */
  58218. get isHovered(): boolean;
  58219. /**
  58220. * If a custom mesh has been set (Default: false)
  58221. */
  58222. protected _customMeshSet: boolean;
  58223. /**
  58224. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  58225. * * When set, interactions will be enabled
  58226. */
  58227. get attachedMesh(): Nullable<AbstractMesh>;
  58228. set attachedMesh(value: Nullable<AbstractMesh>);
  58229. /**
  58230. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  58231. * * When set, interactions will be enabled
  58232. */
  58233. get attachedNode(): Nullable<Node>;
  58234. set attachedNode(value: Nullable<Node>);
  58235. /**
  58236. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  58237. * @param mesh The mesh to replace the default mesh of the gizmo
  58238. */
  58239. setCustomMesh(mesh: Mesh): void;
  58240. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  58241. /**
  58242. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  58243. */
  58244. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  58245. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  58246. /**
  58247. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  58248. */
  58249. updateGizmoPositionToMatchAttachedMesh: boolean;
  58250. /**
  58251. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  58252. */
  58253. updateScale: boolean;
  58254. protected _interactionsEnabled: boolean;
  58255. protected _attachedNodeChanged(value: Nullable<Node>): void;
  58256. private _beforeRenderObserver;
  58257. private _tempQuaternion;
  58258. private _tempVector;
  58259. private _tempVector2;
  58260. private _tempMatrix1;
  58261. private _tempMatrix2;
  58262. private _rightHandtoLeftHandMatrix;
  58263. /**
  58264. * Creates a gizmo
  58265. * @param gizmoLayer The utility layer the gizmo will be added to
  58266. */
  58267. constructor(
  58268. /** The utility layer the gizmo will be added to */
  58269. gizmoLayer?: UtilityLayerRenderer);
  58270. /**
  58271. * Updates the gizmo to match the attached mesh's position/rotation
  58272. */
  58273. protected _update(): void;
  58274. /**
  58275. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  58276. * @param value Node, TransformNode or mesh
  58277. */
  58278. protected _matrixChanged(): void;
  58279. /**
  58280. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  58281. * @param gizmoLayer The utility layer the gizmo will be added to
  58282. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  58283. * @returns {Observer<PointerInfo>} pointerObserver
  58284. */
  58285. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  58286. /**
  58287. * Disposes of the gizmo
  58288. */
  58289. dispose(): void;
  58290. }
  58291. }
  58292. declare module BABYLON {
  58293. /**
  58294. * Single plane drag gizmo
  58295. */
  58296. export class PlaneDragGizmo extends Gizmo {
  58297. /**
  58298. * Drag behavior responsible for the gizmos dragging interactions
  58299. */
  58300. dragBehavior: PointerDragBehavior;
  58301. private _pointerObserver;
  58302. /**
  58303. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  58304. */
  58305. snapDistance: number;
  58306. /**
  58307. * Event that fires each time the gizmo snaps to a new location.
  58308. * * snapDistance is the the change in distance
  58309. */
  58310. onSnapObservable: Observable<{
  58311. snapDistance: number;
  58312. }>;
  58313. private _gizmoMesh;
  58314. private _coloredMaterial;
  58315. private _hoverMaterial;
  58316. private _disableMaterial;
  58317. private _isEnabled;
  58318. private _parent;
  58319. private _dragging;
  58320. /** @hidden */
  58321. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  58322. /**
  58323. * Creates a PlaneDragGizmo
  58324. * @param gizmoLayer The utility layer the gizmo will be added to
  58325. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  58326. * @param color The color of the gizmo
  58327. */
  58328. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  58329. protected _attachedNodeChanged(value: Nullable<Node>): void;
  58330. /**
  58331. * If the gizmo is enabled
  58332. */
  58333. set isEnabled(value: boolean);
  58334. get isEnabled(): boolean;
  58335. /**
  58336. * Disposes of the gizmo
  58337. */
  58338. dispose(): void;
  58339. }
  58340. }
  58341. declare module BABYLON {
  58342. /**
  58343. * Single plane rotation gizmo
  58344. */
  58345. export class PlaneRotationGizmo extends Gizmo {
  58346. /**
  58347. * Drag behavior responsible for the gizmos dragging interactions
  58348. */
  58349. dragBehavior: PointerDragBehavior;
  58350. private _pointerObserver;
  58351. /**
  58352. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  58353. */
  58354. snapDistance: number;
  58355. /**
  58356. * Event that fires each time the gizmo snaps to a new location.
  58357. * * snapDistance is the the change in distance
  58358. */
  58359. onSnapObservable: Observable<{
  58360. snapDistance: number;
  58361. }>;
  58362. private _isEnabled;
  58363. private _parent;
  58364. private _coloredMaterial;
  58365. private _hoverMaterial;
  58366. private _disableMaterial;
  58367. private _gizmoMesh;
  58368. private _rotationCircle;
  58369. private _dragging;
  58370. private static _CircleConstants;
  58371. /**
  58372. * Creates a PlaneRotationGizmo
  58373. * @param gizmoLayer The utility layer the gizmo will be added to
  58374. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  58375. * @param color The color of the gizmo
  58376. * @param tessellation Amount of tessellation to be used when creating rotation circles
  58377. * @param useEulerRotation Use and update Euler angle instead of quaternion
  58378. * @param thickness display gizmo axis thickness
  58379. */
  58380. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  58381. /** Create Geometry for Gizmo */
  58382. private _createGizmoMesh;
  58383. protected _attachedNodeChanged(value: Nullable<Node>): void;
  58384. private setupRotationCircle;
  58385. private updateRotationPath;
  58386. private updateRotationCircle;
  58387. /**
  58388. * If the gizmo is enabled
  58389. */
  58390. set isEnabled(value: boolean);
  58391. get isEnabled(): boolean;
  58392. /**
  58393. * Disposes of the gizmo
  58394. */
  58395. dispose(): void;
  58396. }
  58397. }
  58398. declare module BABYLON {
  58399. /**
  58400. * Gizmo that enables rotating a mesh along 3 axis
  58401. */
  58402. export class RotationGizmo extends Gizmo {
  58403. /**
  58404. * Internal gizmo used for interactions on the x axis
  58405. */
  58406. xGizmo: PlaneRotationGizmo;
  58407. /**
  58408. * Internal gizmo used for interactions on the y axis
  58409. */
  58410. yGizmo: PlaneRotationGizmo;
  58411. /**
  58412. * Internal gizmo used for interactions on the z axis
  58413. */
  58414. zGizmo: PlaneRotationGizmo;
  58415. /** Fires an event when any of it's sub gizmos are dragged */
  58416. onDragStartObservable: Observable<unknown>;
  58417. /** Fires an event when any of it's sub gizmos are released from dragging */
  58418. onDragEndObservable: Observable<unknown>;
  58419. private _meshAttached;
  58420. private _nodeAttached;
  58421. private _observables;
  58422. /** Node Caching for quick lookup */
  58423. private _gizmoAxisCache;
  58424. get attachedMesh(): Nullable<AbstractMesh>;
  58425. set attachedMesh(mesh: Nullable<AbstractMesh>);
  58426. get attachedNode(): Nullable<Node>;
  58427. set attachedNode(node: Nullable<Node>);
  58428. protected _checkBillboardTransform(): void;
  58429. /**
  58430. * True when the mouse pointer is hovering a gizmo mesh
  58431. */
  58432. get isHovered(): boolean;
  58433. /**
  58434. * Creates a RotationGizmo
  58435. * @param gizmoLayer The utility layer the gizmo will be added to
  58436. * @param tessellation Amount of tessellation to be used when creating rotation circles
  58437. * @param useEulerRotation Use and update Euler angle instead of quaternion
  58438. * @param thickness display gizmo axis thickness
  58439. */
  58440. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  58441. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  58442. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  58443. /**
  58444. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  58445. */
  58446. set snapDistance(value: number);
  58447. get snapDistance(): number;
  58448. /**
  58449. * Ratio for the scale of the gizmo (Default: 1)
  58450. */
  58451. set scaleRatio(value: number);
  58452. get scaleRatio(): number;
  58453. /**
  58454. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  58455. * @param mesh Axis gizmo mesh
  58456. * @param cache Gizmo axis definition used for reactive gizmo UI
  58457. */
  58458. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  58459. /**
  58460. * Disposes of the gizmo
  58461. */
  58462. dispose(): void;
  58463. /**
  58464. * CustomMeshes are not supported by this gizmo
  58465. * @param mesh The mesh to replace the default mesh of the gizmo
  58466. */
  58467. setCustomMesh(mesh: Mesh): void;
  58468. }
  58469. }
  58470. declare module BABYLON {
  58471. /**
  58472. * Class containing static functions to help procedurally build meshes
  58473. */
  58474. export class PolyhedronBuilder {
  58475. /**
  58476. * Creates a polyhedron mesh
  58477. * * 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
  58478. * * The parameter `size` (positive float, default 1) sets the polygon size
  58479. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  58480. * * 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`
  58481. * * 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
  58482. * * 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)`)
  58483. * * 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
  58484. * * 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
  58485. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58486. * * 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
  58487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58488. * @param name defines the name of the mesh
  58489. * @param options defines the options used to create the mesh
  58490. * @param scene defines the hosting scene
  58491. * @returns the polyhedron mesh
  58492. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  58493. */
  58494. static CreatePolyhedron(name: string, options: {
  58495. type?: number;
  58496. size?: number;
  58497. sizeX?: number;
  58498. sizeY?: number;
  58499. sizeZ?: number;
  58500. custom?: any;
  58501. faceUV?: Vector4[];
  58502. faceColors?: Color4[];
  58503. flat?: boolean;
  58504. updatable?: boolean;
  58505. sideOrientation?: number;
  58506. frontUVs?: Vector4;
  58507. backUVs?: Vector4;
  58508. }, scene?: Nullable<Scene>): Mesh;
  58509. }
  58510. }
  58511. declare module BABYLON {
  58512. /**
  58513. * Class containing static functions to help procedurally build meshes
  58514. */
  58515. export class BoxBuilder {
  58516. /**
  58517. * Creates a box mesh
  58518. * * The parameter `size` sets the size (float) of each box side (default 1)
  58519. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  58520. * * 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)
  58521. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58522. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58523. * * 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
  58524. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58525. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58526. * @param name defines the name of the mesh
  58527. * @param options defines the options used to create the mesh
  58528. * @param scene defines the hosting scene
  58529. * @returns the box mesh
  58530. */
  58531. static CreateBox(name: string, options: {
  58532. size?: number;
  58533. width?: number;
  58534. height?: number;
  58535. depth?: number;
  58536. faceUV?: Vector4[];
  58537. faceColors?: Color4[];
  58538. sideOrientation?: number;
  58539. frontUVs?: Vector4;
  58540. backUVs?: Vector4;
  58541. wrap?: boolean;
  58542. topBaseAt?: number;
  58543. bottomBaseAt?: number;
  58544. updatable?: boolean;
  58545. }, scene?: Nullable<Scene>): Mesh;
  58546. }
  58547. }
  58548. declare module BABYLON {
  58549. /**
  58550. * Single axis scale gizmo
  58551. */
  58552. export class AxisScaleGizmo extends Gizmo {
  58553. /**
  58554. * Drag behavior responsible for the gizmos dragging interactions
  58555. */
  58556. dragBehavior: PointerDragBehavior;
  58557. private _pointerObserver;
  58558. /**
  58559. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  58560. */
  58561. snapDistance: number;
  58562. /**
  58563. * Event that fires each time the gizmo snaps to a new location.
  58564. * * snapDistance is the the change in distance
  58565. */
  58566. onSnapObservable: Observable<{
  58567. snapDistance: number;
  58568. }>;
  58569. /**
  58570. * If the scaling operation should be done on all axis (default: false)
  58571. */
  58572. uniformScaling: boolean;
  58573. /**
  58574. * Custom sensitivity value for the drag strength
  58575. */
  58576. sensitivity: number;
  58577. private _isEnabled;
  58578. private _parent;
  58579. private _gizmoMesh;
  58580. private _coloredMaterial;
  58581. private _hoverMaterial;
  58582. private _disableMaterial;
  58583. private _dragging;
  58584. private _tmpVector;
  58585. private _tmpMatrix;
  58586. private _tmpMatrix2;
  58587. /**
  58588. * Creates an AxisScaleGizmo
  58589. * @param gizmoLayer The utility layer the gizmo will be added to
  58590. * @param dragAxis The axis which the gizmo will be able to scale on
  58591. * @param color The color of the gizmo
  58592. * @param thickness display gizmo axis thickness
  58593. */
  58594. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  58595. /** Create Geometry for Gizmo */
  58596. private _createGizmoMesh;
  58597. protected _attachedNodeChanged(value: Nullable<Node>): void;
  58598. /**
  58599. * If the gizmo is enabled
  58600. */
  58601. set isEnabled(value: boolean);
  58602. get isEnabled(): boolean;
  58603. /**
  58604. * Disposes of the gizmo
  58605. */
  58606. dispose(): void;
  58607. /**
  58608. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  58609. * @param mesh The mesh to replace the default mesh of the gizmo
  58610. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  58611. */
  58612. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  58613. }
  58614. }
  58615. declare module BABYLON {
  58616. /**
  58617. * Gizmo that enables scaling a mesh along 3 axis
  58618. */
  58619. export class ScaleGizmo extends Gizmo {
  58620. /**
  58621. * Internal gizmo used for interactions on the x axis
  58622. */
  58623. xGizmo: AxisScaleGizmo;
  58624. /**
  58625. * Internal gizmo used for interactions on the y axis
  58626. */
  58627. yGizmo: AxisScaleGizmo;
  58628. /**
  58629. * Internal gizmo used for interactions on the z axis
  58630. */
  58631. zGizmo: AxisScaleGizmo;
  58632. /**
  58633. * Internal gizmo used to scale all axis equally
  58634. */
  58635. uniformScaleGizmo: AxisScaleGizmo;
  58636. private _meshAttached;
  58637. private _nodeAttached;
  58638. private _snapDistance;
  58639. private _uniformScalingMesh;
  58640. private _octahedron;
  58641. private _sensitivity;
  58642. private _coloredMaterial;
  58643. private _hoverMaterial;
  58644. private _disableMaterial;
  58645. private _observables;
  58646. /** Node Caching for quick lookup */
  58647. private _gizmoAxisCache;
  58648. /** Fires an event when any of it's sub gizmos are dragged */
  58649. onDragStartObservable: Observable<unknown>;
  58650. /** Fires an event when any of it's sub gizmos are released from dragging */
  58651. onDragEndObservable: Observable<unknown>;
  58652. get attachedMesh(): Nullable<AbstractMesh>;
  58653. set attachedMesh(mesh: Nullable<AbstractMesh>);
  58654. get attachedNode(): Nullable<Node>;
  58655. set attachedNode(node: Nullable<Node>);
  58656. /**
  58657. * True when the mouse pointer is hovering a gizmo mesh
  58658. */
  58659. get isHovered(): boolean;
  58660. /**
  58661. * Creates a ScaleGizmo
  58662. * @param gizmoLayer The utility layer the gizmo will be added to
  58663. * @param thickness display gizmo axis thickness
  58664. */
  58665. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  58666. /** Create Geometry for Gizmo */
  58667. private _createUniformScaleMesh;
  58668. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  58669. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  58670. /**
  58671. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  58672. */
  58673. set snapDistance(value: number);
  58674. get snapDistance(): number;
  58675. /**
  58676. * Ratio for the scale of the gizmo (Default: 1)
  58677. */
  58678. set scaleRatio(value: number);
  58679. get scaleRatio(): number;
  58680. /**
  58681. * Sensitivity factor for dragging (Default: 1)
  58682. */
  58683. set sensitivity(value: number);
  58684. get sensitivity(): number;
  58685. /**
  58686. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  58687. * @param mesh Axis gizmo mesh
  58688. * @param cache Gizmo axis definition used for reactive gizmo UI
  58689. */
  58690. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  58691. /**
  58692. * Disposes of the gizmo
  58693. */
  58694. dispose(): void;
  58695. }
  58696. }
  58697. declare module BABYLON {
  58698. /**
  58699. * Bounding box gizmo
  58700. */
  58701. export class BoundingBoxGizmo extends Gizmo {
  58702. private _lineBoundingBox;
  58703. private _rotateSpheresParent;
  58704. private _scaleBoxesParent;
  58705. private _boundingDimensions;
  58706. private _renderObserver;
  58707. private _pointerObserver;
  58708. private _scaleDragSpeed;
  58709. private _tmpQuaternion;
  58710. private _tmpVector;
  58711. private _tmpRotationMatrix;
  58712. /**
  58713. * 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)
  58714. */
  58715. ignoreChildren: boolean;
  58716. /**
  58717. * 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)
  58718. */
  58719. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  58720. /**
  58721. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  58722. */
  58723. rotationSphereSize: number;
  58724. /**
  58725. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  58726. */
  58727. scaleBoxSize: number;
  58728. /**
  58729. * 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)
  58730. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  58731. */
  58732. fixedDragMeshScreenSize: boolean;
  58733. /**
  58734. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  58735. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  58736. */
  58737. fixedDragMeshBoundsSize: boolean;
  58738. /**
  58739. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  58740. */
  58741. fixedDragMeshScreenSizeDistanceFactor: number;
  58742. /**
  58743. * Fired when a rotation sphere or scale box is dragged
  58744. */
  58745. onDragStartObservable: Observable<{}>;
  58746. /**
  58747. * Fired when a scale box is dragged
  58748. */
  58749. onScaleBoxDragObservable: Observable<{}>;
  58750. /**
  58751. * Fired when a scale box drag is ended
  58752. */
  58753. onScaleBoxDragEndObservable: Observable<{}>;
  58754. /**
  58755. * Fired when a rotation sphere is dragged
  58756. */
  58757. onRotationSphereDragObservable: Observable<{}>;
  58758. /**
  58759. * Fired when a rotation sphere drag is ended
  58760. */
  58761. onRotationSphereDragEndObservable: Observable<{}>;
  58762. /**
  58763. * 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)
  58764. */
  58765. scalePivot: Nullable<Vector3>;
  58766. /**
  58767. * Mesh used as a pivot to rotate the attached node
  58768. */
  58769. private _anchorMesh;
  58770. private _existingMeshScale;
  58771. private _dragMesh;
  58772. private pointerDragBehavior;
  58773. private coloredMaterial;
  58774. private hoverColoredMaterial;
  58775. /**
  58776. * Sets the color of the bounding box gizmo
  58777. * @param color the color to set
  58778. */
  58779. setColor(color: Color3): void;
  58780. /**
  58781. * Creates an BoundingBoxGizmo
  58782. * @param gizmoLayer The utility layer the gizmo will be added to
  58783. * @param color The color of the gizmo
  58784. */
  58785. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  58786. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  58787. private _selectNode;
  58788. /**
  58789. * Updates the bounding box information for the Gizmo
  58790. */
  58791. updateBoundingBox(): void;
  58792. private _updateRotationSpheres;
  58793. private _updateScaleBoxes;
  58794. /**
  58795. * Enables rotation on the specified axis and disables rotation on the others
  58796. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  58797. */
  58798. setEnabledRotationAxis(axis: string): void;
  58799. /**
  58800. * Enables/disables scaling
  58801. * @param enable if scaling should be enabled
  58802. * @param homogeneousScaling defines if scaling should only be homogeneous
  58803. */
  58804. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  58805. private _updateDummy;
  58806. /**
  58807. * Enables a pointer drag behavior on the bounding box of the gizmo
  58808. */
  58809. enableDragBehavior(): void;
  58810. /**
  58811. * Disposes of the gizmo
  58812. */
  58813. dispose(): void;
  58814. /**
  58815. * 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)
  58816. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  58817. * @returns the bounding box mesh with the passed in mesh as a child
  58818. */
  58819. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  58820. /**
  58821. * CustomMeshes are not supported by this gizmo
  58822. * @param mesh The mesh to replace the default mesh of the gizmo
  58823. */
  58824. setCustomMesh(mesh: Mesh): void;
  58825. }
  58826. }
  58827. declare module BABYLON {
  58828. /**
  58829. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  58830. */
  58831. export class GizmoManager implements IDisposable {
  58832. private scene;
  58833. /**
  58834. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  58835. */
  58836. gizmos: {
  58837. positionGizmo: Nullable<PositionGizmo>;
  58838. rotationGizmo: Nullable<RotationGizmo>;
  58839. scaleGizmo: Nullable<ScaleGizmo>;
  58840. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  58841. };
  58842. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  58843. clearGizmoOnEmptyPointerEvent: boolean;
  58844. /** Fires an event when the manager is attached to a mesh */
  58845. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  58846. /** Fires an event when the manager is attached to a node */
  58847. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  58848. private _gizmosEnabled;
  58849. private _pointerObservers;
  58850. private _attachedMesh;
  58851. private _attachedNode;
  58852. private _boundingBoxColor;
  58853. private _defaultUtilityLayer;
  58854. private _defaultKeepDepthUtilityLayer;
  58855. private _thickness;
  58856. /** Node Caching for quick lookup */
  58857. private _gizmoAxisCache;
  58858. /**
  58859. * When bounding box gizmo is enabled, this can be used to track drag/end events
  58860. */
  58861. boundingBoxDragBehavior: SixDofDragBehavior;
  58862. /**
  58863. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  58864. */
  58865. attachableMeshes: Nullable<Array<AbstractMesh>>;
  58866. /**
  58867. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  58868. */
  58869. attachableNodes: Nullable<Array<Node>>;
  58870. /**
  58871. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  58872. */
  58873. usePointerToAttachGizmos: boolean;
  58874. /**
  58875. * Utility layer that the bounding box gizmo belongs to
  58876. */
  58877. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  58878. /**
  58879. * Utility layer that all gizmos besides bounding box belong to
  58880. */
  58881. get utilityLayer(): UtilityLayerRenderer;
  58882. /**
  58883. * True when the mouse pointer is hovering a gizmo mesh
  58884. */
  58885. get isHovered(): boolean;
  58886. /**
  58887. * Instantiates a gizmo manager
  58888. * @param scene the scene to overlay the gizmos on top of
  58889. * @param thickness display gizmo axis thickness
  58890. * @param utilityLayer the layer where gizmos are rendered
  58891. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  58892. */
  58893. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  58894. /**
  58895. * Subscribes to pointer down events, for attaching and detaching mesh
  58896. * @param scene The scene layer the observer will be added to
  58897. */
  58898. private _attachToMeshPointerObserver;
  58899. /**
  58900. * Attaches a set of gizmos to the specified mesh
  58901. * @param mesh The mesh the gizmo's should be attached to
  58902. */
  58903. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58904. /**
  58905. * Attaches a set of gizmos to the specified node
  58906. * @param node The node the gizmo's should be attached to
  58907. */
  58908. attachToNode(node: Nullable<Node>): void;
  58909. /**
  58910. * If the position gizmo is enabled
  58911. */
  58912. set positionGizmoEnabled(value: boolean);
  58913. get positionGizmoEnabled(): boolean;
  58914. /**
  58915. * If the rotation gizmo is enabled
  58916. */
  58917. set rotationGizmoEnabled(value: boolean);
  58918. get rotationGizmoEnabled(): boolean;
  58919. /**
  58920. * If the scale gizmo is enabled
  58921. */
  58922. set scaleGizmoEnabled(value: boolean);
  58923. get scaleGizmoEnabled(): boolean;
  58924. /**
  58925. * If the boundingBox gizmo is enabled
  58926. */
  58927. set boundingBoxGizmoEnabled(value: boolean);
  58928. get boundingBoxGizmoEnabled(): boolean;
  58929. /**
  58930. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  58931. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  58932. */
  58933. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  58934. /**
  58935. * Disposes of the gizmo manager
  58936. */
  58937. dispose(): void;
  58938. }
  58939. }
  58940. declare module BABYLON {
  58941. /**
  58942. * Gizmo that enables dragging a mesh along 3 axis
  58943. */
  58944. export class PositionGizmo extends Gizmo {
  58945. /**
  58946. * Internal gizmo used for interactions on the x axis
  58947. */
  58948. xGizmo: AxisDragGizmo;
  58949. /**
  58950. * Internal gizmo used for interactions on the y axis
  58951. */
  58952. yGizmo: AxisDragGizmo;
  58953. /**
  58954. * Internal gizmo used for interactions on the z axis
  58955. */
  58956. zGizmo: AxisDragGizmo;
  58957. /**
  58958. * Internal gizmo used for interactions on the yz plane
  58959. */
  58960. xPlaneGizmo: PlaneDragGizmo;
  58961. /**
  58962. * Internal gizmo used for interactions on the xz plane
  58963. */
  58964. yPlaneGizmo: PlaneDragGizmo;
  58965. /**
  58966. * Internal gizmo used for interactions on the xy plane
  58967. */
  58968. zPlaneGizmo: PlaneDragGizmo;
  58969. /**
  58970. * private variables
  58971. */
  58972. private _meshAttached;
  58973. private _nodeAttached;
  58974. private _snapDistance;
  58975. private _observables;
  58976. /** Node Caching for quick lookup */
  58977. private _gizmoAxisCache;
  58978. /** Fires an event when any of it's sub gizmos are dragged */
  58979. onDragStartObservable: Observable<unknown>;
  58980. /** Fires an event when any of it's sub gizmos are released from dragging */
  58981. onDragEndObservable: Observable<unknown>;
  58982. /**
  58983. * If set to true, planar drag is enabled
  58984. */
  58985. private _planarGizmoEnabled;
  58986. get attachedMesh(): Nullable<AbstractMesh>;
  58987. set attachedMesh(mesh: Nullable<AbstractMesh>);
  58988. get attachedNode(): Nullable<Node>;
  58989. set attachedNode(node: Nullable<Node>);
  58990. /**
  58991. * True when the mouse pointer is hovering a gizmo mesh
  58992. */
  58993. get isHovered(): boolean;
  58994. /**
  58995. * Creates a PositionGizmo
  58996. * @param gizmoLayer The utility layer the gizmo will be added to
  58997. @param thickness display gizmo axis thickness
  58998. */
  58999. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  59000. /**
  59001. * If the planar drag gizmo is enabled
  59002. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  59003. */
  59004. set planarGizmoEnabled(value: boolean);
  59005. get planarGizmoEnabled(): boolean;
  59006. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59007. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59008. /**
  59009. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59010. */
  59011. set snapDistance(value: number);
  59012. get snapDistance(): number;
  59013. /**
  59014. * Ratio for the scale of the gizmo (Default: 1)
  59015. */
  59016. set scaleRatio(value: number);
  59017. get scaleRatio(): number;
  59018. /**
  59019. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  59020. * @param mesh Axis gizmo mesh
  59021. * @param cache Gizmo axis definition used for reactive gizmo UI
  59022. */
  59023. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  59024. /**
  59025. * Disposes of the gizmo
  59026. */
  59027. dispose(): void;
  59028. /**
  59029. * CustomMeshes are not supported by this gizmo
  59030. * @param mesh The mesh to replace the default mesh of the gizmo
  59031. */
  59032. setCustomMesh(mesh: Mesh): void;
  59033. }
  59034. }
  59035. declare module BABYLON {
  59036. /**
  59037. * Single axis drag gizmo
  59038. */
  59039. export class AxisDragGizmo extends Gizmo {
  59040. /**
  59041. * Drag behavior responsible for the gizmos dragging interactions
  59042. */
  59043. dragBehavior: PointerDragBehavior;
  59044. private _pointerObserver;
  59045. /**
  59046. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59047. */
  59048. snapDistance: number;
  59049. /**
  59050. * Event that fires each time the gizmo snaps to a new location.
  59051. * * snapDistance is the the change in distance
  59052. */
  59053. onSnapObservable: Observable<{
  59054. snapDistance: number;
  59055. }>;
  59056. private _isEnabled;
  59057. private _parent;
  59058. private _gizmoMesh;
  59059. private _coloredMaterial;
  59060. private _hoverMaterial;
  59061. private _disableMaterial;
  59062. private _dragging;
  59063. /** @hidden */
  59064. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  59065. /** @hidden */
  59066. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  59067. /**
  59068. * Creates an AxisDragGizmo
  59069. * @param gizmoLayer The utility layer the gizmo will be added to
  59070. * @param dragAxis The axis which the gizmo will be able to drag on
  59071. * @param color The color of the gizmo
  59072. * @param thickness display gizmo axis thickness
  59073. */
  59074. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  59075. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59076. /**
  59077. * If the gizmo is enabled
  59078. */
  59079. set isEnabled(value: boolean);
  59080. get isEnabled(): boolean;
  59081. /**
  59082. * Disposes of the gizmo
  59083. */
  59084. dispose(): void;
  59085. }
  59086. }
  59087. declare module BABYLON.Debug {
  59088. /**
  59089. * The Axes viewer will show 3 axes in a specific point in space
  59090. */
  59091. export class AxesViewer {
  59092. private _xAxis;
  59093. private _yAxis;
  59094. private _zAxis;
  59095. private _scaleLinesFactor;
  59096. private _instanced;
  59097. /**
  59098. * Gets the hosting scene
  59099. */
  59100. scene: Nullable<Scene>;
  59101. /**
  59102. * Gets or sets a number used to scale line length
  59103. */
  59104. scaleLines: number;
  59105. /** Gets the node hierarchy used to render x-axis */
  59106. get xAxis(): TransformNode;
  59107. /** Gets the node hierarchy used to render y-axis */
  59108. get yAxis(): TransformNode;
  59109. /** Gets the node hierarchy used to render z-axis */
  59110. get zAxis(): TransformNode;
  59111. /**
  59112. * Creates a new AxesViewer
  59113. * @param scene defines the hosting scene
  59114. * @param scaleLines defines a number used to scale line length (1 by default)
  59115. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  59116. * @param xAxis defines the node hierarchy used to render the x-axis
  59117. * @param yAxis defines the node hierarchy used to render the y-axis
  59118. * @param zAxis defines the node hierarchy used to render the z-axis
  59119. */
  59120. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  59121. /**
  59122. * Force the viewer to update
  59123. * @param position defines the position of the viewer
  59124. * @param xaxis defines the x axis of the viewer
  59125. * @param yaxis defines the y axis of the viewer
  59126. * @param zaxis defines the z axis of the viewer
  59127. */
  59128. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  59129. /**
  59130. * Creates an instance of this axes viewer.
  59131. * @returns a new axes viewer with instanced meshes
  59132. */
  59133. createInstance(): AxesViewer;
  59134. /** Releases resources */
  59135. dispose(): void;
  59136. private static _SetRenderingGroupId;
  59137. }
  59138. }
  59139. declare module BABYLON.Debug {
  59140. /**
  59141. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  59142. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  59143. */
  59144. export class BoneAxesViewer extends AxesViewer {
  59145. /**
  59146. * Gets or sets the target mesh where to display the axes viewer
  59147. */
  59148. mesh: Nullable<Mesh>;
  59149. /**
  59150. * Gets or sets the target bone where to display the axes viewer
  59151. */
  59152. bone: Nullable<Bone>;
  59153. /** Gets current position */
  59154. pos: Vector3;
  59155. /** Gets direction of X axis */
  59156. xaxis: Vector3;
  59157. /** Gets direction of Y axis */
  59158. yaxis: Vector3;
  59159. /** Gets direction of Z axis */
  59160. zaxis: Vector3;
  59161. /**
  59162. * Creates a new BoneAxesViewer
  59163. * @param scene defines the hosting scene
  59164. * @param bone defines the target bone
  59165. * @param mesh defines the target mesh
  59166. * @param scaleLines defines a scaling factor for line length (1 by default)
  59167. */
  59168. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  59169. /**
  59170. * Force the viewer to update
  59171. */
  59172. update(): void;
  59173. /** Releases resources */
  59174. dispose(): void;
  59175. }
  59176. }
  59177. declare module BABYLON {
  59178. /**
  59179. * Interface used to define scene explorer extensibility option
  59180. */
  59181. export interface IExplorerExtensibilityOption {
  59182. /**
  59183. * Define the option label
  59184. */
  59185. label: string;
  59186. /**
  59187. * Defines the action to execute on click
  59188. */
  59189. action: (entity: any) => void;
  59190. }
  59191. /**
  59192. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  59193. */
  59194. export interface IExplorerExtensibilityGroup {
  59195. /**
  59196. * Defines a predicate to test if a given type mut be extended
  59197. */
  59198. predicate: (entity: any) => boolean;
  59199. /**
  59200. * Gets the list of options added to a type
  59201. */
  59202. entries: IExplorerExtensibilityOption[];
  59203. }
  59204. /**
  59205. * Interface used to define the options to use to create the Inspector
  59206. */
  59207. export interface IInspectorOptions {
  59208. /**
  59209. * Display in overlay mode (default: false)
  59210. */
  59211. overlay?: boolean;
  59212. /**
  59213. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  59214. */
  59215. globalRoot?: HTMLElement;
  59216. /**
  59217. * Display the Scene explorer
  59218. */
  59219. showExplorer?: boolean;
  59220. /**
  59221. * Display the property inspector
  59222. */
  59223. showInspector?: boolean;
  59224. /**
  59225. * Display in embed mode (both panes on the right)
  59226. */
  59227. embedMode?: boolean;
  59228. /**
  59229. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  59230. */
  59231. handleResize?: boolean;
  59232. /**
  59233. * Allow the panes to popup (default: true)
  59234. */
  59235. enablePopup?: boolean;
  59236. /**
  59237. * Allow the panes to be closed by users (default: true)
  59238. */
  59239. enableClose?: boolean;
  59240. /**
  59241. * Optional list of extensibility entries
  59242. */
  59243. explorerExtensibility?: IExplorerExtensibilityGroup[];
  59244. /**
  59245. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  59246. */
  59247. inspectorURL?: string;
  59248. /**
  59249. * Optional initial tab (default to DebugLayerTab.Properties)
  59250. */
  59251. initialTab?: DebugLayerTab;
  59252. }
  59253. interface Scene {
  59254. /**
  59255. * @hidden
  59256. * Backing field
  59257. */
  59258. _debugLayer: DebugLayer;
  59259. /**
  59260. * Gets the debug layer (aka Inspector) associated with the scene
  59261. * @see https://doc.babylonjs.com/features/playground_debuglayer
  59262. */
  59263. debugLayer: DebugLayer;
  59264. }
  59265. /**
  59266. * Enum of inspector action tab
  59267. */
  59268. export enum DebugLayerTab {
  59269. /**
  59270. * Properties tag (default)
  59271. */
  59272. Properties = 0,
  59273. /**
  59274. * Debug tab
  59275. */
  59276. Debug = 1,
  59277. /**
  59278. * Statistics tab
  59279. */
  59280. Statistics = 2,
  59281. /**
  59282. * Tools tab
  59283. */
  59284. Tools = 3,
  59285. /**
  59286. * Settings tab
  59287. */
  59288. Settings = 4
  59289. }
  59290. /**
  59291. * The debug layer (aka Inspector) is the go to tool in order to better understand
  59292. * what is happening in your scene
  59293. * @see https://doc.babylonjs.com/features/playground_debuglayer
  59294. */
  59295. export class DebugLayer {
  59296. /**
  59297. * Define the url to get the inspector script from.
  59298. * By default it uses the babylonjs CDN.
  59299. * @ignoreNaming
  59300. */
  59301. static InspectorURL: string;
  59302. private _scene;
  59303. private BJSINSPECTOR;
  59304. private _onPropertyChangedObservable?;
  59305. /**
  59306. * Observable triggered when a property is changed through the inspector.
  59307. */
  59308. get onPropertyChangedObservable(): any;
  59309. /**
  59310. * Instantiates a new debug layer.
  59311. * The debug layer (aka Inspector) is the go to tool in order to better understand
  59312. * what is happening in your scene
  59313. * @see https://doc.babylonjs.com/features/playground_debuglayer
  59314. * @param scene Defines the scene to inspect
  59315. */
  59316. constructor(scene: Scene);
  59317. /** Creates the inspector window. */
  59318. private _createInspector;
  59319. /**
  59320. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  59321. * @param entity defines the entity to select
  59322. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  59323. */
  59324. select(entity: any, lineContainerTitles?: string | string[]): void;
  59325. /** Get the inspector from bundle or global */
  59326. private _getGlobalInspector;
  59327. /**
  59328. * Get if the inspector is visible or not.
  59329. * @returns true if visible otherwise, false
  59330. */
  59331. isVisible(): boolean;
  59332. /**
  59333. * Hide the inspector and close its window.
  59334. */
  59335. hide(): void;
  59336. /**
  59337. * Update the scene in the inspector
  59338. */
  59339. setAsActiveScene(): void;
  59340. /**
  59341. * Launch the debugLayer.
  59342. * @param config Define the configuration of the inspector
  59343. * @return a promise fulfilled when the debug layer is visible
  59344. */
  59345. show(config?: IInspectorOptions): Promise<DebugLayer>;
  59346. }
  59347. }
  59348. declare module BABYLON.Debug {
  59349. /**
  59350. * Used to show the physics impostor around the specific mesh
  59351. */
  59352. export class PhysicsViewer {
  59353. /** @hidden */
  59354. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  59355. /** @hidden */
  59356. protected _meshes: Array<Nullable<AbstractMesh>>;
  59357. /** @hidden */
  59358. protected _scene: Nullable<Scene>;
  59359. /** @hidden */
  59360. protected _numMeshes: number;
  59361. /** @hidden */
  59362. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  59363. private _renderFunction;
  59364. private _utilityLayer;
  59365. private _debugBoxMesh;
  59366. private _debugSphereMesh;
  59367. private _debugCylinderMesh;
  59368. private _debugMaterial;
  59369. private _debugMeshMeshes;
  59370. /**
  59371. * Creates a new PhysicsViewer
  59372. * @param scene defines the hosting scene
  59373. */
  59374. constructor(scene: Scene);
  59375. /** @hidden */
  59376. protected _updateDebugMeshes(): void;
  59377. /**
  59378. * Renders a specified physic impostor
  59379. * @param impostor defines the impostor to render
  59380. * @param targetMesh defines the mesh represented by the impostor
  59381. * @returns the new debug mesh used to render the impostor
  59382. */
  59383. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  59384. /**
  59385. * Hides a specified physic impostor
  59386. * @param impostor defines the impostor to hide
  59387. */
  59388. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  59389. private _getDebugMaterial;
  59390. private _getDebugBoxMesh;
  59391. private _getDebugSphereMesh;
  59392. private _getDebugCylinderMesh;
  59393. private _getDebugMeshMesh;
  59394. private _getDebugMesh;
  59395. /** Releases all resources */
  59396. dispose(): void;
  59397. }
  59398. }
  59399. declare module BABYLON {
  59400. /**
  59401. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  59402. * in order to better appreciate the issue one might have.
  59403. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  59404. */
  59405. export class RayHelper {
  59406. /**
  59407. * Defines the ray we are currently tryin to visualize.
  59408. */
  59409. ray: Nullable<Ray>;
  59410. private _renderPoints;
  59411. private _renderLine;
  59412. private _renderFunction;
  59413. private _scene;
  59414. private _onAfterRenderObserver;
  59415. private _onAfterStepObserver;
  59416. private _attachedToMesh;
  59417. private _meshSpaceDirection;
  59418. private _meshSpaceOrigin;
  59419. /**
  59420. * Helper function to create a colored helper in a scene in one line.
  59421. * @param ray Defines the ray we are currently tryin to visualize
  59422. * @param scene Defines the scene the ray is used in
  59423. * @param color Defines the color we want to see the ray in
  59424. * @returns The newly created ray helper.
  59425. */
  59426. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  59427. /**
  59428. * Instantiate a new ray helper.
  59429. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  59430. * in order to better appreciate the issue one might have.
  59431. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  59432. * @param ray Defines the ray we are currently tryin to visualize
  59433. */
  59434. constructor(ray: Ray);
  59435. /**
  59436. * Shows the ray we are willing to debug.
  59437. * @param scene Defines the scene the ray needs to be rendered in
  59438. * @param color Defines the color the ray needs to be rendered in
  59439. */
  59440. show(scene: Scene, color?: Color3): void;
  59441. /**
  59442. * Hides the ray we are debugging.
  59443. */
  59444. hide(): void;
  59445. private _render;
  59446. /**
  59447. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  59448. * @param mesh Defines the mesh we want the helper attached to
  59449. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  59450. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  59451. * @param length Defines the length of the ray
  59452. */
  59453. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  59454. /**
  59455. * Detach the ray helper from the mesh it has previously been attached to.
  59456. */
  59457. detachFromMesh(): void;
  59458. private _updateToMesh;
  59459. /**
  59460. * Dispose the helper and release its associated resources.
  59461. */
  59462. dispose(): void;
  59463. }
  59464. }
  59465. declare module BABYLON {
  59466. /**
  59467. * Defines the options associated with the creation of a SkeletonViewer.
  59468. */
  59469. export interface ISkeletonViewerOptions {
  59470. /** Should the system pause animations before building the Viewer? */
  59471. pauseAnimations: boolean;
  59472. /** Should the system return the skeleton to rest before building? */
  59473. returnToRest: boolean;
  59474. /** public Display Mode of the Viewer */
  59475. displayMode: number;
  59476. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  59477. displayOptions: ISkeletonViewerDisplayOptions;
  59478. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  59479. computeBonesUsingShaders: boolean;
  59480. /** Flag ignore non weighted bones */
  59481. useAllBones: boolean;
  59482. }
  59483. /**
  59484. * Defines how to display the various bone meshes for the viewer.
  59485. */
  59486. export interface ISkeletonViewerDisplayOptions {
  59487. /** How far down to start tapering the bone spurs */
  59488. midStep?: number;
  59489. /** How big is the midStep? */
  59490. midStepFactor?: number;
  59491. /** Base for the Sphere Size */
  59492. sphereBaseSize?: number;
  59493. /** The ratio of the sphere to the longest bone in units */
  59494. sphereScaleUnit?: number;
  59495. /** Ratio for the Sphere Size */
  59496. sphereFactor?: number;
  59497. /** Whether a spur should attach its far end to the child bone position */
  59498. spurFollowsChild?: boolean;
  59499. /** Whether to show local axes or not */
  59500. showLocalAxes?: boolean;
  59501. /** Length of each local axis */
  59502. localAxesSize?: number;
  59503. }
  59504. /**
  59505. * Defines the constructor options for the BoneWeight Shader.
  59506. */
  59507. export interface IBoneWeightShaderOptions {
  59508. /** Skeleton to Map */
  59509. skeleton: Skeleton;
  59510. /** Colors for Uninfluenced bones */
  59511. colorBase?: Color3;
  59512. /** Colors for 0.0-0.25 Weight bones */
  59513. colorZero?: Color3;
  59514. /** Color for 0.25-0.5 Weight Influence */
  59515. colorQuarter?: Color3;
  59516. /** Color for 0.5-0.75 Weight Influence */
  59517. colorHalf?: Color3;
  59518. /** Color for 0.75-1 Weight Influence */
  59519. colorFull?: Color3;
  59520. /** Color for Zero Weight Influence */
  59521. targetBoneIndex?: number;
  59522. }
  59523. /**
  59524. * Simple structure of the gradient steps for the Color Map.
  59525. */
  59526. export interface ISkeletonMapShaderColorMapKnot {
  59527. /** Color of the Knot */
  59528. color: Color3;
  59529. /** Location of the Knot */
  59530. location: number;
  59531. }
  59532. /**
  59533. * Defines the constructor options for the SkeletonMap Shader.
  59534. */
  59535. export interface ISkeletonMapShaderOptions {
  59536. /** Skeleton to Map */
  59537. skeleton: Skeleton;
  59538. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  59539. colorMap?: ISkeletonMapShaderColorMapKnot[];
  59540. }
  59541. }
  59542. declare module BABYLON {
  59543. /**
  59544. * Class containing static functions to help procedurally build meshes
  59545. */
  59546. export class RibbonBuilder {
  59547. /**
  59548. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59549. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59550. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59551. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59552. * * 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
  59553. * * 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
  59554. * * 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
  59555. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59556. * * 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
  59557. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59558. * * 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
  59559. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59560. * * 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
  59561. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59563. * @param name defines the name of the mesh
  59564. * @param options defines the options used to create the mesh
  59565. * @param scene defines the hosting scene
  59566. * @returns the ribbon mesh
  59567. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59568. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59569. */
  59570. static CreateRibbon(name: string, options: {
  59571. pathArray: Vector3[][];
  59572. closeArray?: boolean;
  59573. closePath?: boolean;
  59574. offset?: number;
  59575. updatable?: boolean;
  59576. sideOrientation?: number;
  59577. frontUVs?: Vector4;
  59578. backUVs?: Vector4;
  59579. instance?: Mesh;
  59580. invertUV?: boolean;
  59581. uvs?: Vector2[];
  59582. colors?: Color4[];
  59583. }, scene?: Nullable<Scene>): Mesh;
  59584. }
  59585. }
  59586. declare module BABYLON {
  59587. /**
  59588. * Class containing static functions to help procedurally build meshes
  59589. */
  59590. export class ShapeBuilder {
  59591. /**
  59592. * 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.
  59593. * * 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.
  59594. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59595. * * 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.
  59596. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59597. * * 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
  59598. * * 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
  59599. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59600. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59601. * * 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
  59602. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59604. * @param name defines the name of the mesh
  59605. * @param options defines the options used to create the mesh
  59606. * @param scene defines the hosting scene
  59607. * @returns the extruded shape mesh
  59608. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59609. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59610. */
  59611. static ExtrudeShape(name: string, options: {
  59612. shape: Vector3[];
  59613. path: Vector3[];
  59614. scale?: number;
  59615. rotation?: number;
  59616. cap?: number;
  59617. updatable?: boolean;
  59618. sideOrientation?: number;
  59619. frontUVs?: Vector4;
  59620. backUVs?: Vector4;
  59621. instance?: Mesh;
  59622. invertUV?: boolean;
  59623. }, scene?: Nullable<Scene>): Mesh;
  59624. /**
  59625. * Creates an custom extruded shape mesh.
  59626. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59627. * * 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.
  59628. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59629. * * 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
  59630. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59631. * * 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
  59632. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59633. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59634. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59635. * * 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
  59636. * * 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
  59637. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59638. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59639. * * 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
  59640. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59642. * @param name defines the name of the mesh
  59643. * @param options defines the options used to create the mesh
  59644. * @param scene defines the hosting scene
  59645. * @returns the custom extruded shape mesh
  59646. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59647. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59648. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59649. */
  59650. static ExtrudeShapeCustom(name: string, options: {
  59651. shape: Vector3[];
  59652. path: Vector3[];
  59653. scaleFunction?: any;
  59654. rotationFunction?: any;
  59655. ribbonCloseArray?: boolean;
  59656. ribbonClosePath?: boolean;
  59657. cap?: number;
  59658. updatable?: boolean;
  59659. sideOrientation?: number;
  59660. frontUVs?: Vector4;
  59661. backUVs?: Vector4;
  59662. instance?: Mesh;
  59663. invertUV?: boolean;
  59664. }, scene?: Nullable<Scene>): Mesh;
  59665. private static _ExtrudeShapeGeneric;
  59666. }
  59667. }
  59668. declare module BABYLON.Debug {
  59669. /**
  59670. * Class used to render a debug view of a given skeleton
  59671. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  59672. */
  59673. export class SkeletonViewer {
  59674. /** defines the skeleton to render */
  59675. skeleton: Skeleton;
  59676. /** defines the mesh attached to the skeleton */
  59677. mesh: AbstractMesh;
  59678. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  59679. autoUpdateBonesMatrices: boolean;
  59680. /** defines the rendering group id to use with the viewer */
  59681. renderingGroupId: number;
  59682. /** is the options for the viewer */
  59683. options: Partial<ISkeletonViewerOptions>;
  59684. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  59685. static readonly DISPLAY_LINES: number;
  59686. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  59687. static readonly DISPLAY_SPHERES: number;
  59688. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  59689. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  59690. /** public static method to create a BoneWeight Shader
  59691. * @param options The constructor options
  59692. * @param scene The scene that the shader is scoped to
  59693. * @returns The created ShaderMaterial
  59694. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  59695. */
  59696. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  59697. /** public static method to create a BoneWeight Shader
  59698. * @param options The constructor options
  59699. * @param scene The scene that the shader is scoped to
  59700. * @returns The created ShaderMaterial
  59701. */
  59702. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  59703. /** private static method to create a BoneWeight Shader
  59704. * @param size The size of the buffer to create (usually the bone count)
  59705. * @param colorMap The gradient data to generate
  59706. * @param scene The scene that the shader is scoped to
  59707. * @returns an Array of floats from the color gradient values
  59708. */
  59709. private static _CreateBoneMapColorBuffer;
  59710. /** If SkeletonViewer scene scope. */
  59711. private _scene;
  59712. /** Gets or sets the color used to render the skeleton */
  59713. color: Color3;
  59714. /** Array of the points of the skeleton fo the line view. */
  59715. private _debugLines;
  59716. /** The SkeletonViewers Mesh. */
  59717. private _debugMesh;
  59718. /** The local axes Meshes. */
  59719. private _localAxes;
  59720. /** If SkeletonViewer is enabled. */
  59721. private _isEnabled;
  59722. /** If SkeletonViewer is ready. */
  59723. private _ready;
  59724. /** SkeletonViewer render observable. */
  59725. private _obs;
  59726. /** The Utility Layer to render the gizmos in. */
  59727. private _utilityLayer;
  59728. private _boneIndices;
  59729. /** Gets the Scene. */
  59730. get scene(): Scene;
  59731. /** Gets the utilityLayer. */
  59732. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  59733. /** Checks Ready Status. */
  59734. get isReady(): Boolean;
  59735. /** Sets Ready Status. */
  59736. set ready(value: boolean);
  59737. /** Gets the debugMesh */
  59738. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  59739. /** Sets the debugMesh */
  59740. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  59741. /** Gets the displayMode */
  59742. get displayMode(): number;
  59743. /** Sets the displayMode */
  59744. set displayMode(value: number);
  59745. /**
  59746. * Creates a new SkeletonViewer
  59747. * @param skeleton defines the skeleton to render
  59748. * @param mesh defines the mesh attached to the skeleton
  59749. * @param scene defines the hosting scene
  59750. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  59751. * @param renderingGroupId defines the rendering group id to use with the viewer
  59752. * @param options All of the extra constructor options for the SkeletonViewer
  59753. */
  59754. constructor(
  59755. /** defines the skeleton to render */
  59756. skeleton: Skeleton,
  59757. /** defines the mesh attached to the skeleton */
  59758. mesh: AbstractMesh,
  59759. /** The Scene scope*/
  59760. scene: Scene,
  59761. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  59762. autoUpdateBonesMatrices?: boolean,
  59763. /** defines the rendering group id to use with the viewer */
  59764. renderingGroupId?: number,
  59765. /** is the options for the viewer */
  59766. options?: Partial<ISkeletonViewerOptions>);
  59767. /** The Dynamic bindings for the update functions */
  59768. private _bindObs;
  59769. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  59770. update(): void;
  59771. /** Gets or sets a boolean indicating if the viewer is enabled */
  59772. set isEnabled(value: boolean);
  59773. get isEnabled(): boolean;
  59774. private _getBonePosition;
  59775. private _getLinesForBonesWithLength;
  59776. private _getLinesForBonesNoLength;
  59777. /** function to revert the mesh and scene back to the initial state. */
  59778. private _revert;
  59779. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  59780. private _getAbsoluteBindPoseToRef;
  59781. /** function to build and bind sphere joint points and spur bone representations. */
  59782. private _buildSpheresAndSpurs;
  59783. private _buildLocalAxes;
  59784. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  59785. private _displayLinesUpdate;
  59786. /** Changes the displayMode of the skeleton viewer
  59787. * @param mode The displayMode numerical value
  59788. */
  59789. changeDisplayMode(mode: number): void;
  59790. /** Sets a display option of the skeleton viewer
  59791. *
  59792. * | Option | Type | Default | Description |
  59793. * | ---------------- | ------- | ------- | ----------- |
  59794. * | 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`. |
  59795. * | 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`. |
  59796. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  59797. * | 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`. |
  59798. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  59799. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  59800. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  59801. *
  59802. * @param option String of the option name
  59803. * @param value The numerical option value
  59804. */
  59805. changeDisplayOptions(option: string, value: number): void;
  59806. /** Release associated resources */
  59807. dispose(): void;
  59808. }
  59809. }
  59810. declare module BABYLON {
  59811. /**
  59812. * A directional light is defined by a direction (what a surprise!).
  59813. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  59814. * 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.
  59815. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59816. */
  59817. export class DirectionalLight extends ShadowLight {
  59818. private _shadowFrustumSize;
  59819. /**
  59820. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  59821. */
  59822. get shadowFrustumSize(): number;
  59823. /**
  59824. * Specifies a fix frustum size for the shadow generation.
  59825. */
  59826. set shadowFrustumSize(value: number);
  59827. private _shadowOrthoScale;
  59828. /**
  59829. * Gets the shadow projection scale against the optimal computed one.
  59830. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  59831. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  59832. */
  59833. get shadowOrthoScale(): number;
  59834. /**
  59835. * Sets the shadow projection scale against the optimal computed one.
  59836. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  59837. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  59838. */
  59839. set shadowOrthoScale(value: number);
  59840. /**
  59841. * Automatically compute the projection matrix to best fit (including all the casters)
  59842. * on each frame.
  59843. */
  59844. autoUpdateExtends: boolean;
  59845. /**
  59846. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  59847. * on each frame. autoUpdateExtends must be set to true for this to work
  59848. */
  59849. autoCalcShadowZBounds: boolean;
  59850. private _orthoLeft;
  59851. private _orthoRight;
  59852. private _orthoTop;
  59853. private _orthoBottom;
  59854. /**
  59855. * Gets or sets the orthoLeft property used to build the light frustum
  59856. */
  59857. get orthoLeft(): number;
  59858. set orthoLeft(left: number);
  59859. /**
  59860. * Gets or sets the orthoRight property used to build the light frustum
  59861. */
  59862. get orthoRight(): number;
  59863. set orthoRight(right: number);
  59864. /**
  59865. * Gets or sets the orthoTop property used to build the light frustum
  59866. */
  59867. get orthoTop(): number;
  59868. set orthoTop(top: number);
  59869. /**
  59870. * Gets or sets the orthoBottom property used to build the light frustum
  59871. */
  59872. get orthoBottom(): number;
  59873. set orthoBottom(bottom: number);
  59874. /**
  59875. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  59876. * The directional light is emitted from everywhere in the given direction.
  59877. * It can cast shadows.
  59878. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59879. * @param name The friendly name of the light
  59880. * @param direction The direction of the light
  59881. * @param scene The scene the light belongs to
  59882. */
  59883. constructor(name: string, direction: Vector3, scene: Scene);
  59884. /**
  59885. * Returns the string "DirectionalLight".
  59886. * @return The class name
  59887. */
  59888. getClassName(): string;
  59889. /**
  59890. * Returns the integer 1.
  59891. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59892. */
  59893. getTypeID(): number;
  59894. /**
  59895. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  59896. * Returns the DirectionalLight Shadow projection matrix.
  59897. */
  59898. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59899. /**
  59900. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  59901. * Returns the DirectionalLight Shadow projection matrix.
  59902. */
  59903. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  59904. /**
  59905. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  59906. * Returns the DirectionalLight Shadow projection matrix.
  59907. */
  59908. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59909. protected _buildUniformLayout(): void;
  59910. /**
  59911. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  59912. * @param effect The effect to update
  59913. * @param lightIndex The index of the light in the effect to update
  59914. * @returns The directional light
  59915. */
  59916. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  59917. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  59918. /**
  59919. * Gets the minZ used for shadow according to both the scene and the light.
  59920. *
  59921. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  59922. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  59923. * @param activeCamera The camera we are returning the min for
  59924. * @returns the depth min z
  59925. */
  59926. getDepthMinZ(activeCamera: Camera): number;
  59927. /**
  59928. * Gets the maxZ used for shadow according to both the scene and the light.
  59929. *
  59930. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  59931. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  59932. * @param activeCamera The camera we are returning the max for
  59933. * @returns the depth max z
  59934. */
  59935. getDepthMaxZ(activeCamera: Camera): number;
  59936. /**
  59937. * Prepares the list of defines specific to the light type.
  59938. * @param defines the list of defines
  59939. * @param lightIndex defines the index of the light for the effect
  59940. */
  59941. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59942. }
  59943. }
  59944. declare module BABYLON {
  59945. /**
  59946. * Class used to render a debug view of the frustum for a directional light
  59947. * @see https://playground.babylonjs.com/#7EFGSG#3
  59948. */
  59949. export class DirectionalLightFrustumViewer {
  59950. private _scene;
  59951. private _light;
  59952. private _camera;
  59953. private _inverseViewMatrix;
  59954. private _visible;
  59955. private _rootNode;
  59956. private _lightHelperFrustumMeshes;
  59957. private _nearLinesPoints;
  59958. private _farLinesPoints;
  59959. private _trLinesPoints;
  59960. private _brLinesPoints;
  59961. private _tlLinesPoints;
  59962. private _blLinesPoints;
  59963. private _nearPlaneVertices;
  59964. private _farPlaneVertices;
  59965. private _rightPlaneVertices;
  59966. private _leftPlaneVertices;
  59967. private _topPlaneVertices;
  59968. private _bottomPlaneVertices;
  59969. private _oldPosition;
  59970. private _oldDirection;
  59971. private _oldAutoCalc;
  59972. private _oldMinZ;
  59973. private _oldMaxZ;
  59974. private _transparency;
  59975. /**
  59976. * Gets or sets the transparency of the frustum planes
  59977. */
  59978. get transparency(): number;
  59979. set transparency(alpha: number);
  59980. private _showLines;
  59981. /**
  59982. * true to display the edges of the frustum
  59983. */
  59984. get showLines(): boolean;
  59985. set showLines(show: boolean);
  59986. private _showPlanes;
  59987. /**
  59988. * true to display the planes of the frustum
  59989. */
  59990. get showPlanes(): boolean;
  59991. set showPlanes(show: boolean);
  59992. /**
  59993. * Creates a new frustum viewer
  59994. * @param light directional light to display the frustum for
  59995. * @param camera camera used to retrieve the minZ / maxZ values if the shadowMinZ/shadowMaxZ values of the light are not setup
  59996. */
  59997. constructor(light: DirectionalLight, camera: Camera);
  59998. /**
  59999. * Shows the frustum
  60000. */
  60001. show(): void;
  60002. /**
  60003. * Hides the frustum
  60004. */
  60005. hide(): void;
  60006. /**
  60007. * Updates the frustum.
  60008. * Call this method to update the frustum view if the light has changed position/direction
  60009. */
  60010. update(): void;
  60011. /**
  60012. * Dispose of the class / remove the frustum view
  60013. */
  60014. dispose(): void;
  60015. protected _createGeometry(): void;
  60016. protected _getInvertViewMatrix(): Matrix;
  60017. }
  60018. }
  60019. declare module BABYLON {
  60020. /**
  60021. * Type to handle enforcement of inputs
  60022. */
  60023. 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;
  60024. }
  60025. declare module BABYLON {
  60026. /**
  60027. * Class that handles all input for a specific device
  60028. */
  60029. export class DeviceSource<T extends DeviceType> {
  60030. /** Type of device */
  60031. readonly deviceType: DeviceType;
  60032. /** "Slot" or index that device is referenced in */
  60033. readonly deviceSlot: number;
  60034. /**
  60035. * Observable to handle device input changes per device
  60036. */
  60037. readonly onInputChangedObservable: Observable<{
  60038. inputIndex: DeviceInput<T>;
  60039. previousState: Nullable<number>;
  60040. currentState: Nullable<number>;
  60041. }>;
  60042. private readonly _deviceInputSystem;
  60043. /**
  60044. * Default Constructor
  60045. * @param deviceInputSystem Reference to DeviceInputSystem
  60046. * @param deviceType Type of device
  60047. * @param deviceSlot "Slot" or index that device is referenced in
  60048. */
  60049. constructor(deviceInputSystem: DeviceInputSystem,
  60050. /** Type of device */
  60051. deviceType: DeviceType,
  60052. /** "Slot" or index that device is referenced in */
  60053. deviceSlot?: number);
  60054. /**
  60055. * Get input for specific input
  60056. * @param inputIndex index of specific input on device
  60057. * @returns Input value from DeviceInputSystem
  60058. */
  60059. getInput(inputIndex: DeviceInput<T>): number;
  60060. }
  60061. /**
  60062. * Class to keep track of devices
  60063. */
  60064. export class DeviceSourceManager implements IDisposable {
  60065. /**
  60066. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  60067. */
  60068. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  60069. /**
  60070. * Observable to be triggered when after a device is disconnected
  60071. */
  60072. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  60073. private readonly _devices;
  60074. private readonly _firstDevice;
  60075. private readonly _deviceInputSystem;
  60076. /**
  60077. * Default Constructor
  60078. * @param engine engine to pull input element from
  60079. */
  60080. constructor(engine: Engine);
  60081. /**
  60082. * Gets a DeviceSource, given a type and slot
  60083. * @param deviceType Enum specifying device type
  60084. * @param deviceSlot "Slot" or index that device is referenced in
  60085. * @returns DeviceSource object
  60086. */
  60087. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  60088. /**
  60089. * Gets an array of DeviceSource objects for a given device type
  60090. * @param deviceType Enum specifying device type
  60091. * @returns Array of DeviceSource objects
  60092. */
  60093. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  60094. /**
  60095. * Returns a read-only list of all available devices
  60096. * @returns Read-only array with active devices
  60097. */
  60098. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  60099. /**
  60100. * Dispose of DeviceInputSystem and other parts
  60101. */
  60102. dispose(): void;
  60103. /**
  60104. * Function to add device name to device list
  60105. * @param deviceType Enum specifying device type
  60106. * @param deviceSlot "Slot" or index that device is referenced in
  60107. */
  60108. private _addDevice;
  60109. /**
  60110. * Function to remove device name to device list
  60111. * @param deviceType Enum specifying device type
  60112. * @param deviceSlot "Slot" or index that device is referenced in
  60113. */
  60114. private _removeDevice;
  60115. /**
  60116. * Updates array storing first connected device of each type
  60117. * @param type Type of Device
  60118. */
  60119. private _updateFirstDevices;
  60120. }
  60121. }
  60122. declare module BABYLON {
  60123. /**
  60124. * Options to create the null engine
  60125. */
  60126. export class NullEngineOptions {
  60127. /**
  60128. * Render width (Default: 512)
  60129. */
  60130. renderWidth: number;
  60131. /**
  60132. * Render height (Default: 256)
  60133. */
  60134. renderHeight: number;
  60135. /**
  60136. * Texture size (Default: 512)
  60137. */
  60138. textureSize: number;
  60139. /**
  60140. * If delta time between frames should be constant
  60141. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  60142. */
  60143. deterministicLockstep: boolean;
  60144. /**
  60145. * Maximum about of steps between frames (Default: 4)
  60146. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  60147. */
  60148. lockstepMaxSteps: number;
  60149. /**
  60150. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  60151. */
  60152. useHighPrecisionMatrix?: boolean;
  60153. }
  60154. /**
  60155. * The null engine class provides support for headless version of babylon.js.
  60156. * This can be used in server side scenario or for testing purposes
  60157. */
  60158. export class NullEngine extends Engine {
  60159. private _options;
  60160. /**
  60161. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  60162. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  60163. * @returns true if engine is in deterministic lock step mode
  60164. */
  60165. isDeterministicLockStep(): boolean;
  60166. /**
  60167. * Gets the max steps when engine is running in deterministic lock step
  60168. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  60169. * @returns the max steps
  60170. */
  60171. getLockstepMaxSteps(): number;
  60172. /**
  60173. * Gets the current hardware scaling level.
  60174. * By default the hardware scaling level is computed from the window device ratio.
  60175. * 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.
  60176. * @returns a number indicating the current hardware scaling level
  60177. */
  60178. getHardwareScalingLevel(): number;
  60179. constructor(options?: NullEngineOptions);
  60180. /**
  60181. * Creates a vertex buffer
  60182. * @param vertices the data for the vertex buffer
  60183. * @returns the new WebGL static buffer
  60184. */
  60185. createVertexBuffer(vertices: FloatArray): DataBuffer;
  60186. /**
  60187. * Creates a new index buffer
  60188. * @param indices defines the content of the index buffer
  60189. * @param updatable defines if the index buffer must be updatable
  60190. * @returns a new webGL buffer
  60191. */
  60192. createIndexBuffer(indices: IndicesArray): DataBuffer;
  60193. /**
  60194. * Clear the current render buffer or the current render target (if any is set up)
  60195. * @param color defines the color to use
  60196. * @param backBuffer defines if the back buffer must be cleared
  60197. * @param depth defines if the depth buffer must be cleared
  60198. * @param stencil defines if the stencil buffer must be cleared
  60199. */
  60200. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  60201. /**
  60202. * Gets the current render width
  60203. * @param useScreen defines if screen size must be used (or the current render target if any)
  60204. * @returns a number defining the current render width
  60205. */
  60206. getRenderWidth(useScreen?: boolean): number;
  60207. /**
  60208. * Gets the current render height
  60209. * @param useScreen defines if screen size must be used (or the current render target if any)
  60210. * @returns a number defining the current render height
  60211. */
  60212. getRenderHeight(useScreen?: boolean): number;
  60213. /**
  60214. * Set the WebGL's viewport
  60215. * @param viewport defines the viewport element to be used
  60216. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  60217. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  60218. */
  60219. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  60220. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  60221. /**
  60222. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  60223. * @param pipelineContext defines the pipeline context to use
  60224. * @param uniformsNames defines the list of uniform names
  60225. * @returns an array of webGL uniform locations
  60226. */
  60227. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  60228. /**
  60229. * Gets the lsit of active attributes for a given webGL program
  60230. * @param pipelineContext defines the pipeline context to use
  60231. * @param attributesNames defines the list of attribute names to get
  60232. * @returns an array of indices indicating the offset of each attribute
  60233. */
  60234. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  60235. /**
  60236. * Binds an effect to the webGL context
  60237. * @param effect defines the effect to bind
  60238. */
  60239. bindSamplers(effect: Effect): void;
  60240. /**
  60241. * Activates an effect, making it the current one (ie. the one used for rendering)
  60242. * @param effect defines the effect to activate
  60243. */
  60244. enableEffect(effect: Effect): void;
  60245. /**
  60246. * Set various states to the webGL context
  60247. * @param culling defines backface culling state
  60248. * @param zOffset defines the value to apply to zOffset (0 by default)
  60249. * @param force defines if states must be applied even if cache is up to date
  60250. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  60251. */
  60252. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  60253. /**
  60254. * Set the value of an uniform to an array of int32
  60255. * @param uniform defines the webGL uniform location where to store the value
  60256. * @param array defines the array of int32 to store
  60257. * @returns true if value was set
  60258. */
  60259. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60260. /**
  60261. * Set the value of an uniform to an array of int32 (stored as vec2)
  60262. * @param uniform defines the webGL uniform location where to store the value
  60263. * @param array defines the array of int32 to store
  60264. * @returns true if value was set
  60265. */
  60266. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60267. /**
  60268. * Set the value of an uniform to an array of int32 (stored as vec3)
  60269. * @param uniform defines the webGL uniform location where to store the value
  60270. * @param array defines the array of int32 to store
  60271. * @returns true if value was set
  60272. */
  60273. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60274. /**
  60275. * Set the value of an uniform to an array of int32 (stored as vec4)
  60276. * @param uniform defines the webGL uniform location where to store the value
  60277. * @param array defines the array of int32 to store
  60278. * @returns true if value was set
  60279. */
  60280. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60281. /**
  60282. * Set the value of an uniform to an array of float32
  60283. * @param uniform defines the webGL uniform location where to store the value
  60284. * @param array defines the array of float32 to store
  60285. * @returns true if value was set
  60286. */
  60287. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60288. /**
  60289. * Set the value of an uniform to an array of float32 (stored as vec2)
  60290. * @param uniform defines the webGL uniform location where to store the value
  60291. * @param array defines the array of float32 to store
  60292. * @returns true if value was set
  60293. */
  60294. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60295. /**
  60296. * Set the value of an uniform to an array of float32 (stored as vec3)
  60297. * @param uniform defines the webGL uniform location where to store the value
  60298. * @param array defines the array of float32 to store
  60299. * @returns true if value was set
  60300. */
  60301. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60302. /**
  60303. * Set the value of an uniform to an array of float32 (stored as vec4)
  60304. * @param uniform defines the webGL uniform location where to store the value
  60305. * @param array defines the array of float32 to store
  60306. * @returns true if value was set
  60307. */
  60308. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60309. /**
  60310. * Set the value of an uniform to an array of number
  60311. * @param uniform defines the webGL uniform location where to store the value
  60312. * @param array defines the array of number to store
  60313. * @returns true if value was set
  60314. */
  60315. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  60316. /**
  60317. * Set the value of an uniform to an array of number (stored as vec2)
  60318. * @param uniform defines the webGL uniform location where to store the value
  60319. * @param array defines the array of number to store
  60320. * @returns true if value was set
  60321. */
  60322. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  60323. /**
  60324. * Set the value of an uniform to an array of number (stored as vec3)
  60325. * @param uniform defines the webGL uniform location where to store the value
  60326. * @param array defines the array of number to store
  60327. * @returns true if value was set
  60328. */
  60329. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  60330. /**
  60331. * Set the value of an uniform to an array of number (stored as vec4)
  60332. * @param uniform defines the webGL uniform location where to store the value
  60333. * @param array defines the array of number to store
  60334. * @returns true if value was set
  60335. */
  60336. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  60337. /**
  60338. * Set the value of an uniform to an array of float32 (stored as matrices)
  60339. * @param uniform defines the webGL uniform location where to store the value
  60340. * @param matrices defines the array of float32 to store
  60341. * @returns true if value was set
  60342. */
  60343. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  60344. /**
  60345. * Set the value of an uniform to a matrix (3x3)
  60346. * @param uniform defines the webGL uniform location where to store the value
  60347. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  60348. * @returns true if value was set
  60349. */
  60350. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  60351. /**
  60352. * Set the value of an uniform to a matrix (2x2)
  60353. * @param uniform defines the webGL uniform location where to store the value
  60354. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  60355. * @returns true if value was set
  60356. */
  60357. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  60358. /**
  60359. * Set the value of an uniform to a number (float)
  60360. * @param uniform defines the webGL uniform location where to store the value
  60361. * @param value defines the float number to store
  60362. * @returns true if value was set
  60363. */
  60364. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  60365. /**
  60366. * Set the value of an uniform to a vec2
  60367. * @param uniform defines the webGL uniform location where to store the value
  60368. * @param x defines the 1st component of the value
  60369. * @param y defines the 2nd component of the value
  60370. * @returns true if value was set
  60371. */
  60372. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  60373. /**
  60374. * Set the value of an uniform to a vec3
  60375. * @param uniform defines the webGL uniform location where to store the value
  60376. * @param x defines the 1st component of the value
  60377. * @param y defines the 2nd component of the value
  60378. * @param z defines the 3rd component of the value
  60379. * @returns true if value was set
  60380. */
  60381. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  60382. /**
  60383. * Set the value of an uniform to a boolean
  60384. * @param uniform defines the webGL uniform location where to store the value
  60385. * @param bool defines the boolean to store
  60386. * @returns true if value was set
  60387. */
  60388. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  60389. /**
  60390. * Set the value of an uniform to a vec4
  60391. * @param uniform defines the webGL uniform location where to store the value
  60392. * @param x defines the 1st component of the value
  60393. * @param y defines the 2nd component of the value
  60394. * @param z defines the 3rd component of the value
  60395. * @param w defines the 4th component of the value
  60396. * @returns true if value was set
  60397. */
  60398. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  60399. /**
  60400. * Sets the current alpha mode
  60401. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  60402. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  60403. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  60404. */
  60405. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  60406. /**
  60407. * Bind webGl buffers directly to the webGL context
  60408. * @param vertexBuffers defines the vertex buffer to bind
  60409. * @param indexBuffer defines the index buffer to bind
  60410. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  60411. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  60412. * @param effect defines the effect associated with the vertex buffer
  60413. */
  60414. bindBuffers(vertexBuffers: {
  60415. [key: string]: VertexBuffer;
  60416. }, indexBuffer: DataBuffer, effect: Effect): void;
  60417. /**
  60418. * Force the entire cache to be cleared
  60419. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  60420. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  60421. */
  60422. wipeCaches(bruteForce?: boolean): void;
  60423. /**
  60424. * Send a draw order
  60425. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  60426. * @param indexStart defines the starting index
  60427. * @param indexCount defines the number of index to draw
  60428. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  60429. */
  60430. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  60431. /**
  60432. * Draw a list of indexed primitives
  60433. * @param fillMode defines the primitive to use
  60434. * @param indexStart defines the starting index
  60435. * @param indexCount defines the number of index to draw
  60436. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  60437. */
  60438. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  60439. /**
  60440. * Draw a list of unindexed primitives
  60441. * @param fillMode defines the primitive to use
  60442. * @param verticesStart defines the index of first vertex to draw
  60443. * @param verticesCount defines the count of vertices to draw
  60444. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  60445. */
  60446. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  60447. /** @hidden */
  60448. protected _createTexture(): WebGLTexture;
  60449. /** @hidden */
  60450. _releaseTexture(texture: InternalTexture): void;
  60451. /**
  60452. * Usually called from Texture.ts.
  60453. * Passed information to create a WebGLTexture
  60454. * @param urlArg defines a value which contains one of the following:
  60455. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  60456. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  60457. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  60458. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  60459. * @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)
  60460. * @param scene needed for loading to the correct scene
  60461. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  60462. * @param onLoad optional callback to be called upon successful completion
  60463. * @param onError optional callback to be called upon failure
  60464. * @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
  60465. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  60466. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  60467. * @param forcedExtension defines the extension to use to pick the right loader
  60468. * @param mimeType defines an optional mime type
  60469. * @returns a InternalTexture for assignment back into BABYLON.Texture
  60470. */
  60471. 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;
  60472. /**
  60473. * Creates a new render target texture
  60474. * @param size defines the size of the texture
  60475. * @param options defines the options used to create the texture
  60476. * @returns a new render target texture stored in an InternalTexture
  60477. */
  60478. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  60479. /**
  60480. * Update the sampling mode of a given texture
  60481. * @param samplingMode defines the required sampling mode
  60482. * @param texture defines the texture to update
  60483. */
  60484. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  60485. /**
  60486. * Binds the frame buffer to the specified texture.
  60487. * @param texture The texture to render to or null for the default canvas
  60488. * @param faceIndex The face of the texture to render to in case of cube texture
  60489. * @param requiredWidth The width of the target to render to
  60490. * @param requiredHeight The height of the target to render to
  60491. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  60492. * @param lodLevel defines le lod level to bind to the frame buffer
  60493. */
  60494. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  60495. /**
  60496. * Unbind the current render target texture from the webGL context
  60497. * @param texture defines the render target texture to unbind
  60498. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  60499. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  60500. */
  60501. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  60502. /**
  60503. * Creates a dynamic vertex buffer
  60504. * @param vertices the data for the dynamic vertex buffer
  60505. * @returns the new WebGL dynamic buffer
  60506. */
  60507. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  60508. /**
  60509. * Update the content of a dynamic texture
  60510. * @param texture defines the texture to update
  60511. * @param canvas defines the canvas containing the source
  60512. * @param invertY defines if data must be stored with Y axis inverted
  60513. * @param premulAlpha defines if alpha is stored as premultiplied
  60514. * @param format defines the format of the data
  60515. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  60516. */
  60517. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  60518. /**
  60519. * Gets a boolean indicating if all created effects are ready
  60520. * @returns true if all effects are ready
  60521. */
  60522. areAllEffectsReady(): boolean;
  60523. /**
  60524. * @hidden
  60525. * Get the current error code of the webGL context
  60526. * @returns the error code
  60527. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  60528. */
  60529. getError(): number;
  60530. /** @hidden */
  60531. _getUnpackAlignement(): number;
  60532. /** @hidden */
  60533. _unpackFlipY(value: boolean): void;
  60534. /**
  60535. * Update a dynamic index buffer
  60536. * @param indexBuffer defines the target index buffer
  60537. * @param indices defines the data to update
  60538. * @param offset defines the offset in the target index buffer where update should start
  60539. */
  60540. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  60541. /**
  60542. * Updates a dynamic vertex buffer.
  60543. * @param vertexBuffer the vertex buffer to update
  60544. * @param vertices the data used to update the vertex buffer
  60545. * @param byteOffset the byte offset of the data (optional)
  60546. * @param byteLength the byte length of the data (optional)
  60547. */
  60548. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  60549. /** @hidden */
  60550. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  60551. /** @hidden */
  60552. _bindTexture(channel: number, texture: InternalTexture): void;
  60553. protected _deleteBuffer(buffer: WebGLBuffer): void;
  60554. /**
  60555. * 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
  60556. */
  60557. releaseEffects(): void;
  60558. displayLoadingUI(): void;
  60559. hideLoadingUI(): void;
  60560. /** @hidden */
  60561. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60562. /** @hidden */
  60563. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60564. /** @hidden */
  60565. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60566. /** @hidden */
  60567. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  60568. }
  60569. }
  60570. declare module BABYLON {
  60571. /** @hidden */
  60572. export class _OcclusionDataStorage {
  60573. /** @hidden */
  60574. occlusionInternalRetryCounter: number;
  60575. /** @hidden */
  60576. isOcclusionQueryInProgress: boolean;
  60577. /** @hidden */
  60578. isOccluded: boolean;
  60579. /** @hidden */
  60580. occlusionRetryCount: number;
  60581. /** @hidden */
  60582. occlusionType: number;
  60583. /** @hidden */
  60584. occlusionQueryAlgorithmType: number;
  60585. }
  60586. interface Engine {
  60587. /**
  60588. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  60589. * @return the new query
  60590. */
  60591. createQuery(): WebGLQuery;
  60592. /**
  60593. * Delete and release a webGL query
  60594. * @param query defines the query to delete
  60595. * @return the current engine
  60596. */
  60597. deleteQuery(query: WebGLQuery): Engine;
  60598. /**
  60599. * Check if a given query has resolved and got its value
  60600. * @param query defines the query to check
  60601. * @returns true if the query got its value
  60602. */
  60603. isQueryResultAvailable(query: WebGLQuery): boolean;
  60604. /**
  60605. * Gets the value of a given query
  60606. * @param query defines the query to check
  60607. * @returns the value of the query
  60608. */
  60609. getQueryResult(query: WebGLQuery): number;
  60610. /**
  60611. * Initiates an occlusion query
  60612. * @param algorithmType defines the algorithm to use
  60613. * @param query defines the query to use
  60614. * @returns the current engine
  60615. * @see https://doc.babylonjs.com/features/occlusionquery
  60616. */
  60617. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  60618. /**
  60619. * Ends an occlusion query
  60620. * @see https://doc.babylonjs.com/features/occlusionquery
  60621. * @param algorithmType defines the algorithm to use
  60622. * @returns the current engine
  60623. */
  60624. endOcclusionQuery(algorithmType: number): Engine;
  60625. /**
  60626. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  60627. * Please note that only one query can be issued at a time
  60628. * @returns a time token used to track the time span
  60629. */
  60630. startTimeQuery(): Nullable<_TimeToken>;
  60631. /**
  60632. * Ends a time query
  60633. * @param token defines the token used to measure the time span
  60634. * @returns the time spent (in ns)
  60635. */
  60636. endTimeQuery(token: _TimeToken): int;
  60637. /** @hidden */
  60638. _currentNonTimestampToken: Nullable<_TimeToken>;
  60639. /** @hidden */
  60640. _createTimeQuery(): WebGLQuery;
  60641. /** @hidden */
  60642. _deleteTimeQuery(query: WebGLQuery): void;
  60643. /** @hidden */
  60644. _getGlAlgorithmType(algorithmType: number): number;
  60645. /** @hidden */
  60646. _getTimeQueryResult(query: WebGLQuery): any;
  60647. /** @hidden */
  60648. _getTimeQueryAvailability(query: WebGLQuery): any;
  60649. }
  60650. interface AbstractMesh {
  60651. /**
  60652. * Backing filed
  60653. * @hidden
  60654. */
  60655. __occlusionDataStorage: _OcclusionDataStorage;
  60656. /**
  60657. * Access property
  60658. * @hidden
  60659. */
  60660. _occlusionDataStorage: _OcclusionDataStorage;
  60661. /**
  60662. * 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.
  60663. * The default value is -1 which means don't break the query and wait till the result
  60664. * @see https://doc.babylonjs.com/features/occlusionquery
  60665. */
  60666. occlusionRetryCount: number;
  60667. /**
  60668. * 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:
  60669. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query within the Mesh.
  60670. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  60671. * * 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.
  60672. * @see https://doc.babylonjs.com/features/occlusionquery
  60673. */
  60674. occlusionType: number;
  60675. /**
  60676. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  60677. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  60678. * * 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.
  60679. * @see https://doc.babylonjs.com/features/occlusionquery
  60680. */
  60681. occlusionQueryAlgorithmType: number;
  60682. /**
  60683. * 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
  60684. * @see https://doc.babylonjs.com/features/occlusionquery
  60685. */
  60686. isOccluded: boolean;
  60687. /**
  60688. * Flag to check the progress status of the query
  60689. * @see https://doc.babylonjs.com/features/occlusionquery
  60690. */
  60691. isOcclusionQueryInProgress: boolean;
  60692. }
  60693. }
  60694. declare module BABYLON {
  60695. /** @hidden */
  60696. export var _forceTransformFeedbackToBundle: boolean;
  60697. interface Engine {
  60698. /**
  60699. * Creates a webGL transform feedback object
  60700. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  60701. * @returns the webGL transform feedback object
  60702. */
  60703. createTransformFeedback(): WebGLTransformFeedback;
  60704. /**
  60705. * Delete a webGL transform feedback object
  60706. * @param value defines the webGL transform feedback object to delete
  60707. */
  60708. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  60709. /**
  60710. * Bind a webGL transform feedback object to the webgl context
  60711. * @param value defines the webGL transform feedback object to bind
  60712. */
  60713. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  60714. /**
  60715. * Begins a transform feedback operation
  60716. * @param usePoints defines if points or triangles must be used
  60717. */
  60718. beginTransformFeedback(usePoints: boolean): void;
  60719. /**
  60720. * Ends a transform feedback operation
  60721. */
  60722. endTransformFeedback(): void;
  60723. /**
  60724. * Specify the varyings to use with transform feedback
  60725. * @param program defines the associated webGL program
  60726. * @param value defines the list of strings representing the varying names
  60727. */
  60728. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  60729. /**
  60730. * Bind a webGL buffer for a transform feedback operation
  60731. * @param value defines the webGL buffer to bind
  60732. */
  60733. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  60734. }
  60735. }
  60736. declare module BABYLON {
  60737. /**
  60738. * Class used to define an additional view for the engine
  60739. * @see https://doc.babylonjs.com/how_to/multi_canvases
  60740. */
  60741. export class EngineView {
  60742. /** Defines the canvas where to render the view */
  60743. target: HTMLCanvasElement;
  60744. /** Defines an optional camera used to render the view (will use active camera else) */
  60745. camera?: Camera;
  60746. }
  60747. interface Engine {
  60748. /**
  60749. * Gets or sets the HTML element to use for attaching events
  60750. */
  60751. inputElement: Nullable<HTMLElement>;
  60752. /**
  60753. * Gets the current engine view
  60754. * @see https://doc.babylonjs.com/how_to/multi_canvases
  60755. */
  60756. activeView: Nullable<EngineView>;
  60757. /** Gets or sets the list of views */
  60758. views: EngineView[];
  60759. /**
  60760. * Register a new child canvas
  60761. * @param canvas defines the canvas to register
  60762. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  60763. * @returns the associated view
  60764. */
  60765. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  60766. /**
  60767. * Remove a registered child canvas
  60768. * @param canvas defines the canvas to remove
  60769. * @returns the current engine
  60770. */
  60771. unRegisterView(canvas: HTMLCanvasElement): Engine;
  60772. }
  60773. }
  60774. declare module BABYLON {
  60775. interface Engine {
  60776. /** @hidden */
  60777. _excludedCompressedTextures: string[];
  60778. /** @hidden */
  60779. _textureFormatInUse: string;
  60780. /**
  60781. * Gets the list of texture formats supported
  60782. */
  60783. readonly texturesSupported: Array<string>;
  60784. /**
  60785. * Gets the texture format in use
  60786. */
  60787. readonly textureFormatInUse: Nullable<string>;
  60788. /**
  60789. * Set the compressed texture extensions or file names to skip.
  60790. *
  60791. * @param skippedFiles defines the list of those texture files you want to skip
  60792. * Example: [".dds", ".env", "myfile.png"]
  60793. */
  60794. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  60795. /**
  60796. * Set the compressed texture format to use, based on the formats you have, and the formats
  60797. * supported by the hardware / browser.
  60798. *
  60799. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  60800. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  60801. * to API arguments needed to compressed textures. This puts the burden on the container
  60802. * generator to house the arcane code for determining these for current & future formats.
  60803. *
  60804. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  60805. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  60806. *
  60807. * Note: The result of this call is not taken into account when a texture is base64.
  60808. *
  60809. * @param formatsAvailable defines the list of those format families you have created
  60810. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  60811. *
  60812. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  60813. * @returns The extension selected.
  60814. */
  60815. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  60816. }
  60817. }
  60818. declare module BABYLON {
  60819. /** @hidden */
  60820. export var rgbdEncodePixelShader: {
  60821. name: string;
  60822. shader: string;
  60823. };
  60824. }
  60825. declare module BABYLON {
  60826. /**
  60827. * Raw texture data and descriptor sufficient for WebGL texture upload
  60828. */
  60829. export interface EnvironmentTextureInfo {
  60830. /**
  60831. * Version of the environment map
  60832. */
  60833. version: number;
  60834. /**
  60835. * Width of image
  60836. */
  60837. width: number;
  60838. /**
  60839. * Irradiance information stored in the file.
  60840. */
  60841. irradiance: any;
  60842. /**
  60843. * Specular information stored in the file.
  60844. */
  60845. specular: any;
  60846. }
  60847. /**
  60848. * Defines One Image in the file. It requires only the position in the file
  60849. * as well as the length.
  60850. */
  60851. interface BufferImageData {
  60852. /**
  60853. * Length of the image data.
  60854. */
  60855. length: number;
  60856. /**
  60857. * Position of the data from the null terminator delimiting the end of the JSON.
  60858. */
  60859. position: number;
  60860. }
  60861. /**
  60862. * Defines the specular data enclosed in the file.
  60863. * This corresponds to the version 1 of the data.
  60864. */
  60865. export interface EnvironmentTextureSpecularInfoV1 {
  60866. /**
  60867. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  60868. */
  60869. specularDataPosition?: number;
  60870. /**
  60871. * This contains all the images data needed to reconstruct the cubemap.
  60872. */
  60873. mipmaps: Array<BufferImageData>;
  60874. /**
  60875. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  60876. */
  60877. lodGenerationScale: number;
  60878. }
  60879. /**
  60880. * Sets of helpers addressing the serialization and deserialization of environment texture
  60881. * stored in a BabylonJS env file.
  60882. * Those files are usually stored as .env files.
  60883. */
  60884. export class EnvironmentTextureTools {
  60885. /**
  60886. * Magic number identifying the env file.
  60887. */
  60888. private static _MagicBytes;
  60889. /**
  60890. * Gets the environment info from an env file.
  60891. * @param data The array buffer containing the .env bytes.
  60892. * @returns the environment file info (the json header) if successfully parsed.
  60893. */
  60894. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  60895. /**
  60896. * Creates an environment texture from a loaded cube texture.
  60897. * @param texture defines the cube texture to convert in env file
  60898. * @return a promise containing the environment data if successful.
  60899. */
  60900. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  60901. /**
  60902. * Creates a JSON representation of the spherical data.
  60903. * @param texture defines the texture containing the polynomials
  60904. * @return the JSON representation of the spherical info
  60905. */
  60906. private static _CreateEnvTextureIrradiance;
  60907. /**
  60908. * Creates the ArrayBufferViews used for initializing environment texture image data.
  60909. * @param data the image data
  60910. * @param info parameters that determine what views will be created for accessing the underlying buffer
  60911. * @return the views described by info providing access to the underlying buffer
  60912. */
  60913. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  60914. /**
  60915. * Uploads the texture info contained in the env file to the GPU.
  60916. * @param texture defines the internal texture to upload to
  60917. * @param data defines the data to load
  60918. * @param info defines the texture info retrieved through the GetEnvInfo method
  60919. * @returns a promise
  60920. */
  60921. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  60922. private static _OnImageReadyAsync;
  60923. /**
  60924. * Uploads the levels of image data to the GPU.
  60925. * @param texture defines the internal texture to upload to
  60926. * @param imageData defines the array buffer views of image data [mipmap][face]
  60927. * @returns a promise
  60928. */
  60929. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  60930. /**
  60931. * Uploads spherical polynomials information to the texture.
  60932. * @param texture defines the texture we are trying to upload the information to
  60933. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  60934. */
  60935. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  60936. /** @hidden */
  60937. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  60938. }
  60939. }
  60940. declare module BABYLON {
  60941. /**
  60942. * Container for accessors for natively-stored mesh data buffers.
  60943. */
  60944. class NativeDataBuffer extends DataBuffer {
  60945. /**
  60946. * Accessor value used to identify/retrieve a natively-stored index buffer.
  60947. */
  60948. nativeIndexBuffer?: any;
  60949. /**
  60950. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  60951. */
  60952. nativeVertexBuffer?: any;
  60953. }
  60954. /** @hidden */
  60955. class NativeTexture extends InternalTexture {
  60956. getInternalTexture(): InternalTexture;
  60957. getViewCount(): number;
  60958. }
  60959. /** @hidden */
  60960. export class NativeEngine extends Engine {
  60961. private readonly _native;
  60962. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  60963. private readonly INVALID_HANDLE;
  60964. private _boundBuffersVertexArray;
  60965. private _currentDepthTest;
  60966. getHardwareScalingLevel(): number;
  60967. constructor();
  60968. dispose(): void;
  60969. /**
  60970. * Can be used to override the current requestAnimationFrame requester.
  60971. * @hidden
  60972. */
  60973. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  60974. /**
  60975. * Override default engine behavior.
  60976. * @param color
  60977. * @param backBuffer
  60978. * @param depth
  60979. * @param stencil
  60980. */
  60981. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  60982. /**
  60983. * Gets host document
  60984. * @returns the host document object
  60985. */
  60986. getHostDocument(): Nullable<Document>;
  60987. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  60988. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  60989. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  60990. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  60991. [key: string]: VertexBuffer;
  60992. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  60993. bindBuffers(vertexBuffers: {
  60994. [key: string]: VertexBuffer;
  60995. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  60996. recordVertexArrayObject(vertexBuffers: {
  60997. [key: string]: VertexBuffer;
  60998. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  60999. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  61000. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  61001. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  61002. /**
  61003. * Draw a list of indexed primitives
  61004. * @param fillMode defines the primitive to use
  61005. * @param indexStart defines the starting index
  61006. * @param indexCount defines the number of index to draw
  61007. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  61008. */
  61009. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  61010. /**
  61011. * Draw a list of unindexed primitives
  61012. * @param fillMode defines the primitive to use
  61013. * @param verticesStart defines the index of first vertex to draw
  61014. * @param verticesCount defines the count of vertices to draw
  61015. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  61016. */
  61017. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  61018. createPipelineContext(): IPipelineContext;
  61019. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  61020. /** @hidden */
  61021. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  61022. /** @hidden */
  61023. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  61024. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  61025. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  61026. protected _setProgram(program: WebGLProgram): void;
  61027. _releaseEffect(effect: Effect): void;
  61028. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  61029. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  61030. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  61031. bindSamplers(effect: Effect): void;
  61032. setMatrix(uniform: WebGLUniformLocation, matrix: IMatrixLike): void;
  61033. getRenderWidth(useScreen?: boolean): number;
  61034. getRenderHeight(useScreen?: boolean): number;
  61035. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  61036. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  61037. /**
  61038. * Gets the client rect of native canvas. Needed for InputManager.
  61039. * @returns a client rectangle
  61040. */
  61041. getInputElementClientRect(): Nullable<ClientRect>;
  61042. /**
  61043. * Set the z offset to apply to current rendering
  61044. * @param value defines the offset to apply
  61045. */
  61046. setZOffset(value: number): void;
  61047. /**
  61048. * Gets the current value of the zOffset
  61049. * @returns the current zOffset state
  61050. */
  61051. getZOffset(): number;
  61052. /**
  61053. * Enable or disable depth buffering
  61054. * @param enable defines the state to set
  61055. */
  61056. setDepthBuffer(enable: boolean): void;
  61057. /**
  61058. * Gets a boolean indicating if depth writing is enabled
  61059. * @returns the current depth writing state
  61060. */
  61061. getDepthWrite(): boolean;
  61062. setDepthFunctionToGreater(): void;
  61063. setDepthFunctionToGreaterOrEqual(): void;
  61064. setDepthFunctionToLess(): void;
  61065. setDepthFunctionToLessOrEqual(): void;
  61066. /**
  61067. * Enable or disable depth writing
  61068. * @param enable defines the state to set
  61069. */
  61070. setDepthWrite(enable: boolean): void;
  61071. /**
  61072. * Enable or disable color writing
  61073. * @param enable defines the state to set
  61074. */
  61075. setColorWrite(enable: boolean): void;
  61076. /**
  61077. * Gets a boolean indicating if color writing is enabled
  61078. * @returns the current color writing state
  61079. */
  61080. getColorWrite(): boolean;
  61081. /**
  61082. * Sets alpha constants used by some alpha blending modes
  61083. * @param r defines the red component
  61084. * @param g defines the green component
  61085. * @param b defines the blue component
  61086. * @param a defines the alpha component
  61087. */
  61088. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  61089. /**
  61090. * Sets the current alpha mode
  61091. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  61092. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  61093. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  61094. */
  61095. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  61096. /**
  61097. * Gets the current alpha mode
  61098. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  61099. * @returns the current alpha mode
  61100. */
  61101. getAlphaMode(): number;
  61102. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  61103. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  61104. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  61105. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  61106. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  61107. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  61108. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  61109. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  61110. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  61111. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  61112. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  61113. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  61114. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  61115. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  61116. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  61117. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  61118. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  61119. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  61120. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  61121. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  61122. setColor3(uniform: WebGLUniformLocation, color3: IColor3Like): boolean;
  61123. setColor4(uniform: WebGLUniformLocation, color3: IColor3Like, alpha: number): boolean;
  61124. wipeCaches(bruteForce?: boolean): void;
  61125. protected _createTexture(): WebGLTexture;
  61126. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  61127. /**
  61128. * Update the content of a dynamic texture
  61129. * @param texture defines the texture to update
  61130. * @param canvas defines the canvas containing the source
  61131. * @param invertY defines if data must be stored with Y axis inverted
  61132. * @param premulAlpha defines if alpha is stored as premultiplied
  61133. * @param format defines the format of the data
  61134. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  61135. */
  61136. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  61137. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  61138. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  61139. /**
  61140. * Usually called from Texture.ts.
  61141. * Passed information to create a WebGLTexture
  61142. * @param url defines a value which contains one of the following:
  61143. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  61144. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  61145. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  61146. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  61147. * @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)
  61148. * @param scene needed for loading to the correct scene
  61149. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  61150. * @param onLoad optional callback to be called upon successful completion
  61151. * @param onError optional callback to be called upon failure
  61152. * @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
  61153. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  61154. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  61155. * @param forcedExtension defines the extension to use to pick the right loader
  61156. * @param mimeType defines an optional mime type
  61157. * @param loaderOptions options to be passed to the loader
  61158. * @returns a InternalTexture for assignment back into BABYLON.Texture
  61159. */
  61160. 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;
  61161. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  61162. _releaseFramebufferObjects(texture: InternalTexture): void;
  61163. /**
  61164. * Creates a cube texture
  61165. * @param rootUrl defines the url where the files to load is located
  61166. * @param scene defines the current scene
  61167. * @param files defines the list of files to load (1 per face)
  61168. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  61169. * @param onLoad defines an optional callback raised when the texture is loaded
  61170. * @param onError defines an optional callback raised if there is an issue to load the texture
  61171. * @param format defines the format of the data
  61172. * @param forcedExtension defines the extension to use to pick the right loader
  61173. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  61174. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  61175. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  61176. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  61177. * @returns the cube texture as an InternalTexture
  61178. */
  61179. 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;
  61180. createRenderTargetTexture(size: number | {
  61181. width: number;
  61182. height: number;
  61183. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  61184. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  61185. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  61186. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  61187. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  61188. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  61189. /**
  61190. * Updates a dynamic vertex buffer.
  61191. * @param vertexBuffer the vertex buffer to update
  61192. * @param data the data used to update the vertex buffer
  61193. * @param byteOffset the byte offset of the data (optional)
  61194. * @param byteLength the byte length of the data (optional)
  61195. */
  61196. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  61197. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  61198. private _updateAnisotropicLevel;
  61199. private _getAddressMode;
  61200. /** @hidden */
  61201. _bindTexture(channel: number, texture: InternalTexture): void;
  61202. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  61203. releaseEffects(): void;
  61204. /** @hidden */
  61205. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  61206. /** @hidden */
  61207. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  61208. /** @hidden */
  61209. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  61210. /** @hidden */
  61211. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  61212. private _getNativeSamplingMode;
  61213. private _getNativeTextureFormat;
  61214. private _getNativeAlphaMode;
  61215. private _getNativeAttribType;
  61216. }
  61217. }
  61218. declare module BABYLON {
  61219. /**
  61220. * Helper class to create the best engine depending on the current hardware
  61221. */
  61222. export class EngineFactory {
  61223. /**
  61224. * Creates an engine based on the capabilities of the underlying hardware
  61225. * @param canvas Defines the canvas to use to display the result
  61226. * @param options Defines the options passed to the engine to create the context dependencies
  61227. * @returns a promise that resolves with the created engine
  61228. */
  61229. static CreateAsync(canvas: HTMLCanvasElement, options: any): Promise<ThinEngine>;
  61230. }
  61231. }
  61232. declare module BABYLON {
  61233. /**
  61234. * Gather the list of clipboard event types as constants.
  61235. */
  61236. export class ClipboardEventTypes {
  61237. /**
  61238. * The clipboard event is fired when a copy command is active (pressed).
  61239. */
  61240. static readonly COPY: number;
  61241. /**
  61242. * The clipboard event is fired when a cut command is active (pressed).
  61243. */
  61244. static readonly CUT: number;
  61245. /**
  61246. * The clipboard event is fired when a paste command is active (pressed).
  61247. */
  61248. static readonly PASTE: number;
  61249. }
  61250. /**
  61251. * This class is used to store clipboard related info for the onClipboardObservable event.
  61252. */
  61253. export class ClipboardInfo {
  61254. /**
  61255. * Defines the type of event (BABYLON.ClipboardEventTypes)
  61256. */
  61257. type: number;
  61258. /**
  61259. * Defines the related dom event
  61260. */
  61261. event: ClipboardEvent;
  61262. /**
  61263. *Creates an instance of ClipboardInfo.
  61264. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  61265. * @param event Defines the related dom event
  61266. */
  61267. constructor(
  61268. /**
  61269. * Defines the type of event (BABYLON.ClipboardEventTypes)
  61270. */
  61271. type: number,
  61272. /**
  61273. * Defines the related dom event
  61274. */
  61275. event: ClipboardEvent);
  61276. /**
  61277. * Get the clipboard event's type from the keycode.
  61278. * @param keyCode Defines the keyCode for the current keyboard event.
  61279. * @return {number}
  61280. */
  61281. static GetTypeFromCharacter(keyCode: number): number;
  61282. }
  61283. }
  61284. declare module BABYLON {
  61285. /**
  61286. * Google Daydream controller
  61287. */
  61288. export class DaydreamController extends WebVRController {
  61289. /**
  61290. * Base Url for the controller model.
  61291. */
  61292. static MODEL_BASE_URL: string;
  61293. /**
  61294. * File name for the controller model.
  61295. */
  61296. static MODEL_FILENAME: string;
  61297. /**
  61298. * Gamepad Id prefix used to identify Daydream Controller.
  61299. */
  61300. static readonly GAMEPAD_ID_PREFIX: string;
  61301. /**
  61302. * Creates a new DaydreamController from a gamepad
  61303. * @param vrGamepad the gamepad that the controller should be created from
  61304. */
  61305. constructor(vrGamepad: any);
  61306. /**
  61307. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  61308. * @param scene scene in which to add meshes
  61309. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  61310. */
  61311. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  61312. /**
  61313. * Called once for each button that changed state since the last frame
  61314. * @param buttonIdx Which button index changed
  61315. * @param state New state of the button
  61316. * @param changes Which properties on the state changed since last frame
  61317. */
  61318. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  61319. }
  61320. }
  61321. declare module BABYLON {
  61322. /**
  61323. * Gear VR Controller
  61324. */
  61325. export class GearVRController extends WebVRController {
  61326. /**
  61327. * Base Url for the controller model.
  61328. */
  61329. static MODEL_BASE_URL: string;
  61330. /**
  61331. * File name for the controller model.
  61332. */
  61333. static MODEL_FILENAME: string;
  61334. /**
  61335. * Gamepad Id prefix used to identify this controller.
  61336. */
  61337. static readonly GAMEPAD_ID_PREFIX: string;
  61338. private readonly _buttonIndexToObservableNameMap;
  61339. /**
  61340. * Creates a new GearVRController from a gamepad
  61341. * @param vrGamepad the gamepad that the controller should be created from
  61342. */
  61343. constructor(vrGamepad: any);
  61344. /**
  61345. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  61346. * @param scene scene in which to add meshes
  61347. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  61348. */
  61349. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  61350. /**
  61351. * Called once for each button that changed state since the last frame
  61352. * @param buttonIdx Which button index changed
  61353. * @param state New state of the button
  61354. * @param changes Which properties on the state changed since last frame
  61355. */
  61356. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  61357. }
  61358. }
  61359. declare module BABYLON {
  61360. /**
  61361. * Generic Controller
  61362. */
  61363. export class GenericController extends WebVRController {
  61364. /**
  61365. * Base Url for the controller model.
  61366. */
  61367. static readonly MODEL_BASE_URL: string;
  61368. /**
  61369. * File name for the controller model.
  61370. */
  61371. static readonly MODEL_FILENAME: string;
  61372. /**
  61373. * Creates a new GenericController from a gamepad
  61374. * @param vrGamepad the gamepad that the controller should be created from
  61375. */
  61376. constructor(vrGamepad: any);
  61377. /**
  61378. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  61379. * @param scene scene in which to add meshes
  61380. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  61381. */
  61382. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  61383. /**
  61384. * Called once for each button that changed state since the last frame
  61385. * @param buttonIdx Which button index changed
  61386. * @param state New state of the button
  61387. * @param changes Which properties on the state changed since last frame
  61388. */
  61389. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  61390. }
  61391. }
  61392. declare module BABYLON {
  61393. /**
  61394. * Oculus Touch Controller
  61395. */
  61396. export class OculusTouchController extends WebVRController {
  61397. /**
  61398. * Base Url for the controller model.
  61399. */
  61400. static MODEL_BASE_URL: string;
  61401. /**
  61402. * File name for the left controller model.
  61403. */
  61404. static MODEL_LEFT_FILENAME: string;
  61405. /**
  61406. * File name for the right controller model.
  61407. */
  61408. static MODEL_RIGHT_FILENAME: string;
  61409. /**
  61410. * Base Url for the Quest controller model.
  61411. */
  61412. static QUEST_MODEL_BASE_URL: string;
  61413. /**
  61414. * @hidden
  61415. * If the controllers are running on a device that needs the updated Quest controller models
  61416. */
  61417. static _IsQuest: boolean;
  61418. /**
  61419. * Fired when the secondary trigger on this controller is modified
  61420. */
  61421. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  61422. /**
  61423. * Fired when the thumb rest on this controller is modified
  61424. */
  61425. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  61426. /**
  61427. * Creates a new OculusTouchController from a gamepad
  61428. * @param vrGamepad the gamepad that the controller should be created from
  61429. */
  61430. constructor(vrGamepad: any);
  61431. /**
  61432. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  61433. * @param scene scene in which to add meshes
  61434. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  61435. */
  61436. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  61437. /**
  61438. * Fired when the A button on this controller is modified
  61439. */
  61440. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61441. /**
  61442. * Fired when the B button on this controller is modified
  61443. */
  61444. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61445. /**
  61446. * Fired when the X button on this controller is modified
  61447. */
  61448. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61449. /**
  61450. * Fired when the Y button on this controller is modified
  61451. */
  61452. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61453. /**
  61454. * Called once for each button that changed state since the last frame
  61455. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  61456. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  61457. * 2) secondary trigger (same)
  61458. * 3) A (right) X (left), touch, pressed = value
  61459. * 4) B / Y
  61460. * 5) thumb rest
  61461. * @param buttonIdx Which button index changed
  61462. * @param state New state of the button
  61463. * @param changes Which properties on the state changed since last frame
  61464. */
  61465. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  61466. }
  61467. }
  61468. declare module BABYLON {
  61469. /**
  61470. * Vive Controller
  61471. */
  61472. export class ViveController extends WebVRController {
  61473. /**
  61474. * Base Url for the controller model.
  61475. */
  61476. static MODEL_BASE_URL: string;
  61477. /**
  61478. * File name for the controller model.
  61479. */
  61480. static MODEL_FILENAME: string;
  61481. /**
  61482. * Creates a new ViveController from a gamepad
  61483. * @param vrGamepad the gamepad that the controller should be created from
  61484. */
  61485. constructor(vrGamepad: any);
  61486. /**
  61487. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  61488. * @param scene scene in which to add meshes
  61489. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  61490. */
  61491. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  61492. /**
  61493. * Fired when the left button on this controller is modified
  61494. */
  61495. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61496. /**
  61497. * Fired when the right button on this controller is modified
  61498. */
  61499. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61500. /**
  61501. * Fired when the menu button on this controller is modified
  61502. */
  61503. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61504. /**
  61505. * Called once for each button that changed state since the last frame
  61506. * Vive mapping:
  61507. * 0: touchpad
  61508. * 1: trigger
  61509. * 2: left AND right buttons
  61510. * 3: menu button
  61511. * @param buttonIdx Which button index changed
  61512. * @param state New state of the button
  61513. * @param changes Which properties on the state changed since last frame
  61514. */
  61515. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  61516. }
  61517. }
  61518. declare module BABYLON {
  61519. /**
  61520. * Defines the WindowsMotionController object that the state of the windows motion controller
  61521. */
  61522. export class WindowsMotionController extends WebVRController {
  61523. /**
  61524. * The base url used to load the left and right controller models
  61525. */
  61526. static MODEL_BASE_URL: string;
  61527. /**
  61528. * The name of the left controller model file
  61529. */
  61530. static MODEL_LEFT_FILENAME: string;
  61531. /**
  61532. * The name of the right controller model file
  61533. */
  61534. static MODEL_RIGHT_FILENAME: string;
  61535. /**
  61536. * The controller name prefix for this controller type
  61537. */
  61538. static readonly GAMEPAD_ID_PREFIX: string;
  61539. /**
  61540. * The controller id pattern for this controller type
  61541. */
  61542. private static readonly GAMEPAD_ID_PATTERN;
  61543. private _loadedMeshInfo;
  61544. protected readonly _mapping: {
  61545. buttons: string[];
  61546. buttonMeshNames: {
  61547. trigger: string;
  61548. menu: string;
  61549. grip: string;
  61550. thumbstick: string;
  61551. trackpad: string;
  61552. };
  61553. buttonObservableNames: {
  61554. trigger: string;
  61555. menu: string;
  61556. grip: string;
  61557. thumbstick: string;
  61558. trackpad: string;
  61559. };
  61560. axisMeshNames: string[];
  61561. pointingPoseMeshName: string;
  61562. };
  61563. /**
  61564. * Fired when the trackpad on this controller is clicked
  61565. */
  61566. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  61567. /**
  61568. * Fired when the trackpad on this controller is modified
  61569. */
  61570. onTrackpadValuesChangedObservable: Observable<StickValues>;
  61571. /**
  61572. * The current x and y values of this controller's trackpad
  61573. */
  61574. trackpad: StickValues;
  61575. /**
  61576. * Creates a new WindowsMotionController from a gamepad
  61577. * @param vrGamepad the gamepad that the controller should be created from
  61578. */
  61579. constructor(vrGamepad: any);
  61580. /**
  61581. * Fired when the trigger on this controller is modified
  61582. */
  61583. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61584. /**
  61585. * Fired when the menu button on this controller is modified
  61586. */
  61587. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61588. /**
  61589. * Fired when the grip button on this controller is modified
  61590. */
  61591. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61592. /**
  61593. * Fired when the thumbstick button on this controller is modified
  61594. */
  61595. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61596. /**
  61597. * Fired when the touchpad button on this controller is modified
  61598. */
  61599. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61600. /**
  61601. * Fired when the touchpad values on this controller are modified
  61602. */
  61603. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  61604. protected _updateTrackpad(): void;
  61605. /**
  61606. * Called once per frame by the engine.
  61607. */
  61608. update(): void;
  61609. /**
  61610. * Called once for each button that changed state since the last frame
  61611. * @param buttonIdx Which button index changed
  61612. * @param state New state of the button
  61613. * @param changes Which properties on the state changed since last frame
  61614. */
  61615. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  61616. /**
  61617. * Moves the buttons on the controller mesh based on their current state
  61618. * @param buttonName the name of the button to move
  61619. * @param buttonValue the value of the button which determines the buttons new position
  61620. */
  61621. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  61622. /**
  61623. * Moves the axis on the controller mesh based on its current state
  61624. * @param axis the index of the axis
  61625. * @param axisValue the value of the axis which determines the meshes new position
  61626. * @hidden
  61627. */
  61628. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  61629. /**
  61630. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  61631. * @param scene scene in which to add meshes
  61632. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  61633. */
  61634. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  61635. /**
  61636. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  61637. * can be transformed by button presses and axes values, based on this._mapping.
  61638. *
  61639. * @param scene scene in which the meshes exist
  61640. * @param meshes list of meshes that make up the controller model to process
  61641. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  61642. */
  61643. private processModel;
  61644. private createMeshInfo;
  61645. /**
  61646. * Gets the ray of the controller in the direction the controller is pointing
  61647. * @param length the length the resulting ray should be
  61648. * @returns a ray in the direction the controller is pointing
  61649. */
  61650. getForwardRay(length?: number): Ray;
  61651. /**
  61652. * Disposes of the controller
  61653. */
  61654. dispose(): void;
  61655. }
  61656. /**
  61657. * This class represents a new windows motion controller in XR.
  61658. */
  61659. export class XRWindowsMotionController extends WindowsMotionController {
  61660. /**
  61661. * Changing the original WIndowsMotionController mapping to fir the new mapping
  61662. */
  61663. protected readonly _mapping: {
  61664. buttons: string[];
  61665. buttonMeshNames: {
  61666. trigger: string;
  61667. menu: string;
  61668. grip: string;
  61669. thumbstick: string;
  61670. trackpad: string;
  61671. };
  61672. buttonObservableNames: {
  61673. trigger: string;
  61674. menu: string;
  61675. grip: string;
  61676. thumbstick: string;
  61677. trackpad: string;
  61678. };
  61679. axisMeshNames: string[];
  61680. pointingPoseMeshName: string;
  61681. };
  61682. /**
  61683. * Construct a new XR-Based windows motion controller
  61684. *
  61685. * @param gamepadInfo the gamepad object from the browser
  61686. */
  61687. constructor(gamepadInfo: any);
  61688. /**
  61689. * holds the thumbstick values (X,Y)
  61690. */
  61691. thumbstickValues: StickValues;
  61692. /**
  61693. * Fired when the thumbstick on this controller is clicked
  61694. */
  61695. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  61696. /**
  61697. * Fired when the thumbstick on this controller is modified
  61698. */
  61699. onThumbstickValuesChangedObservable: Observable<StickValues>;
  61700. /**
  61701. * Fired when the touchpad button on this controller is modified
  61702. */
  61703. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  61704. /**
  61705. * Fired when the touchpad values on this controller are modified
  61706. */
  61707. onTrackpadValuesChangedObservable: Observable<StickValues>;
  61708. /**
  61709. * Fired when the thumbstick button on this controller is modified
  61710. * here to prevent breaking changes
  61711. */
  61712. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61713. /**
  61714. * updating the thumbstick(!) and not the trackpad.
  61715. * This is named this way due to the difference between WebVR and XR and to avoid
  61716. * changing the parent class.
  61717. */
  61718. protected _updateTrackpad(): void;
  61719. /**
  61720. * Disposes the class with joy
  61721. */
  61722. dispose(): void;
  61723. }
  61724. }
  61725. declare module BABYLON {
  61726. /**
  61727. * Class containing static functions to help procedurally build meshes
  61728. */
  61729. export class HemisphereBuilder {
  61730. /**
  61731. * Creates a hemisphere mesh
  61732. * @param name defines the name of the mesh
  61733. * @param options defines the options used to create the mesh
  61734. * @param scene defines the hosting scene
  61735. * @returns the hemisphere mesh
  61736. */
  61737. static CreateHemisphere(name: string, options: {
  61738. segments?: number;
  61739. diameter?: number;
  61740. sideOrientation?: number;
  61741. }, scene: any): Mesh;
  61742. }
  61743. }
  61744. declare module BABYLON {
  61745. /**
  61746. * A spot light is defined by a position, a direction, an angle, and an exponent.
  61747. * These values define a cone of light starting from the position, emitting toward the direction.
  61748. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  61749. * and the exponent defines the speed of the decay of the light with distance (reach).
  61750. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61751. */
  61752. export class SpotLight extends ShadowLight {
  61753. private _angle;
  61754. private _innerAngle;
  61755. private _cosHalfAngle;
  61756. private _lightAngleScale;
  61757. private _lightAngleOffset;
  61758. /**
  61759. * Gets the cone angle of the spot light in Radians.
  61760. */
  61761. get angle(): number;
  61762. /**
  61763. * Sets the cone angle of the spot light in Radians.
  61764. */
  61765. set angle(value: number);
  61766. /**
  61767. * Only used in gltf falloff mode, this defines the angle where
  61768. * the directional falloff will start before cutting at angle which could be seen
  61769. * as outer angle.
  61770. */
  61771. get innerAngle(): number;
  61772. /**
  61773. * Only used in gltf falloff mode, this defines the angle where
  61774. * the directional falloff will start before cutting at angle which could be seen
  61775. * as outer angle.
  61776. */
  61777. set innerAngle(value: number);
  61778. private _shadowAngleScale;
  61779. /**
  61780. * Allows scaling the angle of the light for shadow generation only.
  61781. */
  61782. get shadowAngleScale(): number;
  61783. /**
  61784. * Allows scaling the angle of the light for shadow generation only.
  61785. */
  61786. set shadowAngleScale(value: number);
  61787. /**
  61788. * The light decay speed with the distance from the emission spot.
  61789. */
  61790. exponent: number;
  61791. private _projectionTextureMatrix;
  61792. /**
  61793. * Allows reading the projection texture
  61794. */
  61795. get projectionTextureMatrix(): Matrix;
  61796. protected _projectionTextureLightNear: number;
  61797. /**
  61798. * Gets the near clip of the Spotlight for texture projection.
  61799. */
  61800. get projectionTextureLightNear(): number;
  61801. /**
  61802. * Sets the near clip of the Spotlight for texture projection.
  61803. */
  61804. set projectionTextureLightNear(value: number);
  61805. protected _projectionTextureLightFar: number;
  61806. /**
  61807. * Gets the far clip of the Spotlight for texture projection.
  61808. */
  61809. get projectionTextureLightFar(): number;
  61810. /**
  61811. * Sets the far clip of the Spotlight for texture projection.
  61812. */
  61813. set projectionTextureLightFar(value: number);
  61814. protected _projectionTextureUpDirection: Vector3;
  61815. /**
  61816. * Gets the Up vector of the Spotlight for texture projection.
  61817. */
  61818. get projectionTextureUpDirection(): Vector3;
  61819. /**
  61820. * Sets the Up vector of the Spotlight for texture projection.
  61821. */
  61822. set projectionTextureUpDirection(value: Vector3);
  61823. private _projectionTexture;
  61824. /**
  61825. * Gets the projection texture of the light.
  61826. */
  61827. get projectionTexture(): Nullable<BaseTexture>;
  61828. /**
  61829. * Sets the projection texture of the light.
  61830. */
  61831. set projectionTexture(value: Nullable<BaseTexture>);
  61832. private static _IsProceduralTexture;
  61833. private static _IsTexture;
  61834. private _projectionTextureViewLightDirty;
  61835. private _projectionTextureProjectionLightDirty;
  61836. private _projectionTextureDirty;
  61837. private _projectionTextureViewTargetVector;
  61838. private _projectionTextureViewLightMatrix;
  61839. private _projectionTextureProjectionLightMatrix;
  61840. private _projectionTextureScalingMatrix;
  61841. /**
  61842. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  61843. * It can cast shadows.
  61844. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61845. * @param name The light friendly name
  61846. * @param position The position of the spot light in the scene
  61847. * @param direction The direction of the light in the scene
  61848. * @param angle The cone angle of the light in Radians
  61849. * @param exponent The light decay speed with the distance from the emission spot
  61850. * @param scene The scene the lights belongs to
  61851. */
  61852. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  61853. /**
  61854. * Returns the string "SpotLight".
  61855. * @returns the class name
  61856. */
  61857. getClassName(): string;
  61858. /**
  61859. * Returns the integer 2.
  61860. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61861. */
  61862. getTypeID(): number;
  61863. /**
  61864. * Overrides the direction setter to recompute the projection texture view light Matrix.
  61865. */
  61866. protected _setDirection(value: Vector3): void;
  61867. /**
  61868. * Overrides the position setter to recompute the projection texture view light Matrix.
  61869. */
  61870. protected _setPosition(value: Vector3): void;
  61871. /**
  61872. * 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.
  61873. * Returns the SpotLight.
  61874. */
  61875. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61876. protected _computeProjectionTextureViewLightMatrix(): void;
  61877. protected _computeProjectionTextureProjectionLightMatrix(): void;
  61878. /**
  61879. * Main function for light texture projection matrix computing.
  61880. */
  61881. protected _computeProjectionTextureMatrix(): void;
  61882. protected _buildUniformLayout(): void;
  61883. private _computeAngleValues;
  61884. /**
  61885. * Sets the passed Effect "effect" with the Light textures.
  61886. * @param effect The effect to update
  61887. * @param lightIndex The index of the light in the effect to update
  61888. * @returns The light
  61889. */
  61890. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  61891. /**
  61892. * Sets the passed Effect object with the SpotLight transformed position (or position if not parented) and normalized direction.
  61893. * @param effect The effect to update
  61894. * @param lightIndex The index of the light in the effect to update
  61895. * @returns The spot light
  61896. */
  61897. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  61898. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61899. /**
  61900. * Disposes the light and the associated resources.
  61901. */
  61902. dispose(): void;
  61903. /**
  61904. * Prepares the list of defines specific to the light type.
  61905. * @param defines the list of defines
  61906. * @param lightIndex defines the index of the light for the effect
  61907. */
  61908. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61909. }
  61910. }
  61911. declare module BABYLON {
  61912. /**
  61913. * Gizmo that enables viewing a light
  61914. */
  61915. export class LightGizmo extends Gizmo {
  61916. private _lightMesh;
  61917. private _material;
  61918. private _cachedPosition;
  61919. private _cachedForward;
  61920. private _attachedMeshParent;
  61921. private _pointerObserver;
  61922. /**
  61923. * Event that fires each time the gizmo is clicked
  61924. */
  61925. onClickedObservable: Observable<Light>;
  61926. /**
  61927. * Creates a LightGizmo
  61928. * @param gizmoLayer The utility layer the gizmo will be added to
  61929. */
  61930. constructor(gizmoLayer?: UtilityLayerRenderer);
  61931. private _light;
  61932. /**
  61933. * The light that the gizmo is attached to
  61934. */
  61935. set light(light: Nullable<Light>);
  61936. get light(): Nullable<Light>;
  61937. /**
  61938. * Gets the material used to render the light gizmo
  61939. */
  61940. get material(): StandardMaterial;
  61941. /**
  61942. * @hidden
  61943. * Updates the gizmo to match the attached mesh's position/rotation
  61944. */
  61945. protected _update(): void;
  61946. private static _Scale;
  61947. /**
  61948. * Creates the lines for a light mesh
  61949. */
  61950. private static _CreateLightLines;
  61951. /**
  61952. * Disposes of the light gizmo
  61953. */
  61954. dispose(): void;
  61955. private static _CreateHemisphericLightMesh;
  61956. private static _CreatePointLightMesh;
  61957. private static _CreateSpotLightMesh;
  61958. private static _CreateDirectionalLightMesh;
  61959. }
  61960. }
  61961. declare module BABYLON {
  61962. /**
  61963. * Gizmo that enables viewing a camera
  61964. */
  61965. export class CameraGizmo extends Gizmo {
  61966. private _cameraMesh;
  61967. private _cameraLinesMesh;
  61968. private _material;
  61969. private _pointerObserver;
  61970. /**
  61971. * Event that fires each time the gizmo is clicked
  61972. */
  61973. onClickedObservable: Observable<Camera>;
  61974. /**
  61975. * Creates a CameraGizmo
  61976. * @param gizmoLayer The utility layer the gizmo will be added to
  61977. */
  61978. constructor(gizmoLayer?: UtilityLayerRenderer);
  61979. private _camera;
  61980. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  61981. get displayFrustum(): boolean;
  61982. set displayFrustum(value: boolean);
  61983. /**
  61984. * The camera that the gizmo is attached to
  61985. */
  61986. set camera(camera: Nullable<Camera>);
  61987. get camera(): Nullable<Camera>;
  61988. /**
  61989. * Gets the material used to render the camera gizmo
  61990. */
  61991. get material(): StandardMaterial;
  61992. /**
  61993. * @hidden
  61994. * Updates the gizmo to match the attached mesh's position/rotation
  61995. */
  61996. protected _update(): void;
  61997. private static _Scale;
  61998. private _invProjection;
  61999. /**
  62000. * Disposes of the camera gizmo
  62001. */
  62002. dispose(): void;
  62003. private static _CreateCameraMesh;
  62004. private static _CreateCameraFrustum;
  62005. }
  62006. }
  62007. declare module BABYLON {
  62008. /** @hidden */
  62009. export var backgroundFragmentDeclaration: {
  62010. name: string;
  62011. shader: string;
  62012. };
  62013. }
  62014. declare module BABYLON {
  62015. /** @hidden */
  62016. export var backgroundUboDeclaration: {
  62017. name: string;
  62018. shader: string;
  62019. };
  62020. }
  62021. declare module BABYLON {
  62022. /** @hidden */
  62023. export var backgroundPixelShader: {
  62024. name: string;
  62025. shader: string;
  62026. };
  62027. }
  62028. declare module BABYLON {
  62029. /** @hidden */
  62030. export var backgroundVertexDeclaration: {
  62031. name: string;
  62032. shader: string;
  62033. };
  62034. }
  62035. declare module BABYLON {
  62036. /** @hidden */
  62037. export var backgroundVertexShader: {
  62038. name: string;
  62039. shader: string;
  62040. };
  62041. }
  62042. declare module BABYLON {
  62043. /**
  62044. * Background material used to create an efficient environment around your scene.
  62045. */
  62046. export class BackgroundMaterial extends PushMaterial {
  62047. /**
  62048. * Standard reflectance value at parallel view angle.
  62049. */
  62050. static StandardReflectance0: number;
  62051. /**
  62052. * Standard reflectance value at grazing angle.
  62053. */
  62054. static StandardReflectance90: number;
  62055. protected _primaryColor: Color3;
  62056. /**
  62057. * Key light Color (multiply against the environment texture)
  62058. */
  62059. primaryColor: Color3;
  62060. protected __perceptualColor: Nullable<Color3>;
  62061. /**
  62062. * Experimental Internal Use Only.
  62063. *
  62064. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  62065. * This acts as a helper to set the primary color to a more "human friendly" value.
  62066. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  62067. * output color as close as possible from the chosen value.
  62068. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  62069. * part of lighting setup.)
  62070. */
  62071. get _perceptualColor(): Nullable<Color3>;
  62072. set _perceptualColor(value: Nullable<Color3>);
  62073. protected _primaryColorShadowLevel: float;
  62074. /**
  62075. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  62076. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  62077. */
  62078. get primaryColorShadowLevel(): float;
  62079. set primaryColorShadowLevel(value: float);
  62080. protected _primaryColorHighlightLevel: float;
  62081. /**
  62082. * Defines the level of the highlights (highlight area of the reflection map) in order to help scaling the colors.
  62083. * The primary color is used at the level chosen to define what the white area would look.
  62084. */
  62085. get primaryColorHighlightLevel(): float;
  62086. set primaryColorHighlightLevel(value: float);
  62087. protected _reflectionTexture: Nullable<BaseTexture>;
  62088. /**
  62089. * Reflection Texture used in the material.
  62090. * Should be author in a specific way for the best result (refer to the documentation).
  62091. */
  62092. reflectionTexture: Nullable<BaseTexture>;
  62093. protected _reflectionBlur: float;
  62094. /**
  62095. * Reflection Texture level of blur.
  62096. *
  62097. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  62098. * texture twice.
  62099. */
  62100. reflectionBlur: float;
  62101. protected _diffuseTexture: Nullable<BaseTexture>;
  62102. /**
  62103. * Diffuse Texture used in the material.
  62104. * Should be author in a specific way for the best result (refer to the documentation).
  62105. */
  62106. diffuseTexture: Nullable<BaseTexture>;
  62107. protected _shadowLights: Nullable<IShadowLight[]>;
  62108. /**
  62109. * Specify the list of lights casting shadow on the material.
  62110. * All scene shadow lights will be included if null.
  62111. */
  62112. shadowLights: Nullable<IShadowLight[]>;
  62113. protected _shadowLevel: float;
  62114. /**
  62115. * Helps adjusting the shadow to a softer level if required.
  62116. * 0 means black shadows and 1 means no shadows.
  62117. */
  62118. shadowLevel: float;
  62119. protected _sceneCenter: Vector3;
  62120. /**
  62121. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  62122. * It is usually zero but might be interesting to modify according to your setup.
  62123. */
  62124. sceneCenter: Vector3;
  62125. protected _opacityFresnel: boolean;
  62126. /**
  62127. * This helps specifying that the material is falling off to the sky box at grazing angle.
  62128. * This helps ensuring a nice transition when the camera goes under the ground.
  62129. */
  62130. opacityFresnel: boolean;
  62131. protected _reflectionFresnel: boolean;
  62132. /**
  62133. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  62134. * This helps adding a mirror texture on the ground.
  62135. */
  62136. reflectionFresnel: boolean;
  62137. protected _reflectionFalloffDistance: number;
  62138. /**
  62139. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  62140. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  62141. */
  62142. reflectionFalloffDistance: number;
  62143. protected _reflectionAmount: number;
  62144. /**
  62145. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  62146. */
  62147. reflectionAmount: number;
  62148. protected _reflectionReflectance0: number;
  62149. /**
  62150. * This specifies the weight of the reflection at grazing angle.
  62151. */
  62152. reflectionReflectance0: number;
  62153. protected _reflectionReflectance90: number;
  62154. /**
  62155. * This specifies the weight of the reflection at a perpendicular point of view.
  62156. */
  62157. reflectionReflectance90: number;
  62158. /**
  62159. * Sets the reflection reflectance fresnel values according to the default standard
  62160. * empirically know to work well :-)
  62161. */
  62162. set reflectionStandardFresnelWeight(value: number);
  62163. protected _useRGBColor: boolean;
  62164. /**
  62165. * Helps to directly use the maps channels instead of their level.
  62166. */
  62167. useRGBColor: boolean;
  62168. protected _enableNoise: boolean;
  62169. /**
  62170. * This helps reducing the banding effect that could occur on the background.
  62171. */
  62172. enableNoise: boolean;
  62173. /**
  62174. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  62175. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  62176. * Recommended to be keep at 1.0 except for special cases.
  62177. */
  62178. get fovMultiplier(): number;
  62179. set fovMultiplier(value: number);
  62180. private _fovMultiplier;
  62181. /**
  62182. * Enable the FOV adjustment feature controlled by fovMultiplier.
  62183. */
  62184. useEquirectangularFOV: boolean;
  62185. private _maxSimultaneousLights;
  62186. /**
  62187. * Number of Simultaneous lights allowed on the material.
  62188. */
  62189. maxSimultaneousLights: int;
  62190. private _shadowOnly;
  62191. /**
  62192. * Make the material only render shadows
  62193. */
  62194. shadowOnly: boolean;
  62195. /**
  62196. * Default configuration related to image processing available in the Background Material.
  62197. */
  62198. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  62199. /**
  62200. * Keep track of the image processing observer to allow dispose and replace.
  62201. */
  62202. private _imageProcessingObserver;
  62203. /**
  62204. * Attaches a new image processing configuration to the PBR Material.
  62205. * @param configuration (if null the scene configuration will be use)
  62206. */
  62207. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  62208. /**
  62209. * Gets the image processing configuration used either in this material.
  62210. */
  62211. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  62212. /**
  62213. * Sets the Default image processing configuration used either in the this material.
  62214. *
  62215. * If sets to null, the scene one is in use.
  62216. */
  62217. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  62218. /**
  62219. * Gets whether the color curves effect is enabled.
  62220. */
  62221. get cameraColorCurvesEnabled(): boolean;
  62222. /**
  62223. * Sets whether the color curves effect is enabled.
  62224. */
  62225. set cameraColorCurvesEnabled(value: boolean);
  62226. /**
  62227. * Gets whether the color grading effect is enabled.
  62228. */
  62229. get cameraColorGradingEnabled(): boolean;
  62230. /**
  62231. * Gets whether the color grading effect is enabled.
  62232. */
  62233. set cameraColorGradingEnabled(value: boolean);
  62234. /**
  62235. * Gets whether tonemapping is enabled or not.
  62236. */
  62237. get cameraToneMappingEnabled(): boolean;
  62238. /**
  62239. * Sets whether tonemapping is enabled or not
  62240. */
  62241. set cameraToneMappingEnabled(value: boolean);
  62242. /**
  62243. * The camera exposure used on this material.
  62244. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  62245. * This corresponds to a photographic exposure.
  62246. */
  62247. get cameraExposure(): float;
  62248. /**
  62249. * The camera exposure used on this material.
  62250. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  62251. * This corresponds to a photographic exposure.
  62252. */
  62253. set cameraExposure(value: float);
  62254. /**
  62255. * Gets The camera contrast used on this material.
  62256. */
  62257. get cameraContrast(): float;
  62258. /**
  62259. * Sets The camera contrast used on this material.
  62260. */
  62261. set cameraContrast(value: float);
  62262. /**
  62263. * Gets the Color Grading 2D Lookup Texture.
  62264. */
  62265. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  62266. /**
  62267. * Sets the Color Grading 2D Lookup Texture.
  62268. */
  62269. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  62270. /**
  62271. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  62272. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  62273. * 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;
  62274. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  62275. */
  62276. get cameraColorCurves(): Nullable<ColorCurves>;
  62277. /**
  62278. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  62279. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  62280. * 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;
  62281. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  62282. */
  62283. set cameraColorCurves(value: Nullable<ColorCurves>);
  62284. /**
  62285. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  62286. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  62287. */
  62288. switchToBGR: boolean;
  62289. private _renderTargets;
  62290. private _reflectionControls;
  62291. private _white;
  62292. private _primaryShadowColor;
  62293. private _primaryHighlightColor;
  62294. /**
  62295. * Instantiates a Background Material in the given scene
  62296. * @param name The friendly name of the material
  62297. * @param scene The scene to add the material to
  62298. */
  62299. constructor(name: string, scene: Scene);
  62300. /**
  62301. * Gets a boolean indicating that current material needs to register RTT
  62302. */
  62303. get hasRenderTargetTextures(): boolean;
  62304. /**
  62305. * The entire material has been created in order to prevent overdraw.
  62306. * @returns false
  62307. */
  62308. needAlphaTesting(): boolean;
  62309. /**
  62310. * The entire material has been created in order to prevent overdraw.
  62311. * @returns true if blending is enable
  62312. */
  62313. needAlphaBlending(): boolean;
  62314. /**
  62315. * Checks whether the material is ready to be rendered for a given mesh.
  62316. * @param mesh The mesh to render
  62317. * @param subMesh The submesh to check against
  62318. * @param useInstances Specify wether or not the material is used with instances
  62319. * @returns true if all the dependencies are ready (Textures, Effects...)
  62320. */
  62321. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  62322. /**
  62323. * Compute the primary color according to the chosen perceptual color.
  62324. */
  62325. private _computePrimaryColorFromPerceptualColor;
  62326. /**
  62327. * Compute the highlights and shadow colors according to their chosen levels.
  62328. */
  62329. private _computePrimaryColors;
  62330. /**
  62331. * Build the uniform buffer used in the material.
  62332. */
  62333. buildUniformLayout(): void;
  62334. /**
  62335. * Unbind the material.
  62336. */
  62337. unbind(): void;
  62338. /**
  62339. * Bind only the world matrix to the material.
  62340. * @param world The world matrix to bind.
  62341. */
  62342. bindOnlyWorldMatrix(world: Matrix): void;
  62343. /**
  62344. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  62345. * @param world The world matrix to bind.
  62346. * @param subMesh The submesh to bind for.
  62347. */
  62348. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  62349. /**
  62350. * Checks to see if a texture is used in the material.
  62351. * @param texture - Base texture to use.
  62352. * @returns - Boolean specifying if a texture is used in the material.
  62353. */
  62354. hasTexture(texture: BaseTexture): boolean;
  62355. /**
  62356. * Dispose the material.
  62357. * @param forceDisposeEffect Force disposal of the associated effect.
  62358. * @param forceDisposeTextures Force disposal of the associated textures.
  62359. */
  62360. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  62361. /**
  62362. * Clones the material.
  62363. * @param name The cloned name.
  62364. * @returns The cloned material.
  62365. */
  62366. clone(name: string): BackgroundMaterial;
  62367. /**
  62368. * Serializes the current material to its JSON representation.
  62369. * @returns The JSON representation.
  62370. */
  62371. serialize(): any;
  62372. /**
  62373. * Gets the class name of the material
  62374. * @returns "BackgroundMaterial"
  62375. */
  62376. getClassName(): string;
  62377. /**
  62378. * Parse a JSON input to create back a background material.
  62379. * @param source The JSON data to parse
  62380. * @param scene The scene to create the parsed material in
  62381. * @param rootUrl The root url of the assets the material depends upon
  62382. * @returns the instantiated BackgroundMaterial.
  62383. */
  62384. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  62385. }
  62386. }
  62387. declare module BABYLON {
  62388. /**
  62389. * Represents the different options available during the creation of
  62390. * a Environment helper.
  62391. *
  62392. * This can control the default ground, skybox and image processing setup of your scene.
  62393. */
  62394. export interface IEnvironmentHelperOptions {
  62395. /**
  62396. * Specifies whether or not to create a ground.
  62397. * True by default.
  62398. */
  62399. createGround: boolean;
  62400. /**
  62401. * Specifies the ground size.
  62402. * 15 by default.
  62403. */
  62404. groundSize: number;
  62405. /**
  62406. * The texture used on the ground for the main color.
  62407. * Comes from the BabylonJS CDN by default.
  62408. *
  62409. * Remarks: Can be either a texture or a url.
  62410. */
  62411. groundTexture: string | BaseTexture;
  62412. /**
  62413. * The color mixed in the ground texture by default.
  62414. * BabylonJS clearColor by default.
  62415. */
  62416. groundColor: Color3;
  62417. /**
  62418. * Specifies the ground opacity.
  62419. * 1 by default.
  62420. */
  62421. groundOpacity: number;
  62422. /**
  62423. * Enables the ground to receive shadows.
  62424. * True by default.
  62425. */
  62426. enableGroundShadow: boolean;
  62427. /**
  62428. * Helps preventing the shadow to be fully black on the ground.
  62429. * 0.5 by default.
  62430. */
  62431. groundShadowLevel: number;
  62432. /**
  62433. * Creates a mirror texture attach to the ground.
  62434. * false by default.
  62435. */
  62436. enableGroundMirror: boolean;
  62437. /**
  62438. * Specifies the ground mirror size ratio.
  62439. * 0.3 by default as the default kernel is 64.
  62440. */
  62441. groundMirrorSizeRatio: number;
  62442. /**
  62443. * Specifies the ground mirror blur kernel size.
  62444. * 64 by default.
  62445. */
  62446. groundMirrorBlurKernel: number;
  62447. /**
  62448. * Specifies the ground mirror visibility amount.
  62449. * 1 by default
  62450. */
  62451. groundMirrorAmount: number;
  62452. /**
  62453. * Specifies the ground mirror reflectance weight.
  62454. * This uses the standard weight of the background material to setup the fresnel effect
  62455. * of the mirror.
  62456. * 1 by default.
  62457. */
  62458. groundMirrorFresnelWeight: number;
  62459. /**
  62460. * Specifies the ground mirror Falloff distance.
  62461. * This can helps reducing the size of the reflection.
  62462. * 0 by Default.
  62463. */
  62464. groundMirrorFallOffDistance: number;
  62465. /**
  62466. * Specifies the ground mirror texture type.
  62467. * Unsigned Int by Default.
  62468. */
  62469. groundMirrorTextureType: number;
  62470. /**
  62471. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  62472. * the shown objects.
  62473. */
  62474. groundYBias: number;
  62475. /**
  62476. * Specifies whether or not to create a skybox.
  62477. * True by default.
  62478. */
  62479. createSkybox: boolean;
  62480. /**
  62481. * Specifies the skybox size.
  62482. * 20 by default.
  62483. */
  62484. skyboxSize: number;
  62485. /**
  62486. * The texture used on the skybox for the main color.
  62487. * Comes from the BabylonJS CDN by default.
  62488. *
  62489. * Remarks: Can be either a texture or a url.
  62490. */
  62491. skyboxTexture: string | BaseTexture;
  62492. /**
  62493. * The color mixed in the skybox texture by default.
  62494. * BabylonJS clearColor by default.
  62495. */
  62496. skyboxColor: Color3;
  62497. /**
  62498. * The background rotation around the Y axis of the scene.
  62499. * This helps aligning the key lights of your scene with the background.
  62500. * 0 by default.
  62501. */
  62502. backgroundYRotation: number;
  62503. /**
  62504. * Compute automatically the size of the elements to best fit with the scene.
  62505. */
  62506. sizeAuto: boolean;
  62507. /**
  62508. * Default position of the rootMesh if autoSize is not true.
  62509. */
  62510. rootPosition: Vector3;
  62511. /**
  62512. * Sets up the image processing in the scene.
  62513. * true by default.
  62514. */
  62515. setupImageProcessing: boolean;
  62516. /**
  62517. * The texture used as your environment texture in the scene.
  62518. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  62519. *
  62520. * Remarks: Can be either a texture or a url.
  62521. */
  62522. environmentTexture: string | BaseTexture;
  62523. /**
  62524. * The value of the exposure to apply to the scene.
  62525. * 0.6 by default if setupImageProcessing is true.
  62526. */
  62527. cameraExposure: number;
  62528. /**
  62529. * The value of the contrast to apply to the scene.
  62530. * 1.6 by default if setupImageProcessing is true.
  62531. */
  62532. cameraContrast: number;
  62533. /**
  62534. * Specifies whether or not tonemapping should be enabled in the scene.
  62535. * true by default if setupImageProcessing is true.
  62536. */
  62537. toneMappingEnabled: boolean;
  62538. }
  62539. /**
  62540. * The Environment helper class can be used to add a fully featured none expensive background to your scene.
  62541. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  62542. * It also helps with the default setup of your imageProcessing configuration.
  62543. */
  62544. export class EnvironmentHelper {
  62545. /**
  62546. * Default ground texture URL.
  62547. */
  62548. private static _groundTextureCDNUrl;
  62549. /**
  62550. * Default skybox texture URL.
  62551. */
  62552. private static _skyboxTextureCDNUrl;
  62553. /**
  62554. * Default environment texture URL.
  62555. */
  62556. private static _environmentTextureCDNUrl;
  62557. /**
  62558. * Creates the default options for the helper.
  62559. */
  62560. private static _getDefaultOptions;
  62561. private _rootMesh;
  62562. /**
  62563. * Gets the root mesh created by the helper.
  62564. */
  62565. get rootMesh(): Mesh;
  62566. private _skybox;
  62567. /**
  62568. * Gets the skybox created by the helper.
  62569. */
  62570. get skybox(): Nullable<Mesh>;
  62571. private _skyboxTexture;
  62572. /**
  62573. * Gets the skybox texture created by the helper.
  62574. */
  62575. get skyboxTexture(): Nullable<BaseTexture>;
  62576. private _skyboxMaterial;
  62577. /**
  62578. * Gets the skybox material created by the helper.
  62579. */
  62580. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  62581. private _ground;
  62582. /**
  62583. * Gets the ground mesh created by the helper.
  62584. */
  62585. get ground(): Nullable<Mesh>;
  62586. private _groundTexture;
  62587. /**
  62588. * Gets the ground texture created by the helper.
  62589. */
  62590. get groundTexture(): Nullable<BaseTexture>;
  62591. private _groundMirror;
  62592. /**
  62593. * Gets the ground mirror created by the helper.
  62594. */
  62595. get groundMirror(): Nullable<MirrorTexture>;
  62596. /**
  62597. * Gets the ground mirror render list to helps pushing the meshes
  62598. * you wish in the ground reflection.
  62599. */
  62600. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  62601. private _groundMaterial;
  62602. /**
  62603. * Gets the ground material created by the helper.
  62604. */
  62605. get groundMaterial(): Nullable<BackgroundMaterial>;
  62606. /**
  62607. * Stores the creation options.
  62608. */
  62609. private readonly _scene;
  62610. private _options;
  62611. /**
  62612. * This observable will be notified with any error during the creation of the environment,
  62613. * mainly texture creation errors.
  62614. */
  62615. onErrorObservable: Observable<{
  62616. message?: string;
  62617. exception?: any;
  62618. }>;
  62619. /**
  62620. * constructor
  62621. * @param options Defines the options we want to customize the helper
  62622. * @param scene The scene to add the material to
  62623. */
  62624. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  62625. /**
  62626. * Updates the background according to the new options
  62627. * @param options
  62628. */
  62629. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  62630. /**
  62631. * Sets the primary color of all the available elements.
  62632. * @param color the main color to affect to the ground and the background
  62633. */
  62634. setMainColor(color: Color3): void;
  62635. /**
  62636. * Setup the image processing according to the specified options.
  62637. */
  62638. private _setupImageProcessing;
  62639. /**
  62640. * Setup the environment texture according to the specified options.
  62641. */
  62642. private _setupEnvironmentTexture;
  62643. /**
  62644. * Setup the background according to the specified options.
  62645. */
  62646. private _setupBackground;
  62647. /**
  62648. * Get the scene sizes according to the setup.
  62649. */
  62650. private _getSceneSize;
  62651. /**
  62652. * Setup the ground according to the specified options.
  62653. */
  62654. private _setupGround;
  62655. /**
  62656. * Setup the ground material according to the specified options.
  62657. */
  62658. private _setupGroundMaterial;
  62659. /**
  62660. * Setup the ground diffuse texture according to the specified options.
  62661. */
  62662. private _setupGroundDiffuseTexture;
  62663. /**
  62664. * Setup the ground mirror texture according to the specified options.
  62665. */
  62666. private _setupGroundMirrorTexture;
  62667. /**
  62668. * Setup the ground to receive the mirror texture.
  62669. */
  62670. private _setupMirrorInGroundMaterial;
  62671. /**
  62672. * Setup the skybox according to the specified options.
  62673. */
  62674. private _setupSkybox;
  62675. /**
  62676. * Setup the skybox material according to the specified options.
  62677. */
  62678. private _setupSkyboxMaterial;
  62679. /**
  62680. * Setup the skybox reflection texture according to the specified options.
  62681. */
  62682. private _setupSkyboxReflectionTexture;
  62683. private _errorHandler;
  62684. /**
  62685. * Dispose all the elements created by the Helper.
  62686. */
  62687. dispose(): void;
  62688. }
  62689. }
  62690. declare module BABYLON {
  62691. /**
  62692. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  62693. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  62694. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  62695. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62696. */
  62697. export abstract class TextureDome<T extends Texture> extends TransformNode {
  62698. protected onError: Nullable<(message?: string, exception?: any) => void>;
  62699. /**
  62700. * Define the source as a Monoscopic panoramic 360/180.
  62701. */
  62702. static readonly MODE_MONOSCOPIC: number;
  62703. /**
  62704. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  62705. */
  62706. static readonly MODE_TOPBOTTOM: number;
  62707. /**
  62708. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  62709. */
  62710. static readonly MODE_SIDEBYSIDE: number;
  62711. private _halfDome;
  62712. private _crossEye;
  62713. protected _useDirectMapping: boolean;
  62714. /**
  62715. * The texture being displayed on the sphere
  62716. */
  62717. protected _texture: T;
  62718. /**
  62719. * Gets the texture being displayed on the sphere
  62720. */
  62721. get texture(): T;
  62722. /**
  62723. * Sets the texture being displayed on the sphere
  62724. */
  62725. set texture(newTexture: T);
  62726. /**
  62727. * The skybox material
  62728. */
  62729. protected _material: BackgroundMaterial;
  62730. /**
  62731. * The surface used for the dome
  62732. */
  62733. protected _mesh: Mesh;
  62734. /**
  62735. * Gets the mesh used for the dome.
  62736. */
  62737. get mesh(): Mesh;
  62738. /**
  62739. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  62740. */
  62741. private _halfDomeMask;
  62742. /**
  62743. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  62744. * Also see the options.resolution property.
  62745. */
  62746. get fovMultiplier(): number;
  62747. set fovMultiplier(value: number);
  62748. protected _textureMode: number;
  62749. /**
  62750. * Gets or set the current texture mode for the texture. It can be:
  62751. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  62752. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  62753. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  62754. */
  62755. get textureMode(): number;
  62756. /**
  62757. * Sets the current texture mode for the texture. It can be:
  62758. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  62759. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  62760. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  62761. */
  62762. set textureMode(value: number);
  62763. /**
  62764. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  62765. */
  62766. get halfDome(): boolean;
  62767. /**
  62768. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  62769. */
  62770. set halfDome(enabled: boolean);
  62771. /**
  62772. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  62773. */
  62774. set crossEye(enabled: boolean);
  62775. /**
  62776. * Is it a cross-eye texture?
  62777. */
  62778. get crossEye(): boolean;
  62779. /**
  62780. * The background material of this dome.
  62781. */
  62782. get material(): BackgroundMaterial;
  62783. /**
  62784. * Oberserver used in Stereoscopic VR Mode.
  62785. */
  62786. private _onBeforeCameraRenderObserver;
  62787. /**
  62788. * Observable raised when an error occurred while loading the texture
  62789. */
  62790. onLoadErrorObservable: Observable<string>;
  62791. /**
  62792. * Observable raised when the texture finished loading
  62793. */
  62794. onLoadObservable: Observable<void>;
  62795. /**
  62796. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  62797. * @param name Element's name, child elements will append suffixes for their own names.
  62798. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  62799. * @param options An object containing optional or exposed sub element properties
  62800. */
  62801. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  62802. resolution?: number;
  62803. clickToPlay?: boolean;
  62804. autoPlay?: boolean;
  62805. loop?: boolean;
  62806. size?: number;
  62807. poster?: string;
  62808. faceForward?: boolean;
  62809. useDirectMapping?: boolean;
  62810. halfDomeMode?: boolean;
  62811. crossEyeMode?: boolean;
  62812. generateMipMaps?: boolean;
  62813. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  62814. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  62815. protected _changeTextureMode(value: number): void;
  62816. /**
  62817. * Releases resources associated with this node.
  62818. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  62819. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  62820. */
  62821. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  62822. }
  62823. }
  62824. declare module BABYLON {
  62825. /**
  62826. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  62827. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  62828. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  62829. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62830. */
  62831. export class PhotoDome extends TextureDome<Texture> {
  62832. /**
  62833. * Define the image as a Monoscopic panoramic 360 image.
  62834. */
  62835. static readonly MODE_MONOSCOPIC: number;
  62836. /**
  62837. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  62838. */
  62839. static readonly MODE_TOPBOTTOM: number;
  62840. /**
  62841. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  62842. */
  62843. static readonly MODE_SIDEBYSIDE: number;
  62844. /**
  62845. * Gets or sets the texture being displayed on the sphere
  62846. */
  62847. get photoTexture(): Texture;
  62848. /**
  62849. * sets the texture being displayed on the sphere
  62850. */
  62851. set photoTexture(value: Texture);
  62852. /**
  62853. * Gets the current video mode for the video. It can be:
  62854. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  62855. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  62856. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  62857. */
  62858. get imageMode(): number;
  62859. /**
  62860. * Sets the current video mode for the video. It can be:
  62861. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  62862. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  62863. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  62864. */
  62865. set imageMode(value: number);
  62866. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  62867. }
  62868. }
  62869. declare module BABYLON {
  62870. /**
  62871. * Direct draw surface info
  62872. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  62873. */
  62874. export interface DDSInfo {
  62875. /**
  62876. * Width of the texture
  62877. */
  62878. width: number;
  62879. /**
  62880. * Width of the texture
  62881. */
  62882. height: number;
  62883. /**
  62884. * Number of Mipmaps for the texture
  62885. * @see https://en.wikipedia.org/wiki/Mipmap
  62886. */
  62887. mipmapCount: number;
  62888. /**
  62889. * If the textures format is a known fourCC format
  62890. * @see https://www.fourcc.org/
  62891. */
  62892. isFourCC: boolean;
  62893. /**
  62894. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  62895. */
  62896. isRGB: boolean;
  62897. /**
  62898. * If the texture is a lumincance format
  62899. */
  62900. isLuminance: boolean;
  62901. /**
  62902. * If this is a cube texture
  62903. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  62904. */
  62905. isCube: boolean;
  62906. /**
  62907. * If the texture is a compressed format eg. FOURCC_DXT1
  62908. */
  62909. isCompressed: boolean;
  62910. /**
  62911. * The dxgiFormat of the texture
  62912. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  62913. */
  62914. dxgiFormat: number;
  62915. /**
  62916. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  62917. */
  62918. textureType: number;
  62919. /**
  62920. * Sphericle polynomial created for the dds texture
  62921. */
  62922. sphericalPolynomial?: SphericalPolynomial;
  62923. }
  62924. /**
  62925. * Class used to provide DDS decompression tools
  62926. */
  62927. export class DDSTools {
  62928. /**
  62929. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  62930. */
  62931. static StoreLODInAlphaChannel: boolean;
  62932. /**
  62933. * Gets DDS information from an array buffer
  62934. * @param data defines the array buffer view to read data from
  62935. * @returns the DDS information
  62936. */
  62937. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  62938. private static _FloatView;
  62939. private static _Int32View;
  62940. private static _ToHalfFloat;
  62941. private static _FromHalfFloat;
  62942. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  62943. private static _GetHalfFloatRGBAArrayBuffer;
  62944. private static _GetFloatRGBAArrayBuffer;
  62945. private static _GetFloatAsUIntRGBAArrayBuffer;
  62946. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  62947. private static _GetRGBAArrayBuffer;
  62948. private static _ExtractLongWordOrder;
  62949. private static _GetRGBArrayBuffer;
  62950. private static _GetLuminanceArrayBuffer;
  62951. /**
  62952. * Uploads DDS Levels to a Babylon Texture
  62953. * @hidden
  62954. */
  62955. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  62956. }
  62957. interface ThinEngine {
  62958. /**
  62959. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  62960. * @param rootUrl defines the url where the file to load is located
  62961. * @param scene defines the current scene
  62962. * @param lodScale defines scale to apply to the mip map selection
  62963. * @param lodOffset defines offset to apply to the mip map selection
  62964. * @param onLoad defines an optional callback raised when the texture is loaded
  62965. * @param onError defines an optional callback raised if there is an issue to load the texture
  62966. * @param format defines the format of the data
  62967. * @param forcedExtension defines the extension to use to pick the right loader
  62968. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  62969. * @returns the cube texture as an InternalTexture
  62970. */
  62971. 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;
  62972. }
  62973. }
  62974. declare module BABYLON {
  62975. /**
  62976. * Implementation of the DDS Texture Loader.
  62977. * @hidden
  62978. */
  62979. export class _DDSTextureLoader implements IInternalTextureLoader {
  62980. /**
  62981. * Defines whether the loader supports cascade loading the different faces.
  62982. */
  62983. readonly supportCascades: boolean;
  62984. /**
  62985. * This returns if the loader support the current file information.
  62986. * @param extension defines the file extension of the file being loaded
  62987. * @returns true if the loader can load the specified file
  62988. */
  62989. canLoad(extension: string): boolean;
  62990. /**
  62991. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62992. * @param data contains the texture data
  62993. * @param texture defines the BabylonJS internal texture
  62994. * @param createPolynomials will be true if polynomials have been requested
  62995. * @param onLoad defines the callback to trigger once the texture is ready
  62996. * @param onError defines the callback to trigger in case of error
  62997. */
  62998. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62999. /**
  63000. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63001. * @param data contains the texture data
  63002. * @param texture defines the BabylonJS internal texture
  63003. * @param callback defines the method to call once ready to upload
  63004. */
  63005. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63006. }
  63007. }
  63008. declare module BABYLON {
  63009. /**
  63010. * Implementation of the ENV Texture Loader.
  63011. * @hidden
  63012. */
  63013. export class _ENVTextureLoader implements IInternalTextureLoader {
  63014. /**
  63015. * Defines whether the loader supports cascade loading the different faces.
  63016. */
  63017. readonly supportCascades: boolean;
  63018. /**
  63019. * This returns if the loader support the current file information.
  63020. * @param extension defines the file extension of the file being loaded
  63021. * @returns true if the loader can load the specified file
  63022. */
  63023. canLoad(extension: string): boolean;
  63024. /**
  63025. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63026. * @param data contains the texture data
  63027. * @param texture defines the BabylonJS internal texture
  63028. * @param createPolynomials will be true if polynomials have been requested
  63029. * @param onLoad defines the callback to trigger once the texture is ready
  63030. * @param onError defines the callback to trigger in case of error
  63031. */
  63032. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63033. /**
  63034. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63035. * @param data contains the texture data
  63036. * @param texture defines the BabylonJS internal texture
  63037. * @param callback defines the method to call once ready to upload
  63038. */
  63039. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63040. }
  63041. }
  63042. declare module BABYLON {
  63043. /**
  63044. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  63045. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  63046. */
  63047. export class KhronosTextureContainer {
  63048. /** contents of the KTX container file */
  63049. data: ArrayBufferView;
  63050. private static HEADER_LEN;
  63051. private static COMPRESSED_2D;
  63052. private static COMPRESSED_3D;
  63053. private static TEX_2D;
  63054. private static TEX_3D;
  63055. /**
  63056. * Gets the openGL type
  63057. */
  63058. glType: number;
  63059. /**
  63060. * Gets the openGL type size
  63061. */
  63062. glTypeSize: number;
  63063. /**
  63064. * Gets the openGL format
  63065. */
  63066. glFormat: number;
  63067. /**
  63068. * Gets the openGL internal format
  63069. */
  63070. glInternalFormat: number;
  63071. /**
  63072. * Gets the base internal format
  63073. */
  63074. glBaseInternalFormat: number;
  63075. /**
  63076. * Gets image width in pixel
  63077. */
  63078. pixelWidth: number;
  63079. /**
  63080. * Gets image height in pixel
  63081. */
  63082. pixelHeight: number;
  63083. /**
  63084. * Gets image depth in pixels
  63085. */
  63086. pixelDepth: number;
  63087. /**
  63088. * Gets the number of array elements
  63089. */
  63090. numberOfArrayElements: number;
  63091. /**
  63092. * Gets the number of faces
  63093. */
  63094. numberOfFaces: number;
  63095. /**
  63096. * Gets the number of mipmap levels
  63097. */
  63098. numberOfMipmapLevels: number;
  63099. /**
  63100. * Gets the bytes of key value data
  63101. */
  63102. bytesOfKeyValueData: number;
  63103. /**
  63104. * Gets the load type
  63105. */
  63106. loadType: number;
  63107. /**
  63108. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  63109. */
  63110. isInvalid: boolean;
  63111. /**
  63112. * Creates a new KhronosTextureContainer
  63113. * @param data contents of the KTX container file
  63114. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  63115. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  63116. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  63117. */
  63118. constructor(
  63119. /** contents of the KTX container file */
  63120. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  63121. /**
  63122. * Uploads KTX content to a Babylon Texture.
  63123. * It is assumed that the texture has already been created & is currently bound
  63124. * @hidden
  63125. */
  63126. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  63127. private _upload2DCompressedLevels;
  63128. /**
  63129. * Checks if the given data starts with a KTX file identifier.
  63130. * @param data the data to check
  63131. * @returns true if the data is a KTX file or false otherwise
  63132. */
  63133. static IsValid(data: ArrayBufferView): boolean;
  63134. }
  63135. }
  63136. declare module BABYLON {
  63137. /**
  63138. * Helper class to push actions to a pool of workers.
  63139. */
  63140. export class WorkerPool implements IDisposable {
  63141. private _workerInfos;
  63142. private _pendingActions;
  63143. /**
  63144. * Constructor
  63145. * @param workers Array of workers to use for actions
  63146. */
  63147. constructor(workers: Array<Worker>);
  63148. /**
  63149. * Terminates all workers and clears any pending actions.
  63150. */
  63151. dispose(): void;
  63152. /**
  63153. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63154. * pended until a worker has completed its action.
  63155. * @param action The action to perform. Call onComplete when the action is complete.
  63156. */
  63157. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63158. private _execute;
  63159. }
  63160. }
  63161. declare module BABYLON {
  63162. /**
  63163. * Class for loading KTX2 files
  63164. */
  63165. export class KhronosTextureContainer2 {
  63166. private static _WorkerPoolPromise?;
  63167. private static _Initialized;
  63168. private static _Ktx2Decoder;
  63169. /**
  63170. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  63171. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  63172. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  63173. * Urls you can change:
  63174. * URLConfig.jsDecoderModule
  63175. * URLConfig.wasmUASTCToASTC
  63176. * URLConfig.wasmUASTCToBC7
  63177. * URLConfig.wasmUASTCToRGBA_UNORM
  63178. * URLConfig.wasmUASTCToRGBA_SRGB
  63179. * URLConfig.jsMSCTranscoder
  63180. * URLConfig.wasmMSCTranscoder
  63181. * URLConfig.wasmZSTDDecoder
  63182. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#29
  63183. */
  63184. static URLConfig: {
  63185. jsDecoderModule: string;
  63186. wasmUASTCToASTC: null;
  63187. wasmUASTCToBC7: null;
  63188. wasmUASTCToRGBA_UNORM: null;
  63189. wasmUASTCToRGBA_SRGB: null;
  63190. jsMSCTranscoder: null;
  63191. wasmMSCTranscoder: null;
  63192. wasmZSTDDecoder: null;
  63193. };
  63194. /**
  63195. * Default number of workers used to handle data decoding
  63196. */
  63197. static DefaultNumWorkers: number;
  63198. private static GetDefaultNumWorkers;
  63199. private _engine;
  63200. private static _CreateWorkerPool;
  63201. /**
  63202. * Constructor
  63203. * @param engine The engine to use
  63204. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63205. */
  63206. constructor(engine: ThinEngine, numWorkers?: number);
  63207. /** @hidden */
  63208. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  63209. /**
  63210. * Stop all async operations and release resources.
  63211. */
  63212. dispose(): void;
  63213. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  63214. /**
  63215. * Checks if the given data starts with a KTX2 file identifier.
  63216. * @param data the data to check
  63217. * @returns true if the data is a KTX2 file or false otherwise
  63218. */
  63219. static IsValid(data: ArrayBufferView): boolean;
  63220. }
  63221. }
  63222. declare module BABYLON {
  63223. /**
  63224. * Implementation of the KTX Texture Loader.
  63225. * @hidden
  63226. */
  63227. export class _KTXTextureLoader implements IInternalTextureLoader {
  63228. /**
  63229. * Defines whether the loader supports cascade loading the different faces.
  63230. */
  63231. readonly supportCascades: boolean;
  63232. /**
  63233. * This returns if the loader support the current file information.
  63234. * @param extension defines the file extension of the file being loaded
  63235. * @param mimeType defines the optional mime type of the file being loaded
  63236. * @returns true if the loader can load the specified file
  63237. */
  63238. canLoad(extension: string, mimeType?: string): boolean;
  63239. /**
  63240. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63241. * @param data contains the texture data
  63242. * @param texture defines the BabylonJS internal texture
  63243. * @param createPolynomials will be true if polynomials have been requested
  63244. * @param onLoad defines the callback to trigger once the texture is ready
  63245. * @param onError defines the callback to trigger in case of error
  63246. */
  63247. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63248. /**
  63249. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63250. * @param data contains the texture data
  63251. * @param texture defines the BabylonJS internal texture
  63252. * @param callback defines the method to call once ready to upload
  63253. */
  63254. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  63255. }
  63256. }
  63257. declare module BABYLON {
  63258. /** @hidden */
  63259. export var _forceSceneHelpersToBundle: boolean;
  63260. interface Scene {
  63261. /**
  63262. * Creates a default light for the scene.
  63263. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  63264. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  63265. */
  63266. createDefaultLight(replace?: boolean): void;
  63267. /**
  63268. * Creates a default camera for the scene.
  63269. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  63270. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  63271. * @param replace has default false, when true replaces the active camera in the scene
  63272. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  63273. */
  63274. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  63275. /**
  63276. * Creates a default camera and a default light.
  63277. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  63278. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  63279. * @param replace has the default false, when true replaces the active camera/light in the scene
  63280. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  63281. */
  63282. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  63283. /**
  63284. * Creates a new sky box
  63285. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  63286. * @param environmentTexture defines the texture to use as environment texture
  63287. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  63288. * @param scale defines the overall scale of the skybox
  63289. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  63290. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  63291. * @returns a new mesh holding the sky box
  63292. */
  63293. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  63294. /**
  63295. * Creates a new environment
  63296. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  63297. * @param options defines the options you can use to configure the environment
  63298. * @returns the new EnvironmentHelper
  63299. */
  63300. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  63301. /**
  63302. * Creates a new VREXperienceHelper
  63303. * @see https://doc.babylonjs.com/how_to/webvr_helper
  63304. * @param webVROptions defines the options used to create the new VREXperienceHelper
  63305. * @returns a new VREXperienceHelper
  63306. */
  63307. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  63308. /**
  63309. * Creates a new WebXRDefaultExperience
  63310. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  63311. * @param options experience options
  63312. * @returns a promise for a new WebXRDefaultExperience
  63313. */
  63314. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  63315. }
  63316. }
  63317. declare module BABYLON {
  63318. /**
  63319. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  63320. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  63321. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  63322. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  63323. */
  63324. export class VideoDome extends TextureDome<VideoTexture> {
  63325. /**
  63326. * Define the video source as a Monoscopic panoramic 360 video.
  63327. */
  63328. static readonly MODE_MONOSCOPIC: number;
  63329. /**
  63330. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  63331. */
  63332. static readonly MODE_TOPBOTTOM: number;
  63333. /**
  63334. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  63335. */
  63336. static readonly MODE_SIDEBYSIDE: number;
  63337. /**
  63338. * Get the video texture associated with this video dome
  63339. */
  63340. get videoTexture(): VideoTexture;
  63341. /**
  63342. * Get the video mode of this dome
  63343. */
  63344. get videoMode(): number;
  63345. /**
  63346. * Set the video mode of this dome.
  63347. * @see textureMode
  63348. */
  63349. set videoMode(value: number);
  63350. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  63351. }
  63352. }
  63353. declare module BABYLON {
  63354. /**
  63355. * This class can be used to get instrumentation data from a Babylon engine
  63356. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  63357. */
  63358. export class EngineInstrumentation implements IDisposable {
  63359. /**
  63360. * Define the instrumented engine.
  63361. */
  63362. engine: Engine;
  63363. private _captureGPUFrameTime;
  63364. private _gpuFrameTimeToken;
  63365. private _gpuFrameTime;
  63366. private _captureShaderCompilationTime;
  63367. private _shaderCompilationTime;
  63368. private _onBeginFrameObserver;
  63369. private _onEndFrameObserver;
  63370. private _onBeforeShaderCompilationObserver;
  63371. private _onAfterShaderCompilationObserver;
  63372. /**
  63373. * Gets the perf counter used for GPU frame time
  63374. */
  63375. get gpuFrameTimeCounter(): PerfCounter;
  63376. /**
  63377. * Gets the GPU frame time capture status
  63378. */
  63379. get captureGPUFrameTime(): boolean;
  63380. /**
  63381. * Enable or disable the GPU frame time capture
  63382. */
  63383. set captureGPUFrameTime(value: boolean);
  63384. /**
  63385. * Gets the perf counter used for shader compilation time
  63386. */
  63387. get shaderCompilationTimeCounter(): PerfCounter;
  63388. /**
  63389. * Gets the shader compilation time capture status
  63390. */
  63391. get captureShaderCompilationTime(): boolean;
  63392. /**
  63393. * Enable or disable the shader compilation time capture
  63394. */
  63395. set captureShaderCompilationTime(value: boolean);
  63396. /**
  63397. * Instantiates a new engine instrumentation.
  63398. * This class can be used to get instrumentation data from a Babylon engine
  63399. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  63400. * @param engine Defines the engine to instrument
  63401. */
  63402. constructor(
  63403. /**
  63404. * Define the instrumented engine.
  63405. */
  63406. engine: Engine);
  63407. /**
  63408. * Dispose and release associated resources.
  63409. */
  63410. dispose(): void;
  63411. }
  63412. }
  63413. declare module BABYLON {
  63414. /**
  63415. * This class can be used to get instrumentation data from a Babylon engine
  63416. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  63417. */
  63418. export class SceneInstrumentation implements IDisposable {
  63419. /**
  63420. * Defines the scene to instrument
  63421. */
  63422. scene: Scene;
  63423. private _captureActiveMeshesEvaluationTime;
  63424. private _activeMeshesEvaluationTime;
  63425. private _captureRenderTargetsRenderTime;
  63426. private _renderTargetsRenderTime;
  63427. private _captureFrameTime;
  63428. private _frameTime;
  63429. private _captureRenderTime;
  63430. private _renderTime;
  63431. private _captureInterFrameTime;
  63432. private _interFrameTime;
  63433. private _captureParticlesRenderTime;
  63434. private _particlesRenderTime;
  63435. private _captureSpritesRenderTime;
  63436. private _spritesRenderTime;
  63437. private _capturePhysicsTime;
  63438. private _physicsTime;
  63439. private _captureAnimationsTime;
  63440. private _animationsTime;
  63441. private _captureCameraRenderTime;
  63442. private _cameraRenderTime;
  63443. private _onBeforeActiveMeshesEvaluationObserver;
  63444. private _onAfterActiveMeshesEvaluationObserver;
  63445. private _onBeforeRenderTargetsRenderObserver;
  63446. private _onAfterRenderTargetsRenderObserver;
  63447. private _onAfterRenderObserver;
  63448. private _onBeforeDrawPhaseObserver;
  63449. private _onAfterDrawPhaseObserver;
  63450. private _onBeforeAnimationsObserver;
  63451. private _onBeforeParticlesRenderingObserver;
  63452. private _onAfterParticlesRenderingObserver;
  63453. private _onBeforeSpritesRenderingObserver;
  63454. private _onAfterSpritesRenderingObserver;
  63455. private _onBeforePhysicsObserver;
  63456. private _onAfterPhysicsObserver;
  63457. private _onAfterAnimationsObserver;
  63458. private _onBeforeCameraRenderObserver;
  63459. private _onAfterCameraRenderObserver;
  63460. /**
  63461. * Gets the perf counter used for active meshes evaluation time
  63462. */
  63463. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  63464. /**
  63465. * Gets the active meshes evaluation time capture status
  63466. */
  63467. get captureActiveMeshesEvaluationTime(): boolean;
  63468. /**
  63469. * Enable or disable the active meshes evaluation time capture
  63470. */
  63471. set captureActiveMeshesEvaluationTime(value: boolean);
  63472. /**
  63473. * Gets the perf counter used for render targets render time
  63474. */
  63475. get renderTargetsRenderTimeCounter(): PerfCounter;
  63476. /**
  63477. * Gets the render targets render time capture status
  63478. */
  63479. get captureRenderTargetsRenderTime(): boolean;
  63480. /**
  63481. * Enable or disable the render targets render time capture
  63482. */
  63483. set captureRenderTargetsRenderTime(value: boolean);
  63484. /**
  63485. * Gets the perf counter used for particles render time
  63486. */
  63487. get particlesRenderTimeCounter(): PerfCounter;
  63488. /**
  63489. * Gets the particles render time capture status
  63490. */
  63491. get captureParticlesRenderTime(): boolean;
  63492. /**
  63493. * Enable or disable the particles render time capture
  63494. */
  63495. set captureParticlesRenderTime(value: boolean);
  63496. /**
  63497. * Gets the perf counter used for sprites render time
  63498. */
  63499. get spritesRenderTimeCounter(): PerfCounter;
  63500. /**
  63501. * Gets the sprites render time capture status
  63502. */
  63503. get captureSpritesRenderTime(): boolean;
  63504. /**
  63505. * Enable or disable the sprites render time capture
  63506. */
  63507. set captureSpritesRenderTime(value: boolean);
  63508. /**
  63509. * Gets the perf counter used for physics time
  63510. */
  63511. get physicsTimeCounter(): PerfCounter;
  63512. /**
  63513. * Gets the physics time capture status
  63514. */
  63515. get capturePhysicsTime(): boolean;
  63516. /**
  63517. * Enable or disable the physics time capture
  63518. */
  63519. set capturePhysicsTime(value: boolean);
  63520. /**
  63521. * Gets the perf counter used for animations time
  63522. */
  63523. get animationsTimeCounter(): PerfCounter;
  63524. /**
  63525. * Gets the animations time capture status
  63526. */
  63527. get captureAnimationsTime(): boolean;
  63528. /**
  63529. * Enable or disable the animations time capture
  63530. */
  63531. set captureAnimationsTime(value: boolean);
  63532. /**
  63533. * Gets the perf counter used for frame time capture
  63534. */
  63535. get frameTimeCounter(): PerfCounter;
  63536. /**
  63537. * Gets the frame time capture status
  63538. */
  63539. get captureFrameTime(): boolean;
  63540. /**
  63541. * Enable or disable the frame time capture
  63542. */
  63543. set captureFrameTime(value: boolean);
  63544. /**
  63545. * Gets the perf counter used for inter-frames time capture
  63546. */
  63547. get interFrameTimeCounter(): PerfCounter;
  63548. /**
  63549. * Gets the inter-frames time capture status
  63550. */
  63551. get captureInterFrameTime(): boolean;
  63552. /**
  63553. * Enable or disable the inter-frames time capture
  63554. */
  63555. set captureInterFrameTime(value: boolean);
  63556. /**
  63557. * Gets the perf counter used for render time capture
  63558. */
  63559. get renderTimeCounter(): PerfCounter;
  63560. /**
  63561. * Gets the render time capture status
  63562. */
  63563. get captureRenderTime(): boolean;
  63564. /**
  63565. * Enable or disable the render time capture
  63566. */
  63567. set captureRenderTime(value: boolean);
  63568. /**
  63569. * Gets the perf counter used for camera render time capture
  63570. */
  63571. get cameraRenderTimeCounter(): PerfCounter;
  63572. /**
  63573. * Gets the camera render time capture status
  63574. */
  63575. get captureCameraRenderTime(): boolean;
  63576. /**
  63577. * Enable or disable the camera render time capture
  63578. */
  63579. set captureCameraRenderTime(value: boolean);
  63580. /**
  63581. * Gets the perf counter used for draw calls
  63582. */
  63583. get drawCallsCounter(): PerfCounter;
  63584. /**
  63585. * Instantiates a new scene instrumentation.
  63586. * This class can be used to get instrumentation data from a Babylon engine
  63587. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  63588. * @param scene Defines the scene to instrument
  63589. */
  63590. constructor(
  63591. /**
  63592. * Defines the scene to instrument
  63593. */
  63594. scene: Scene);
  63595. /**
  63596. * Dispose and release associated resources.
  63597. */
  63598. dispose(): void;
  63599. }
  63600. }
  63601. declare module BABYLON {
  63602. /** @hidden */
  63603. export var glowMapGenerationPixelShader: {
  63604. name: string;
  63605. shader: string;
  63606. };
  63607. }
  63608. declare module BABYLON {
  63609. /** @hidden */
  63610. export var glowMapGenerationVertexShader: {
  63611. name: string;
  63612. shader: string;
  63613. };
  63614. }
  63615. declare module BABYLON {
  63616. /**
  63617. * Effect layer options. This helps customizing the behaviour
  63618. * of the effect layer.
  63619. */
  63620. export interface IEffectLayerOptions {
  63621. /**
  63622. * Multiplication factor apply to the canvas size to compute the render target size
  63623. * used to generated the objects (the smaller the faster).
  63624. */
  63625. mainTextureRatio: number;
  63626. /**
  63627. * Enforces a fixed size texture to ensure effect stability across devices.
  63628. */
  63629. mainTextureFixedSize?: number;
  63630. /**
  63631. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  63632. */
  63633. alphaBlendingMode: number;
  63634. /**
  63635. * The camera attached to the layer.
  63636. */
  63637. camera: Nullable<Camera>;
  63638. /**
  63639. * The rendering group to draw the layer in.
  63640. */
  63641. renderingGroupId: number;
  63642. }
  63643. /**
  63644. * The effect layer Helps adding post process effect blended with the main pass.
  63645. *
  63646. * This can be for instance use to generate glow or highlight effects on the scene.
  63647. *
  63648. * The effect layer class can not be used directly and is intented to inherited from to be
  63649. * customized per effects.
  63650. */
  63651. export abstract class EffectLayer {
  63652. private _vertexBuffers;
  63653. private _indexBuffer;
  63654. private _cachedDefines;
  63655. private _effectLayerMapGenerationEffect;
  63656. private _effectLayerOptions;
  63657. private _mergeEffect;
  63658. protected _scene: Scene;
  63659. protected _engine: Engine;
  63660. protected _maxSize: number;
  63661. protected _mainTextureDesiredSize: ISize;
  63662. protected _mainTexture: RenderTargetTexture;
  63663. protected _shouldRender: boolean;
  63664. protected _postProcesses: PostProcess[];
  63665. protected _textures: BaseTexture[];
  63666. protected _emissiveTextureAndColor: {
  63667. texture: Nullable<BaseTexture>;
  63668. color: Color4;
  63669. };
  63670. /**
  63671. * The name of the layer
  63672. */
  63673. name: string;
  63674. /**
  63675. * The clear color of the texture used to generate the glow map.
  63676. */
  63677. neutralColor: Color4;
  63678. /**
  63679. * Specifies whether the highlight layer is enabled or not.
  63680. */
  63681. isEnabled: boolean;
  63682. /**
  63683. * Gets the camera attached to the layer.
  63684. */
  63685. get camera(): Nullable<Camera>;
  63686. /**
  63687. * Gets the rendering group id the layer should render in.
  63688. */
  63689. get renderingGroupId(): number;
  63690. set renderingGroupId(renderingGroupId: number);
  63691. /**
  63692. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  63693. */
  63694. disableBoundingBoxesFromEffectLayer: boolean;
  63695. /**
  63696. * An event triggered when the effect layer has been disposed.
  63697. */
  63698. onDisposeObservable: Observable<EffectLayer>;
  63699. /**
  63700. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  63701. */
  63702. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  63703. /**
  63704. * An event triggered when the generated texture is being merged in the scene.
  63705. */
  63706. onBeforeComposeObservable: Observable<EffectLayer>;
  63707. /**
  63708. * An event triggered when the mesh is rendered into the effect render target.
  63709. */
  63710. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  63711. /**
  63712. * An event triggered after the mesh has been rendered into the effect render target.
  63713. */
  63714. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  63715. /**
  63716. * An event triggered when the generated texture has been merged in the scene.
  63717. */
  63718. onAfterComposeObservable: Observable<EffectLayer>;
  63719. /**
  63720. * An event triggered when the effect layer changes its size.
  63721. */
  63722. onSizeChangedObservable: Observable<EffectLayer>;
  63723. /** @hidden */
  63724. static _SceneComponentInitialization: (scene: Scene) => void;
  63725. /**
  63726. * Instantiates a new effect Layer and references it in the scene.
  63727. * @param name The name of the layer
  63728. * @param scene The scene to use the layer in
  63729. */
  63730. constructor(
  63731. /** The Friendly of the effect in the scene */
  63732. name: string, scene: Scene);
  63733. /**
  63734. * Get the effect name of the layer.
  63735. * @return The effect name
  63736. */
  63737. abstract getEffectName(): string;
  63738. /**
  63739. * Checks for the readiness of the element composing the layer.
  63740. * @param subMesh the mesh to check for
  63741. * @param useInstances specify whether or not to use instances to render the mesh
  63742. * @return true if ready otherwise, false
  63743. */
  63744. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63745. /**
  63746. * Returns whether or not the layer needs stencil enabled during the mesh rendering.
  63747. * @returns true if the effect requires stencil during the main canvas render pass.
  63748. */
  63749. abstract needStencil(): boolean;
  63750. /**
  63751. * Create the merge effect. This is the shader use to blit the information back
  63752. * to the main canvas at the end of the scene rendering.
  63753. * @returns The effect containing the shader used to merge the effect on the main canvas
  63754. */
  63755. protected abstract _createMergeEffect(): Effect;
  63756. /**
  63757. * Creates the render target textures and post processes used in the effect layer.
  63758. */
  63759. protected abstract _createTextureAndPostProcesses(): void;
  63760. /**
  63761. * Implementation specific of rendering the generating effect on the main canvas.
  63762. * @param effect The effect used to render through
  63763. */
  63764. protected abstract _internalRender(effect: Effect): void;
  63765. /**
  63766. * Sets the required values for both the emissive texture and and the main color.
  63767. */
  63768. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63769. /**
  63770. * Free any resources and references associated to a mesh.
  63771. * Internal use
  63772. * @param mesh The mesh to free.
  63773. */
  63774. abstract _disposeMesh(mesh: Mesh): void;
  63775. /**
  63776. * Serializes this layer (Glow or Highlight for example)
  63777. * @returns a serialized layer object
  63778. */
  63779. abstract serialize?(): any;
  63780. /**
  63781. * Initializes the effect layer with the required options.
  63782. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  63783. */
  63784. protected _init(options: Partial<IEffectLayerOptions>): void;
  63785. /**
  63786. * Generates the index buffer of the full screen quad blending to the main canvas.
  63787. */
  63788. private _generateIndexBuffer;
  63789. /**
  63790. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  63791. */
  63792. private _generateVertexBuffer;
  63793. /**
  63794. * Sets the main texture desired size which is the closest power of two
  63795. * of the engine canvas size.
  63796. */
  63797. private _setMainTextureSize;
  63798. /**
  63799. * Creates the main texture for the effect layer.
  63800. */
  63801. protected _createMainTexture(): void;
  63802. /**
  63803. * Adds specific effects defines.
  63804. * @param defines The defines to add specifics to.
  63805. */
  63806. protected _addCustomEffectDefines(defines: string[]): void;
  63807. /**
  63808. * Checks for the readiness of the element composing the layer.
  63809. * @param subMesh the mesh to check for
  63810. * @param useInstances specify whether or not to use instances to render the mesh
  63811. * @param emissiveTexture the associated emissive texture used to generate the glow
  63812. * @return true if ready otherwise, false
  63813. */
  63814. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  63815. /**
  63816. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  63817. */
  63818. render(): void;
  63819. /**
  63820. * Determine if a given mesh will be used in the current effect.
  63821. * @param mesh mesh to test
  63822. * @returns true if the mesh will be used
  63823. */
  63824. hasMesh(mesh: AbstractMesh): boolean;
  63825. /**
  63826. * Returns true if the layer contains information to display, otherwise false.
  63827. * @returns true if the glow layer should be rendered
  63828. */
  63829. shouldRender(): boolean;
  63830. /**
  63831. * Returns true if the mesh should render, otherwise false.
  63832. * @param mesh The mesh to render
  63833. * @returns true if it should render otherwise false
  63834. */
  63835. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  63836. /**
  63837. * Returns true if the mesh can be rendered, otherwise false.
  63838. * @param mesh The mesh to render
  63839. * @param material The material used on the mesh
  63840. * @returns true if it can be rendered otherwise false
  63841. */
  63842. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63843. /**
  63844. * Returns true if the mesh should render, otherwise false.
  63845. * @param mesh The mesh to render
  63846. * @returns true if it should render otherwise false
  63847. */
  63848. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  63849. /**
  63850. * Renders the submesh passed in parameter to the generation map.
  63851. */
  63852. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  63853. /**
  63854. * Defines whether the current material of the mesh should be use to render the effect.
  63855. * @param mesh defines the current mesh to render
  63856. */
  63857. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  63858. /**
  63859. * Rebuild the required buffers.
  63860. * @hidden Internal use only.
  63861. */
  63862. _rebuild(): void;
  63863. /**
  63864. * Dispose only the render target textures and post process.
  63865. */
  63866. private _disposeTextureAndPostProcesses;
  63867. /**
  63868. * Dispose the highlight layer and free resources.
  63869. */
  63870. dispose(): void;
  63871. /**
  63872. * Gets the class name of the effect layer
  63873. * @returns the string with the class name of the effect layer
  63874. */
  63875. getClassName(): string;
  63876. /**
  63877. * Creates an effect layer from parsed effect layer data
  63878. * @param parsedEffectLayer defines effect layer data
  63879. * @param scene defines the current scene
  63880. * @param rootUrl defines the root URL containing the effect layer information
  63881. * @returns a parsed effect Layer
  63882. */
  63883. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  63884. }
  63885. }
  63886. declare module BABYLON {
  63887. interface AbstractScene {
  63888. /**
  63889. * The list of effect layers (highlights/glow) added to the scene
  63890. * @see https://doc.babylonjs.com/how_to/highlight_layer
  63891. * @see https://doc.babylonjs.com/how_to/glow_layer
  63892. */
  63893. effectLayers: Array<EffectLayer>;
  63894. /**
  63895. * Removes the given effect layer from this scene.
  63896. * @param toRemove defines the effect layer to remove
  63897. * @returns the index of the removed effect layer
  63898. */
  63899. removeEffectLayer(toRemove: EffectLayer): number;
  63900. /**
  63901. * Adds the given effect layer to this scene
  63902. * @param newEffectLayer defines the effect layer to add
  63903. */
  63904. addEffectLayer(newEffectLayer: EffectLayer): void;
  63905. }
  63906. /**
  63907. * Defines the layer scene component responsible to manage any effect layers
  63908. * in a given scene.
  63909. */
  63910. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  63911. /**
  63912. * The component name helpful to identify the component in the list of scene components.
  63913. */
  63914. readonly name: string;
  63915. /**
  63916. * The scene the component belongs to.
  63917. */
  63918. scene: Scene;
  63919. private _engine;
  63920. private _renderEffects;
  63921. private _needStencil;
  63922. private _previousStencilState;
  63923. /**
  63924. * Creates a new instance of the component for the given scene
  63925. * @param scene Defines the scene to register the component in
  63926. */
  63927. constructor(scene: Scene);
  63928. /**
  63929. * Registers the component in a given scene
  63930. */
  63931. register(): void;
  63932. /**
  63933. * Rebuilds the elements related to this component in case of
  63934. * context lost for instance.
  63935. */
  63936. rebuild(): void;
  63937. /**
  63938. * Serializes the component data to the specified json object
  63939. * @param serializationObject The object to serialize to
  63940. */
  63941. serialize(serializationObject: any): void;
  63942. /**
  63943. * Adds all the elements from the container to the scene
  63944. * @param container the container holding the elements
  63945. */
  63946. addFromContainer(container: AbstractScene): void;
  63947. /**
  63948. * Removes all the elements in the container from the scene
  63949. * @param container contains the elements to remove
  63950. * @param dispose if the removed element should be disposed (default: false)
  63951. */
  63952. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63953. /**
  63954. * Disposes the component and the associated resources.
  63955. */
  63956. dispose(): void;
  63957. private _isReadyForMesh;
  63958. private _renderMainTexture;
  63959. private _setStencil;
  63960. private _setStencilBack;
  63961. private _draw;
  63962. private _drawCamera;
  63963. private _drawRenderingGroup;
  63964. }
  63965. }
  63966. declare module BABYLON {
  63967. /** @hidden */
  63968. export var glowMapMergePixelShader: {
  63969. name: string;
  63970. shader: string;
  63971. };
  63972. }
  63973. declare module BABYLON {
  63974. /** @hidden */
  63975. export var glowMapMergeVertexShader: {
  63976. name: string;
  63977. shader: string;
  63978. };
  63979. }
  63980. declare module BABYLON {
  63981. interface AbstractScene {
  63982. /**
  63983. * Return a the first highlight layer of the scene with a given name.
  63984. * @param name The name of the highlight layer to look for.
  63985. * @return The highlight layer if found otherwise null.
  63986. */
  63987. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  63988. }
  63989. /**
  63990. * Glow layer options. This helps customizing the behaviour
  63991. * of the glow layer.
  63992. */
  63993. export interface IGlowLayerOptions {
  63994. /**
  63995. * Multiplication factor apply to the canvas size to compute the render target size
  63996. * used to generated the glowing objects (the smaller the faster).
  63997. */
  63998. mainTextureRatio: number;
  63999. /**
  64000. * Enforces a fixed size texture to ensure resize independent blur.
  64001. */
  64002. mainTextureFixedSize?: number;
  64003. /**
  64004. * How big is the kernel of the blur texture.
  64005. */
  64006. blurKernelSize: number;
  64007. /**
  64008. * The camera attached to the layer.
  64009. */
  64010. camera: Nullable<Camera>;
  64011. /**
  64012. * Enable MSAA by choosing the number of samples.
  64013. */
  64014. mainTextureSamples?: number;
  64015. /**
  64016. * The rendering group to draw the layer in.
  64017. */
  64018. renderingGroupId: number;
  64019. }
  64020. /**
  64021. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  64022. *
  64023. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  64024. *
  64025. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  64026. */
  64027. export class GlowLayer extends EffectLayer {
  64028. /**
  64029. * Effect Name of the layer.
  64030. */
  64031. static readonly EffectName: string;
  64032. /**
  64033. * The default blur kernel size used for the glow.
  64034. */
  64035. static DefaultBlurKernelSize: number;
  64036. /**
  64037. * The default texture size ratio used for the glow.
  64038. */
  64039. static DefaultTextureRatio: number;
  64040. /**
  64041. * Sets the kernel size of the blur.
  64042. */
  64043. set blurKernelSize(value: number);
  64044. /**
  64045. * Gets the kernel size of the blur.
  64046. */
  64047. get blurKernelSize(): number;
  64048. /**
  64049. * Sets the glow intensity.
  64050. */
  64051. set intensity(value: number);
  64052. /**
  64053. * Gets the glow intensity.
  64054. */
  64055. get intensity(): number;
  64056. private _options;
  64057. private _intensity;
  64058. private _horizontalBlurPostprocess1;
  64059. private _verticalBlurPostprocess1;
  64060. private _horizontalBlurPostprocess2;
  64061. private _verticalBlurPostprocess2;
  64062. private _blurTexture1;
  64063. private _blurTexture2;
  64064. private _postProcesses1;
  64065. private _postProcesses2;
  64066. private _includedOnlyMeshes;
  64067. private _excludedMeshes;
  64068. private _meshesUsingTheirOwnMaterials;
  64069. /**
  64070. * Callback used to let the user override the color selection on a per mesh basis
  64071. */
  64072. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  64073. /**
  64074. * Callback used to let the user override the texture selection on a per mesh basis
  64075. */
  64076. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  64077. /**
  64078. * Instantiates a new glow Layer and references it to the scene.
  64079. * @param name The name of the layer
  64080. * @param scene The scene to use the layer in
  64081. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  64082. */
  64083. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  64084. /**
  64085. * Get the effect name of the layer.
  64086. * @return The effect name
  64087. */
  64088. getEffectName(): string;
  64089. /**
  64090. * Create the merge effect. This is the shader use to blit the information back
  64091. * to the main canvas at the end of the scene rendering.
  64092. */
  64093. protected _createMergeEffect(): Effect;
  64094. /**
  64095. * Creates the render target textures and post processes used in the glow layer.
  64096. */
  64097. protected _createTextureAndPostProcesses(): void;
  64098. /**
  64099. * Checks for the readiness of the element composing the layer.
  64100. * @param subMesh the mesh to check for
  64101. * @param useInstances specify whether or not to use instances to render the mesh
  64102. * @param emissiveTexture the associated emissive texture used to generate the glow
  64103. * @return true if ready otherwise, false
  64104. */
  64105. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64106. /**
  64107. * Returns whether or not the layer needs stencil enabled during the mesh rendering.
  64108. */
  64109. needStencil(): boolean;
  64110. /**
  64111. * Returns true if the mesh can be rendered, otherwise false.
  64112. * @param mesh The mesh to render
  64113. * @param material The material used on the mesh
  64114. * @returns true if it can be rendered otherwise false
  64115. */
  64116. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  64117. /**
  64118. * Implementation specific of rendering the generating effect on the main canvas.
  64119. * @param effect The effect used to render through
  64120. */
  64121. protected _internalRender(effect: Effect): void;
  64122. /**
  64123. * Sets the required values for both the emissive texture and and the main color.
  64124. */
  64125. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  64126. /**
  64127. * Returns true if the mesh should render, otherwise false.
  64128. * @param mesh The mesh to render
  64129. * @returns true if it should render otherwise false
  64130. */
  64131. protected _shouldRenderMesh(mesh: Mesh): boolean;
  64132. /**
  64133. * Adds specific effects defines.
  64134. * @param defines The defines to add specifics to.
  64135. */
  64136. protected _addCustomEffectDefines(defines: string[]): void;
  64137. /**
  64138. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  64139. * @param mesh The mesh to exclude from the glow layer
  64140. */
  64141. addExcludedMesh(mesh: Mesh): void;
  64142. /**
  64143. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  64144. * @param mesh The mesh to remove
  64145. */
  64146. removeExcludedMesh(mesh: Mesh): void;
  64147. /**
  64148. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  64149. * @param mesh The mesh to include in the glow layer
  64150. */
  64151. addIncludedOnlyMesh(mesh: Mesh): void;
  64152. /**
  64153. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  64154. * @param mesh The mesh to remove
  64155. */
  64156. removeIncludedOnlyMesh(mesh: Mesh): void;
  64157. /**
  64158. * Determine if a given mesh will be used in the glow layer
  64159. * @param mesh The mesh to test
  64160. * @returns true if the mesh will be highlighted by the current glow layer
  64161. */
  64162. hasMesh(mesh: AbstractMesh): boolean;
  64163. /**
  64164. * Defines whether the current material of the mesh should be use to render the effect.
  64165. * @param mesh defines the current mesh to render
  64166. */
  64167. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  64168. /**
  64169. * Add a mesh to be rendered through its own material and not with emissive only.
  64170. * @param mesh The mesh for which we need to use its material
  64171. */
  64172. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  64173. /**
  64174. * Remove a mesh from being rendered through its own material and not with emissive only.
  64175. * @param mesh The mesh for which we need to not use its material
  64176. */
  64177. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  64178. /**
  64179. * Free any resources and references associated to a mesh.
  64180. * Internal use
  64181. * @param mesh The mesh to free.
  64182. * @hidden
  64183. */
  64184. _disposeMesh(mesh: Mesh): void;
  64185. /**
  64186. * Gets the class name of the effect layer
  64187. * @returns the string with the class name of the effect layer
  64188. */
  64189. getClassName(): string;
  64190. /**
  64191. * Serializes this glow layer
  64192. * @returns a serialized glow layer object
  64193. */
  64194. serialize(): any;
  64195. /**
  64196. * Creates a Glow Layer from parsed glow layer data
  64197. * @param parsedGlowLayer defines glow layer data
  64198. * @param scene defines the current scene
  64199. * @param rootUrl defines the root URL containing the glow layer information
  64200. * @returns a parsed Glow Layer
  64201. */
  64202. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  64203. }
  64204. }
  64205. declare module BABYLON {
  64206. /** @hidden */
  64207. export var glowBlurPostProcessPixelShader: {
  64208. name: string;
  64209. shader: string;
  64210. };
  64211. }
  64212. declare module BABYLON {
  64213. interface AbstractScene {
  64214. /**
  64215. * Return a the first highlight layer of the scene with a given name.
  64216. * @param name The name of the highlight layer to look for.
  64217. * @return The highlight layer if found otherwise null.
  64218. */
  64219. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  64220. }
  64221. /**
  64222. * Highlight layer options. This helps customizing the behaviour
  64223. * of the highlight layer.
  64224. */
  64225. export interface IHighlightLayerOptions {
  64226. /**
  64227. * Multiplication factor apply to the canvas size to compute the render target size
  64228. * used to generated the glowing objects (the smaller the faster).
  64229. */
  64230. mainTextureRatio: number;
  64231. /**
  64232. * Enforces a fixed size texture to ensure resize independent blur.
  64233. */
  64234. mainTextureFixedSize?: number;
  64235. /**
  64236. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  64237. * of the picture to blur (the smaller the faster).
  64238. */
  64239. blurTextureSizeRatio: number;
  64240. /**
  64241. * How big in texel of the blur texture is the vertical blur.
  64242. */
  64243. blurVerticalSize: number;
  64244. /**
  64245. * How big in texel of the blur texture is the horizontal blur.
  64246. */
  64247. blurHorizontalSize: number;
  64248. /**
  64249. * Alpha blending mode used to apply the blur. Default is combine.
  64250. */
  64251. alphaBlendingMode: number;
  64252. /**
  64253. * The camera attached to the layer.
  64254. */
  64255. camera: Nullable<Camera>;
  64256. /**
  64257. * Should we display highlight as a solid stroke?
  64258. */
  64259. isStroke?: boolean;
  64260. /**
  64261. * The rendering group to draw the layer in.
  64262. */
  64263. renderingGroupId: number;
  64264. }
  64265. /**
  64266. * The highlight layer Helps adding a glow effect around a mesh.
  64267. *
  64268. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  64269. * glowy meshes to your scene.
  64270. *
  64271. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  64272. */
  64273. export class HighlightLayer extends EffectLayer {
  64274. name: string;
  64275. /**
  64276. * Effect Name of the highlight layer.
  64277. */
  64278. static readonly EffectName: string;
  64279. /**
  64280. * The neutral color used during the preparation of the glow effect.
  64281. * This is black by default as the blend operation is a blend operation.
  64282. */
  64283. static NeutralColor: Color4;
  64284. /**
  64285. * Stencil value used for glowing meshes.
  64286. */
  64287. static GlowingMeshStencilReference: number;
  64288. /**
  64289. * Stencil value used for the other meshes in the scene.
  64290. */
  64291. static NormalMeshStencilReference: number;
  64292. /**
  64293. * Specifies whether or not the inner glow is ACTIVE in the layer.
  64294. */
  64295. innerGlow: boolean;
  64296. /**
  64297. * Specifies whether or not the outer glow is ACTIVE in the layer.
  64298. */
  64299. outerGlow: boolean;
  64300. /**
  64301. * Specifies the horizontal size of the blur.
  64302. */
  64303. set blurHorizontalSize(value: number);
  64304. /**
  64305. * Specifies the vertical size of the blur.
  64306. */
  64307. set blurVerticalSize(value: number);
  64308. /**
  64309. * Gets the horizontal size of the blur.
  64310. */
  64311. get blurHorizontalSize(): number;
  64312. /**
  64313. * Gets the vertical size of the blur.
  64314. */
  64315. get blurVerticalSize(): number;
  64316. /**
  64317. * An event triggered when the highlight layer is being blurred.
  64318. */
  64319. onBeforeBlurObservable: Observable<HighlightLayer>;
  64320. /**
  64321. * An event triggered when the highlight layer has been blurred.
  64322. */
  64323. onAfterBlurObservable: Observable<HighlightLayer>;
  64324. private _instanceGlowingMeshStencilReference;
  64325. private _options;
  64326. private _downSamplePostprocess;
  64327. private _horizontalBlurPostprocess;
  64328. private _verticalBlurPostprocess;
  64329. private _blurTexture;
  64330. private _meshes;
  64331. private _excludedMeshes;
  64332. /**
  64333. * Instantiates a new highlight Layer and references it to the scene..
  64334. * @param name The name of the layer
  64335. * @param scene The scene to use the layer in
  64336. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  64337. */
  64338. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  64339. /**
  64340. * Get the effect name of the layer.
  64341. * @return The effect name
  64342. */
  64343. getEffectName(): string;
  64344. /**
  64345. * Create the merge effect. This is the shader use to blit the information back
  64346. * to the main canvas at the end of the scene rendering.
  64347. */
  64348. protected _createMergeEffect(): Effect;
  64349. /**
  64350. * Creates the render target textures and post processes used in the highlight layer.
  64351. */
  64352. protected _createTextureAndPostProcesses(): void;
  64353. /**
  64354. * Returns whether or not the layer needs stencil enabled during the mesh rendering.
  64355. */
  64356. needStencil(): boolean;
  64357. /**
  64358. * Checks for the readiness of the element composing the layer.
  64359. * @param subMesh the mesh to check for
  64360. * @param useInstances specify wether or not to use instances to render the mesh
  64361. * @param emissiveTexture the associated emissive texture used to generate the glow
  64362. * @return true if ready otherwise, false
  64363. */
  64364. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64365. /**
  64366. * Implementation specific of rendering the generating effect on the main canvas.
  64367. * @param effect The effect used to render through
  64368. */
  64369. protected _internalRender(effect: Effect): void;
  64370. /**
  64371. * Returns true if the layer contains information to display, otherwise false.
  64372. */
  64373. shouldRender(): boolean;
  64374. /**
  64375. * Returns true if the mesh should render, otherwise false.
  64376. * @param mesh The mesh to render
  64377. * @returns true if it should render otherwise false
  64378. */
  64379. protected _shouldRenderMesh(mesh: Mesh): boolean;
  64380. /**
  64381. * Returns true if the mesh can be rendered, otherwise false.
  64382. * @param mesh The mesh to render
  64383. * @param material The material used on the mesh
  64384. * @returns true if it can be rendered otherwise false
  64385. */
  64386. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  64387. /**
  64388. * Adds specific effects defines.
  64389. * @param defines The defines to add specifics to.
  64390. */
  64391. protected _addCustomEffectDefines(defines: string[]): void;
  64392. /**
  64393. * Sets the required values for both the emissive texture and and the main color.
  64394. */
  64395. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  64396. /**
  64397. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  64398. * @param mesh The mesh to exclude from the highlight layer
  64399. */
  64400. addExcludedMesh(mesh: Mesh): void;
  64401. /**
  64402. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  64403. * @param mesh The mesh to highlight
  64404. */
  64405. removeExcludedMesh(mesh: Mesh): void;
  64406. /**
  64407. * Determine if a given mesh will be highlighted by the current HighlightLayer
  64408. * @param mesh mesh to test
  64409. * @returns true if the mesh will be highlighted by the current HighlightLayer
  64410. */
  64411. hasMesh(mesh: AbstractMesh): boolean;
  64412. /**
  64413. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  64414. * @param mesh The mesh to highlight
  64415. * @param color The color of the highlight
  64416. * @param glowEmissiveOnly Extract the glow from the emissive texture
  64417. */
  64418. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  64419. /**
  64420. * Remove a mesh from the highlight layer in order to make it stop glowing.
  64421. * @param mesh The mesh to highlight
  64422. */
  64423. removeMesh(mesh: Mesh): void;
  64424. /**
  64425. * Remove all the meshes currently referenced in the highlight layer
  64426. */
  64427. removeAllMeshes(): void;
  64428. /**
  64429. * Force the stencil to the normal expected value for none glowing parts
  64430. */
  64431. private _defaultStencilReference;
  64432. /**
  64433. * Free any resources and references associated to a mesh.
  64434. * Internal use
  64435. * @param mesh The mesh to free.
  64436. * @hidden
  64437. */
  64438. _disposeMesh(mesh: Mesh): void;
  64439. /**
  64440. * Dispose the highlight layer and free resources.
  64441. */
  64442. dispose(): void;
  64443. /**
  64444. * Gets the class name of the effect layer
  64445. * @returns the string with the class name of the effect layer
  64446. */
  64447. getClassName(): string;
  64448. /**
  64449. * Serializes this Highlight layer
  64450. * @returns a serialized Highlight layer object
  64451. */
  64452. serialize(): any;
  64453. /**
  64454. * Creates a Highlight layer from parsed Highlight layer data
  64455. * @param parsedHightlightLayer defines the Highlight layer data
  64456. * @param scene defines the current scene
  64457. * @param rootUrl defines the root URL containing the Highlight layer information
  64458. * @returns a parsed Highlight layer
  64459. */
  64460. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  64461. }
  64462. }
  64463. declare module BABYLON {
  64464. interface AbstractScene {
  64465. /**
  64466. * The list of layers (background and foreground) of the scene
  64467. */
  64468. layers: Array<Layer>;
  64469. }
  64470. /**
  64471. * Defines the layer scene component responsible to manage any layers
  64472. * in a given scene.
  64473. */
  64474. export class LayerSceneComponent implements ISceneComponent {
  64475. /**
  64476. * The component name helpful to identify the component in the list of scene components.
  64477. */
  64478. readonly name: string;
  64479. /**
  64480. * The scene the component belongs to.
  64481. */
  64482. scene: Scene;
  64483. private _engine;
  64484. /**
  64485. * Creates a new instance of the component for the given scene
  64486. * @param scene Defines the scene to register the component in
  64487. */
  64488. constructor(scene: Scene);
  64489. /**
  64490. * Registers the component in a given scene
  64491. */
  64492. register(): void;
  64493. /**
  64494. * Rebuilds the elements related to this component in case of
  64495. * context lost for instance.
  64496. */
  64497. rebuild(): void;
  64498. /**
  64499. * Disposes the component and the associated resources.
  64500. */
  64501. dispose(): void;
  64502. private _draw;
  64503. private _drawCameraPredicate;
  64504. private _drawCameraBackground;
  64505. private _drawCameraForeground;
  64506. private _drawRenderTargetPredicate;
  64507. private _drawRenderTargetBackground;
  64508. private _drawRenderTargetForeground;
  64509. /**
  64510. * Adds all the elements from the container to the scene
  64511. * @param container the container holding the elements
  64512. */
  64513. addFromContainer(container: AbstractScene): void;
  64514. /**
  64515. * Removes all the elements in the container from the scene
  64516. * @param container contains the elements to remove
  64517. * @param dispose if the removed element should be disposed (default: false)
  64518. */
  64519. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  64520. }
  64521. }
  64522. declare module BABYLON {
  64523. /** @hidden */
  64524. export var layerPixelShader: {
  64525. name: string;
  64526. shader: string;
  64527. };
  64528. }
  64529. declare module BABYLON {
  64530. /** @hidden */
  64531. export var layerVertexShader: {
  64532. name: string;
  64533. shader: string;
  64534. };
  64535. }
  64536. declare module BABYLON {
  64537. /**
  64538. * This represents a full screen 2d layer.
  64539. * This can be useful to display a picture in the background of your scene for instance.
  64540. * @see https://www.babylonjs-playground.com/#08A2BS#1
  64541. */
  64542. export class Layer {
  64543. /**
  64544. * Define the name of the layer.
  64545. */
  64546. name: string;
  64547. /**
  64548. * Define the texture the layer should display.
  64549. */
  64550. texture: Nullable<Texture>;
  64551. /**
  64552. * Is the layer in background or foreground.
  64553. */
  64554. isBackground: boolean;
  64555. /**
  64556. * Define the color of the layer (instead of texture).
  64557. */
  64558. color: Color4;
  64559. /**
  64560. * Define the scale of the layer in order to zoom in out of the texture.
  64561. */
  64562. scale: Vector2;
  64563. /**
  64564. * Define an offset for the layer in order to shift the texture.
  64565. */
  64566. offset: Vector2;
  64567. /**
  64568. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  64569. */
  64570. alphaBlendingMode: number;
  64571. /**
  64572. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  64573. * Alpha test will not mix with the background color in case of transparency.
  64574. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  64575. */
  64576. alphaTest: boolean;
  64577. /**
  64578. * Define a mask to restrict the layer to only some of the scene cameras.
  64579. */
  64580. layerMask: number;
  64581. /**
  64582. * Define the list of render target the layer is visible into.
  64583. */
  64584. renderTargetTextures: RenderTargetTexture[];
  64585. /**
  64586. * Define if the layer is only used in renderTarget or if it also
  64587. * renders in the main frame buffer of the canvas.
  64588. */
  64589. renderOnlyInRenderTargetTextures: boolean;
  64590. private _scene;
  64591. private _vertexBuffers;
  64592. private _indexBuffer;
  64593. private _effect;
  64594. private _previousDefines;
  64595. /**
  64596. * An event triggered when the layer is disposed.
  64597. */
  64598. onDisposeObservable: Observable<Layer>;
  64599. private _onDisposeObserver;
  64600. /**
  64601. * Back compatibility with callback before the onDisposeObservable existed.
  64602. * The set callback will be triggered when the layer has been disposed.
  64603. */
  64604. set onDispose(callback: () => void);
  64605. /**
  64606. * An event triggered before rendering the scene
  64607. */
  64608. onBeforeRenderObservable: Observable<Layer>;
  64609. private _onBeforeRenderObserver;
  64610. /**
  64611. * Back compatibility with callback before the onBeforeRenderObservable existed.
  64612. * The set callback will be triggered just before rendering the layer.
  64613. */
  64614. set onBeforeRender(callback: () => void);
  64615. /**
  64616. * An event triggered after rendering the scene
  64617. */
  64618. onAfterRenderObservable: Observable<Layer>;
  64619. private _onAfterRenderObserver;
  64620. /**
  64621. * Back compatibility with callback before the onAfterRenderObservable existed.
  64622. * The set callback will be triggered just after rendering the layer.
  64623. */
  64624. set onAfterRender(callback: () => void);
  64625. /**
  64626. * Instantiates a new layer.
  64627. * This represents a full screen 2d layer.
  64628. * This can be useful to display a picture in the background of your scene for instance.
  64629. * @see https://www.babylonjs-playground.com/#08A2BS#1
  64630. * @param name Define the name of the layer in the scene
  64631. * @param imgUrl Define the url of the texture to display in the layer
  64632. * @param scene Define the scene the layer belongs to
  64633. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  64634. * @param color Defines a color for the layer
  64635. */
  64636. constructor(
  64637. /**
  64638. * Define the name of the layer.
  64639. */
  64640. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  64641. private _createIndexBuffer;
  64642. /** @hidden */
  64643. _rebuild(): void;
  64644. /**
  64645. * Renders the layer in the scene.
  64646. */
  64647. render(): void;
  64648. /**
  64649. * Disposes and releases the associated resources.
  64650. */
  64651. dispose(): void;
  64652. }
  64653. }
  64654. declare module BABYLON {
  64655. /** @hidden */
  64656. export var lensFlarePixelShader: {
  64657. name: string;
  64658. shader: string;
  64659. };
  64660. }
  64661. declare module BABYLON {
  64662. /** @hidden */
  64663. export var lensFlareVertexShader: {
  64664. name: string;
  64665. shader: string;
  64666. };
  64667. }
  64668. declare module BABYLON {
  64669. /**
  64670. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  64671. * It is usually composed of several `lensFlare`.
  64672. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64673. */
  64674. export class LensFlareSystem {
  64675. /**
  64676. * Define the name of the lens flare system
  64677. */
  64678. name: string;
  64679. /**
  64680. * List of lens flares used in this system.
  64681. */
  64682. lensFlares: LensFlare[];
  64683. /**
  64684. * Define a limit from the border the lens flare can be visible.
  64685. */
  64686. borderLimit: number;
  64687. /**
  64688. * Define a viewport border we do not want to see the lens flare in.
  64689. */
  64690. viewportBorder: number;
  64691. /**
  64692. * Define a predicate which could limit the list of meshes able to occlude the effect.
  64693. */
  64694. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  64695. /**
  64696. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  64697. */
  64698. layerMask: number;
  64699. /**
  64700. * Define the id of the lens flare system in the scene.
  64701. * (equal to name by default)
  64702. */
  64703. id: string;
  64704. private _scene;
  64705. private _emitter;
  64706. private _vertexBuffers;
  64707. private _indexBuffer;
  64708. private _effect;
  64709. private _positionX;
  64710. private _positionY;
  64711. private _isEnabled;
  64712. /** @hidden */
  64713. static _SceneComponentInitialization: (scene: Scene) => void;
  64714. /**
  64715. * Instantiates a lens flare system.
  64716. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  64717. * It is usually composed of several `lensFlare`.
  64718. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64719. * @param name Define the name of the lens flare system in the scene
  64720. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  64721. * @param scene Define the scene the lens flare system belongs to
  64722. */
  64723. constructor(
  64724. /**
  64725. * Define the name of the lens flare system
  64726. */
  64727. name: string, emitter: any, scene: Scene);
  64728. /**
  64729. * Define if the lens flare system is enabled.
  64730. */
  64731. get isEnabled(): boolean;
  64732. set isEnabled(value: boolean);
  64733. /**
  64734. * Get the scene the effects belongs to.
  64735. * @returns the scene holding the lens flare system
  64736. */
  64737. getScene(): Scene;
  64738. /**
  64739. * Get the emitter of the lens flare system.
  64740. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  64741. * @returns the emitter of the lens flare system
  64742. */
  64743. getEmitter(): any;
  64744. /**
  64745. * Set the emitter of the lens flare system.
  64746. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  64747. * @param newEmitter Define the new emitter of the system
  64748. */
  64749. setEmitter(newEmitter: any): void;
  64750. /**
  64751. * Get the lens flare system emitter position.
  64752. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  64753. * @returns the position
  64754. */
  64755. getEmitterPosition(): Vector3;
  64756. /**
  64757. * @hidden
  64758. */
  64759. computeEffectivePosition(globalViewport: Viewport): boolean;
  64760. /** @hidden */
  64761. _isVisible(): boolean;
  64762. /**
  64763. * @hidden
  64764. */
  64765. render(): boolean;
  64766. /**
  64767. * Dispose and release the lens flare with its associated resources.
  64768. */
  64769. dispose(): void;
  64770. /**
  64771. * Parse a lens flare system from a JSON representation
  64772. * @param parsedLensFlareSystem Define the JSON to parse
  64773. * @param scene Define the scene the parsed system should be instantiated in
  64774. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  64775. * @returns the parsed system
  64776. */
  64777. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  64778. /**
  64779. * Serialize the current Lens Flare System into a JSON representation.
  64780. * @returns the serialized JSON
  64781. */
  64782. serialize(): any;
  64783. }
  64784. }
  64785. declare module BABYLON {
  64786. /**
  64787. * This represents one of the lens effect in a `lensFlareSystem`.
  64788. * It controls one of the individual texture used in the effect.
  64789. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64790. */
  64791. export class LensFlare {
  64792. /**
  64793. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  64794. */
  64795. size: number;
  64796. /**
  64797. * 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.
  64798. */
  64799. position: number;
  64800. /**
  64801. * Define the lens color.
  64802. */
  64803. color: Color3;
  64804. /**
  64805. * Define the lens texture.
  64806. */
  64807. texture: Nullable<Texture>;
  64808. /**
  64809. * Define the alpha mode to render this particular lens.
  64810. */
  64811. alphaMode: number;
  64812. private _system;
  64813. /**
  64814. * Creates a new Lens Flare.
  64815. * This represents one of the lens effect in a `lensFlareSystem`.
  64816. * It controls one of the individual texture used in the effect.
  64817. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64818. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  64819. * @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.
  64820. * @param color Define the lens color
  64821. * @param imgUrl Define the lens texture url
  64822. * @param system Define the `lensFlareSystem` this flare is part of
  64823. * @returns The newly created Lens Flare
  64824. */
  64825. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  64826. /**
  64827. * Instantiates a new Lens Flare.
  64828. * This represents one of the lens effect in a `lensFlareSystem`.
  64829. * It controls one of the individual texture used in the effect.
  64830. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64831. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  64832. * @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.
  64833. * @param color Define the lens color
  64834. * @param imgUrl Define the lens texture url
  64835. * @param system Define the `lensFlareSystem` this flare is part of
  64836. */
  64837. constructor(
  64838. /**
  64839. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  64840. */
  64841. size: number,
  64842. /**
  64843. * 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.
  64844. */
  64845. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  64846. /**
  64847. * Dispose and release the lens flare with its associated resources.
  64848. */
  64849. dispose(): void;
  64850. }
  64851. }
  64852. declare module BABYLON {
  64853. interface AbstractScene {
  64854. /**
  64855. * The list of lens flare system added to the scene
  64856. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64857. */
  64858. lensFlareSystems: Array<LensFlareSystem>;
  64859. /**
  64860. * Removes the given lens flare system from this scene.
  64861. * @param toRemove The lens flare system to remove
  64862. * @returns The index of the removed lens flare system
  64863. */
  64864. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  64865. /**
  64866. * Adds the given lens flare system to this scene
  64867. * @param newLensFlareSystem The lens flare system to add
  64868. */
  64869. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  64870. /**
  64871. * Gets a lens flare system using its name
  64872. * @param name defines the name to look for
  64873. * @returns the lens flare system or null if not found
  64874. */
  64875. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  64876. /**
  64877. * Gets a lens flare system using its id
  64878. * @param id defines the id to look for
  64879. * @returns the lens flare system or null if not found
  64880. */
  64881. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  64882. }
  64883. /**
  64884. * Defines the lens flare scene component responsible to manage any lens flares
  64885. * in a given scene.
  64886. */
  64887. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  64888. /**
  64889. * The component name helpful to identify the component in the list of scene components.
  64890. */
  64891. readonly name: string;
  64892. /**
  64893. * The scene the component belongs to.
  64894. */
  64895. scene: Scene;
  64896. /**
  64897. * Creates a new instance of the component for the given scene
  64898. * @param scene Defines the scene to register the component in
  64899. */
  64900. constructor(scene: Scene);
  64901. /**
  64902. * Registers the component in a given scene
  64903. */
  64904. register(): void;
  64905. /**
  64906. * Rebuilds the elements related to this component in case of
  64907. * context lost for instance.
  64908. */
  64909. rebuild(): void;
  64910. /**
  64911. * Adds all the elements from the container to the scene
  64912. * @param container the container holding the elements
  64913. */
  64914. addFromContainer(container: AbstractScene): void;
  64915. /**
  64916. * Removes all the elements in the container from the scene
  64917. * @param container contains the elements to remove
  64918. * @param dispose if the removed element should be disposed (default: false)
  64919. */
  64920. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  64921. /**
  64922. * Serializes the component data to the specified json object
  64923. * @param serializationObject The object to serialize to
  64924. */
  64925. serialize(serializationObject: any): void;
  64926. /**
  64927. * Disposes the component and the associated resources.
  64928. */
  64929. dispose(): void;
  64930. private _draw;
  64931. }
  64932. }
  64933. declare module BABYLON {
  64934. /** @hidden */
  64935. export var depthPixelShader: {
  64936. name: string;
  64937. shader: string;
  64938. };
  64939. }
  64940. declare module BABYLON {
  64941. /** @hidden */
  64942. export var depthVertexShader: {
  64943. name: string;
  64944. shader: string;
  64945. };
  64946. }
  64947. declare module BABYLON {
  64948. /**
  64949. * This represents a depth renderer in Babylon.
  64950. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  64951. */
  64952. export class DepthRenderer {
  64953. private _scene;
  64954. private _depthMap;
  64955. private _effect;
  64956. private readonly _storeNonLinearDepth;
  64957. private readonly _clearColor;
  64958. /** Get if the depth renderer is using packed depth or not */
  64959. readonly isPacked: boolean;
  64960. private _cachedDefines;
  64961. private _camera;
  64962. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  64963. enabled: boolean;
  64964. /**
  64965. * Specifies that the depth renderer will only be used within
  64966. * the camera it is created for.
  64967. * This can help forcing its rendering during the camera processing.
  64968. */
  64969. useOnlyInActiveCamera: boolean;
  64970. /** @hidden */
  64971. static _SceneComponentInitialization: (scene: Scene) => void;
  64972. /**
  64973. * Instantiates a depth renderer
  64974. * @param scene The scene the renderer belongs to
  64975. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64976. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64977. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64978. */
  64979. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64980. /**
  64981. * Creates the depth rendering effect and checks if the effect is ready.
  64982. * @param subMesh The submesh to be used to render the depth map of
  64983. * @param useInstances If multiple world instances should be used
  64984. * @returns if the depth renderer is ready to render the depth map
  64985. */
  64986. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64987. /**
  64988. * Gets the texture which the depth map will be written to.
  64989. * @returns The depth map texture
  64990. */
  64991. getDepthMap(): RenderTargetTexture;
  64992. /**
  64993. * Disposes of the depth renderer.
  64994. */
  64995. dispose(): void;
  64996. }
  64997. }
  64998. declare module BABYLON {
  64999. /** @hidden */
  65000. export var minmaxReduxPixelShader: {
  65001. name: string;
  65002. shader: string;
  65003. };
  65004. }
  65005. declare module BABYLON {
  65006. /**
  65007. * This class computes a min/max reduction from a texture: it means it computes the minimum
  65008. * and maximum values from all values of the texture.
  65009. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  65010. * The source values are read from the red channel of the texture.
  65011. */
  65012. export class MinMaxReducer {
  65013. /**
  65014. * Observable triggered when the computation has been performed
  65015. */
  65016. onAfterReductionPerformed: Observable<{
  65017. min: number;
  65018. max: number;
  65019. }>;
  65020. protected _camera: Camera;
  65021. protected _sourceTexture: Nullable<RenderTargetTexture>;
  65022. protected _reductionSteps: Nullable<Array<PostProcess>>;
  65023. protected _postProcessManager: PostProcessManager;
  65024. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  65025. protected _forceFullscreenViewport: boolean;
  65026. /**
  65027. * Creates a min/max reducer
  65028. * @param camera The camera to use for the post processes
  65029. */
  65030. constructor(camera: Camera);
  65031. /**
  65032. * Gets the texture used to read the values from.
  65033. */
  65034. get sourceTexture(): Nullable<RenderTargetTexture>;
  65035. /**
  65036. * Sets the source texture to read the values from.
  65037. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  65038. * because in such textures '1' value must not be taken into account to compute the maximum
  65039. * as this value is used to clear the texture.
  65040. * Note that the computation is not activated by calling this function, you must call activate() for that!
  65041. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  65042. * @param depthRedux Indicates if the texture is a depth texture or not
  65043. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  65044. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  65045. */
  65046. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  65047. /**
  65048. * Defines the refresh rate of the computation.
  65049. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  65050. */
  65051. get refreshRate(): number;
  65052. set refreshRate(value: number);
  65053. protected _activated: boolean;
  65054. /**
  65055. * Gets the activation status of the reducer
  65056. */
  65057. get activated(): boolean;
  65058. /**
  65059. * Activates the reduction computation.
  65060. * When activated, the observers registered in onAfterReductionPerformed are
  65061. * called after the computation is performed
  65062. */
  65063. activate(): void;
  65064. /**
  65065. * Deactivates the reduction computation.
  65066. */
  65067. deactivate(): void;
  65068. /**
  65069. * Disposes the min/max reducer
  65070. * @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.
  65071. */
  65072. dispose(disposeAll?: boolean): void;
  65073. }
  65074. }
  65075. declare module BABYLON {
  65076. /**
  65077. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  65078. */
  65079. export class DepthReducer extends MinMaxReducer {
  65080. private _depthRenderer;
  65081. private _depthRendererId;
  65082. /**
  65083. * Gets the depth renderer used for the computation.
  65084. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  65085. */
  65086. get depthRenderer(): Nullable<DepthRenderer>;
  65087. /**
  65088. * Creates a depth reducer
  65089. * @param camera The camera used to render the depth texture
  65090. */
  65091. constructor(camera: Camera);
  65092. /**
  65093. * Sets the depth renderer to use to generate the depth map
  65094. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  65095. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  65096. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  65097. */
  65098. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  65099. /** @hidden */
  65100. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  65101. /**
  65102. * Activates the reduction computation.
  65103. * When activated, the observers registered in onAfterReductionPerformed are
  65104. * called after the computation is performed
  65105. */
  65106. activate(): void;
  65107. /**
  65108. * Deactivates the reduction computation.
  65109. */
  65110. deactivate(): void;
  65111. /**
  65112. * Disposes the depth reducer
  65113. * @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.
  65114. */
  65115. dispose(disposeAll?: boolean): void;
  65116. }
  65117. }
  65118. declare module BABYLON {
  65119. /**
  65120. * A CSM implementation allowing casting shadows on large scenes.
  65121. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  65122. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  65123. */
  65124. export class CascadedShadowGenerator extends ShadowGenerator {
  65125. private static readonly frustumCornersNDCSpace;
  65126. /**
  65127. * Name of the CSM class
  65128. */
  65129. static CLASSNAME: string;
  65130. /**
  65131. * Defines the default number of cascades used by the CSM.
  65132. */
  65133. static readonly DEFAULT_CASCADES_COUNT: number;
  65134. /**
  65135. * Defines the minimum number of cascades used by the CSM.
  65136. */
  65137. static readonly MIN_CASCADES_COUNT: number;
  65138. /**
  65139. * Defines the maximum number of cascades used by the CSM.
  65140. */
  65141. static readonly MAX_CASCADES_COUNT: number;
  65142. protected _validateFilter(filter: number): number;
  65143. /**
  65144. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  65145. */
  65146. penumbraDarkness: number;
  65147. private _numCascades;
  65148. /**
  65149. * Gets or set the number of cascades used by the CSM.
  65150. */
  65151. get numCascades(): number;
  65152. set numCascades(value: number);
  65153. /**
  65154. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  65155. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  65156. */
  65157. stabilizeCascades: boolean;
  65158. private _freezeShadowCastersBoundingInfo;
  65159. private _freezeShadowCastersBoundingInfoObservable;
  65160. /**
  65161. * Enables or disables the shadow casters bounding info computation.
  65162. * If your shadow casters don't move, you can disable this feature.
  65163. * If it is enabled, the bounding box computation is done every frame.
  65164. */
  65165. get freezeShadowCastersBoundingInfo(): boolean;
  65166. set freezeShadowCastersBoundingInfo(freeze: boolean);
  65167. private _scbiMin;
  65168. private _scbiMax;
  65169. protected _computeShadowCastersBoundingInfo(): void;
  65170. protected _shadowCastersBoundingInfo: BoundingInfo;
  65171. /**
  65172. * Gets or sets the shadow casters bounding info.
  65173. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  65174. * so that the system won't overwrite the bounds you provide
  65175. */
  65176. get shadowCastersBoundingInfo(): BoundingInfo;
  65177. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  65178. protected _breaksAreDirty: boolean;
  65179. protected _minDistance: number;
  65180. protected _maxDistance: number;
  65181. /**
  65182. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  65183. *
  65184. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  65185. * If you don't know these values, simply leave them to their defaults and don't call this function.
  65186. * @param min minimal distance for the breaks (default to 0.)
  65187. * @param max maximal distance for the breaks (default to 1.)
  65188. */
  65189. setMinMaxDistance(min: number, max: number): void;
  65190. /** Gets the minimal distance used in the cascade break computation */
  65191. get minDistance(): number;
  65192. /** Gets the maximal distance used in the cascade break computation */
  65193. get maxDistance(): number;
  65194. /**
  65195. * Gets the class name of that object
  65196. * @returns "CascadedShadowGenerator"
  65197. */
  65198. getClassName(): string;
  65199. private _cascadeMinExtents;
  65200. private _cascadeMaxExtents;
  65201. /**
  65202. * Gets a cascade minimum extents
  65203. * @param cascadeIndex index of the cascade
  65204. * @returns the minimum cascade extents
  65205. */
  65206. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  65207. /**
  65208. * Gets a cascade maximum extents
  65209. * @param cascadeIndex index of the cascade
  65210. * @returns the maximum cascade extents
  65211. */
  65212. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  65213. private _cascades;
  65214. private _currentLayer;
  65215. private _viewSpaceFrustumsZ;
  65216. private _viewMatrices;
  65217. private _projectionMatrices;
  65218. private _transformMatrices;
  65219. private _transformMatricesAsArray;
  65220. private _frustumLengths;
  65221. private _lightSizeUVCorrection;
  65222. private _depthCorrection;
  65223. private _frustumCornersWorldSpace;
  65224. private _frustumCenter;
  65225. private _shadowCameraPos;
  65226. private _shadowMaxZ;
  65227. /**
  65228. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  65229. * It defaults to camera.maxZ
  65230. */
  65231. get shadowMaxZ(): number;
  65232. /**
  65233. * Sets the shadow max z distance.
  65234. */
  65235. set shadowMaxZ(value: number);
  65236. protected _debug: boolean;
  65237. /**
  65238. * Gets or sets the debug flag.
  65239. * When enabled, the cascades are materialized by different colors on the screen.
  65240. */
  65241. get debug(): boolean;
  65242. set debug(dbg: boolean);
  65243. private _depthClamp;
  65244. /**
  65245. * Gets or sets the depth clamping value.
  65246. *
  65247. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  65248. * to account for the shadow casters far away.
  65249. *
  65250. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  65251. */
  65252. get depthClamp(): boolean;
  65253. set depthClamp(value: boolean);
  65254. private _cascadeBlendPercentage;
  65255. /**
  65256. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  65257. * It defaults to 0.1 (10% blending).
  65258. */
  65259. get cascadeBlendPercentage(): number;
  65260. set cascadeBlendPercentage(value: number);
  65261. private _lambda;
  65262. /**
  65263. * Gets or set the lambda parameter.
  65264. * This parameter is used to split the camera frustum and create the cascades.
  65265. * 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.
  65266. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  65267. */
  65268. get lambda(): number;
  65269. set lambda(value: number);
  65270. /**
  65271. * Gets the view matrix corresponding to a given cascade
  65272. * @param cascadeNum cascade to retrieve the view matrix from
  65273. * @returns the cascade view matrix
  65274. */
  65275. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  65276. /**
  65277. * Gets the projection matrix corresponding to a given cascade
  65278. * @param cascadeNum cascade to retrieve the projection matrix from
  65279. * @returns the cascade projection matrix
  65280. */
  65281. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  65282. /**
  65283. * Gets the transformation matrix corresponding to a given cascade
  65284. * @param cascadeNum cascade to retrieve the transformation matrix from
  65285. * @returns the cascade transformation matrix
  65286. */
  65287. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  65288. private _depthRenderer;
  65289. /**
  65290. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  65291. *
  65292. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  65293. *
  65294. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  65295. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  65296. * @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
  65297. */
  65298. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  65299. private _depthReducer;
  65300. private _autoCalcDepthBounds;
  65301. /**
  65302. * Gets or sets the autoCalcDepthBounds property.
  65303. *
  65304. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  65305. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  65306. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  65307. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  65308. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  65309. */
  65310. get autoCalcDepthBounds(): boolean;
  65311. set autoCalcDepthBounds(value: boolean);
  65312. /**
  65313. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  65314. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  65315. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  65316. * for setting the refresh rate on the renderer yourself!
  65317. */
  65318. get autoCalcDepthBoundsRefreshRate(): number;
  65319. set autoCalcDepthBoundsRefreshRate(value: number);
  65320. /**
  65321. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  65322. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  65323. * you change the camera near/far planes!
  65324. */
  65325. splitFrustum(): void;
  65326. private _splitFrustum;
  65327. private _computeMatrices;
  65328. private _computeFrustumInWorldSpace;
  65329. private _computeCascadeFrustum;
  65330. /**
  65331. * Support test.
  65332. */
  65333. static get IsSupported(): boolean;
  65334. /** @hidden */
  65335. static _SceneComponentInitialization: (scene: Scene) => void;
  65336. /**
  65337. * Creates a Cascaded Shadow Generator object.
  65338. * A ShadowGenerator is the required tool to use the shadows.
  65339. * Each directional light casting shadows needs to use its own ShadowGenerator.
  65340. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  65341. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  65342. * @param light The directional light object generating the shadows.
  65343. * @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.
  65344. */
  65345. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  65346. protected _initializeGenerator(): void;
  65347. protected _createTargetRenderTexture(): void;
  65348. protected _initializeShadowMap(): void;
  65349. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  65350. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  65351. /**
  65352. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  65353. * @param defines Defines of the material we want to update
  65354. * @param lightIndex Index of the light in the enabled light list of the material
  65355. */
  65356. prepareDefines(defines: any, lightIndex: number): void;
  65357. /**
  65358. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  65359. * defined in the generator but impacting the effect).
  65360. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  65361. * @param effect The effect we are binfing the information for
  65362. */
  65363. bindShadowLight(lightIndex: string, effect: Effect): void;
  65364. /**
  65365. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  65366. * (eq to view projection * shadow projection matrices)
  65367. * @returns The transform matrix used to create the shadow map
  65368. */
  65369. getTransformMatrix(): Matrix;
  65370. /**
  65371. * Disposes the ShadowGenerator.
  65372. * Returns nothing.
  65373. */
  65374. dispose(): void;
  65375. /**
  65376. * Serializes the shadow generator setup to a json object.
  65377. * @returns The serialized JSON object
  65378. */
  65379. serialize(): any;
  65380. /**
  65381. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  65382. * @param parsedShadowGenerator The JSON object to parse
  65383. * @param scene The scene to create the shadow map for
  65384. * @returns The parsed shadow generator
  65385. */
  65386. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  65387. }
  65388. }
  65389. declare module BABYLON {
  65390. /**
  65391. * Defines the shadow generator component responsible to manage any shadow generators
  65392. * in a given scene.
  65393. */
  65394. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  65395. /**
  65396. * The component name helpful to identify the component in the list of scene components.
  65397. */
  65398. readonly name: string;
  65399. /**
  65400. * The scene the component belongs to.
  65401. */
  65402. scene: Scene;
  65403. /**
  65404. * Creates a new instance of the component for the given scene
  65405. * @param scene Defines the scene to register the component in
  65406. */
  65407. constructor(scene: Scene);
  65408. /**
  65409. * Registers the component in a given scene
  65410. */
  65411. register(): void;
  65412. /**
  65413. * Rebuilds the elements related to this component in case of
  65414. * context lost for instance.
  65415. */
  65416. rebuild(): void;
  65417. /**
  65418. * Serializes the component data to the specified json object
  65419. * @param serializationObject The object to serialize to
  65420. */
  65421. serialize(serializationObject: any): void;
  65422. /**
  65423. * Adds all the elements from the container to the scene
  65424. * @param container the container holding the elements
  65425. */
  65426. addFromContainer(container: AbstractScene): void;
  65427. /**
  65428. * Removes all the elements in the container from the scene
  65429. * @param container contains the elements to remove
  65430. * @param dispose if the removed element should be disposed (default: false)
  65431. */
  65432. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  65433. /**
  65434. * Rebuilds the elements related to this component in case of
  65435. * context lost for instance.
  65436. */
  65437. dispose(): void;
  65438. private _gatherRenderTargets;
  65439. }
  65440. }
  65441. declare module BABYLON {
  65442. /**
  65443. * A point light is a light defined by an unique point in world space.
  65444. * The light is emitted in every direction from this point.
  65445. * A good example of a point light is a standard light bulb.
  65446. * Documentation: https://doc.babylonjs.com/babylon101/lights
  65447. */
  65448. export class PointLight extends ShadowLight {
  65449. private _shadowAngle;
  65450. /**
  65451. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  65452. * This specifies what angle the shadow will use to be created.
  65453. *
  65454. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  65455. */
  65456. get shadowAngle(): number;
  65457. /**
  65458. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  65459. * This specifies what angle the shadow will use to be created.
  65460. *
  65461. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  65462. */
  65463. set shadowAngle(value: number);
  65464. /**
  65465. * Gets the direction if it has been set.
  65466. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  65467. */
  65468. get direction(): Vector3;
  65469. /**
  65470. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  65471. */
  65472. set direction(value: Vector3);
  65473. /**
  65474. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  65475. * A PointLight emits the light in every direction.
  65476. * It can cast shadows.
  65477. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  65478. * ```javascript
  65479. * var pointLight = new PointLight("pl", camera.position, scene);
  65480. * ```
  65481. * Documentation : https://doc.babylonjs.com/babylon101/lights
  65482. * @param name The light friendly name
  65483. * @param position The position of the point light in the scene
  65484. * @param scene The scene the lights belongs to
  65485. */
  65486. constructor(name: string, position: Vector3, scene: Scene);
  65487. /**
  65488. * Returns the string "PointLight"
  65489. * @returns the class name
  65490. */
  65491. getClassName(): string;
  65492. /**
  65493. * Returns the integer 0.
  65494. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  65495. */
  65496. getTypeID(): number;
  65497. /**
  65498. * Specifies whether or not the shadowmap should be a cube texture.
  65499. * @returns true if the shadowmap needs to be a cube texture.
  65500. */
  65501. needCube(): boolean;
  65502. /**
  65503. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  65504. * @param faceIndex The index of the face we are computed the direction to generate shadow
  65505. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  65506. */
  65507. getShadowDirection(faceIndex?: number): Vector3;
  65508. /**
  65509. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  65510. * - fov = PI / 2
  65511. * - aspect ratio : 1.0
  65512. * - z-near and far equal to the active camera minZ and maxZ.
  65513. * Returns the PointLight.
  65514. */
  65515. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  65516. protected _buildUniformLayout(): void;
  65517. /**
  65518. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  65519. * @param effect The effect to update
  65520. * @param lightIndex The index of the light in the effect to update
  65521. * @returns The point light
  65522. */
  65523. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  65524. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  65525. /**
  65526. * Prepares the list of defines specific to the light type.
  65527. * @param defines the list of defines
  65528. * @param lightIndex defines the index of the light for the effect
  65529. */
  65530. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  65531. }
  65532. }
  65533. declare module BABYLON {
  65534. /**
  65535. * Header information of HDR texture files.
  65536. */
  65537. export interface HDRInfo {
  65538. /**
  65539. * The height of the texture in pixels.
  65540. */
  65541. height: number;
  65542. /**
  65543. * The width of the texture in pixels.
  65544. */
  65545. width: number;
  65546. /**
  65547. * The index of the beginning of the data in the binary file.
  65548. */
  65549. dataPosition: number;
  65550. }
  65551. /**
  65552. * This groups tools to convert HDR texture to native colors array.
  65553. */
  65554. export class HDRTools {
  65555. private static Ldexp;
  65556. private static Rgbe2float;
  65557. private static readStringLine;
  65558. /**
  65559. * Reads header information from an RGBE texture stored in a native array.
  65560. * More information on this format are available here:
  65561. * https://en.wikipedia.org/wiki/RGBE_image_format
  65562. *
  65563. * @param uint8array The binary file stored in native array.
  65564. * @return The header information.
  65565. */
  65566. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  65567. /**
  65568. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  65569. * This RGBE texture needs to store the information as a panorama.
  65570. *
  65571. * More information on this format are available here:
  65572. * https://en.wikipedia.org/wiki/RGBE_image_format
  65573. *
  65574. * @param buffer The binary file stored in an array buffer.
  65575. * @param size The expected size of the extracted cubemap.
  65576. * @return The Cube Map information.
  65577. */
  65578. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  65579. /**
  65580. * Returns the pixels data extracted from an RGBE texture.
  65581. * This pixels will be stored left to right up to down in the R G B order in one array.
  65582. *
  65583. * More information on this format are available here:
  65584. * https://en.wikipedia.org/wiki/RGBE_image_format
  65585. *
  65586. * @param uint8array The binary file stored in an array buffer.
  65587. * @param hdrInfo The header information of the file.
  65588. * @return The pixels data in RGB right to left up to down order.
  65589. */
  65590. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  65591. private static RGBE_ReadPixels_RLE;
  65592. private static RGBE_ReadPixels_NOT_RLE;
  65593. }
  65594. }
  65595. declare module BABYLON {
  65596. /**
  65597. * Effect Render Options
  65598. */
  65599. export interface IEffectRendererOptions {
  65600. /**
  65601. * Defines the vertices positions.
  65602. */
  65603. positions?: number[];
  65604. /**
  65605. * Defines the indices.
  65606. */
  65607. indices?: number[];
  65608. }
  65609. /**
  65610. * Helper class to render one or more effects.
  65611. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  65612. */
  65613. export class EffectRenderer {
  65614. private engine;
  65615. private static _DefaultOptions;
  65616. private _vertexBuffers;
  65617. private _indexBuffer;
  65618. private _fullscreenViewport;
  65619. /**
  65620. * Creates an effect renderer
  65621. * @param engine the engine to use for rendering
  65622. * @param options defines the options of the effect renderer
  65623. */
  65624. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  65625. /**
  65626. * Sets the current viewport in normalized coordinates 0-1
  65627. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  65628. */
  65629. setViewport(viewport?: Viewport): void;
  65630. /**
  65631. * Binds the embedded attributes buffer to the effect.
  65632. * @param effect Defines the effect to bind the attributes for
  65633. */
  65634. bindBuffers(effect: Effect): void;
  65635. /**
  65636. * Sets the current effect wrapper to use during draw.
  65637. * The effect needs to be ready before calling this api.
  65638. * This also sets the default full screen position attribute.
  65639. * @param effectWrapper Defines the effect to draw with
  65640. */
  65641. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  65642. /**
  65643. * Restores engine states
  65644. */
  65645. restoreStates(): void;
  65646. /**
  65647. * Draws a full screen quad.
  65648. */
  65649. draw(): void;
  65650. private isRenderTargetTexture;
  65651. /**
  65652. * renders one or more effects to a specified texture
  65653. * @param effectWrapper the effect to renderer
  65654. * @param outputTexture texture to draw to, if null it will render to the screen.
  65655. */
  65656. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  65657. /**
  65658. * Disposes of the effect renderer
  65659. */
  65660. dispose(): void;
  65661. }
  65662. /**
  65663. * Options to create an EffectWrapper
  65664. */
  65665. interface EffectWrapperCreationOptions {
  65666. /**
  65667. * Engine to use to create the effect
  65668. */
  65669. engine: ThinEngine;
  65670. /**
  65671. * Fragment shader for the effect
  65672. */
  65673. fragmentShader: string;
  65674. /**
  65675. * Use the shader store instead of direct source code
  65676. */
  65677. useShaderStore?: boolean;
  65678. /**
  65679. * Vertex shader for the effect
  65680. */
  65681. vertexShader?: string;
  65682. /**
  65683. * Attributes to use in the shader
  65684. */
  65685. attributeNames?: Array<string>;
  65686. /**
  65687. * Uniforms to use in the shader
  65688. */
  65689. uniformNames?: Array<string>;
  65690. /**
  65691. * Texture sampler names to use in the shader
  65692. */
  65693. samplerNames?: Array<string>;
  65694. /**
  65695. * Defines to use in the shader
  65696. */
  65697. defines?: Array<string>;
  65698. /**
  65699. * Callback when effect is compiled
  65700. */
  65701. onCompiled?: Nullable<(effect: Effect) => void>;
  65702. /**
  65703. * The friendly name of the effect displayed in Spector.
  65704. */
  65705. name?: string;
  65706. }
  65707. /**
  65708. * Wraps an effect to be used for rendering
  65709. */
  65710. export class EffectWrapper {
  65711. /**
  65712. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  65713. */
  65714. onApplyObservable: Observable<{}>;
  65715. /**
  65716. * The underlying effect
  65717. */
  65718. effect: Effect;
  65719. /**
  65720. * Creates an effect to be renderer
  65721. * @param creationOptions options to create the effect
  65722. */
  65723. constructor(creationOptions: EffectWrapperCreationOptions);
  65724. /**
  65725. * Disposes of the effect wrapper
  65726. */
  65727. dispose(): void;
  65728. }
  65729. }
  65730. declare module BABYLON {
  65731. /** @hidden */
  65732. export var hdrFilteringVertexShader: {
  65733. name: string;
  65734. shader: string;
  65735. };
  65736. }
  65737. declare module BABYLON {
  65738. /** @hidden */
  65739. export var hdrFilteringPixelShader: {
  65740. name: string;
  65741. shader: string;
  65742. };
  65743. }
  65744. declare module BABYLON {
  65745. /**
  65746. * Options for texture filtering
  65747. */
  65748. interface IHDRFilteringOptions {
  65749. /**
  65750. * Scales pixel intensity for the input HDR map.
  65751. */
  65752. hdrScale?: number;
  65753. /**
  65754. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  65755. */
  65756. quality?: number;
  65757. }
  65758. /**
  65759. * Filters HDR maps to get correct renderings of PBR reflections
  65760. */
  65761. export class HDRFiltering {
  65762. private _engine;
  65763. private _effectRenderer;
  65764. private _effectWrapper;
  65765. private _lodGenerationOffset;
  65766. private _lodGenerationScale;
  65767. /**
  65768. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  65769. * you care about baking speed.
  65770. */
  65771. quality: number;
  65772. /**
  65773. * Scales pixel intensity for the input HDR map.
  65774. */
  65775. hdrScale: number;
  65776. /**
  65777. * Instantiates HDR filter for reflection maps
  65778. *
  65779. * @param engine Thin engine
  65780. * @param options Options
  65781. */
  65782. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  65783. private _createRenderTarget;
  65784. private _prefilterInternal;
  65785. private _createEffect;
  65786. /**
  65787. * Get a value indicating if the filter is ready to be used
  65788. * @param texture Texture to filter
  65789. * @returns true if the filter is ready
  65790. */
  65791. isReady(texture: BaseTexture): boolean;
  65792. /**
  65793. * Prefilters a cube texture to have mipmap levels representing roughness values.
  65794. * Prefiltering will be invoked at the end of next rendering pass.
  65795. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  65796. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  65797. * @param texture Texture to filter
  65798. * @param onFinished Callback when filtering is done
  65799. * @return Promise called when prefiltering is done
  65800. */
  65801. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<void>;
  65802. }
  65803. }
  65804. declare module BABYLON {
  65805. /**
  65806. * This represents a texture coming from an HDR input.
  65807. *
  65808. * The only supported format is currently panorama picture stored in RGBE format.
  65809. * Example of such files can be found on HDRLib: http://hdrlib.com/
  65810. */
  65811. export class HDRCubeTexture extends BaseTexture {
  65812. private static _facesMapping;
  65813. private _generateHarmonics;
  65814. private _noMipmap;
  65815. private _prefilterOnLoad;
  65816. private _textureMatrix;
  65817. private _size;
  65818. private _onLoad;
  65819. private _onError;
  65820. /**
  65821. * The texture URL.
  65822. */
  65823. url: string;
  65824. protected _isBlocking: boolean;
  65825. /**
  65826. * Sets whether or not the texture is blocking during loading.
  65827. */
  65828. set isBlocking(value: boolean);
  65829. /**
  65830. * Gets whether or not the texture is blocking during loading.
  65831. */
  65832. get isBlocking(): boolean;
  65833. protected _rotationY: number;
  65834. /**
  65835. * Sets texture matrix rotation angle around Y axis in radians.
  65836. */
  65837. set rotationY(value: number);
  65838. /**
  65839. * Gets texture matrix rotation angle around Y axis radians.
  65840. */
  65841. get rotationY(): number;
  65842. /**
  65843. * Gets or sets the center of the bounding box associated with the cube texture
  65844. * It must define where the camera used to render the texture was set
  65845. */
  65846. boundingBoxPosition: Vector3;
  65847. private _boundingBoxSize;
  65848. /**
  65849. * Gets or sets the size of the bounding box associated with the cube texture
  65850. * When defined, the cubemap will switch to local mode
  65851. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  65852. * @example https://www.babylonjs-playground.com/#RNASML
  65853. */
  65854. set boundingBoxSize(value: Vector3);
  65855. get boundingBoxSize(): Vector3;
  65856. /**
  65857. * Instantiates an HDRTexture from the following parameters.
  65858. *
  65859. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  65860. * @param sceneOrEngine The scene or engine the texture will be used in
  65861. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  65862. * @param noMipmap Forces to not generate the mipmap if true
  65863. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  65864. * @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)
  65865. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  65866. */
  65867. 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>);
  65868. /**
  65869. * Get the current class name of the texture useful for serialization or dynamic coding.
  65870. * @returns "HDRCubeTexture"
  65871. */
  65872. getClassName(): string;
  65873. /**
  65874. * Occurs when the file is raw .hdr file.
  65875. */
  65876. private loadTexture;
  65877. clone(): HDRCubeTexture;
  65878. delayLoad(): void;
  65879. /**
  65880. * Get the texture reflection matrix used to rotate/transform the reflection.
  65881. * @returns the reflection matrix
  65882. */
  65883. getReflectionTextureMatrix(): Matrix;
  65884. /**
  65885. * Set the texture reflection matrix used to rotate/transform the reflection.
  65886. * @param value Define the reflection matrix to set
  65887. */
  65888. setReflectionTextureMatrix(value: Matrix): void;
  65889. /**
  65890. * Parses a JSON representation of an HDR Texture in order to create the texture
  65891. * @param parsedTexture Define the JSON representation
  65892. * @param scene Define the scene the texture should be created in
  65893. * @param rootUrl Define the root url in case we need to load relative dependencies
  65894. * @returns the newly created texture after parsing
  65895. */
  65896. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  65897. serialize(): any;
  65898. }
  65899. }
  65900. declare module BABYLON {
  65901. /**
  65902. * Class used to control physics engine
  65903. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  65904. */
  65905. export class PhysicsEngine implements IPhysicsEngine {
  65906. private _physicsPlugin;
  65907. /**
  65908. * Global value used to control the smallest number supported by the simulation
  65909. */
  65910. static Epsilon: number;
  65911. private _impostors;
  65912. private _joints;
  65913. private _subTimeStep;
  65914. /**
  65915. * Gets the gravity vector used by the simulation
  65916. */
  65917. gravity: Vector3;
  65918. /**
  65919. * Factory used to create the default physics plugin.
  65920. * @returns The default physics plugin
  65921. */
  65922. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  65923. /**
  65924. * Creates a new Physics Engine
  65925. * @param gravity defines the gravity vector used by the simulation
  65926. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  65927. */
  65928. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  65929. /**
  65930. * Sets the gravity vector used by the simulation
  65931. * @param gravity defines the gravity vector to use
  65932. */
  65933. setGravity(gravity: Vector3): void;
  65934. /**
  65935. * Set the time step of the physics engine.
  65936. * Default is 1/60.
  65937. * To slow it down, enter 1/600 for example.
  65938. * To speed it up, 1/30
  65939. * @param newTimeStep defines the new timestep to apply to this world.
  65940. */
  65941. setTimeStep(newTimeStep?: number): void;
  65942. /**
  65943. * Get the time step of the physics engine.
  65944. * @returns the current time step
  65945. */
  65946. getTimeStep(): number;
  65947. /**
  65948. * Set the sub time step of the physics engine.
  65949. * Default is 0 meaning there is no sub steps
  65950. * To increase physics resolution precision, set a small value (like 1 ms)
  65951. * @param subTimeStep defines the new sub timestep used for physics resolution.
  65952. */
  65953. setSubTimeStep(subTimeStep?: number): void;
  65954. /**
  65955. * Get the sub time step of the physics engine.
  65956. * @returns the current sub time step
  65957. */
  65958. getSubTimeStep(): number;
  65959. /**
  65960. * Release all resources
  65961. */
  65962. dispose(): void;
  65963. /**
  65964. * Gets the name of the current physics plugin
  65965. * @returns the name of the plugin
  65966. */
  65967. getPhysicsPluginName(): string;
  65968. /**
  65969. * Adding a new impostor for the impostor tracking.
  65970. * This will be done by the impostor itself.
  65971. * @param impostor the impostor to add
  65972. */
  65973. addImpostor(impostor: PhysicsImpostor): void;
  65974. /**
  65975. * Remove an impostor from the engine.
  65976. * This impostor and its mesh will not longer be updated by the physics engine.
  65977. * @param impostor the impostor to remove
  65978. */
  65979. removeImpostor(impostor: PhysicsImpostor): void;
  65980. /**
  65981. * Add a joint to the physics engine
  65982. * @param mainImpostor defines the main impostor to which the joint is added.
  65983. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  65984. * @param joint defines the joint that will connect both impostors.
  65985. */
  65986. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  65987. /**
  65988. * Removes a joint from the simulation
  65989. * @param mainImpostor defines the impostor used with the joint
  65990. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  65991. * @param joint defines the joint to remove
  65992. */
  65993. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  65994. /**
  65995. * Called by the scene. No need to call it.
  65996. * @param delta defines the timespan between frames
  65997. */
  65998. _step(delta: number): void;
  65999. /**
  66000. * Gets the current plugin used to run the simulation
  66001. * @returns current plugin
  66002. */
  66003. getPhysicsPlugin(): IPhysicsEnginePlugin;
  66004. /**
  66005. * Gets the list of physic impostors
  66006. * @returns an array of PhysicsImpostor
  66007. */
  66008. getImpostors(): Array<PhysicsImpostor>;
  66009. /**
  66010. * Gets the impostor for a physics enabled object
  66011. * @param object defines the object impersonated by the impostor
  66012. * @returns the PhysicsImpostor or null if not found
  66013. */
  66014. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  66015. /**
  66016. * Gets the impostor for a physics body object
  66017. * @param body defines physics body used by the impostor
  66018. * @returns the PhysicsImpostor or null if not found
  66019. */
  66020. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  66021. /**
  66022. * Does a raycast in the physics world
  66023. * @param from when should the ray start?
  66024. * @param to when should the ray end?
  66025. * @returns PhysicsRaycastResult
  66026. */
  66027. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  66028. }
  66029. }
  66030. declare module BABYLON {
  66031. /** @hidden */
  66032. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  66033. private _useDeltaForWorldStep;
  66034. world: any;
  66035. name: string;
  66036. private _physicsMaterials;
  66037. private _fixedTimeStep;
  66038. private _cannonRaycastResult;
  66039. private _raycastResult;
  66040. private _physicsBodysToRemoveAfterStep;
  66041. private _firstFrame;
  66042. BJSCANNON: any;
  66043. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  66044. setGravity(gravity: Vector3): void;
  66045. setTimeStep(timeStep: number): void;
  66046. getTimeStep(): number;
  66047. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  66048. private _removeMarkedPhysicsBodiesFromWorld;
  66049. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  66050. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  66051. generatePhysicsBody(impostor: PhysicsImpostor): void;
  66052. private _processChildMeshes;
  66053. removePhysicsBody(impostor: PhysicsImpostor): void;
  66054. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  66055. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  66056. private _addMaterial;
  66057. private _checkWithEpsilon;
  66058. private _createShape;
  66059. private _createHeightmap;
  66060. private _minus90X;
  66061. private _plus90X;
  66062. private _tmpPosition;
  66063. private _tmpDeltaPosition;
  66064. private _tmpUnityRotation;
  66065. private _updatePhysicsBodyTransformation;
  66066. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  66067. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  66068. isSupported(): boolean;
  66069. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  66070. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  66071. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  66072. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  66073. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  66074. getBodyMass(impostor: PhysicsImpostor): number;
  66075. getBodyFriction(impostor: PhysicsImpostor): number;
  66076. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  66077. getBodyRestitution(impostor: PhysicsImpostor): number;
  66078. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  66079. sleepBody(impostor: PhysicsImpostor): void;
  66080. wakeUpBody(impostor: PhysicsImpostor): void;
  66081. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  66082. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  66083. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  66084. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  66085. getRadius(impostor: PhysicsImpostor): number;
  66086. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  66087. dispose(): void;
  66088. private _extendNamespace;
  66089. /**
  66090. * Does a raycast in the physics world
  66091. * @param from when should the ray start?
  66092. * @param to when should the ray end?
  66093. * @returns PhysicsRaycastResult
  66094. */
  66095. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  66096. }
  66097. }
  66098. declare module BABYLON {
  66099. /** @hidden */
  66100. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  66101. private _useDeltaForWorldStep;
  66102. world: any;
  66103. name: string;
  66104. BJSOIMO: any;
  66105. private _raycastResult;
  66106. private _fixedTimeStep;
  66107. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  66108. setGravity(gravity: Vector3): void;
  66109. setTimeStep(timeStep: number): void;
  66110. getTimeStep(): number;
  66111. private _tmpImpostorsArray;
  66112. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  66113. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  66114. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  66115. generatePhysicsBody(impostor: PhysicsImpostor): void;
  66116. private _tmpPositionVector;
  66117. removePhysicsBody(impostor: PhysicsImpostor): void;
  66118. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  66119. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  66120. isSupported(): boolean;
  66121. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  66122. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  66123. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  66124. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  66125. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  66126. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  66127. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  66128. getBodyMass(impostor: PhysicsImpostor): number;
  66129. getBodyFriction(impostor: PhysicsImpostor): number;
  66130. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  66131. getBodyRestitution(impostor: PhysicsImpostor): number;
  66132. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  66133. sleepBody(impostor: PhysicsImpostor): void;
  66134. wakeUpBody(impostor: PhysicsImpostor): void;
  66135. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  66136. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  66137. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  66138. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  66139. getRadius(impostor: PhysicsImpostor): number;
  66140. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  66141. dispose(): void;
  66142. /**
  66143. * Does a raycast in the physics world
  66144. * @param from when should the ray start?
  66145. * @param to when should the ray end?
  66146. * @returns PhysicsRaycastResult
  66147. */
  66148. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  66149. }
  66150. }
  66151. declare module BABYLON {
  66152. /**
  66153. * AmmoJS Physics plugin
  66154. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  66155. * @see https://github.com/kripken/ammo.js/
  66156. */
  66157. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  66158. private _useDeltaForWorldStep;
  66159. /**
  66160. * Reference to the Ammo library
  66161. */
  66162. bjsAMMO: any;
  66163. /**
  66164. * Created ammoJS world which physics bodies are added to
  66165. */
  66166. world: any;
  66167. /**
  66168. * Name of the plugin
  66169. */
  66170. name: string;
  66171. private _timeStep;
  66172. private _fixedTimeStep;
  66173. private _maxSteps;
  66174. private _tmpQuaternion;
  66175. private _tmpAmmoTransform;
  66176. private _tmpAmmoQuaternion;
  66177. private _tmpAmmoConcreteContactResultCallback;
  66178. private _collisionConfiguration;
  66179. private _dispatcher;
  66180. private _overlappingPairCache;
  66181. private _solver;
  66182. private _softBodySolver;
  66183. private _tmpAmmoVectorA;
  66184. private _tmpAmmoVectorB;
  66185. private _tmpAmmoVectorC;
  66186. private _tmpAmmoVectorD;
  66187. private _tmpContactCallbackResult;
  66188. private _tmpAmmoVectorRCA;
  66189. private _tmpAmmoVectorRCB;
  66190. private _raycastResult;
  66191. private _tmpContactPoint;
  66192. private static readonly DISABLE_COLLISION_FLAG;
  66193. private static readonly KINEMATIC_FLAG;
  66194. private static readonly DISABLE_DEACTIVATION_FLAG;
  66195. /**
  66196. * Initializes the ammoJS plugin
  66197. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  66198. * @param ammoInjection can be used to inject your own ammo reference
  66199. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  66200. */
  66201. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  66202. /**
  66203. * Sets the gravity of the physics world (m/(s^2))
  66204. * @param gravity Gravity to set
  66205. */
  66206. setGravity(gravity: Vector3): void;
  66207. /**
  66208. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  66209. * @param timeStep timestep to use in seconds
  66210. */
  66211. setTimeStep(timeStep: number): void;
  66212. /**
  66213. * 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)
  66214. * @param fixedTimeStep fixedTimeStep to use in seconds
  66215. */
  66216. setFixedTimeStep(fixedTimeStep: number): void;
  66217. /**
  66218. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  66219. * @param maxSteps the maximum number of steps by the physics engine per frame
  66220. */
  66221. setMaxSteps(maxSteps: number): void;
  66222. /**
  66223. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  66224. * @returns the current timestep in seconds
  66225. */
  66226. getTimeStep(): number;
  66227. /**
  66228. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  66229. */
  66230. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  66231. private _isImpostorInContact;
  66232. private _isImpostorPairInContact;
  66233. private _stepSimulation;
  66234. /**
  66235. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  66236. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  66237. * After the step the babylon meshes are set to the position of the physics imposters
  66238. * @param delta amount of time to step forward
  66239. * @param impostors array of imposters to update before/after the step
  66240. */
  66241. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  66242. /**
  66243. * Update babylon mesh to match physics world object
  66244. * @param impostor imposter to match
  66245. */
  66246. private _afterSoftStep;
  66247. /**
  66248. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  66249. * @param impostor imposter to match
  66250. */
  66251. private _ropeStep;
  66252. /**
  66253. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  66254. * @param impostor imposter to match
  66255. */
  66256. private _softbodyOrClothStep;
  66257. private _tmpMatrix;
  66258. /**
  66259. * Applies an impulse on the imposter
  66260. * @param impostor imposter to apply impulse to
  66261. * @param force amount of force to be applied to the imposter
  66262. * @param contactPoint the location to apply the impulse on the imposter
  66263. */
  66264. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  66265. /**
  66266. * Applies a force on the imposter
  66267. * @param impostor imposter to apply force
  66268. * @param force amount of force to be applied to the imposter
  66269. * @param contactPoint the location to apply the force on the imposter
  66270. */
  66271. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  66272. /**
  66273. * Creates a physics body using the plugin
  66274. * @param impostor the imposter to create the physics body on
  66275. */
  66276. generatePhysicsBody(impostor: PhysicsImpostor): void;
  66277. /**
  66278. * Removes the physics body from the imposter and disposes of the body's memory
  66279. * @param impostor imposter to remove the physics body from
  66280. */
  66281. removePhysicsBody(impostor: PhysicsImpostor): void;
  66282. /**
  66283. * Generates a joint
  66284. * @param impostorJoint the imposter joint to create the joint with
  66285. */
  66286. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  66287. /**
  66288. * Removes a joint
  66289. * @param impostorJoint the imposter joint to remove the joint from
  66290. */
  66291. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  66292. private _addMeshVerts;
  66293. /**
  66294. * Initialise the soft body vertices to match its object's (mesh) vertices
  66295. * Softbody vertices (nodes) are in world space and to match this
  66296. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  66297. * @param impostor to create the softbody for
  66298. */
  66299. private _softVertexData;
  66300. /**
  66301. * Create an impostor's soft body
  66302. * @param impostor to create the softbody for
  66303. */
  66304. private _createSoftbody;
  66305. /**
  66306. * Create cloth for an impostor
  66307. * @param impostor to create the softbody for
  66308. */
  66309. private _createCloth;
  66310. /**
  66311. * Create rope for an impostor
  66312. * @param impostor to create the softbody for
  66313. */
  66314. private _createRope;
  66315. /**
  66316. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  66317. * @param impostor to create the custom physics shape for
  66318. */
  66319. private _createCustom;
  66320. private _addHullVerts;
  66321. private _createShape;
  66322. /**
  66323. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  66324. * @param impostor imposter containing the physics body and babylon object
  66325. */
  66326. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  66327. /**
  66328. * Sets the babylon object's position/rotation from the physics body's position/rotation
  66329. * @param impostor imposter containing the physics body and babylon object
  66330. * @param newPosition new position
  66331. * @param newRotation new rotation
  66332. */
  66333. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  66334. /**
  66335. * If this plugin is supported
  66336. * @returns true if its supported
  66337. */
  66338. isSupported(): boolean;
  66339. /**
  66340. * Sets the linear velocity of the physics body
  66341. * @param impostor imposter to set the velocity on
  66342. * @param velocity velocity to set
  66343. */
  66344. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  66345. /**
  66346. * Sets the angular velocity of the physics body
  66347. * @param impostor imposter to set the velocity on
  66348. * @param velocity velocity to set
  66349. */
  66350. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  66351. /**
  66352. * gets the linear velocity
  66353. * @param impostor imposter to get linear velocity from
  66354. * @returns linear velocity
  66355. */
  66356. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  66357. /**
  66358. * gets the angular velocity
  66359. * @param impostor imposter to get angular velocity from
  66360. * @returns angular velocity
  66361. */
  66362. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  66363. /**
  66364. * Sets the mass of physics body
  66365. * @param impostor imposter to set the mass on
  66366. * @param mass mass to set
  66367. */
  66368. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  66369. /**
  66370. * Gets the mass of the physics body
  66371. * @param impostor imposter to get the mass from
  66372. * @returns mass
  66373. */
  66374. getBodyMass(impostor: PhysicsImpostor): number;
  66375. /**
  66376. * Gets friction of the impostor
  66377. * @param impostor impostor to get friction from
  66378. * @returns friction value
  66379. */
  66380. getBodyFriction(impostor: PhysicsImpostor): number;
  66381. /**
  66382. * Sets friction of the impostor
  66383. * @param impostor impostor to set friction on
  66384. * @param friction friction value
  66385. */
  66386. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  66387. /**
  66388. * Gets restitution of the impostor
  66389. * @param impostor impostor to get restitution from
  66390. * @returns restitution value
  66391. */
  66392. getBodyRestitution(impostor: PhysicsImpostor): number;
  66393. /**
  66394. * Sets restitution of the impostor
  66395. * @param impostor impostor to set resitution on
  66396. * @param restitution resitution value
  66397. */
  66398. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  66399. /**
  66400. * Gets pressure inside the impostor
  66401. * @param impostor impostor to get pressure from
  66402. * @returns pressure value
  66403. */
  66404. getBodyPressure(impostor: PhysicsImpostor): number;
  66405. /**
  66406. * Sets pressure inside a soft body impostor
  66407. * Cloth and rope must remain 0 pressure
  66408. * @param impostor impostor to set pressure on
  66409. * @param pressure pressure value
  66410. */
  66411. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  66412. /**
  66413. * Gets stiffness of the impostor
  66414. * @param impostor impostor to get stiffness from
  66415. * @returns pressure value
  66416. */
  66417. getBodyStiffness(impostor: PhysicsImpostor): number;
  66418. /**
  66419. * Sets stiffness of the impostor
  66420. * @param impostor impostor to set stiffness on
  66421. * @param stiffness stiffness value from 0 to 1
  66422. */
  66423. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  66424. /**
  66425. * Gets velocityIterations of the impostor
  66426. * @param impostor impostor to get velocity iterations from
  66427. * @returns velocityIterations value
  66428. */
  66429. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  66430. /**
  66431. * Sets velocityIterations of the impostor
  66432. * @param impostor impostor to set velocity iterations on
  66433. * @param velocityIterations velocityIterations value
  66434. */
  66435. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  66436. /**
  66437. * Gets positionIterations of the impostor
  66438. * @param impostor impostor to get position iterations from
  66439. * @returns positionIterations value
  66440. */
  66441. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  66442. /**
  66443. * Sets positionIterations of the impostor
  66444. * @param impostor impostor to set position on
  66445. * @param positionIterations positionIterations value
  66446. */
  66447. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  66448. /**
  66449. * Append an anchor to a cloth object
  66450. * @param impostor is the cloth impostor to add anchor to
  66451. * @param otherImpostor is the rigid impostor to anchor to
  66452. * @param width ratio across width from 0 to 1
  66453. * @param height ratio up height from 0 to 1
  66454. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little stretch
  66455. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  66456. */
  66457. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  66458. /**
  66459. * Append an hook to a rope object
  66460. * @param impostor is the rope impostor to add hook to
  66461. * @param otherImpostor is the rigid impostor to hook to
  66462. * @param length ratio along the rope from 0 to 1
  66463. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little stretch
  66464. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  66465. */
  66466. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  66467. /**
  66468. * Sleeps the physics body and stops it from being active
  66469. * @param impostor impostor to sleep
  66470. */
  66471. sleepBody(impostor: PhysicsImpostor): void;
  66472. /**
  66473. * Activates the physics body
  66474. * @param impostor impostor to activate
  66475. */
  66476. wakeUpBody(impostor: PhysicsImpostor): void;
  66477. /**
  66478. * Updates the distance parameters of the joint
  66479. * @param joint joint to update
  66480. * @param maxDistance maximum distance of the joint
  66481. * @param minDistance minimum distance of the joint
  66482. */
  66483. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  66484. /**
  66485. * Sets a motor on the joint
  66486. * @param joint joint to set motor on
  66487. * @param speed speed of the motor
  66488. * @param maxForce maximum force of the motor
  66489. * @param motorIndex index of the motor
  66490. */
  66491. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  66492. /**
  66493. * Sets the motors limit
  66494. * @param joint joint to set limit on
  66495. * @param upperLimit upper limit
  66496. * @param lowerLimit lower limit
  66497. */
  66498. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  66499. /**
  66500. * Syncs the position and rotation of a mesh with the impostor
  66501. * @param mesh mesh to sync
  66502. * @param impostor impostor to update the mesh with
  66503. */
  66504. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  66505. /**
  66506. * Gets the radius of the impostor
  66507. * @param impostor impostor to get radius from
  66508. * @returns the radius
  66509. */
  66510. getRadius(impostor: PhysicsImpostor): number;
  66511. /**
  66512. * Gets the box size of the impostor
  66513. * @param impostor impostor to get box size from
  66514. * @param result the resulting box size
  66515. */
  66516. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  66517. /**
  66518. * Disposes of the impostor
  66519. */
  66520. dispose(): void;
  66521. /**
  66522. * Does a raycast in the physics world
  66523. * @param from when should the ray start?
  66524. * @param to when should the ray end?
  66525. * @returns PhysicsRaycastResult
  66526. */
  66527. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  66528. }
  66529. }
  66530. declare module BABYLON {
  66531. interface AbstractScene {
  66532. /**
  66533. * The list of reflection probes added to the scene
  66534. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  66535. */
  66536. reflectionProbes: Array<ReflectionProbe>;
  66537. /**
  66538. * Removes the given reflection probe from this scene.
  66539. * @param toRemove The reflection probe to remove
  66540. * @returns The index of the removed reflection probe
  66541. */
  66542. removeReflectionProbe(toRemove: ReflectionProbe): number;
  66543. /**
  66544. * Adds the given reflection probe to this scene.
  66545. * @param newReflectionProbe The reflection probe to add
  66546. */
  66547. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  66548. }
  66549. /**
  66550. * Class used to generate realtime reflection / refraction cube textures
  66551. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  66552. */
  66553. export class ReflectionProbe {
  66554. /** defines the name of the probe */
  66555. name: string;
  66556. private _scene;
  66557. private _renderTargetTexture;
  66558. private _projectionMatrix;
  66559. private _viewMatrix;
  66560. private _target;
  66561. private _add;
  66562. private _attachedMesh;
  66563. private _invertYAxis;
  66564. /** Gets or sets probe position (center of the cube map) */
  66565. position: Vector3;
  66566. /**
  66567. * Creates a new reflection probe
  66568. * @param name defines the name of the probe
  66569. * @param size defines the texture resolution (for each face)
  66570. * @param scene defines the hosting scene
  66571. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  66572. * @param useFloat defines if HDR data (float data) should be used to store colors (false by default)
  66573. * @param linearSpace defines if the probe should be generated in linear space or not (false by default)
  66574. */
  66575. constructor(
  66576. /** defines the name of the probe */
  66577. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean, linearSpace?: boolean);
  66578. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  66579. get samples(): number;
  66580. set samples(value: number);
  66581. /** Gets or sets the refresh rate to use (on every frame by default) */
  66582. get refreshRate(): number;
  66583. set refreshRate(value: number);
  66584. /**
  66585. * Gets the hosting scene
  66586. * @returns a Scene
  66587. */
  66588. getScene(): Scene;
  66589. /** Gets the internal CubeTexture used to render to */
  66590. get cubeTexture(): RenderTargetTexture;
  66591. /** Gets the list of meshes to render */
  66592. get renderList(): Nullable<AbstractMesh[]>;
  66593. /**
  66594. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  66595. * @param mesh defines the mesh to attach to
  66596. */
  66597. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  66598. /**
  66599. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  66600. * @param renderingGroupId The rendering group id corresponding to its index
  66601. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  66602. */
  66603. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  66604. /**
  66605. * Clean all associated resources
  66606. */
  66607. dispose(): void;
  66608. /**
  66609. * Converts the reflection probe information to a readable string for debug purpose.
  66610. * @param fullDetails Supports for multiple levels of logging within scene loading
  66611. * @returns the human readable reflection probe info
  66612. */
  66613. toString(fullDetails?: boolean): string;
  66614. /**
  66615. * Get the class name of the refection probe.
  66616. * @returns "ReflectionProbe"
  66617. */
  66618. getClassName(): string;
  66619. /**
  66620. * Serialize the reflection probe to a JSON representation we can easily use in the respective Parse function.
  66621. * @returns The JSON representation of the texture
  66622. */
  66623. serialize(): any;
  66624. /**
  66625. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  66626. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  66627. * @param scene Define the scene the parsed reflection probe should be instantiated in
  66628. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  66629. * @returns The parsed reflection probe if successful
  66630. */
  66631. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  66632. }
  66633. }
  66634. declare module BABYLON {
  66635. /** @hidden */
  66636. export var _BabylonLoaderRegistered: boolean;
  66637. /**
  66638. * Helps setting up some configuration for the babylon file loader.
  66639. */
  66640. export class BabylonFileLoaderConfiguration {
  66641. /**
  66642. * The loader does not allow injecting custom physics engine into the plugins.
  66643. * Unfortunately in ES6, we need to manually inject them into the plugin.
  66644. * So you could set this variable to your engine import to make it work.
  66645. */
  66646. static LoaderInjectedPhysicsEngine: any;
  66647. }
  66648. }
  66649. declare module BABYLON {
  66650. /**
  66651. * A material to use for fast depth-only rendering.
  66652. */
  66653. export class OcclusionMaterial extends ShaderMaterial {
  66654. constructor(name: string, scene: Scene);
  66655. }
  66656. }
  66657. declare module BABYLON {
  66658. /**
  66659. * The Physically based simple base material of BJS.
  66660. *
  66661. * This enables better naming and convention enforcements on top of the pbrMaterial.
  66662. * It is used as the base class for both the specGloss and metalRough conventions.
  66663. */
  66664. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  66665. /**
  66666. * Number of Simultaneous lights allowed on the material.
  66667. */
  66668. maxSimultaneousLights: number;
  66669. /**
  66670. * If sets to true, disables all the lights affecting the material.
  66671. */
  66672. disableLighting: boolean;
  66673. /**
  66674. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  66675. */
  66676. environmentTexture: BaseTexture;
  66677. /**
  66678. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  66679. */
  66680. invertNormalMapX: boolean;
  66681. /**
  66682. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  66683. */
  66684. invertNormalMapY: boolean;
  66685. /**
  66686. * Normal map used in the model.
  66687. */
  66688. normalTexture: BaseTexture;
  66689. /**
  66690. * Emissivie color used to self-illuminate the model.
  66691. */
  66692. emissiveColor: Color3;
  66693. /**
  66694. * Emissivie texture used to self-illuminate the model.
  66695. */
  66696. emissiveTexture: BaseTexture;
  66697. /**
  66698. * Occlusion Channel Strength.
  66699. */
  66700. occlusionStrength: number;
  66701. /**
  66702. * Occlusion Texture of the material (adding extra occlusion effects).
  66703. */
  66704. occlusionTexture: BaseTexture;
  66705. /**
  66706. * Defines the alpha limits in alpha test mode.
  66707. */
  66708. alphaCutOff: number;
  66709. /**
  66710. * Gets the current double sided mode.
  66711. */
  66712. get doubleSided(): boolean;
  66713. /**
  66714. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  66715. */
  66716. set doubleSided(value: boolean);
  66717. /**
  66718. * Stores the pre-calculated light information of a mesh in a texture.
  66719. */
  66720. lightmapTexture: BaseTexture;
  66721. /**
  66722. * If true, the light map contains occlusion information instead of lighting info.
  66723. */
  66724. useLightmapAsShadowmap: boolean;
  66725. /**
  66726. * Instantiates a new PBRMaterial instance.
  66727. *
  66728. * @param name The material name
  66729. * @param scene The scene the material will be use in.
  66730. */
  66731. constructor(name: string, scene: Scene);
  66732. getClassName(): string;
  66733. }
  66734. }
  66735. declare module BABYLON {
  66736. /**
  66737. * The PBR material of BJS following the metal roughness convention.
  66738. *
  66739. * This fits to the PBR convention in the GLTF definition:
  66740. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  66741. */
  66742. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  66743. /**
  66744. * The base color has two different interpretations depending on the value of metalness.
  66745. * When the material is a metal, the base color is the specific measured reflectance value
  66746. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  66747. * of the material.
  66748. */
  66749. baseColor: Color3;
  66750. /**
  66751. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  66752. * well as opacity information in the alpha channel.
  66753. */
  66754. baseTexture: BaseTexture;
  66755. /**
  66756. * Specifies the metallic scalar value of the material.
  66757. * Can also be used to scale the metalness values of the metallic texture.
  66758. */
  66759. metallic: number;
  66760. /**
  66761. * Specifies the roughness scalar value of the material.
  66762. * Can also be used to scale the roughness values of the metallic texture.
  66763. */
  66764. roughness: number;
  66765. /**
  66766. * Texture containing both the metallic value in the B channel and the
  66767. * roughness value in the G channel to keep better precision.
  66768. */
  66769. metallicRoughnessTexture: BaseTexture;
  66770. /**
  66771. * Instantiates a new PBRMetalRoughnessMaterial instance.
  66772. *
  66773. * @param name The material name
  66774. * @param scene The scene the material will be use in.
  66775. */
  66776. constructor(name: string, scene: Scene);
  66777. /**
  66778. * Return the current class name of the material.
  66779. */
  66780. getClassName(): string;
  66781. /**
  66782. * Makes a duplicate of the current material.
  66783. * @param name - name to use for the new material.
  66784. */
  66785. clone(name: string): PBRMetallicRoughnessMaterial;
  66786. /**
  66787. * Serialize the material to a parsable JSON object.
  66788. */
  66789. serialize(): any;
  66790. /**
  66791. * Parses a JSON object corresponding to the serialize function.
  66792. */
  66793. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  66794. }
  66795. }
  66796. declare module BABYLON {
  66797. /**
  66798. * The PBR material of BJS following the specular glossiness convention.
  66799. *
  66800. * This fits to the PBR convention in the GLTF definition:
  66801. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  66802. */
  66803. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  66804. /**
  66805. * Specifies the diffuse color of the material.
  66806. */
  66807. diffuseColor: Color3;
  66808. /**
  66809. * Specifies the diffuse texture of the material. This can also contains the opacity value in its alpha
  66810. * channel.
  66811. */
  66812. diffuseTexture: BaseTexture;
  66813. /**
  66814. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  66815. */
  66816. specularColor: Color3;
  66817. /**
  66818. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  66819. */
  66820. glossiness: number;
  66821. /**
  66822. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  66823. */
  66824. specularGlossinessTexture: BaseTexture;
  66825. /**
  66826. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  66827. */
  66828. get useMicroSurfaceFromReflectivityMapAlpha(): boolean;
  66829. /**
  66830. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  66831. *
  66832. * @param name The material name
  66833. * @param scene The scene the material will be use in.
  66834. */
  66835. constructor(name: string, scene: Scene);
  66836. /**
  66837. * Return the current class name of the material.
  66838. */
  66839. getClassName(): string;
  66840. /**
  66841. * Makes a duplicate of the current material.
  66842. * @param name - name to use for the new material.
  66843. */
  66844. clone(name: string): PBRSpecularGlossinessMaterial;
  66845. /**
  66846. * Serialize the material to a parsable JSON object.
  66847. */
  66848. serialize(): any;
  66849. /**
  66850. * Parses a JSON object corresponding to the serialize function.
  66851. */
  66852. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  66853. }
  66854. }
  66855. declare module BABYLON {
  66856. /**
  66857. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  66858. * It can help converting any input color in a desired output one. This can then be used to create effects
  66859. * from sepia, black and white to sixties or futuristic rendering...
  66860. *
  66861. * The only supported format is currently 3dl.
  66862. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  66863. */
  66864. export class ColorGradingTexture extends BaseTexture {
  66865. /**
  66866. * The texture URL.
  66867. */
  66868. url: string;
  66869. /**
  66870. * Empty line regex stored for GC.
  66871. */
  66872. private static _noneEmptyLineRegex;
  66873. private _textureMatrix;
  66874. private _onLoad;
  66875. /**
  66876. * Instantiates a ColorGradingTexture from the following parameters.
  66877. *
  66878. * @param url The location of the color grading data (currently only supporting 3dl)
  66879. * @param sceneOrEngine The scene or engine the texture will be used in
  66880. * @param onLoad defines a callback triggered when the texture has been loaded
  66881. */
  66882. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  66883. /**
  66884. * Fires the onload event from the constructor if requested.
  66885. */
  66886. private _triggerOnLoad;
  66887. /**
  66888. * Returns the texture matrix used in most of the material.
  66889. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  66890. */
  66891. getTextureMatrix(): Matrix;
  66892. /**
  66893. * Occurs when the file being loaded is a .3dl LUT file.
  66894. */
  66895. private load3dlTexture;
  66896. /**
  66897. * Starts the loading process of the texture.
  66898. */
  66899. private loadTexture;
  66900. /**
  66901. * Clones the color grading texture.
  66902. */
  66903. clone(): ColorGradingTexture;
  66904. /**
  66905. * Called during delayed load for textures.
  66906. */
  66907. delayLoad(): void;
  66908. /**
  66909. * Parses a color grading texture serialized by Babylon.
  66910. * @param parsedTexture The texture information being parsedTexture
  66911. * @param scene The scene to load the texture in
  66912. * @param rootUrl The root url of the data assets to load
  66913. * @return A color grading texture
  66914. */
  66915. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  66916. /**
  66917. * Serializes the LUT texture to json format.
  66918. */
  66919. serialize(): any;
  66920. }
  66921. }
  66922. declare module BABYLON {
  66923. /**
  66924. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  66925. */
  66926. export class EquiRectangularCubeTexture extends BaseTexture {
  66927. /** The six faces of the cube. */
  66928. private static _FacesMapping;
  66929. private _noMipmap;
  66930. private _onLoad;
  66931. private _onError;
  66932. /** The size of the cubemap. */
  66933. private _size;
  66934. /** The buffer of the image. */
  66935. private _buffer;
  66936. /** The width of the input image. */
  66937. private _width;
  66938. /** The height of the input image. */
  66939. private _height;
  66940. /** The URL to the image. */
  66941. url: string;
  66942. /**
  66943. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  66944. * @param url The location of the image
  66945. * @param scene The scene the texture will be used in
  66946. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  66947. * @param noMipmap Forces to not generate the mipmap if true
  66948. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  66949. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  66950. * @param onLoad — defines a callback called when texture is loaded
  66951. * @param onError — defines a callback called if there is an error
  66952. */
  66953. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  66954. /**
  66955. * Load the image data, by putting the image on a canvas and extracting its buffer.
  66956. */
  66957. private loadImage;
  66958. /**
  66959. * Convert the image buffer into a cubemap and create a CubeTexture.
  66960. */
  66961. private loadTexture;
  66962. /**
  66963. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  66964. * @param buffer The ArrayBuffer that should be converted.
  66965. * @returns The buffer as Float32Array.
  66966. */
  66967. private getFloat32ArrayFromArrayBuffer;
  66968. /**
  66969. * Get the current class name of the texture useful for serialization or dynamic coding.
  66970. * @returns "EquiRectangularCubeTexture"
  66971. */
  66972. getClassName(): string;
  66973. /**
  66974. * Create a clone of the current EquiRectangularCubeTexture and return it.
  66975. * @returns A clone of the current EquiRectangularCubeTexture.
  66976. */
  66977. clone(): EquiRectangularCubeTexture;
  66978. }
  66979. }
  66980. declare module BABYLON {
  66981. /**
  66982. * Defines the options related to the creation of an HtmlElementTexture
  66983. */
  66984. export interface IHtmlElementTextureOptions {
  66985. /**
  66986. * Defines whether mip maps should be created or not.
  66987. */
  66988. generateMipMaps?: boolean;
  66989. /**
  66990. * Defines the sampling mode of the texture.
  66991. */
  66992. samplingMode?: number;
  66993. /**
  66994. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  66995. */
  66996. engine: Nullable<ThinEngine>;
  66997. /**
  66998. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  66999. */
  67000. scene: Nullable<Scene>;
  67001. }
  67002. /**
  67003. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  67004. * To be as efficient as possible depending on your constraints nothing aside the first upload
  67005. * is automatically managed.
  67006. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  67007. * in your application.
  67008. *
  67009. * As the update is not automatic, you need to call them manually.
  67010. */
  67011. export class HtmlElementTexture extends BaseTexture {
  67012. /**
  67013. * The texture URL.
  67014. */
  67015. element: HTMLVideoElement | HTMLCanvasElement;
  67016. private static readonly DefaultOptions;
  67017. private _textureMatrix;
  67018. private _isVideo;
  67019. private _generateMipMaps;
  67020. private _samplingMode;
  67021. /**
  67022. * Instantiates a HtmlElementTexture from the following parameters.
  67023. *
  67024. * @param name Defines the name of the texture
  67025. * @param element Defines the video or canvas the texture is filled with
  67026. * @param options Defines the other none mandatory texture creation options
  67027. */
  67028. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  67029. private _createInternalTexture;
  67030. /**
  67031. * Returns the texture matrix used in most of the material.
  67032. */
  67033. getTextureMatrix(): Matrix;
  67034. /**
  67035. * Updates the content of the texture.
  67036. * @param invertY Defines whether the texture should be inverted on Y (false by default on video and true on canvas)
  67037. */
  67038. update(invertY?: Nullable<boolean>): void;
  67039. }
  67040. }
  67041. declare module BABYLON {
  67042. /**
  67043. * Based on jsTGALoader - Javascript loader for TGA file
  67044. * By Vincent Thibault
  67045. * @see http://blog.robrowser.com/javascript-tga-loader.html
  67046. */
  67047. export class TGATools {
  67048. private static _TYPE_INDEXED;
  67049. private static _TYPE_RGB;
  67050. private static _TYPE_GREY;
  67051. private static _TYPE_RLE_INDEXED;
  67052. private static _TYPE_RLE_RGB;
  67053. private static _TYPE_RLE_GREY;
  67054. private static _ORIGIN_MASK;
  67055. private static _ORIGIN_SHIFT;
  67056. private static _ORIGIN_BL;
  67057. private static _ORIGIN_BR;
  67058. private static _ORIGIN_UL;
  67059. private static _ORIGIN_UR;
  67060. /**
  67061. * Gets the header of a TGA file
  67062. * @param data defines the TGA data
  67063. * @returns the header
  67064. */
  67065. static GetTGAHeader(data: Uint8Array): any;
  67066. /**
  67067. * Uploads TGA content to a Babylon Texture
  67068. * @hidden
  67069. */
  67070. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  67071. /** @hidden */
  67072. 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;
  67073. /** @hidden */
  67074. 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;
  67075. /** @hidden */
  67076. 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;
  67077. /** @hidden */
  67078. 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;
  67079. /** @hidden */
  67080. 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;
  67081. /** @hidden */
  67082. 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;
  67083. }
  67084. }
  67085. declare module BABYLON {
  67086. /**
  67087. * Implementation of the TGA Texture Loader.
  67088. * @hidden
  67089. */
  67090. export class _TGATextureLoader implements IInternalTextureLoader {
  67091. /**
  67092. * Defines whether the loader supports cascade loading the different faces.
  67093. */
  67094. readonly supportCascades: boolean;
  67095. /**
  67096. * This returns if the loader support the current file information.
  67097. * @param extension defines the file extension of the file being loaded
  67098. * @returns true if the loader can load the specified file
  67099. */
  67100. canLoad(extension: string): boolean;
  67101. /**
  67102. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  67103. * @param data contains the texture data
  67104. * @param texture defines the BabylonJS internal texture
  67105. * @param createPolynomials will be true if polynomials have been requested
  67106. * @param onLoad defines the callback to trigger once the texture is ready
  67107. * @param onError defines the callback to trigger in case of error
  67108. */
  67109. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  67110. /**
  67111. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  67112. * @param data contains the texture data
  67113. * @param texture defines the BabylonJS internal texture
  67114. * @param callback defines the method to call once ready to upload
  67115. */
  67116. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  67117. }
  67118. }
  67119. declare module BABYLON {
  67120. /**
  67121. * Implementation of the HDR Texture Loader.
  67122. * @hidden
  67123. */
  67124. export class _HDRTextureLoader implements IInternalTextureLoader {
  67125. /**
  67126. * Defines whether the loader supports cascade loading the different faces.
  67127. */
  67128. readonly supportCascades: boolean;
  67129. /**
  67130. * This returns if the loader support the current file information.
  67131. * @param extension defines the file extension of the file being loaded
  67132. * @returns true if the loader can load the specified file
  67133. */
  67134. canLoad(extension: string): boolean;
  67135. /**
  67136. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  67137. * @param data contains the texture data
  67138. * @param texture defines the BabylonJS internal texture
  67139. * @param createPolynomials will be true if polynomials have been requested
  67140. * @param onLoad defines the callback to trigger once the texture is ready
  67141. * @param onError defines the callback to trigger in case of error
  67142. */
  67143. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  67144. /**
  67145. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  67146. * @param data contains the texture data
  67147. * @param texture defines the BabylonJS internal texture
  67148. * @param callback defines the method to call once ready to upload
  67149. */
  67150. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  67151. }
  67152. }
  67153. declare module BABYLON {
  67154. /**
  67155. * Info about the .basis files
  67156. */
  67157. class BasisFileInfo {
  67158. /**
  67159. * If the file has alpha
  67160. */
  67161. hasAlpha: boolean;
  67162. /**
  67163. * Info about each image of the basis file
  67164. */
  67165. images: Array<{
  67166. levels: Array<{
  67167. width: number;
  67168. height: number;
  67169. transcodedPixels: ArrayBufferView;
  67170. }>;
  67171. }>;
  67172. }
  67173. /**
  67174. * Result of transcoding a basis file
  67175. */
  67176. class TranscodeResult {
  67177. /**
  67178. * Info about the .basis file
  67179. */
  67180. fileInfo: BasisFileInfo;
  67181. /**
  67182. * Format to use when loading the file
  67183. */
  67184. format: number;
  67185. }
  67186. /**
  67187. * Configuration options for the Basis transcoder
  67188. */
  67189. export class BasisTranscodeConfiguration {
  67190. /**
  67191. * Supported compression formats used to determine the supported output format of the transcoder
  67192. */
  67193. supportedCompressionFormats?: {
  67194. /**
  67195. * etc1 compression format
  67196. */
  67197. etc1?: boolean;
  67198. /**
  67199. * s3tc compression format
  67200. */
  67201. s3tc?: boolean;
  67202. /**
  67203. * pvrtc compression format
  67204. */
  67205. pvrtc?: boolean;
  67206. /**
  67207. * etc2 compression format
  67208. */
  67209. etc2?: boolean;
  67210. };
  67211. /**
  67212. * If mipmap levels should be loaded for transcoded images (Default: true)
  67213. */
  67214. loadMipmapLevels?: boolean;
  67215. /**
  67216. * Index of a single image to load (Default: all images)
  67217. */
  67218. loadSingleImage?: number;
  67219. }
  67220. /**
  67221. * Used to load .Basis files
  67222. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  67223. */
  67224. export class BasisTools {
  67225. private static _IgnoreSupportedFormats;
  67226. /**
  67227. * URL to use when loading the basis transcoder
  67228. */
  67229. static JSModuleURL: string;
  67230. /**
  67231. * URL to use when loading the wasm module for the transcoder
  67232. */
  67233. static WasmModuleURL: string;
  67234. /**
  67235. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  67236. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  67237. * @returns internal format corresponding to the Basis format
  67238. */
  67239. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  67240. private static _WorkerPromise;
  67241. private static _Worker;
  67242. private static _actionId;
  67243. private static _CreateWorkerAsync;
  67244. /**
  67245. * Transcodes a loaded image file to compressed pixel data
  67246. * @param data image data to transcode
  67247. * @param config configuration options for the transcoding
  67248. * @returns a promise resulting in the transcoded image
  67249. */
  67250. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  67251. /**
  67252. * Loads a texture from the transcode result
  67253. * @param texture texture load to
  67254. * @param transcodeResult the result of transcoding the basis file to load from
  67255. */
  67256. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  67257. }
  67258. }
  67259. declare module BABYLON {
  67260. /**
  67261. * Loader for .basis file format
  67262. */
  67263. export class _BasisTextureLoader implements IInternalTextureLoader {
  67264. /**
  67265. * Defines whether the loader supports cascade loading the different faces.
  67266. */
  67267. readonly supportCascades: boolean;
  67268. /**
  67269. * This returns if the loader support the current file information.
  67270. * @param extension defines the file extension of the file being loaded
  67271. * @returns true if the loader can load the specified file
  67272. */
  67273. canLoad(extension: string): boolean;
  67274. /**
  67275. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  67276. * @param data contains the texture data
  67277. * @param texture defines the BabylonJS internal texture
  67278. * @param createPolynomials will be true if polynomials have been requested
  67279. * @param onLoad defines the callback to trigger once the texture is ready
  67280. * @param onError defines the callback to trigger in case of error
  67281. */
  67282. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  67283. /**
  67284. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  67285. * @param data contains the texture data
  67286. * @param texture defines the BabylonJS internal texture
  67287. * @param callback defines the method to call once ready to upload
  67288. */
  67289. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  67290. }
  67291. }
  67292. declare module BABYLON {
  67293. /**
  67294. * Defines the basic options interface of a TexturePacker Frame
  67295. */
  67296. export interface ITexturePackerFrame {
  67297. /**
  67298. * The frame ID
  67299. */
  67300. id: number;
  67301. /**
  67302. * The frames Scale
  67303. */
  67304. scale: Vector2;
  67305. /**
  67306. * The Frames offset
  67307. */
  67308. offset: Vector2;
  67309. }
  67310. /**
  67311. * This is a support class for frame Data on texture packer sets.
  67312. */
  67313. export class TexturePackerFrame implements ITexturePackerFrame {
  67314. /**
  67315. * The frame ID
  67316. */
  67317. id: number;
  67318. /**
  67319. * The frames Scale
  67320. */
  67321. scale: Vector2;
  67322. /**
  67323. * The Frames offset
  67324. */
  67325. offset: Vector2;
  67326. /**
  67327. * Initializes a texture package frame.
  67328. * @param id The numerical frame identifier
  67329. * @param scale Scalar Vector2 for UV frame
  67330. * @param offset Vector2 for the frame position in UV units.
  67331. * @returns TexturePackerFrame
  67332. */
  67333. constructor(id: number, scale: Vector2, offset: Vector2);
  67334. }
  67335. }
  67336. declare module BABYLON {
  67337. /**
  67338. * Defines the basic options interface of a TexturePacker
  67339. */
  67340. export interface ITexturePackerOptions {
  67341. /**
  67342. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  67343. */
  67344. map?: string[];
  67345. /**
  67346. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  67347. */
  67348. uvsIn?: string;
  67349. /**
  67350. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  67351. */
  67352. uvsOut?: string;
  67353. /**
  67354. * number representing the layout style. Defaults to LAYOUT_STRIP
  67355. */
  67356. layout?: number;
  67357. /**
  67358. * number of columns if using custom column count layout(2). This defaults to 4.
  67359. */
  67360. colnum?: number;
  67361. /**
  67362. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  67363. */
  67364. updateInputMeshes?: boolean;
  67365. /**
  67366. * boolean flag to dispose all the source textures. Defaults to true.
  67367. */
  67368. disposeSources?: boolean;
  67369. /**
  67370. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  67371. */
  67372. fillBlanks?: boolean;
  67373. /**
  67374. * string value representing the context fill style color. Defaults to 'black'.
  67375. */
  67376. customFillColor?: string;
  67377. /**
  67378. * Width and Height Value of each Frame in the TexturePacker Sets
  67379. */
  67380. frameSize?: number;
  67381. /**
  67382. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  67383. */
  67384. paddingRatio?: number;
  67385. /**
  67386. * Number that declares the fill method for the padding gutter.
  67387. */
  67388. paddingMode?: number;
  67389. /**
  67390. * If in SUBUV_COLOR padding mode what color to use.
  67391. */
  67392. paddingColor?: Color3 | Color4;
  67393. }
  67394. /**
  67395. * Defines the basic interface of a TexturePacker JSON File
  67396. */
  67397. export interface ITexturePackerJSON {
  67398. /**
  67399. * The frame ID
  67400. */
  67401. name: string;
  67402. /**
  67403. * The base64 channel data
  67404. */
  67405. sets: any;
  67406. /**
  67407. * The options of the Packer
  67408. */
  67409. options: ITexturePackerOptions;
  67410. /**
  67411. * The frame data of the Packer
  67412. */
  67413. frames: Array<number>;
  67414. }
  67415. /**
  67416. * This is a support class that generates a series of packed texture sets.
  67417. * @see https://doc.babylonjs.com/babylon101/materials
  67418. */
  67419. export class TexturePacker {
  67420. /** Packer Layout Constant 0 */
  67421. static readonly LAYOUT_STRIP: number;
  67422. /** Packer Layout Constant 1 */
  67423. static readonly LAYOUT_POWER2: number;
  67424. /** Packer Layout Constant 2 */
  67425. static readonly LAYOUT_COLNUM: number;
  67426. /** Packer Layout Constant 0 */
  67427. static readonly SUBUV_WRAP: number;
  67428. /** Packer Layout Constant 1 */
  67429. static readonly SUBUV_EXTEND: number;
  67430. /** Packer Layout Constant 2 */
  67431. static readonly SUBUV_COLOR: number;
  67432. /** The Name of the Texture Package */
  67433. name: string;
  67434. /** The scene scope of the TexturePacker */
  67435. scene: Scene;
  67436. /** The Meshes to target */
  67437. meshes: AbstractMesh[];
  67438. /** Arguments passed with the Constructor */
  67439. options: ITexturePackerOptions;
  67440. /** The promise that is started upon initialization */
  67441. promise: Nullable<Promise<TexturePacker | string>>;
  67442. /** The Container object for the channel sets that are generated */
  67443. sets: object;
  67444. /** The Container array for the frames that are generated */
  67445. frames: TexturePackerFrame[];
  67446. /** The expected number of textures the system is parsing. */
  67447. private _expecting;
  67448. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  67449. private _paddingValue;
  67450. /**
  67451. * Initializes a texture package series from an array of meshes or a single mesh.
  67452. * @param name The name of the package
  67453. * @param meshes The target meshes to compose the package from
  67454. * @param options The arguments that texture packer should follow while building.
  67455. * @param scene The scene which the textures are scoped to.
  67456. * @returns TexturePacker
  67457. */
  67458. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  67459. /**
  67460. * Starts the package process
  67461. * @param resolve The promises resolution function
  67462. * @returns TexturePacker
  67463. */
  67464. private _createFrames;
  67465. /**
  67466. * Calculates the Size of the Channel Sets
  67467. * @returns Vector2
  67468. */
  67469. private _calculateSize;
  67470. /**
  67471. * Calculates the UV data for the frames.
  67472. * @param baseSize the base frameSize
  67473. * @param padding the base frame padding
  67474. * @param dtSize size of the Dynamic Texture for that channel
  67475. * @param dtUnits is 1/dtSize
  67476. * @param update flag to update the input meshes
  67477. */
  67478. private _calculateMeshUVFrames;
  67479. /**
  67480. * Calculates the frames Offset.
  67481. * @param index of the frame
  67482. * @returns Vector2
  67483. */
  67484. private _getFrameOffset;
  67485. /**
  67486. * Updates a Mesh to the frame data
  67487. * @param mesh that is the target
  67488. * @param frameID or the frame index
  67489. */
  67490. private _updateMeshUV;
  67491. /**
  67492. * Updates a Meshes materials to use the texture packer channels
  67493. * @param m is the mesh to target
  67494. * @param force all channels on the packer to be set.
  67495. */
  67496. private _updateTextureReferences;
  67497. /**
  67498. * Public method to set a Mesh to a frame
  67499. * @param m that is the target
  67500. * @param frameID or the frame index
  67501. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  67502. */
  67503. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  67504. /**
  67505. * Starts the async promise to compile the texture packer.
  67506. * @returns Promise<void>
  67507. */
  67508. processAsync(): Promise<void>;
  67509. /**
  67510. * Disposes all textures associated with this packer
  67511. */
  67512. dispose(): void;
  67513. /**
  67514. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  67515. * @param imageType is the image type to use.
  67516. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  67517. */
  67518. download(imageType?: string, quality?: number): void;
  67519. /**
  67520. * Public method to load a texturePacker JSON file.
  67521. * @param data of the JSON file in string format.
  67522. */
  67523. updateFromJSON(data: string): void;
  67524. }
  67525. }
  67526. declare module BABYLON {
  67527. /**
  67528. * 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.
  67529. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  67530. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  67531. */
  67532. export class CustomProceduralTexture extends ProceduralTexture {
  67533. private _animate;
  67534. private _time;
  67535. private _config;
  67536. private _texturePath;
  67537. /**
  67538. * Instantiates a new Custom Procedural Texture.
  67539. * 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.
  67540. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  67541. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  67542. * @param name Define the name of the texture
  67543. * @param texturePath Define the folder path containing all the custom texture related files (config, shaders...)
  67544. * @param size Define the size of the texture to create
  67545. * @param scene Define the scene the texture belongs to
  67546. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  67547. * @param generateMipMaps Define if the texture should creates mip maps or not
  67548. */
  67549. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  67550. private _loadJson;
  67551. /**
  67552. * Is the texture ready to be used ? (rendered at least once)
  67553. * @returns true if ready, otherwise, false.
  67554. */
  67555. isReady(): boolean;
  67556. /**
  67557. * Render the texture to its associated render target.
  67558. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  67559. */
  67560. render(useCameraPostProcess?: boolean): void;
  67561. /**
  67562. * Update the list of dependant textures samplers in the shader.
  67563. */
  67564. updateTextures(): void;
  67565. /**
  67566. * Update the uniform values of the procedural texture in the shader.
  67567. */
  67568. updateShaderUniforms(): void;
  67569. /**
  67570. * Define if the texture animates or not.
  67571. */
  67572. get animate(): boolean;
  67573. set animate(value: boolean);
  67574. }
  67575. }
  67576. declare module BABYLON {
  67577. /** @hidden */
  67578. export var noisePixelShader: {
  67579. name: string;
  67580. shader: string;
  67581. };
  67582. }
  67583. declare module BABYLON {
  67584. /**
  67585. * Class used to generate noise procedural textures
  67586. */
  67587. export class NoiseProceduralTexture extends ProceduralTexture {
  67588. /** Gets or sets the start time (default is 0) */
  67589. time: number;
  67590. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  67591. brightness: number;
  67592. /** Defines the number of octaves to process */
  67593. octaves: number;
  67594. /** Defines the level of persistence (0.8 by default) */
  67595. persistence: number;
  67596. /** Gets or sets animation speed factor (default is 1) */
  67597. animationSpeedFactor: number;
  67598. /**
  67599. * Creates a new NoiseProceduralTexture
  67600. * @param name defines the name fo the texture
  67601. * @param size defines the size of the texture (default is 256)
  67602. * @param scene defines the hosting scene
  67603. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  67604. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  67605. */
  67606. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  67607. private _updateShaderUniforms;
  67608. protected _getDefines(): string;
  67609. /** Generate the current state of the procedural texture */
  67610. render(useCameraPostProcess?: boolean): void;
  67611. /**
  67612. * Serializes this noise procedural texture
  67613. * @returns a serialized noise procedural texture object
  67614. */
  67615. serialize(): any;
  67616. /**
  67617. * Clone the texture.
  67618. * @returns the cloned texture
  67619. */
  67620. clone(): NoiseProceduralTexture;
  67621. /**
  67622. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  67623. * @param parsedTexture defines parsed texture data
  67624. * @param scene defines the current scene
  67625. * @param rootUrl defines the root URL containing noise procedural texture information
  67626. * @returns a parsed NoiseProceduralTexture
  67627. */
  67628. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  67629. }
  67630. }
  67631. declare module BABYLON {
  67632. /**
  67633. * Raw cube texture where the raw buffers are passed in
  67634. */
  67635. export class RawCubeTexture extends CubeTexture {
  67636. /**
  67637. * Creates a cube texture where the raw buffers are passed in.
  67638. * @param scene defines the scene the texture is attached to
  67639. * @param data defines the array of data to use to create each face
  67640. * @param size defines the size of the textures
  67641. * @param format defines the format of the data
  67642. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  67643. * @param generateMipMaps defines if the engine should generate the mip levels
  67644. * @param invertY defines if data must be stored with Y axis inverted
  67645. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  67646. * @param compression defines the compression used (null by default)
  67647. */
  67648. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  67649. /**
  67650. * Updates the raw cube texture.
  67651. * @param data defines the data to store
  67652. * @param format defines the data format
  67653. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  67654. * @param invertY defines if data must be stored with Y axis inverted
  67655. * @param compression defines the compression used (null by default)
  67656. * @param level defines which level of the texture to update
  67657. */
  67658. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  67659. /**
  67660. * Updates a raw cube texture with RGBD encoded data.
  67661. * @param data defines the array of data [mipmap][face] to use to create each face
  67662. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  67663. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  67664. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  67665. * @returns a promise that resolves when the operation is complete
  67666. */
  67667. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  67668. /**
  67669. * Clones the raw cube texture.
  67670. * @return a new cube texture
  67671. */
  67672. clone(): CubeTexture;
  67673. /** @hidden */
  67674. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  67675. }
  67676. }
  67677. declare module BABYLON {
  67678. /**
  67679. * Class used to store 3D textures containing user data
  67680. */
  67681. export class RawTexture3D extends Texture {
  67682. /** Gets or sets the texture format to use */
  67683. format: number;
  67684. /**
  67685. * Create a new RawTexture3D
  67686. * @param data defines the data of the texture
  67687. * @param width defines the width of the texture
  67688. * @param height defines the height of the texture
  67689. * @param depth defines the depth of the texture
  67690. * @param format defines the texture format to use
  67691. * @param scene defines the hosting scene
  67692. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  67693. * @param invertY defines if texture must be stored with Y axis inverted
  67694. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67695. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  67696. */
  67697. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  67698. /** Gets or sets the texture format to use */
  67699. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  67700. /**
  67701. * Update the texture with new data
  67702. * @param data defines the data to store in the texture
  67703. */
  67704. update(data: ArrayBufferView): void;
  67705. }
  67706. }
  67707. declare module BABYLON {
  67708. /**
  67709. * Creates a refraction texture used by refraction channel of the standard material.
  67710. * It is like a mirror but to see through a material.
  67711. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  67712. */
  67713. export class RefractionTexture extends RenderTargetTexture {
  67714. /**
  67715. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  67716. * 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.
  67717. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  67718. */
  67719. refractionPlane: Plane;
  67720. /**
  67721. * Define how deep under the surface we should see.
  67722. */
  67723. depth: number;
  67724. /**
  67725. * Creates a refraction texture used by refraction channel of the standard material.
  67726. * It is like a mirror but to see through a material.
  67727. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  67728. * @param name Define the texture name
  67729. * @param size Define the size of the underlying texture
  67730. * @param scene Define the scene the refraction belongs to
  67731. * @param generateMipMaps Define if we need to generate mips level for the refraction
  67732. */
  67733. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  67734. /**
  67735. * Clone the refraction texture.
  67736. * @returns the cloned texture
  67737. */
  67738. clone(): RefractionTexture;
  67739. /**
  67740. * Serialize the texture to a JSON representation you could use in Parse later on
  67741. * @returns the serialized JSON representation
  67742. */
  67743. serialize(): any;
  67744. }
  67745. }
  67746. declare module BABYLON {
  67747. /**
  67748. * Block used to add support for vertex skinning (bones)
  67749. */
  67750. export class BonesBlock extends NodeMaterialBlock {
  67751. /**
  67752. * Creates a new BonesBlock
  67753. * @param name defines the block name
  67754. */
  67755. constructor(name: string);
  67756. /**
  67757. * Initialize the block and prepare the context for build
  67758. * @param state defines the state that will be used for the build
  67759. */
  67760. initialize(state: NodeMaterialBuildState): void;
  67761. /**
  67762. * Gets the current class name
  67763. * @returns the class name
  67764. */
  67765. getClassName(): string;
  67766. /**
  67767. * Gets the matrix indices input component
  67768. */
  67769. get matricesIndices(): NodeMaterialConnectionPoint;
  67770. /**
  67771. * Gets the matrix weights input component
  67772. */
  67773. get matricesWeights(): NodeMaterialConnectionPoint;
  67774. /**
  67775. * Gets the extra matrix indices input component
  67776. */
  67777. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  67778. /**
  67779. * Gets the extra matrix weights input component
  67780. */
  67781. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  67782. /**
  67783. * Gets the world input component
  67784. */
  67785. get world(): NodeMaterialConnectionPoint;
  67786. /**
  67787. * Gets the output component
  67788. */
  67789. get output(): NodeMaterialConnectionPoint;
  67790. autoConfigure(material: NodeMaterial): void;
  67791. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  67792. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67793. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67794. protected _buildBlock(state: NodeMaterialBuildState): this;
  67795. }
  67796. }
  67797. declare module BABYLON {
  67798. /**
  67799. * Block used to add support for instances
  67800. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  67801. */
  67802. export class InstancesBlock extends NodeMaterialBlock {
  67803. /**
  67804. * Creates a new InstancesBlock
  67805. * @param name defines the block name
  67806. */
  67807. constructor(name: string);
  67808. /**
  67809. * Gets the current class name
  67810. * @returns the class name
  67811. */
  67812. getClassName(): string;
  67813. /**
  67814. * Gets the first world row input component
  67815. */
  67816. get world0(): NodeMaterialConnectionPoint;
  67817. /**
  67818. * Gets the second world row input component
  67819. */
  67820. get world1(): NodeMaterialConnectionPoint;
  67821. /**
  67822. * Gets the third world row input component
  67823. */
  67824. get world2(): NodeMaterialConnectionPoint;
  67825. /**
  67826. * Gets the forth world row input component
  67827. */
  67828. get world3(): NodeMaterialConnectionPoint;
  67829. /**
  67830. * Gets the world input component
  67831. */
  67832. get world(): NodeMaterialConnectionPoint;
  67833. /**
  67834. * Gets the output component
  67835. */
  67836. get output(): NodeMaterialConnectionPoint;
  67837. /**
  67838. * Gets the instanceID component
  67839. */
  67840. get instanceID(): NodeMaterialConnectionPoint;
  67841. autoConfigure(material: NodeMaterial): void;
  67842. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  67843. protected _buildBlock(state: NodeMaterialBuildState): this;
  67844. }
  67845. }
  67846. declare module BABYLON {
  67847. /**
  67848. * Block used to add morph targets support to vertex shader
  67849. */
  67850. export class MorphTargetsBlock extends NodeMaterialBlock {
  67851. private _repeatableContentAnchor;
  67852. /**
  67853. * Create a new MorphTargetsBlock
  67854. * @param name defines the block name
  67855. */
  67856. constructor(name: string);
  67857. /**
  67858. * Gets the current class name
  67859. * @returns the class name
  67860. */
  67861. getClassName(): string;
  67862. /**
  67863. * Gets the position input component
  67864. */
  67865. get position(): NodeMaterialConnectionPoint;
  67866. /**
  67867. * Gets the normal input component
  67868. */
  67869. get normal(): NodeMaterialConnectionPoint;
  67870. /**
  67871. * Gets the tangent input component
  67872. */
  67873. get tangent(): NodeMaterialConnectionPoint;
  67874. /**
  67875. * Gets the tangent input component
  67876. */
  67877. get uv(): NodeMaterialConnectionPoint;
  67878. /**
  67879. * Gets the position output component
  67880. */
  67881. get positionOutput(): NodeMaterialConnectionPoint;
  67882. /**
  67883. * Gets the normal output component
  67884. */
  67885. get normalOutput(): NodeMaterialConnectionPoint;
  67886. /**
  67887. * Gets the tangent output component
  67888. */
  67889. get tangentOutput(): NodeMaterialConnectionPoint;
  67890. /**
  67891. * Gets the tangent output component
  67892. */
  67893. get uvOutput(): NodeMaterialConnectionPoint;
  67894. initialize(state: NodeMaterialBuildState): void;
  67895. autoConfigure(material: NodeMaterial): void;
  67896. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67897. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67898. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  67899. protected _buildBlock(state: NodeMaterialBuildState): this;
  67900. }
  67901. }
  67902. declare module BABYLON {
  67903. /**
  67904. * Block used to get data information from a light
  67905. */
  67906. export class LightInformationBlock extends NodeMaterialBlock {
  67907. private _lightDataUniformName;
  67908. private _lightColorUniformName;
  67909. private _lightTypeDefineName;
  67910. /**
  67911. * Gets or sets the light associated with this block
  67912. */
  67913. light: Nullable<Light>;
  67914. /**
  67915. * Creates a new LightInformationBlock
  67916. * @param name defines the block name
  67917. */
  67918. constructor(name: string);
  67919. /**
  67920. * Gets the current class name
  67921. * @returns the class name
  67922. */
  67923. getClassName(): string;
  67924. /**
  67925. * Gets the world position input component
  67926. */
  67927. get worldPosition(): NodeMaterialConnectionPoint;
  67928. /**
  67929. * Gets the direction output component
  67930. */
  67931. get direction(): NodeMaterialConnectionPoint;
  67932. /**
  67933. * Gets the direction output component
  67934. */
  67935. get color(): NodeMaterialConnectionPoint;
  67936. /**
  67937. * Gets the direction output component
  67938. */
  67939. get intensity(): NodeMaterialConnectionPoint;
  67940. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67941. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67942. protected _buildBlock(state: NodeMaterialBuildState): this;
  67943. serialize(): any;
  67944. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67945. }
  67946. }
  67947. declare module BABYLON {
  67948. /**
  67949. * Block used to add image processing support to fragment shader
  67950. */
  67951. export class ImageProcessingBlock extends NodeMaterialBlock {
  67952. /**
  67953. * Create a new ImageProcessingBlock
  67954. * @param name defines the block name
  67955. */
  67956. constructor(name: string);
  67957. /**
  67958. * Gets the current class name
  67959. * @returns the class name
  67960. */
  67961. getClassName(): string;
  67962. /**
  67963. * Gets the color input component
  67964. */
  67965. get color(): NodeMaterialConnectionPoint;
  67966. /**
  67967. * Gets the output component
  67968. */
  67969. get output(): NodeMaterialConnectionPoint;
  67970. /**
  67971. * Initialize the block and prepare the context for build
  67972. * @param state defines the state that will be used for the build
  67973. */
  67974. initialize(state: NodeMaterialBuildState): void;
  67975. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  67976. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67977. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67978. protected _buildBlock(state: NodeMaterialBuildState): this;
  67979. }
  67980. }
  67981. declare module BABYLON {
  67982. /**
  67983. * Block used to perturb normals based on a normal map
  67984. */
  67985. export class PerturbNormalBlock extends NodeMaterialBlock {
  67986. private _tangentSpaceParameterName;
  67987. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67988. invertX: boolean;
  67989. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  67990. invertY: boolean;
  67991. /**
  67992. * Create a new PerturbNormalBlock
  67993. * @param name defines the block name
  67994. */
  67995. constructor(name: string);
  67996. /**
  67997. * Gets the current class name
  67998. * @returns the class name
  67999. */
  68000. getClassName(): string;
  68001. /**
  68002. * Gets the world position input component
  68003. */
  68004. get worldPosition(): NodeMaterialConnectionPoint;
  68005. /**
  68006. * Gets the world normal input component
  68007. */
  68008. get worldNormal(): NodeMaterialConnectionPoint;
  68009. /**
  68010. * Gets the world tangent input component
  68011. */
  68012. get worldTangent(): NodeMaterialConnectionPoint;
  68013. /**
  68014. * Gets the uv input component
  68015. */
  68016. get uv(): NodeMaterialConnectionPoint;
  68017. /**
  68018. * Gets the normal map color input component
  68019. */
  68020. get normalMapColor(): NodeMaterialConnectionPoint;
  68021. /**
  68022. * Gets the strength input component
  68023. */
  68024. get strength(): NodeMaterialConnectionPoint;
  68025. /**
  68026. * Gets the output component
  68027. */
  68028. get output(): NodeMaterialConnectionPoint;
  68029. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68030. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  68031. autoConfigure(material: NodeMaterial): void;
  68032. protected _buildBlock(state: NodeMaterialBuildState): this;
  68033. protected _dumpPropertiesCode(): string;
  68034. serialize(): any;
  68035. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68036. }
  68037. }
  68038. declare module BABYLON {
  68039. /**
  68040. * Block used to discard a pixel if a value is smaller than a cutoff
  68041. */
  68042. export class DiscardBlock extends NodeMaterialBlock {
  68043. /**
  68044. * Create a new DiscardBlock
  68045. * @param name defines the block name
  68046. */
  68047. constructor(name: string);
  68048. /**
  68049. * Gets the current class name
  68050. * @returns the class name
  68051. */
  68052. getClassName(): string;
  68053. /**
  68054. * Gets the color input component
  68055. */
  68056. get value(): NodeMaterialConnectionPoint;
  68057. /**
  68058. * Gets the cutoff input component
  68059. */
  68060. get cutoff(): NodeMaterialConnectionPoint;
  68061. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68062. }
  68063. }
  68064. declare module BABYLON {
  68065. /**
  68066. * Block used to test if the fragment shader is front facing
  68067. */
  68068. export class FrontFacingBlock extends NodeMaterialBlock {
  68069. /**
  68070. * Creates a new FrontFacingBlock
  68071. * @param name defines the block name
  68072. */
  68073. constructor(name: string);
  68074. /**
  68075. * Gets the current class name
  68076. * @returns the class name
  68077. */
  68078. getClassName(): string;
  68079. /**
  68080. * Gets the output component
  68081. */
  68082. get output(): NodeMaterialConnectionPoint;
  68083. protected _buildBlock(state: NodeMaterialBuildState): this;
  68084. }
  68085. }
  68086. declare module BABYLON {
  68087. /**
  68088. * Block used to get the derivative value on x and y of a given input
  68089. */
  68090. export class DerivativeBlock extends NodeMaterialBlock {
  68091. /**
  68092. * Create a new DerivativeBlock
  68093. * @param name defines the block name
  68094. */
  68095. constructor(name: string);
  68096. /**
  68097. * Gets the current class name
  68098. * @returns the class name
  68099. */
  68100. getClassName(): string;
  68101. /**
  68102. * Gets the input component
  68103. */
  68104. get input(): NodeMaterialConnectionPoint;
  68105. /**
  68106. * Gets the derivative output on x
  68107. */
  68108. get dx(): NodeMaterialConnectionPoint;
  68109. /**
  68110. * Gets the derivative output on y
  68111. */
  68112. get dy(): NodeMaterialConnectionPoint;
  68113. protected _buildBlock(state: NodeMaterialBuildState): this;
  68114. }
  68115. }
  68116. declare module BABYLON {
  68117. /**
  68118. * Block used to make gl_FragCoord available
  68119. */
  68120. export class FragCoordBlock extends NodeMaterialBlock {
  68121. /**
  68122. * Creates a new FragCoordBlock
  68123. * @param name defines the block name
  68124. */
  68125. constructor(name: string);
  68126. /**
  68127. * Gets the current class name
  68128. * @returns the class name
  68129. */
  68130. getClassName(): string;
  68131. /**
  68132. * Gets the xy component
  68133. */
  68134. get xy(): NodeMaterialConnectionPoint;
  68135. /**
  68136. * Gets the xyz component
  68137. */
  68138. get xyz(): NodeMaterialConnectionPoint;
  68139. /**
  68140. * Gets the xyzw component
  68141. */
  68142. get xyzw(): NodeMaterialConnectionPoint;
  68143. /**
  68144. * Gets the x component
  68145. */
  68146. get x(): NodeMaterialConnectionPoint;
  68147. /**
  68148. * Gets the y component
  68149. */
  68150. get y(): NodeMaterialConnectionPoint;
  68151. /**
  68152. * Gets the z component
  68153. */
  68154. get z(): NodeMaterialConnectionPoint;
  68155. /**
  68156. * Gets the w component
  68157. */
  68158. get output(): NodeMaterialConnectionPoint;
  68159. protected writeOutputs(state: NodeMaterialBuildState): string;
  68160. protected _buildBlock(state: NodeMaterialBuildState): this;
  68161. }
  68162. }
  68163. declare module BABYLON {
  68164. /**
  68165. * Block used to get the screen sizes
  68166. */
  68167. export class ScreenSizeBlock extends NodeMaterialBlock {
  68168. private _varName;
  68169. private _scene;
  68170. /**
  68171. * Creates a new ScreenSizeBlock
  68172. * @param name defines the block name
  68173. */
  68174. constructor(name: string);
  68175. /**
  68176. * Gets the current class name
  68177. * @returns the class name
  68178. */
  68179. getClassName(): string;
  68180. /**
  68181. * Gets the xy component
  68182. */
  68183. get xy(): NodeMaterialConnectionPoint;
  68184. /**
  68185. * Gets the x component
  68186. */
  68187. get x(): NodeMaterialConnectionPoint;
  68188. /**
  68189. * Gets the y component
  68190. */
  68191. get y(): NodeMaterialConnectionPoint;
  68192. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  68193. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  68194. protected _buildBlock(state: NodeMaterialBuildState): this;
  68195. }
  68196. }
  68197. declare module BABYLON {
  68198. /**
  68199. * Block used to add support for scene fog
  68200. */
  68201. export class FogBlock extends NodeMaterialBlock {
  68202. private _fogDistanceName;
  68203. private _fogParameters;
  68204. /**
  68205. * Create a new FogBlock
  68206. * @param name defines the block name
  68207. */
  68208. constructor(name: string);
  68209. /**
  68210. * Gets the current class name
  68211. * @returns the class name
  68212. */
  68213. getClassName(): string;
  68214. /**
  68215. * Gets the world position input component
  68216. */
  68217. get worldPosition(): NodeMaterialConnectionPoint;
  68218. /**
  68219. * Gets the view input component
  68220. */
  68221. get view(): NodeMaterialConnectionPoint;
  68222. /**
  68223. * Gets the color input component
  68224. */
  68225. get input(): NodeMaterialConnectionPoint;
  68226. /**
  68227. * Gets the fog color input component
  68228. */
  68229. get fogColor(): NodeMaterialConnectionPoint;
  68230. /**
  68231. * Gets the output component
  68232. */
  68233. get output(): NodeMaterialConnectionPoint;
  68234. autoConfigure(material: NodeMaterial): void;
  68235. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68236. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  68237. protected _buildBlock(state: NodeMaterialBuildState): this;
  68238. }
  68239. }
  68240. declare module BABYLON {
  68241. /**
  68242. * Block used to add light in the fragment shader
  68243. */
  68244. export class LightBlock extends NodeMaterialBlock {
  68245. private _lightId;
  68246. /**
  68247. * Gets or sets the light associated with this block
  68248. */
  68249. light: Nullable<Light>;
  68250. /**
  68251. * Create a new LightBlock
  68252. * @param name defines the block name
  68253. */
  68254. constructor(name: string);
  68255. /**
  68256. * Gets the current class name
  68257. * @returns the class name
  68258. */
  68259. getClassName(): string;
  68260. /**
  68261. * Gets the world position input component
  68262. */
  68263. get worldPosition(): NodeMaterialConnectionPoint;
  68264. /**
  68265. * Gets the world normal input component
  68266. */
  68267. get worldNormal(): NodeMaterialConnectionPoint;
  68268. /**
  68269. * Gets the camera (or eye) position component
  68270. */
  68271. get cameraPosition(): NodeMaterialConnectionPoint;
  68272. /**
  68273. * Gets the glossiness component
  68274. */
  68275. get glossiness(): NodeMaterialConnectionPoint;
  68276. /**
  68277. * Gets the glossiness power component
  68278. */
  68279. get glossPower(): NodeMaterialConnectionPoint;
  68280. /**
  68281. * Gets the diffuse color component
  68282. */
  68283. get diffuseColor(): NodeMaterialConnectionPoint;
  68284. /**
  68285. * Gets the specular color component
  68286. */
  68287. get specularColor(): NodeMaterialConnectionPoint;
  68288. /**
  68289. * Gets the view matrix component
  68290. */
  68291. get view(): NodeMaterialConnectionPoint;
  68292. /**
  68293. * Gets the diffuse output component
  68294. */
  68295. get diffuseOutput(): NodeMaterialConnectionPoint;
  68296. /**
  68297. * Gets the specular output component
  68298. */
  68299. get specularOutput(): NodeMaterialConnectionPoint;
  68300. /**
  68301. * Gets the shadow output component
  68302. */
  68303. get shadow(): NodeMaterialConnectionPoint;
  68304. autoConfigure(material: NodeMaterial): void;
  68305. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68306. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  68307. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  68308. private _injectVertexCode;
  68309. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68310. serialize(): any;
  68311. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68312. }
  68313. }
  68314. declare module BABYLON {
  68315. /**
  68316. * Block used to read a reflection texture from a sampler
  68317. */
  68318. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  68319. /**
  68320. * Create a new ReflectionTextureBlock
  68321. * @param name defines the block name
  68322. */
  68323. constructor(name: string);
  68324. /**
  68325. * Gets the current class name
  68326. * @returns the class name
  68327. */
  68328. getClassName(): string;
  68329. /**
  68330. * Gets the world position input component
  68331. */
  68332. get position(): NodeMaterialConnectionPoint;
  68333. /**
  68334. * Gets the world position input component
  68335. */
  68336. get worldPosition(): NodeMaterialConnectionPoint;
  68337. /**
  68338. * Gets the world normal input component
  68339. */
  68340. get worldNormal(): NodeMaterialConnectionPoint;
  68341. /**
  68342. * Gets the world input component
  68343. */
  68344. get world(): NodeMaterialConnectionPoint;
  68345. /**
  68346. * Gets the camera (or eye) position component
  68347. */
  68348. get cameraPosition(): NodeMaterialConnectionPoint;
  68349. /**
  68350. * Gets the view input component
  68351. */
  68352. get view(): NodeMaterialConnectionPoint;
  68353. /**
  68354. * Gets the rgb output component
  68355. */
  68356. get rgb(): NodeMaterialConnectionPoint;
  68357. /**
  68358. * Gets the rgba output component
  68359. */
  68360. get rgba(): NodeMaterialConnectionPoint;
  68361. /**
  68362. * Gets the r output component
  68363. */
  68364. get r(): NodeMaterialConnectionPoint;
  68365. /**
  68366. * Gets the g output component
  68367. */
  68368. get g(): NodeMaterialConnectionPoint;
  68369. /**
  68370. * Gets the b output component
  68371. */
  68372. get b(): NodeMaterialConnectionPoint;
  68373. /**
  68374. * Gets the a output component
  68375. */
  68376. get a(): NodeMaterialConnectionPoint;
  68377. autoConfigure(material: NodeMaterial): void;
  68378. protected _buildBlock(state: NodeMaterialBuildState): this;
  68379. }
  68380. }
  68381. declare module BABYLON {
  68382. /**
  68383. * Block used to add 2 vectors
  68384. */
  68385. export class AddBlock extends NodeMaterialBlock {
  68386. /**
  68387. * Creates a new AddBlock
  68388. * @param name defines the block name
  68389. */
  68390. constructor(name: string);
  68391. /**
  68392. * Gets the current class name
  68393. * @returns the class name
  68394. */
  68395. getClassName(): string;
  68396. /**
  68397. * Gets the left operand input component
  68398. */
  68399. get left(): NodeMaterialConnectionPoint;
  68400. /**
  68401. * Gets the right operand input component
  68402. */
  68403. get right(): NodeMaterialConnectionPoint;
  68404. /**
  68405. * Gets the output component
  68406. */
  68407. get output(): NodeMaterialConnectionPoint;
  68408. protected _buildBlock(state: NodeMaterialBuildState): this;
  68409. }
  68410. }
  68411. declare module BABYLON {
  68412. /**
  68413. * Block used to scale a vector by a float
  68414. */
  68415. export class ScaleBlock extends NodeMaterialBlock {
  68416. /**
  68417. * Creates a new ScaleBlock
  68418. * @param name defines the block name
  68419. */
  68420. constructor(name: string);
  68421. /**
  68422. * Gets the current class name
  68423. * @returns the class name
  68424. */
  68425. getClassName(): string;
  68426. /**
  68427. * Gets the input component
  68428. */
  68429. get input(): NodeMaterialConnectionPoint;
  68430. /**
  68431. * Gets the factor input component
  68432. */
  68433. get factor(): NodeMaterialConnectionPoint;
  68434. /**
  68435. * Gets the output component
  68436. */
  68437. get output(): NodeMaterialConnectionPoint;
  68438. protected _buildBlock(state: NodeMaterialBuildState): this;
  68439. }
  68440. }
  68441. declare module BABYLON {
  68442. /**
  68443. * Block used to clamp a float
  68444. */
  68445. export class ClampBlock extends NodeMaterialBlock {
  68446. /** Gets or sets the minimum range */
  68447. minimum: number;
  68448. /** Gets or sets the maximum range */
  68449. maximum: number;
  68450. /**
  68451. * Creates a new ClampBlock
  68452. * @param name defines the block name
  68453. */
  68454. constructor(name: string);
  68455. /**
  68456. * Gets the current class name
  68457. * @returns the class name
  68458. */
  68459. getClassName(): string;
  68460. /**
  68461. * Gets the value input component
  68462. */
  68463. get value(): NodeMaterialConnectionPoint;
  68464. /**
  68465. * Gets the output component
  68466. */
  68467. get output(): NodeMaterialConnectionPoint;
  68468. protected _buildBlock(state: NodeMaterialBuildState): this;
  68469. protected _dumpPropertiesCode(): string;
  68470. serialize(): any;
  68471. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68472. }
  68473. }
  68474. declare module BABYLON {
  68475. /**
  68476. * Block used to apply a cross product between 2 vectors
  68477. */
  68478. export class CrossBlock extends NodeMaterialBlock {
  68479. /**
  68480. * Creates a new CrossBlock
  68481. * @param name defines the block name
  68482. */
  68483. constructor(name: string);
  68484. /**
  68485. * Gets the current class name
  68486. * @returns the class name
  68487. */
  68488. getClassName(): string;
  68489. /**
  68490. * Gets the left operand input component
  68491. */
  68492. get left(): NodeMaterialConnectionPoint;
  68493. /**
  68494. * Gets the right operand input component
  68495. */
  68496. get right(): NodeMaterialConnectionPoint;
  68497. /**
  68498. * Gets the output component
  68499. */
  68500. get output(): NodeMaterialConnectionPoint;
  68501. protected _buildBlock(state: NodeMaterialBuildState): this;
  68502. }
  68503. }
  68504. declare module BABYLON {
  68505. /**
  68506. * Block used to apply a dot product between 2 vectors
  68507. */
  68508. export class DotBlock extends NodeMaterialBlock {
  68509. /**
  68510. * Creates a new DotBlock
  68511. * @param name defines the block name
  68512. */
  68513. constructor(name: string);
  68514. /**
  68515. * Gets the current class name
  68516. * @returns the class name
  68517. */
  68518. getClassName(): string;
  68519. /**
  68520. * Gets the left operand input component
  68521. */
  68522. get left(): NodeMaterialConnectionPoint;
  68523. /**
  68524. * Gets the right operand input component
  68525. */
  68526. get right(): NodeMaterialConnectionPoint;
  68527. /**
  68528. * Gets the output component
  68529. */
  68530. get output(): NodeMaterialConnectionPoint;
  68531. protected _buildBlock(state: NodeMaterialBuildState): this;
  68532. }
  68533. }
  68534. declare module BABYLON {
  68535. /**
  68536. * Block used to normalize a vector
  68537. */
  68538. export class NormalizeBlock extends NodeMaterialBlock {
  68539. /**
  68540. * Creates a new NormalizeBlock
  68541. * @param name defines the block name
  68542. */
  68543. constructor(name: string);
  68544. /**
  68545. * Gets the current class name
  68546. * @returns the class name
  68547. */
  68548. getClassName(): string;
  68549. /**
  68550. * Gets the input component
  68551. */
  68552. get input(): NodeMaterialConnectionPoint;
  68553. /**
  68554. * Gets the output component
  68555. */
  68556. get output(): NodeMaterialConnectionPoint;
  68557. protected _buildBlock(state: NodeMaterialBuildState): this;
  68558. }
  68559. }
  68560. declare module BABYLON {
  68561. /**
  68562. * Block used to create a Color3/4 out of individual inputs (one for each component)
  68563. */
  68564. export class ColorMergerBlock extends NodeMaterialBlock {
  68565. /**
  68566. * Create a new ColorMergerBlock
  68567. * @param name defines the block name
  68568. */
  68569. constructor(name: string);
  68570. /**
  68571. * Gets the current class name
  68572. * @returns the class name
  68573. */
  68574. getClassName(): string;
  68575. /**
  68576. * Gets the rgb component (input)
  68577. */
  68578. get rgbIn(): NodeMaterialConnectionPoint;
  68579. /**
  68580. * Gets the r component (input)
  68581. */
  68582. get r(): NodeMaterialConnectionPoint;
  68583. /**
  68584. * Gets the g component (input)
  68585. */
  68586. get g(): NodeMaterialConnectionPoint;
  68587. /**
  68588. * Gets the b component (input)
  68589. */
  68590. get b(): NodeMaterialConnectionPoint;
  68591. /**
  68592. * Gets the a component (input)
  68593. */
  68594. get a(): NodeMaterialConnectionPoint;
  68595. /**
  68596. * Gets the rgba component (output)
  68597. */
  68598. get rgba(): NodeMaterialConnectionPoint;
  68599. /**
  68600. * Gets the rgb component (output)
  68601. */
  68602. get rgbOut(): NodeMaterialConnectionPoint;
  68603. /**
  68604. * Gets the rgb component (output)
  68605. * @deprecated Please use rgbOut instead.
  68606. */
  68607. get rgb(): NodeMaterialConnectionPoint;
  68608. protected _buildBlock(state: NodeMaterialBuildState): this;
  68609. }
  68610. }
  68611. declare module BABYLON {
  68612. /**
  68613. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  68614. */
  68615. export class VectorSplitterBlock extends NodeMaterialBlock {
  68616. /**
  68617. * Create a new VectorSplitterBlock
  68618. * @param name defines the block name
  68619. */
  68620. constructor(name: string);
  68621. /**
  68622. * Gets the current class name
  68623. * @returns the class name
  68624. */
  68625. getClassName(): string;
  68626. /**
  68627. * Gets the xyzw component (input)
  68628. */
  68629. get xyzw(): NodeMaterialConnectionPoint;
  68630. /**
  68631. * Gets the xyz component (input)
  68632. */
  68633. get xyzIn(): NodeMaterialConnectionPoint;
  68634. /**
  68635. * Gets the xy component (input)
  68636. */
  68637. get xyIn(): NodeMaterialConnectionPoint;
  68638. /**
  68639. * Gets the xyz component (output)
  68640. */
  68641. get xyzOut(): NodeMaterialConnectionPoint;
  68642. /**
  68643. * Gets the xy component (output)
  68644. */
  68645. get xyOut(): NodeMaterialConnectionPoint;
  68646. /**
  68647. * Gets the x component (output)
  68648. */
  68649. get x(): NodeMaterialConnectionPoint;
  68650. /**
  68651. * Gets the y component (output)
  68652. */
  68653. get y(): NodeMaterialConnectionPoint;
  68654. /**
  68655. * Gets the z component (output)
  68656. */
  68657. get z(): NodeMaterialConnectionPoint;
  68658. /**
  68659. * Gets the w component (output)
  68660. */
  68661. get w(): NodeMaterialConnectionPoint;
  68662. protected _inputRename(name: string): string;
  68663. protected _outputRename(name: string): string;
  68664. protected _buildBlock(state: NodeMaterialBuildState): this;
  68665. }
  68666. }
  68667. declare module BABYLON {
  68668. /**
  68669. * Block used to lerp between 2 values
  68670. */
  68671. export class LerpBlock extends NodeMaterialBlock {
  68672. /**
  68673. * Creates a new LerpBlock
  68674. * @param name defines the block name
  68675. */
  68676. constructor(name: string);
  68677. /**
  68678. * Gets the current class name
  68679. * @returns the class name
  68680. */
  68681. getClassName(): string;
  68682. /**
  68683. * Gets the left operand input component
  68684. */
  68685. get left(): NodeMaterialConnectionPoint;
  68686. /**
  68687. * Gets the right operand input component
  68688. */
  68689. get right(): NodeMaterialConnectionPoint;
  68690. /**
  68691. * Gets the gradient operand input component
  68692. */
  68693. get gradient(): NodeMaterialConnectionPoint;
  68694. /**
  68695. * Gets the output component
  68696. */
  68697. get output(): NodeMaterialConnectionPoint;
  68698. protected _buildBlock(state: NodeMaterialBuildState): this;
  68699. }
  68700. }
  68701. declare module BABYLON {
  68702. /**
  68703. * Block used to divide 2 vectors
  68704. */
  68705. export class DivideBlock extends NodeMaterialBlock {
  68706. /**
  68707. * Creates a new DivideBlock
  68708. * @param name defines the block name
  68709. */
  68710. constructor(name: string);
  68711. /**
  68712. * Gets the current class name
  68713. * @returns the class name
  68714. */
  68715. getClassName(): string;
  68716. /**
  68717. * Gets the left operand input component
  68718. */
  68719. get left(): NodeMaterialConnectionPoint;
  68720. /**
  68721. * Gets the right operand input component
  68722. */
  68723. get right(): NodeMaterialConnectionPoint;
  68724. /**
  68725. * Gets the output component
  68726. */
  68727. get output(): NodeMaterialConnectionPoint;
  68728. protected _buildBlock(state: NodeMaterialBuildState): this;
  68729. }
  68730. }
  68731. declare module BABYLON {
  68732. /**
  68733. * Block used to subtract 2 vectors
  68734. */
  68735. export class SubtractBlock extends NodeMaterialBlock {
  68736. /**
  68737. * Creates a new SubtractBlock
  68738. * @param name defines the block name
  68739. */
  68740. constructor(name: string);
  68741. /**
  68742. * Gets the current class name
  68743. * @returns the class name
  68744. */
  68745. getClassName(): string;
  68746. /**
  68747. * Gets the left operand input component
  68748. */
  68749. get left(): NodeMaterialConnectionPoint;
  68750. /**
  68751. * Gets the right operand input component
  68752. */
  68753. get right(): NodeMaterialConnectionPoint;
  68754. /**
  68755. * Gets the output component
  68756. */
  68757. get output(): NodeMaterialConnectionPoint;
  68758. protected _buildBlock(state: NodeMaterialBuildState): this;
  68759. }
  68760. }
  68761. declare module BABYLON {
  68762. /**
  68763. * Block used to step a value
  68764. */
  68765. export class StepBlock extends NodeMaterialBlock {
  68766. /**
  68767. * Creates a new StepBlock
  68768. * @param name defines the block name
  68769. */
  68770. constructor(name: string);
  68771. /**
  68772. * Gets the current class name
  68773. * @returns the class name
  68774. */
  68775. getClassName(): string;
  68776. /**
  68777. * Gets the value operand input component
  68778. */
  68779. get value(): NodeMaterialConnectionPoint;
  68780. /**
  68781. * Gets the edge operand input component
  68782. */
  68783. get edge(): NodeMaterialConnectionPoint;
  68784. /**
  68785. * Gets the output component
  68786. */
  68787. get output(): NodeMaterialConnectionPoint;
  68788. protected _buildBlock(state: NodeMaterialBuildState): this;
  68789. }
  68790. }
  68791. declare module BABYLON {
  68792. /**
  68793. * Block used to get the opposite (1 - x) of a value
  68794. */
  68795. export class OneMinusBlock extends NodeMaterialBlock {
  68796. /**
  68797. * Creates a new OneMinusBlock
  68798. * @param name defines the block name
  68799. */
  68800. constructor(name: string);
  68801. /**
  68802. * Gets the current class name
  68803. * @returns the class name
  68804. */
  68805. getClassName(): string;
  68806. /**
  68807. * Gets the input component
  68808. */
  68809. get input(): NodeMaterialConnectionPoint;
  68810. /**
  68811. * Gets the output component
  68812. */
  68813. get output(): NodeMaterialConnectionPoint;
  68814. protected _buildBlock(state: NodeMaterialBuildState): this;
  68815. }
  68816. }
  68817. declare module BABYLON {
  68818. /**
  68819. * Block used to get the view direction
  68820. */
  68821. export class ViewDirectionBlock extends NodeMaterialBlock {
  68822. /**
  68823. * Creates a new ViewDirectionBlock
  68824. * @param name defines the block name
  68825. */
  68826. constructor(name: string);
  68827. /**
  68828. * Gets the current class name
  68829. * @returns the class name
  68830. */
  68831. getClassName(): string;
  68832. /**
  68833. * Gets the world position component
  68834. */
  68835. get worldPosition(): NodeMaterialConnectionPoint;
  68836. /**
  68837. * Gets the camera position component
  68838. */
  68839. get cameraPosition(): NodeMaterialConnectionPoint;
  68840. /**
  68841. * Gets the output component
  68842. */
  68843. get output(): NodeMaterialConnectionPoint;
  68844. autoConfigure(material: NodeMaterial): void;
  68845. protected _buildBlock(state: NodeMaterialBuildState): this;
  68846. }
  68847. }
  68848. declare module BABYLON {
  68849. /**
  68850. * Block used to compute fresnel value
  68851. */
  68852. export class FresnelBlock extends NodeMaterialBlock {
  68853. /**
  68854. * Create a new FresnelBlock
  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 world normal input component
  68865. */
  68866. get worldNormal(): NodeMaterialConnectionPoint;
  68867. /**
  68868. * Gets the view direction input component
  68869. */
  68870. get viewDirection(): NodeMaterialConnectionPoint;
  68871. /**
  68872. * Gets the bias input component
  68873. */
  68874. get bias(): NodeMaterialConnectionPoint;
  68875. /**
  68876. * Gets the camera (or eye) position component
  68877. */
  68878. get power(): NodeMaterialConnectionPoint;
  68879. /**
  68880. * Gets the fresnel output component
  68881. */
  68882. get fresnel(): NodeMaterialConnectionPoint;
  68883. autoConfigure(material: NodeMaterial): void;
  68884. protected _buildBlock(state: NodeMaterialBuildState): this;
  68885. }
  68886. }
  68887. declare module BABYLON {
  68888. /**
  68889. * Block used to get the max of 2 values
  68890. */
  68891. export class MaxBlock extends NodeMaterialBlock {
  68892. /**
  68893. * Creates a new MaxBlock
  68894. * @param name defines the block name
  68895. */
  68896. constructor(name: string);
  68897. /**
  68898. * Gets the current class name
  68899. * @returns the class name
  68900. */
  68901. getClassName(): string;
  68902. /**
  68903. * Gets the left operand input component
  68904. */
  68905. get left(): NodeMaterialConnectionPoint;
  68906. /**
  68907. * Gets the right operand input component
  68908. */
  68909. get right(): NodeMaterialConnectionPoint;
  68910. /**
  68911. * Gets the output component
  68912. */
  68913. get output(): NodeMaterialConnectionPoint;
  68914. protected _buildBlock(state: NodeMaterialBuildState): this;
  68915. }
  68916. }
  68917. declare module BABYLON {
  68918. /**
  68919. * Block used to get the min of 2 values
  68920. */
  68921. export class MinBlock extends NodeMaterialBlock {
  68922. /**
  68923. * Creates a new MinBlock
  68924. * @param name defines the block name
  68925. */
  68926. constructor(name: string);
  68927. /**
  68928. * Gets the current class name
  68929. * @returns the class name
  68930. */
  68931. getClassName(): string;
  68932. /**
  68933. * Gets the left operand input component
  68934. */
  68935. get left(): NodeMaterialConnectionPoint;
  68936. /**
  68937. * Gets the right operand input component
  68938. */
  68939. get right(): NodeMaterialConnectionPoint;
  68940. /**
  68941. * Gets the output component
  68942. */
  68943. get output(): NodeMaterialConnectionPoint;
  68944. protected _buildBlock(state: NodeMaterialBuildState): this;
  68945. }
  68946. }
  68947. declare module BABYLON {
  68948. /**
  68949. * Block used to get the distance between 2 values
  68950. */
  68951. export class DistanceBlock extends NodeMaterialBlock {
  68952. /**
  68953. * Creates a new DistanceBlock
  68954. * @param name defines the block name
  68955. */
  68956. constructor(name: string);
  68957. /**
  68958. * Gets the current class name
  68959. * @returns the class name
  68960. */
  68961. getClassName(): string;
  68962. /**
  68963. * Gets the left operand input component
  68964. */
  68965. get left(): NodeMaterialConnectionPoint;
  68966. /**
  68967. * Gets the right operand input component
  68968. */
  68969. get right(): NodeMaterialConnectionPoint;
  68970. /**
  68971. * Gets the output component
  68972. */
  68973. get output(): NodeMaterialConnectionPoint;
  68974. protected _buildBlock(state: NodeMaterialBuildState): this;
  68975. }
  68976. }
  68977. declare module BABYLON {
  68978. /**
  68979. * Block used to get the length of a vector
  68980. */
  68981. export class LengthBlock extends NodeMaterialBlock {
  68982. /**
  68983. * Creates a new LengthBlock
  68984. * @param name defines the block name
  68985. */
  68986. constructor(name: string);
  68987. /**
  68988. * Gets the current class name
  68989. * @returns the class name
  68990. */
  68991. getClassName(): string;
  68992. /**
  68993. * Gets the value input component
  68994. */
  68995. get value(): NodeMaterialConnectionPoint;
  68996. /**
  68997. * Gets the output component
  68998. */
  68999. get output(): NodeMaterialConnectionPoint;
  69000. protected _buildBlock(state: NodeMaterialBuildState): this;
  69001. }
  69002. }
  69003. declare module BABYLON {
  69004. /**
  69005. * Block used to get negative version of a value (i.e. x * -1)
  69006. */
  69007. export class NegateBlock extends NodeMaterialBlock {
  69008. /**
  69009. * Creates a new NegateBlock
  69010. * @param name defines the block name
  69011. */
  69012. constructor(name: string);
  69013. /**
  69014. * Gets the current class name
  69015. * @returns the class name
  69016. */
  69017. getClassName(): string;
  69018. /**
  69019. * Gets the value input component
  69020. */
  69021. get value(): NodeMaterialConnectionPoint;
  69022. /**
  69023. * Gets the output component
  69024. */
  69025. get output(): NodeMaterialConnectionPoint;
  69026. protected _buildBlock(state: NodeMaterialBuildState): this;
  69027. }
  69028. }
  69029. declare module BABYLON {
  69030. /**
  69031. * Block used to get the value of the first parameter raised to the power of the second
  69032. */
  69033. export class PowBlock extends NodeMaterialBlock {
  69034. /**
  69035. * Creates a new PowBlock
  69036. * @param name defines the block name
  69037. */
  69038. constructor(name: string);
  69039. /**
  69040. * Gets the current class name
  69041. * @returns the class name
  69042. */
  69043. getClassName(): string;
  69044. /**
  69045. * Gets the value operand input component
  69046. */
  69047. get value(): NodeMaterialConnectionPoint;
  69048. /**
  69049. * Gets the power operand input component
  69050. */
  69051. get power(): NodeMaterialConnectionPoint;
  69052. /**
  69053. * Gets the output component
  69054. */
  69055. get output(): NodeMaterialConnectionPoint;
  69056. protected _buildBlock(state: NodeMaterialBuildState): this;
  69057. }
  69058. }
  69059. declare module BABYLON {
  69060. /**
  69061. * Block used to get a random number
  69062. */
  69063. export class RandomNumberBlock extends NodeMaterialBlock {
  69064. /**
  69065. * Creates a new RandomNumberBlock
  69066. * @param name defines the block name
  69067. */
  69068. constructor(name: string);
  69069. /**
  69070. * Gets the current class name
  69071. * @returns the class name
  69072. */
  69073. getClassName(): string;
  69074. /**
  69075. * Gets the seed input component
  69076. */
  69077. get seed(): NodeMaterialConnectionPoint;
  69078. /**
  69079. * Gets the output component
  69080. */
  69081. get output(): NodeMaterialConnectionPoint;
  69082. protected _buildBlock(state: NodeMaterialBuildState): this;
  69083. }
  69084. }
  69085. declare module BABYLON {
  69086. /**
  69087. * Block used to compute arc tangent of 2 values
  69088. */
  69089. export class ArcTan2Block extends NodeMaterialBlock {
  69090. /**
  69091. * Creates a new ArcTan2Block
  69092. * @param name defines the block name
  69093. */
  69094. constructor(name: string);
  69095. /**
  69096. * Gets the current class name
  69097. * @returns the class name
  69098. */
  69099. getClassName(): string;
  69100. /**
  69101. * Gets the x operand input component
  69102. */
  69103. get x(): NodeMaterialConnectionPoint;
  69104. /**
  69105. * Gets the y operand input component
  69106. */
  69107. get y(): NodeMaterialConnectionPoint;
  69108. /**
  69109. * Gets the output component
  69110. */
  69111. get output(): NodeMaterialConnectionPoint;
  69112. protected _buildBlock(state: NodeMaterialBuildState): this;
  69113. }
  69114. }
  69115. declare module BABYLON {
  69116. /**
  69117. * Block used to smooth step a value
  69118. */
  69119. export class SmoothStepBlock extends NodeMaterialBlock {
  69120. /**
  69121. * Creates a new SmoothStepBlock
  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 operand input component
  69132. */
  69133. get value(): NodeMaterialConnectionPoint;
  69134. /**
  69135. * Gets the first edge operand input component
  69136. */
  69137. get edge0(): NodeMaterialConnectionPoint;
  69138. /**
  69139. * Gets the second edge operand input component
  69140. */
  69141. get edge1(): NodeMaterialConnectionPoint;
  69142. /**
  69143. * Gets the output component
  69144. */
  69145. get output(): NodeMaterialConnectionPoint;
  69146. protected _buildBlock(state: NodeMaterialBuildState): this;
  69147. }
  69148. }
  69149. declare module BABYLON {
  69150. /**
  69151. * Block used to get the reciprocal (1 / x) of a value
  69152. */
  69153. export class ReciprocalBlock extends NodeMaterialBlock {
  69154. /**
  69155. * Creates a new ReciprocalBlock
  69156. * @param name defines the block name
  69157. */
  69158. constructor(name: string);
  69159. /**
  69160. * Gets the current class name
  69161. * @returns the class name
  69162. */
  69163. getClassName(): string;
  69164. /**
  69165. * Gets the input component
  69166. */
  69167. get input(): NodeMaterialConnectionPoint;
  69168. /**
  69169. * Gets the output component
  69170. */
  69171. get output(): NodeMaterialConnectionPoint;
  69172. protected _buildBlock(state: NodeMaterialBuildState): this;
  69173. }
  69174. }
  69175. declare module BABYLON {
  69176. /**
  69177. * Block used to replace a color by another one
  69178. */
  69179. export class ReplaceColorBlock extends NodeMaterialBlock {
  69180. /**
  69181. * Creates a new ReplaceColorBlock
  69182. * @param name defines the block name
  69183. */
  69184. constructor(name: string);
  69185. /**
  69186. * Gets the current class name
  69187. * @returns the class name
  69188. */
  69189. getClassName(): string;
  69190. /**
  69191. * Gets the value input component
  69192. */
  69193. get value(): NodeMaterialConnectionPoint;
  69194. /**
  69195. * Gets the reference input component
  69196. */
  69197. get reference(): NodeMaterialConnectionPoint;
  69198. /**
  69199. * Gets the distance input component
  69200. */
  69201. get distance(): NodeMaterialConnectionPoint;
  69202. /**
  69203. * Gets the replacement input component
  69204. */
  69205. get replacement(): NodeMaterialConnectionPoint;
  69206. /**
  69207. * Gets the output component
  69208. */
  69209. get output(): NodeMaterialConnectionPoint;
  69210. protected _buildBlock(state: NodeMaterialBuildState): this;
  69211. }
  69212. }
  69213. declare module BABYLON {
  69214. /**
  69215. * Block used to posterize a value
  69216. * @see https://en.wikipedia.org/wiki/Posterization
  69217. */
  69218. export class PosterizeBlock extends NodeMaterialBlock {
  69219. /**
  69220. * Creates a new PosterizeBlock
  69221. * @param name defines the block name
  69222. */
  69223. constructor(name: string);
  69224. /**
  69225. * Gets the current class name
  69226. * @returns the class name
  69227. */
  69228. getClassName(): string;
  69229. /**
  69230. * Gets the value input component
  69231. */
  69232. get value(): NodeMaterialConnectionPoint;
  69233. /**
  69234. * Gets the steps input component
  69235. */
  69236. get steps(): NodeMaterialConnectionPoint;
  69237. /**
  69238. * Gets the output component
  69239. */
  69240. get output(): NodeMaterialConnectionPoint;
  69241. protected _buildBlock(state: NodeMaterialBuildState): this;
  69242. }
  69243. }
  69244. declare module BABYLON {
  69245. /**
  69246. * Operations supported by the Wave block
  69247. */
  69248. export enum WaveBlockKind {
  69249. /** SawTooth */
  69250. SawTooth = 0,
  69251. /** Square */
  69252. Square = 1,
  69253. /** Triangle */
  69254. Triangle = 2
  69255. }
  69256. /**
  69257. * Block used to apply wave operation to floats
  69258. */
  69259. export class WaveBlock extends NodeMaterialBlock {
  69260. /**
  69261. * Gets or sets the kibnd of wave to be applied by the block
  69262. */
  69263. kind: WaveBlockKind;
  69264. /**
  69265. * Creates a new WaveBlock
  69266. * @param name defines the block name
  69267. */
  69268. constructor(name: string);
  69269. /**
  69270. * Gets the current class name
  69271. * @returns the class name
  69272. */
  69273. getClassName(): string;
  69274. /**
  69275. * Gets the input component
  69276. */
  69277. get input(): NodeMaterialConnectionPoint;
  69278. /**
  69279. * Gets the output component
  69280. */
  69281. get output(): NodeMaterialConnectionPoint;
  69282. protected _buildBlock(state: NodeMaterialBuildState): this;
  69283. serialize(): any;
  69284. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69285. }
  69286. }
  69287. declare module BABYLON {
  69288. /**
  69289. * Class used to store a color step for the GradientBlock
  69290. */
  69291. export class GradientBlockColorStep {
  69292. private _step;
  69293. /**
  69294. * Gets value indicating which step this color is associated with (between 0 and 1)
  69295. */
  69296. get step(): number;
  69297. /**
  69298. * Sets a value indicating which step this color is associated with (between 0 and 1)
  69299. */
  69300. set step(val: number);
  69301. private _color;
  69302. /**
  69303. * Gets the color associated with this step
  69304. */
  69305. get color(): Color3;
  69306. /**
  69307. * Sets the color associated with this step
  69308. */
  69309. set color(val: Color3);
  69310. /**
  69311. * Creates a new GradientBlockColorStep
  69312. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  69313. * @param color defines the color associated with this step
  69314. */
  69315. constructor(step: number, color: Color3);
  69316. }
  69317. /**
  69318. * Block used to return a color from a gradient based on an input value between 0 and 1
  69319. */
  69320. export class GradientBlock extends NodeMaterialBlock {
  69321. /**
  69322. * Gets or sets the list of color steps
  69323. */
  69324. colorSteps: GradientBlockColorStep[];
  69325. /** Gets an observable raised when the value is changed */
  69326. onValueChangedObservable: Observable<GradientBlock>;
  69327. /** calls observable when the value is changed*/
  69328. colorStepsUpdated(): void;
  69329. /**
  69330. * Creates a new GradientBlock
  69331. * @param name defines the block name
  69332. */
  69333. constructor(name: string);
  69334. /**
  69335. * Gets the current class name
  69336. * @returns the class name
  69337. */
  69338. getClassName(): string;
  69339. /**
  69340. * Gets the gradient input component
  69341. */
  69342. get gradient(): NodeMaterialConnectionPoint;
  69343. /**
  69344. * Gets the output component
  69345. */
  69346. get output(): NodeMaterialConnectionPoint;
  69347. private _writeColorConstant;
  69348. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  69349. serialize(): any;
  69350. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69351. protected _dumpPropertiesCode(): string;
  69352. }
  69353. }
  69354. declare module BABYLON {
  69355. /**
  69356. * Block used to normalize lerp between 2 values
  69357. */
  69358. export class NLerpBlock extends NodeMaterialBlock {
  69359. /**
  69360. * Creates a new NLerpBlock
  69361. * @param name defines the block name
  69362. */
  69363. constructor(name: string);
  69364. /**
  69365. * Gets the current class name
  69366. * @returns the class name
  69367. */
  69368. getClassName(): string;
  69369. /**
  69370. * Gets the left operand input component
  69371. */
  69372. get left(): NodeMaterialConnectionPoint;
  69373. /**
  69374. * Gets the right operand input component
  69375. */
  69376. get right(): NodeMaterialConnectionPoint;
  69377. /**
  69378. * Gets the gradient operand input component
  69379. */
  69380. get gradient(): NodeMaterialConnectionPoint;
  69381. /**
  69382. * Gets the output component
  69383. */
  69384. get output(): NodeMaterialConnectionPoint;
  69385. protected _buildBlock(state: NodeMaterialBuildState): this;
  69386. }
  69387. }
  69388. declare module BABYLON {
  69389. /**
  69390. * block used to Generate a Worley Noise 3D Noise Pattern
  69391. */
  69392. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  69393. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  69394. manhattanDistance: boolean;
  69395. /**
  69396. * Creates a new WorleyNoise3DBlock
  69397. * @param name defines the block name
  69398. */
  69399. constructor(name: string);
  69400. /**
  69401. * Gets the current class name
  69402. * @returns the class name
  69403. */
  69404. getClassName(): string;
  69405. /**
  69406. * Gets the seed input component
  69407. */
  69408. get seed(): NodeMaterialConnectionPoint;
  69409. /**
  69410. * Gets the jitter input component
  69411. */
  69412. get jitter(): NodeMaterialConnectionPoint;
  69413. /**
  69414. * Gets the output component
  69415. */
  69416. get output(): NodeMaterialConnectionPoint;
  69417. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  69418. /**
  69419. * Exposes the properties to the UI?
  69420. */
  69421. protected _dumpPropertiesCode(): string;
  69422. /**
  69423. * Exposes the properties to the Serialize?
  69424. */
  69425. serialize(): any;
  69426. /**
  69427. * Exposes the properties to the deserialize?
  69428. */
  69429. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69430. }
  69431. }
  69432. declare module BABYLON {
  69433. /**
  69434. * block used to Generate a Simplex Perlin 3d Noise Pattern
  69435. */
  69436. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  69437. /**
  69438. * Creates a new SimplexPerlin3DBlock
  69439. * @param name defines the block name
  69440. */
  69441. constructor(name: string);
  69442. /**
  69443. * Gets the current class name
  69444. * @returns the class name
  69445. */
  69446. getClassName(): string;
  69447. /**
  69448. * Gets the seed operand input component
  69449. */
  69450. get seed(): NodeMaterialConnectionPoint;
  69451. /**
  69452. * Gets the output component
  69453. */
  69454. get output(): NodeMaterialConnectionPoint;
  69455. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  69456. }
  69457. }
  69458. declare module BABYLON {
  69459. /**
  69460. * Block used to blend normals
  69461. */
  69462. export class NormalBlendBlock extends NodeMaterialBlock {
  69463. /**
  69464. * Creates a new NormalBlendBlock
  69465. * @param name defines the block name
  69466. */
  69467. constructor(name: string);
  69468. /**
  69469. * Gets the current class name
  69470. * @returns the class name
  69471. */
  69472. getClassName(): string;
  69473. /**
  69474. * Gets the first input component
  69475. */
  69476. get normalMap0(): NodeMaterialConnectionPoint;
  69477. /**
  69478. * Gets the second input component
  69479. */
  69480. get normalMap1(): NodeMaterialConnectionPoint;
  69481. /**
  69482. * Gets the output component
  69483. */
  69484. get output(): NodeMaterialConnectionPoint;
  69485. protected _buildBlock(state: NodeMaterialBuildState): this;
  69486. }
  69487. }
  69488. declare module BABYLON {
  69489. /**
  69490. * Block used to rotate a 2d vector by a given angle
  69491. */
  69492. export class Rotate2dBlock extends NodeMaterialBlock {
  69493. /**
  69494. * Creates a new Rotate2dBlock
  69495. * @param name defines the block name
  69496. */
  69497. constructor(name: string);
  69498. /**
  69499. * Gets the current class name
  69500. * @returns the class name
  69501. */
  69502. getClassName(): string;
  69503. /**
  69504. * Gets the input vector
  69505. */
  69506. get input(): NodeMaterialConnectionPoint;
  69507. /**
  69508. * Gets the input angle
  69509. */
  69510. get angle(): NodeMaterialConnectionPoint;
  69511. /**
  69512. * Gets the output component
  69513. */
  69514. get output(): NodeMaterialConnectionPoint;
  69515. autoConfigure(material: NodeMaterial): void;
  69516. protected _buildBlock(state: NodeMaterialBuildState): this;
  69517. }
  69518. }
  69519. declare module BABYLON {
  69520. /**
  69521. * Block used to get the reflected vector from a direction and a normal
  69522. */
  69523. export class ReflectBlock extends NodeMaterialBlock {
  69524. /**
  69525. * Creates a new ReflectBlock
  69526. * @param name defines the block name
  69527. */
  69528. constructor(name: string);
  69529. /**
  69530. * Gets the current class name
  69531. * @returns the class name
  69532. */
  69533. getClassName(): string;
  69534. /**
  69535. * Gets the incident component
  69536. */
  69537. get incident(): NodeMaterialConnectionPoint;
  69538. /**
  69539. * Gets the normal component
  69540. */
  69541. get normal(): NodeMaterialConnectionPoint;
  69542. /**
  69543. * Gets the output component
  69544. */
  69545. get output(): NodeMaterialConnectionPoint;
  69546. protected _buildBlock(state: NodeMaterialBuildState): this;
  69547. }
  69548. }
  69549. declare module BABYLON {
  69550. /**
  69551. * Block used to get the refracted vector from a direction and a normal
  69552. */
  69553. export class RefractBlock extends NodeMaterialBlock {
  69554. /**
  69555. * Creates a new RefractBlock
  69556. * @param name defines the block name
  69557. */
  69558. constructor(name: string);
  69559. /**
  69560. * Gets the current class name
  69561. * @returns the class name
  69562. */
  69563. getClassName(): string;
  69564. /**
  69565. * Gets the incident component
  69566. */
  69567. get incident(): NodeMaterialConnectionPoint;
  69568. /**
  69569. * Gets the normal component
  69570. */
  69571. get normal(): NodeMaterialConnectionPoint;
  69572. /**
  69573. * Gets the index of refraction component
  69574. */
  69575. get ior(): NodeMaterialConnectionPoint;
  69576. /**
  69577. * Gets the output component
  69578. */
  69579. get output(): NodeMaterialConnectionPoint;
  69580. protected _buildBlock(state: NodeMaterialBuildState): this;
  69581. }
  69582. }
  69583. declare module BABYLON {
  69584. /**
  69585. * Block used to desaturate a color
  69586. */
  69587. export class DesaturateBlock extends NodeMaterialBlock {
  69588. /**
  69589. * Creates a new DesaturateBlock
  69590. * @param name defines the block name
  69591. */
  69592. constructor(name: string);
  69593. /**
  69594. * Gets the current class name
  69595. * @returns the class name
  69596. */
  69597. getClassName(): string;
  69598. /**
  69599. * Gets the color operand input component
  69600. */
  69601. get color(): NodeMaterialConnectionPoint;
  69602. /**
  69603. * Gets the level operand input component
  69604. */
  69605. get level(): NodeMaterialConnectionPoint;
  69606. /**
  69607. * Gets the output component
  69608. */
  69609. get output(): NodeMaterialConnectionPoint;
  69610. protected _buildBlock(state: NodeMaterialBuildState): this;
  69611. }
  69612. }
  69613. declare module BABYLON {
  69614. /**
  69615. * Block used to implement the reflection module of the PBR material
  69616. */
  69617. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  69618. /** @hidden */
  69619. _defineLODReflectionAlpha: string;
  69620. /** @hidden */
  69621. _defineLinearSpecularReflection: string;
  69622. private _vEnvironmentIrradianceName;
  69623. /** @hidden */
  69624. _vReflectionMicrosurfaceInfosName: string;
  69625. /** @hidden */
  69626. _vReflectionInfosName: string;
  69627. /** @hidden */
  69628. _vReflectionFilteringInfoName: string;
  69629. private _scene;
  69630. /**
  69631. * The properties below are set by the main PBR block prior to calling methods of this class.
  69632. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  69633. * It's less burden on the user side in the editor part.
  69634. */
  69635. /** @hidden */
  69636. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  69637. /** @hidden */
  69638. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  69639. /** @hidden */
  69640. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  69641. /** @hidden */
  69642. viewConnectionPoint: NodeMaterialConnectionPoint;
  69643. /**
  69644. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  69645. * diffuse part of the IBL.
  69646. */
  69647. useSphericalHarmonics: boolean;
  69648. /**
  69649. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  69650. */
  69651. forceIrradianceInFragment: boolean;
  69652. /**
  69653. * Create a new ReflectionBlock
  69654. * @param name defines the block name
  69655. */
  69656. constructor(name: string);
  69657. /**
  69658. * Gets the current class name
  69659. * @returns the class name
  69660. */
  69661. getClassName(): string;
  69662. /**
  69663. * Gets the position input component
  69664. */
  69665. get position(): NodeMaterialConnectionPoint;
  69666. /**
  69667. * Gets the world position input component
  69668. */
  69669. get worldPosition(): NodeMaterialConnectionPoint;
  69670. /**
  69671. * Gets the world normal input component
  69672. */
  69673. get worldNormal(): NodeMaterialConnectionPoint;
  69674. /**
  69675. * Gets the world input component
  69676. */
  69677. get world(): NodeMaterialConnectionPoint;
  69678. /**
  69679. * Gets the camera (or eye) position component
  69680. */
  69681. get cameraPosition(): NodeMaterialConnectionPoint;
  69682. /**
  69683. * Gets the view input component
  69684. */
  69685. get view(): NodeMaterialConnectionPoint;
  69686. /**
  69687. * Gets the color input component
  69688. */
  69689. get color(): NodeMaterialConnectionPoint;
  69690. /**
  69691. * Gets the reflection object output component
  69692. */
  69693. get reflection(): NodeMaterialConnectionPoint;
  69694. /**
  69695. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  69696. */
  69697. get hasTexture(): boolean;
  69698. /**
  69699. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  69700. */
  69701. get reflectionColor(): string;
  69702. protected _getTexture(): Nullable<BaseTexture>;
  69703. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69704. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69705. /**
  69706. * Gets the code to inject in the vertex shader
  69707. * @param state current state of the node material building
  69708. * @returns the shader code
  69709. */
  69710. handleVertexSide(state: NodeMaterialBuildState): string;
  69711. /**
  69712. * Gets the main code of the block (fragment side)
  69713. * @param state current state of the node material building
  69714. * @param normalVarName name of the existing variable corresponding to the normal
  69715. * @returns the shader code
  69716. */
  69717. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  69718. protected _buildBlock(state: NodeMaterialBuildState): this;
  69719. protected _dumpPropertiesCode(): string;
  69720. serialize(): any;
  69721. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69722. }
  69723. }
  69724. declare module BABYLON {
  69725. /**
  69726. * Block used to implement the sheen module of the PBR material
  69727. */
  69728. export class SheenBlock extends NodeMaterialBlock {
  69729. /**
  69730. * Create a new SheenBlock
  69731. * @param name defines the block name
  69732. */
  69733. constructor(name: string);
  69734. /**
  69735. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  69736. * It allows the strength of the sheen effect to not depend on the base color of the material,
  69737. * making it easier to setup and tweak the effect
  69738. */
  69739. albedoScaling: boolean;
  69740. /**
  69741. * Defines if the sheen is linked to the sheen color.
  69742. */
  69743. linkSheenWithAlbedo: boolean;
  69744. /**
  69745. * Initialize the block and prepare the context for build
  69746. * @param state defines the state that will be used for the build
  69747. */
  69748. initialize(state: NodeMaterialBuildState): void;
  69749. /**
  69750. * Gets the current class name
  69751. * @returns the class name
  69752. */
  69753. getClassName(): string;
  69754. /**
  69755. * Gets the intensity input component
  69756. */
  69757. get intensity(): NodeMaterialConnectionPoint;
  69758. /**
  69759. * Gets the color input component
  69760. */
  69761. get color(): NodeMaterialConnectionPoint;
  69762. /**
  69763. * Gets the roughness input component
  69764. */
  69765. get roughness(): NodeMaterialConnectionPoint;
  69766. /**
  69767. * Gets the sheen object output component
  69768. */
  69769. get sheen(): NodeMaterialConnectionPoint;
  69770. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69771. /**
  69772. * Gets the main code of the block (fragment side)
  69773. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69774. * @returns the shader code
  69775. */
  69776. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  69777. protected _buildBlock(state: NodeMaterialBuildState): this;
  69778. protected _dumpPropertiesCode(): string;
  69779. serialize(): any;
  69780. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69781. }
  69782. }
  69783. declare module BABYLON {
  69784. /**
  69785. * Block used to implement the anisotropy module of the PBR material
  69786. */
  69787. export class AnisotropyBlock extends NodeMaterialBlock {
  69788. /**
  69789. * The two properties below are set by the main PBR block prior to calling methods of this class.
  69790. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  69791. * It's less burden on the user side in the editor part.
  69792. */
  69793. /** @hidden */
  69794. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  69795. /** @hidden */
  69796. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  69797. /**
  69798. * Create a new AnisotropyBlock
  69799. * @param name defines the block name
  69800. */
  69801. constructor(name: string);
  69802. /**
  69803. * Initialize the block and prepare the context for build
  69804. * @param state defines the state that will be used for the build
  69805. */
  69806. initialize(state: NodeMaterialBuildState): void;
  69807. /**
  69808. * Gets the current class name
  69809. * @returns the class name
  69810. */
  69811. getClassName(): string;
  69812. /**
  69813. * Gets the intensity input component
  69814. */
  69815. get intensity(): NodeMaterialConnectionPoint;
  69816. /**
  69817. * Gets the direction input component
  69818. */
  69819. get direction(): NodeMaterialConnectionPoint;
  69820. /**
  69821. * Gets the uv input component
  69822. */
  69823. get uv(): NodeMaterialConnectionPoint;
  69824. /**
  69825. * Gets the worldTangent input component
  69826. */
  69827. get worldTangent(): NodeMaterialConnectionPoint;
  69828. /**
  69829. * Gets the anisotropy object output component
  69830. */
  69831. get anisotropy(): NodeMaterialConnectionPoint;
  69832. private _generateTBNSpace;
  69833. /**
  69834. * Gets the main code of the block (fragment side)
  69835. * @param state current state of the node material building
  69836. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69837. * @returns the shader code
  69838. */
  69839. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  69840. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69841. protected _buildBlock(state: NodeMaterialBuildState): this;
  69842. }
  69843. }
  69844. declare module BABYLON {
  69845. /**
  69846. * Block used to implement the clear coat module of the PBR material
  69847. */
  69848. export class ClearCoatBlock extends NodeMaterialBlock {
  69849. private _scene;
  69850. /**
  69851. * Create a new ClearCoatBlock
  69852. * @param name defines the block name
  69853. */
  69854. constructor(name: string);
  69855. /**
  69856. * Defines if the F0 value should be remapped to account for the interface change in the material.
  69857. */
  69858. remapF0OnInterfaceChange: boolean;
  69859. /**
  69860. * Initialize the block and prepare the context for build
  69861. * @param state defines the state that will be used for the build
  69862. */
  69863. initialize(state: NodeMaterialBuildState): void;
  69864. /**
  69865. * Gets the current class name
  69866. * @returns the class name
  69867. */
  69868. getClassName(): string;
  69869. /**
  69870. * Gets the intensity input component
  69871. */
  69872. get intensity(): NodeMaterialConnectionPoint;
  69873. /**
  69874. * Gets the roughness input component
  69875. */
  69876. get roughness(): NodeMaterialConnectionPoint;
  69877. /**
  69878. * Gets the ior input component
  69879. */
  69880. get indexOfRefraction(): NodeMaterialConnectionPoint;
  69881. /**
  69882. * Gets the bump texture input component
  69883. */
  69884. get normalMapColor(): NodeMaterialConnectionPoint;
  69885. /**
  69886. * Gets the uv input component
  69887. */
  69888. get uv(): NodeMaterialConnectionPoint;
  69889. /**
  69890. * Gets the tint color input component
  69891. */
  69892. get tintColor(): NodeMaterialConnectionPoint;
  69893. /**
  69894. * Gets the tint "at distance" input component
  69895. */
  69896. get tintAtDistance(): NodeMaterialConnectionPoint;
  69897. /**
  69898. * Gets the tint thickness input component
  69899. */
  69900. get tintThickness(): NodeMaterialConnectionPoint;
  69901. /**
  69902. * Gets the world tangent input component
  69903. */
  69904. get worldTangent(): NodeMaterialConnectionPoint;
  69905. /**
  69906. * Gets the clear coat object output component
  69907. */
  69908. get clearcoat(): NodeMaterialConnectionPoint;
  69909. autoConfigure(material: NodeMaterial): void;
  69910. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69911. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69912. private _generateTBNSpace;
  69913. /**
  69914. * Gets the main code of the block (fragment side)
  69915. * @param state current state of the node material building
  69916. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  69917. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69918. * @param worldPosVarName name of the variable holding the world position
  69919. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69920. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  69921. * @param worldNormalVarName name of the variable holding the world normal
  69922. * @returns the shader code
  69923. */
  69924. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  69925. protected _buildBlock(state: NodeMaterialBuildState): this;
  69926. protected _dumpPropertiesCode(): string;
  69927. serialize(): any;
  69928. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69929. }
  69930. }
  69931. declare module BABYLON {
  69932. /**
  69933. * Block used to implement the sub surface module of the PBR material
  69934. */
  69935. export class SubSurfaceBlock extends NodeMaterialBlock {
  69936. /**
  69937. * Create a new SubSurfaceBlock
  69938. * @param name defines the block name
  69939. */
  69940. constructor(name: string);
  69941. /**
  69942. * Initialize the block and prepare the context for build
  69943. * @param state defines the state that will be used for the build
  69944. */
  69945. initialize(state: NodeMaterialBuildState): void;
  69946. /**
  69947. * Gets the current class name
  69948. * @returns the class name
  69949. */
  69950. getClassName(): string;
  69951. /**
  69952. * Gets the thickness component
  69953. */
  69954. get thickness(): NodeMaterialConnectionPoint;
  69955. /**
  69956. * Gets the tint color input component
  69957. */
  69958. get tintColor(): NodeMaterialConnectionPoint;
  69959. /**
  69960. * Gets the translucency intensity input component
  69961. */
  69962. get translucencyIntensity(): NodeMaterialConnectionPoint;
  69963. /**
  69964. * Gets the translucency diffusion distance input component
  69965. */
  69966. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  69967. /**
  69968. * Gets the refraction object parameters
  69969. */
  69970. get refraction(): NodeMaterialConnectionPoint;
  69971. /**
  69972. * Gets the sub surface object output component
  69973. */
  69974. get subsurface(): NodeMaterialConnectionPoint;
  69975. autoConfigure(material: NodeMaterial): void;
  69976. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69977. /**
  69978. * Gets the main code of the block (fragment side)
  69979. * @param state current state of the node material building
  69980. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  69981. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69982. * @param worldPosVarName name of the variable holding the world position
  69983. * @returns the shader code
  69984. */
  69985. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  69986. protected _buildBlock(state: NodeMaterialBuildState): this;
  69987. }
  69988. }
  69989. declare module BABYLON {
  69990. /**
  69991. * Block used to implement the PBR metallic/roughness model
  69992. */
  69993. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  69994. /**
  69995. * Gets or sets the light associated with this block
  69996. */
  69997. light: Nullable<Light>;
  69998. private _lightId;
  69999. private _scene;
  70000. private _environmentBRDFTexture;
  70001. private _environmentBrdfSamplerName;
  70002. private _vNormalWName;
  70003. private _invertNormalName;
  70004. private _metallicReflectanceColor;
  70005. private _metallicF0Factor;
  70006. private _vMetallicReflectanceFactorsName;
  70007. /**
  70008. * Create a new ReflectionBlock
  70009. * @param name defines the block name
  70010. */
  70011. constructor(name: string);
  70012. /**
  70013. * Intensity of the direct lights e.g. the four lights available in your scene.
  70014. * This impacts both the direct diffuse and specular highlights.
  70015. */
  70016. directIntensity: number;
  70017. /**
  70018. * Intensity of the environment e.g. how much the environment will light the object
  70019. * either through harmonics for rough material or through the reflection for shiny ones.
  70020. */
  70021. environmentIntensity: number;
  70022. /**
  70023. * This is a special control allowing the reduction of the specular highlights coming from the
  70024. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  70025. */
  70026. specularIntensity: number;
  70027. /**
  70028. * Defines the falloff type used in this material.
  70029. * It by default is Physical.
  70030. */
  70031. lightFalloff: number;
  70032. /**
  70033. * Specifies that alpha test should be used
  70034. */
  70035. useAlphaTest: boolean;
  70036. /**
  70037. * Defines the alpha limits in alpha test mode.
  70038. */
  70039. alphaTestCutoff: number;
  70040. /**
  70041. * Specifies that alpha blending should be used
  70042. */
  70043. useAlphaBlending: boolean;
  70044. /**
  70045. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  70046. * A car glass is a good example of that. When the street lights reflects on it you can not see what is behind.
  70047. */
  70048. useRadianceOverAlpha: boolean;
  70049. /**
  70050. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  70051. * A car glass is a good example of that. When sun reflects on it you can not see what is behind.
  70052. */
  70053. useSpecularOverAlpha: boolean;
  70054. /**
  70055. * Enables specular anti aliasing in the PBR shader.
  70056. * It will both interacts on the Geometry for analytical and IBL lighting.
  70057. * It also prefilter the roughness map based on the bump values.
  70058. */
  70059. enableSpecularAntiAliasing: boolean;
  70060. /**
  70061. * Enables realtime filtering on the texture.
  70062. */
  70063. realTimeFiltering: boolean;
  70064. /**
  70065. * Quality switch for realtime filtering
  70066. */
  70067. realTimeFilteringQuality: number;
  70068. /**
  70069. * Defines if the material uses energy conservation.
  70070. */
  70071. useEnergyConservation: boolean;
  70072. /**
  70073. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  70074. * too much the area relying on ambient texture to define their ambient occlusion.
  70075. */
  70076. useRadianceOcclusion: boolean;
  70077. /**
  70078. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  70079. * makes the reflect vector face the model (under horizon).
  70080. */
  70081. useHorizonOcclusion: boolean;
  70082. /**
  70083. * If set to true, no lighting calculations will be applied.
  70084. */
  70085. unlit: boolean;
  70086. /**
  70087. * Force normal to face away from face.
  70088. */
  70089. forceNormalForward: boolean;
  70090. /**
  70091. * Defines the material debug mode.
  70092. * It helps seeing only some components of the material while troubleshooting.
  70093. */
  70094. debugMode: number;
  70095. /**
  70096. * Specify from where on screen the debug mode should start.
  70097. * The value goes from -1 (full screen) to 1 (not visible)
  70098. * It helps with side by side comparison against the final render
  70099. * This defaults to 0
  70100. */
  70101. debugLimit: number;
  70102. /**
  70103. * As the default viewing range might not be enough (if the ambient is really small for instance)
  70104. * You can use the factor to better multiply the final value.
  70105. */
  70106. debugFactor: number;
  70107. /**
  70108. * Initialize the block and prepare the context for build
  70109. * @param state defines the state that will be used for the build
  70110. */
  70111. initialize(state: NodeMaterialBuildState): void;
  70112. /**
  70113. * Gets the current class name
  70114. * @returns the class name
  70115. */
  70116. getClassName(): string;
  70117. /**
  70118. * Gets the world position input component
  70119. */
  70120. get worldPosition(): NodeMaterialConnectionPoint;
  70121. /**
  70122. * Gets the world normal input component
  70123. */
  70124. get worldNormal(): NodeMaterialConnectionPoint;
  70125. /**
  70126. * Gets the view matrix parameter
  70127. */
  70128. get view(): NodeMaterialConnectionPoint;
  70129. /**
  70130. * Gets the camera position input component
  70131. */
  70132. get cameraPosition(): NodeMaterialConnectionPoint;
  70133. /**
  70134. * Gets the perturbed normal input component
  70135. */
  70136. get perturbedNormal(): NodeMaterialConnectionPoint;
  70137. /**
  70138. * Gets the base color input component
  70139. */
  70140. get baseColor(): NodeMaterialConnectionPoint;
  70141. /**
  70142. * Gets the metallic input component
  70143. */
  70144. get metallic(): NodeMaterialConnectionPoint;
  70145. /**
  70146. * Gets the roughness input component
  70147. */
  70148. get roughness(): NodeMaterialConnectionPoint;
  70149. /**
  70150. * Gets the ambient occlusion input component
  70151. */
  70152. get ambientOcc(): NodeMaterialConnectionPoint;
  70153. /**
  70154. * Gets the opacity input component
  70155. */
  70156. get opacity(): NodeMaterialConnectionPoint;
  70157. /**
  70158. * Gets the index of refraction input component
  70159. */
  70160. get indexOfRefraction(): NodeMaterialConnectionPoint;
  70161. /**
  70162. * Gets the ambient color input component
  70163. */
  70164. get ambientColor(): NodeMaterialConnectionPoint;
  70165. /**
  70166. * Gets the reflection object parameters
  70167. */
  70168. get reflection(): NodeMaterialConnectionPoint;
  70169. /**
  70170. * Gets the clear coat object parameters
  70171. */
  70172. get clearcoat(): NodeMaterialConnectionPoint;
  70173. /**
  70174. * Gets the sheen object parameters
  70175. */
  70176. get sheen(): NodeMaterialConnectionPoint;
  70177. /**
  70178. * Gets the sub surface object parameters
  70179. */
  70180. get subsurface(): NodeMaterialConnectionPoint;
  70181. /**
  70182. * Gets the anisotropy object parameters
  70183. */
  70184. get anisotropy(): NodeMaterialConnectionPoint;
  70185. /**
  70186. * Gets the ambient output component
  70187. */
  70188. get ambientClr(): NodeMaterialConnectionPoint;
  70189. /**
  70190. * Gets the diffuse output component
  70191. */
  70192. get diffuseDir(): NodeMaterialConnectionPoint;
  70193. /**
  70194. * Gets the specular output component
  70195. */
  70196. get specularDir(): NodeMaterialConnectionPoint;
  70197. /**
  70198. * Gets the clear coat output component
  70199. */
  70200. get clearcoatDir(): NodeMaterialConnectionPoint;
  70201. /**
  70202. * Gets the sheen output component
  70203. */
  70204. get sheenDir(): NodeMaterialConnectionPoint;
  70205. /**
  70206. * Gets the indirect diffuse output component
  70207. */
  70208. get diffuseIndirect(): NodeMaterialConnectionPoint;
  70209. /**
  70210. * Gets the indirect specular output component
  70211. */
  70212. get specularIndirect(): NodeMaterialConnectionPoint;
  70213. /**
  70214. * Gets the indirect clear coat output component
  70215. */
  70216. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  70217. /**
  70218. * Gets the indirect sheen output component
  70219. */
  70220. get sheenIndirect(): NodeMaterialConnectionPoint;
  70221. /**
  70222. * Gets the refraction output component
  70223. */
  70224. get refraction(): NodeMaterialConnectionPoint;
  70225. /**
  70226. * Gets the global lighting output component
  70227. */
  70228. get lighting(): NodeMaterialConnectionPoint;
  70229. /**
  70230. * Gets the shadow output component
  70231. */
  70232. get shadow(): NodeMaterialConnectionPoint;
  70233. /**
  70234. * Gets the alpha output component
  70235. */
  70236. get alpha(): NodeMaterialConnectionPoint;
  70237. autoConfigure(material: NodeMaterial): void;
  70238. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  70239. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  70240. isReady(): boolean;
  70241. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  70242. private _injectVertexCode;
  70243. private _getAlbedoOpacityCode;
  70244. private _getAmbientOcclusionCode;
  70245. private _getReflectivityCode;
  70246. protected _buildBlock(state: NodeMaterialBuildState): this;
  70247. protected _dumpPropertiesCode(): string;
  70248. serialize(): any;
  70249. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  70250. }
  70251. }
  70252. declare module BABYLON {
  70253. /**
  70254. * Block used to compute value of one parameter modulo another
  70255. */
  70256. export class ModBlock extends NodeMaterialBlock {
  70257. /**
  70258. * Creates a new ModBlock
  70259. * @param name defines the block name
  70260. */
  70261. constructor(name: string);
  70262. /**
  70263. * Gets the current class name
  70264. * @returns the class name
  70265. */
  70266. getClassName(): string;
  70267. /**
  70268. * Gets the left operand input component
  70269. */
  70270. get left(): NodeMaterialConnectionPoint;
  70271. /**
  70272. * Gets the right operand input component
  70273. */
  70274. get right(): NodeMaterialConnectionPoint;
  70275. /**
  70276. * Gets the output component
  70277. */
  70278. get output(): NodeMaterialConnectionPoint;
  70279. protected _buildBlock(state: NodeMaterialBuildState): this;
  70280. }
  70281. }
  70282. declare module BABYLON {
  70283. /**
  70284. * Configuration for Draco compression
  70285. */
  70286. export interface IDracoCompressionConfiguration {
  70287. /**
  70288. * Configuration for the decoder.
  70289. */
  70290. decoder: {
  70291. /**
  70292. * The url to the WebAssembly module.
  70293. */
  70294. wasmUrl?: string;
  70295. /**
  70296. * The url to the WebAssembly binary.
  70297. */
  70298. wasmBinaryUrl?: string;
  70299. /**
  70300. * The url to the fallback JavaScript module.
  70301. */
  70302. fallbackUrl?: string;
  70303. };
  70304. }
  70305. /**
  70306. * Draco compression (https://google.github.io/draco/)
  70307. *
  70308. * This class wraps the Draco module.
  70309. *
  70310. * **Encoder**
  70311. *
  70312. * The encoder is not currently implemented.
  70313. *
  70314. * **Decoder**
  70315. *
  70316. * 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.
  70317. *
  70318. * To update the configuration, use the following code:
  70319. * ```javascript
  70320. * DracoCompression.Configuration = {
  70321. * decoder: {
  70322. * wasmUrl: "<url to the WebAssembly library>",
  70323. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  70324. * fallbackUrl: "<url to the fallback JavaScript library>",
  70325. * }
  70326. * };
  70327. * ```
  70328. *
  70329. * 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.
  70330. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  70331. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  70332. *
  70333. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  70334. * ```javascript
  70335. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  70336. * ```
  70337. *
  70338. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  70339. */
  70340. export class DracoCompression implements IDisposable {
  70341. private _workerPoolPromise?;
  70342. private _decoderModulePromise?;
  70343. /**
  70344. * The configuration. Defaults to the following urls:
  70345. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  70346. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  70347. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  70348. */
  70349. static Configuration: IDracoCompressionConfiguration;
  70350. /**
  70351. * Returns true if the decoder configuration is available.
  70352. */
  70353. static get DecoderAvailable(): boolean;
  70354. /**
  70355. * Default number of workers to create when creating the draco compression object.
  70356. */
  70357. static DefaultNumWorkers: number;
  70358. private static GetDefaultNumWorkers;
  70359. private static _Default;
  70360. /**
  70361. * Default instance for the draco compression object.
  70362. */
  70363. static get Default(): DracoCompression;
  70364. /**
  70365. * Constructor
  70366. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  70367. */
  70368. constructor(numWorkers?: number);
  70369. /**
  70370. * Stop all async operations and release resources.
  70371. */
  70372. dispose(): void;
  70373. /**
  70374. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  70375. * @returns a promise that resolves when ready
  70376. */
  70377. whenReadyAsync(): Promise<void>;
  70378. /**
  70379. * Decode Draco compressed mesh data to vertex data.
  70380. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  70381. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  70382. * @returns A promise that resolves with the decoded vertex data
  70383. */
  70384. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  70385. [kind: string]: number;
  70386. }): Promise<VertexData>;
  70387. }
  70388. }
  70389. declare module BABYLON {
  70390. /**
  70391. * Class for building Constructive Solid Geometry
  70392. */
  70393. export class CSG {
  70394. private polygons;
  70395. /**
  70396. * The world matrix
  70397. */
  70398. matrix: Matrix;
  70399. /**
  70400. * Stores the position
  70401. */
  70402. position: Vector3;
  70403. /**
  70404. * Stores the rotation
  70405. */
  70406. rotation: Vector3;
  70407. /**
  70408. * Stores the rotation quaternion
  70409. */
  70410. rotationQuaternion: Nullable<Quaternion>;
  70411. /**
  70412. * Stores the scaling vector
  70413. */
  70414. scaling: Vector3;
  70415. /**
  70416. * Convert the Mesh to CSG
  70417. * @param mesh The Mesh to convert to CSG
  70418. * @returns A new CSG from the Mesh
  70419. */
  70420. static FromMesh(mesh: Mesh): CSG;
  70421. /**
  70422. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  70423. * @param polygons Polygons used to construct a CSG solid
  70424. */
  70425. private static FromPolygons;
  70426. /**
  70427. * Clones, or makes a deep copy, of the CSG
  70428. * @returns A new CSG
  70429. */
  70430. clone(): CSG;
  70431. /**
  70432. * Unions this CSG with another CSG
  70433. * @param csg The CSG to union against this CSG
  70434. * @returns The unioned CSG
  70435. */
  70436. union(csg: CSG): CSG;
  70437. /**
  70438. * Unions this CSG with another CSG in place
  70439. * @param csg The CSG to union against this CSG
  70440. */
  70441. unionInPlace(csg: CSG): void;
  70442. /**
  70443. * Subtracts this CSG with another CSG
  70444. * @param csg The CSG to subtract against this CSG
  70445. * @returns A new CSG
  70446. */
  70447. subtract(csg: CSG): CSG;
  70448. /**
  70449. * Subtracts this CSG with another CSG in place
  70450. * @param csg The CSG to subtract against this CSG
  70451. */
  70452. subtractInPlace(csg: CSG): void;
  70453. /**
  70454. * Intersect this CSG with another CSG
  70455. * @param csg The CSG to intersect against this CSG
  70456. * @returns A new CSG
  70457. */
  70458. intersect(csg: CSG): CSG;
  70459. /**
  70460. * Intersects this CSG with another CSG in place
  70461. * @param csg The CSG to intersect against this CSG
  70462. */
  70463. intersectInPlace(csg: CSG): void;
  70464. /**
  70465. * Return a new CSG solid with solid and empty space switched. This solid is
  70466. * not modified.
  70467. * @returns A new CSG solid with solid and empty space switched
  70468. */
  70469. inverse(): CSG;
  70470. /**
  70471. * Inverses the CSG in place
  70472. */
  70473. inverseInPlace(): void;
  70474. /**
  70475. * This is used to keep meshes transformations so they can be restored
  70476. * when we build back a Babylon Mesh
  70477. * NB : All CSG operations are performed in world coordinates
  70478. * @param csg The CSG to copy the transform attributes from
  70479. * @returns This CSG
  70480. */
  70481. copyTransformAttributes(csg: CSG): CSG;
  70482. /**
  70483. * Build Raw mesh from CSG
  70484. * Coordinates here are in world space
  70485. * @param name The name of the mesh geometry
  70486. * @param scene The Scene
  70487. * @param keepSubMeshes Specifies if the submeshes should be kept
  70488. * @returns A new Mesh
  70489. */
  70490. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  70491. /**
  70492. * Build Mesh from CSG taking material and transforms into account
  70493. * @param name The name of the Mesh
  70494. * @param material The material of the Mesh
  70495. * @param scene The Scene
  70496. * @param keepSubMeshes Specifies if submeshes should be kept
  70497. * @returns The new Mesh
  70498. */
  70499. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  70500. }
  70501. }
  70502. declare module BABYLON {
  70503. /**
  70504. * Class used to create a trail following a mesh
  70505. */
  70506. export class TrailMesh extends Mesh {
  70507. private _generator;
  70508. private _autoStart;
  70509. private _running;
  70510. private _diameter;
  70511. private _length;
  70512. private _sectionPolygonPointsCount;
  70513. private _sectionVectors;
  70514. private _sectionNormalVectors;
  70515. private _beforeRenderObserver;
  70516. /**
  70517. * @constructor
  70518. * @param name The value used by scene.getMeshByName() to do a lookup.
  70519. * @param generator The mesh or transform node to generate a trail.
  70520. * @param scene The scene to add this mesh to.
  70521. * @param diameter Diameter of trailing mesh. Default is 1.
  70522. * @param length Length of trailing mesh. Default is 60.
  70523. * @param autoStart Automatically start trailing mesh. Default true.
  70524. */
  70525. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  70526. /**
  70527. * "TrailMesh"
  70528. * @returns "TrailMesh"
  70529. */
  70530. getClassName(): string;
  70531. private _createMesh;
  70532. /**
  70533. * Start trailing mesh.
  70534. */
  70535. start(): void;
  70536. /**
  70537. * Stop trailing mesh.
  70538. */
  70539. stop(): void;
  70540. /**
  70541. * Update trailing mesh geometry.
  70542. */
  70543. update(): void;
  70544. /**
  70545. * Returns a new TrailMesh object.
  70546. * @param name is a string, the name given to the new mesh
  70547. * @param newGenerator use new generator object for cloned trail mesh
  70548. * @returns a new mesh
  70549. */
  70550. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  70551. /**
  70552. * Serializes this trail mesh
  70553. * @param serializationObject object to write serialization to
  70554. */
  70555. serialize(serializationObject: any): void;
  70556. /**
  70557. * Parses a serialized trail mesh
  70558. * @param parsedMesh the serialized mesh
  70559. * @param scene the scene to create the trail mesh in
  70560. * @returns the created trail mesh
  70561. */
  70562. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  70563. }
  70564. }
  70565. declare module BABYLON {
  70566. /**
  70567. * Class containing static functions to help procedurally build meshes
  70568. */
  70569. export class TiledBoxBuilder {
  70570. /**
  70571. * Creates a box mesh
  70572. * 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)
  70573. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70574. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70575. * * 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
  70576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70577. * @param name defines the name of the mesh
  70578. * @param options defines the options used to create the mesh
  70579. * @param scene defines the hosting scene
  70580. * @returns the box mesh
  70581. */
  70582. static CreateTiledBox(name: string, options: {
  70583. pattern?: number;
  70584. width?: number;
  70585. height?: number;
  70586. depth?: number;
  70587. tileSize?: number;
  70588. tileWidth?: number;
  70589. tileHeight?: number;
  70590. alignHorizontal?: number;
  70591. alignVertical?: number;
  70592. faceUV?: Vector4[];
  70593. faceColors?: Color4[];
  70594. sideOrientation?: number;
  70595. updatable?: boolean;
  70596. }, scene?: Nullable<Scene>): Mesh;
  70597. }
  70598. }
  70599. declare module BABYLON {
  70600. /**
  70601. * Class containing static functions to help procedurally build meshes
  70602. */
  70603. export class TorusKnotBuilder {
  70604. /**
  70605. * Creates a torus knot mesh
  70606. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70607. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70608. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70609. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70610. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70611. * * 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
  70612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70613. * @param name defines the name of the mesh
  70614. * @param options defines the options used to create the mesh
  70615. * @param scene defines the hosting scene
  70616. * @returns the torus knot mesh
  70617. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70618. */
  70619. static CreateTorusKnot(name: string, options: {
  70620. radius?: number;
  70621. tube?: number;
  70622. radialSegments?: number;
  70623. tubularSegments?: number;
  70624. p?: number;
  70625. q?: number;
  70626. updatable?: boolean;
  70627. sideOrientation?: number;
  70628. frontUVs?: Vector4;
  70629. backUVs?: Vector4;
  70630. }, scene: any): Mesh;
  70631. }
  70632. }
  70633. declare module BABYLON {
  70634. /**
  70635. * Polygon
  70636. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  70637. */
  70638. export class Polygon {
  70639. /**
  70640. * Creates a rectangle
  70641. * @param xmin bottom X coord
  70642. * @param ymin bottom Y coord
  70643. * @param xmax top X coord
  70644. * @param ymax top Y coord
  70645. * @returns points that make the resulting rectangle
  70646. */
  70647. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  70648. /**
  70649. * Creates a circle
  70650. * @param radius radius of circle
  70651. * @param cx scale in x
  70652. * @param cy scale in y
  70653. * @param numberOfSides number of sides that make up the circle
  70654. * @returns points that make the resulting circle
  70655. */
  70656. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  70657. /**
  70658. * Creates a polygon from input string
  70659. * @param input Input polygon data
  70660. * @returns the parsed points
  70661. */
  70662. static Parse(input: string): Vector2[];
  70663. /**
  70664. * Starts building a polygon from x and y coordinates
  70665. * @param x x coordinate
  70666. * @param y y coordinate
  70667. * @returns the started path2
  70668. */
  70669. static StartingAt(x: number, y: number): Path2;
  70670. }
  70671. /**
  70672. * Builds a polygon
  70673. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  70674. */
  70675. export class PolygonMeshBuilder {
  70676. private _points;
  70677. private _outlinepoints;
  70678. private _holes;
  70679. private _name;
  70680. private _scene;
  70681. private _epoints;
  70682. private _eholes;
  70683. private _addToepoint;
  70684. /**
  70685. * Babylon reference to the earcut plugin.
  70686. */
  70687. bjsEarcut: any;
  70688. /**
  70689. * Creates a PolygonMeshBuilder
  70690. * @param name name of the builder
  70691. * @param contours Path of the polygon
  70692. * @param scene scene to add to when creating the mesh
  70693. * @param earcutInjection can be used to inject your own earcut reference
  70694. */
  70695. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  70696. /**
  70697. * Adds a hole within the polygon
  70698. * @param hole Array of points defining the hole
  70699. * @returns this
  70700. */
  70701. addHole(hole: Vector2[]): PolygonMeshBuilder;
  70702. /**
  70703. * Creates the polygon
  70704. * @param updatable If the mesh should be updatable
  70705. * @param depth The depth of the mesh created
  70706. * @param smoothingThreshold Dot product threshold for smoothed normals
  70707. * @returns the created mesh
  70708. */
  70709. build(updatable?: boolean, depth?: number, smoothingThreshold?: number): Mesh;
  70710. /**
  70711. * Creates the polygon
  70712. * @param depth The depth of the mesh created
  70713. * @param smoothingThreshold Dot product threshold for smoothed normals
  70714. * @returns the created VertexData
  70715. */
  70716. buildVertexData(depth?: number, smoothingThreshold?: number): VertexData;
  70717. /**
  70718. * Adds a side to the polygon
  70719. * @param positions points that make the polygon
  70720. * @param normals normals of the polygon
  70721. * @param uvs uvs of the polygon
  70722. * @param indices indices of the polygon
  70723. * @param bounds bounds of the polygon
  70724. * @param points points of the polygon
  70725. * @param depth depth of the polygon
  70726. * @param flip flip of the polygon
  70727. */
  70728. private addSide;
  70729. }
  70730. }
  70731. declare module BABYLON {
  70732. /**
  70733. * Class containing static functions to help procedurally build meshes
  70734. */
  70735. export class PolygonBuilder {
  70736. /**
  70737. * Creates a polygon mesh
  70738. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70739. * * 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
  70740. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70742. * * 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)
  70743. * * Remember you can only change the shape positions, not their number when updating a polygon
  70744. * @param name defines the name of the mesh
  70745. * @param options defines the options used to create the mesh
  70746. * @param scene defines the hosting scene
  70747. * @param earcutInjection can be used to inject your own earcut reference
  70748. * @returns the polygon mesh
  70749. */
  70750. static CreatePolygon(name: string, options: {
  70751. shape: Vector3[];
  70752. holes?: Vector3[][];
  70753. depth?: number;
  70754. smoothingThreshold?: number;
  70755. faceUV?: Vector4[];
  70756. faceColors?: Color4[];
  70757. updatable?: boolean;
  70758. sideOrientation?: number;
  70759. frontUVs?: Vector4;
  70760. backUVs?: Vector4;
  70761. wrap?: boolean;
  70762. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70763. /**
  70764. * Creates an extruded polygon mesh, with depth in the Y direction.
  70765. * * 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)
  70766. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70767. * @param name defines the name of the mesh
  70768. * @param options defines the options used to create the mesh
  70769. * @param scene defines the hosting scene
  70770. * @param earcutInjection can be used to inject your own earcut reference
  70771. * @returns the polygon mesh
  70772. */
  70773. static ExtrudePolygon(name: string, options: {
  70774. shape: Vector3[];
  70775. holes?: Vector3[][];
  70776. depth?: number;
  70777. faceUV?: Vector4[];
  70778. faceColors?: Color4[];
  70779. updatable?: boolean;
  70780. sideOrientation?: number;
  70781. frontUVs?: Vector4;
  70782. backUVs?: Vector4;
  70783. wrap?: boolean;
  70784. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70785. }
  70786. }
  70787. declare module BABYLON {
  70788. /**
  70789. * Class containing static functions to help procedurally build meshes
  70790. */
  70791. export class LatheBuilder {
  70792. /**
  70793. * Creates lathe mesh.
  70794. * The lathe is a shape with a symmetry axis : a 2D model shape is rotated around this axis to design the lathe
  70795. * * 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
  70796. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70797. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70798. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70799. * * 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
  70800. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70801. * * 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
  70802. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70803. * * 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
  70804. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70806. * @param name defines the name of the mesh
  70807. * @param options defines the options used to create the mesh
  70808. * @param scene defines the hosting scene
  70809. * @returns the lathe mesh
  70810. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70811. */
  70812. static CreateLathe(name: string, options: {
  70813. shape: Vector3[];
  70814. radius?: number;
  70815. tessellation?: number;
  70816. clip?: number;
  70817. arc?: number;
  70818. closed?: boolean;
  70819. updatable?: boolean;
  70820. sideOrientation?: number;
  70821. frontUVs?: Vector4;
  70822. backUVs?: Vector4;
  70823. cap?: number;
  70824. invertUV?: boolean;
  70825. }, scene?: Nullable<Scene>): Mesh;
  70826. }
  70827. }
  70828. declare module BABYLON {
  70829. /**
  70830. * Class containing static functions to help procedurally build meshes
  70831. */
  70832. export class TiledPlaneBuilder {
  70833. /**
  70834. * Creates a tiled plane mesh
  70835. * * The parameter `pattern` will, depending on value, do nothing or
  70836. * * * flip (reflect about central vertical) alternate tiles across and up
  70837. * * * flip every tile on alternate rows
  70838. * * * rotate (180 degs) alternate tiles across and up
  70839. * * * rotate every tile on alternate rows
  70840. * * * flip and rotate alternate tiles across and up
  70841. * * * flip and rotate every tile on alternate rows
  70842. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  70843. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  70844. * * 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
  70845. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70846. * * 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)
  70847. * * 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)
  70848. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70849. * @param name defines the name of the mesh
  70850. * @param options defines the options used to create the mesh
  70851. * @param scene defines the hosting scene
  70852. * @returns the box mesh
  70853. */
  70854. static CreateTiledPlane(name: string, options: {
  70855. pattern?: number;
  70856. tileSize?: number;
  70857. tileWidth?: number;
  70858. tileHeight?: number;
  70859. size?: number;
  70860. width?: number;
  70861. height?: number;
  70862. alignHorizontal?: number;
  70863. alignVertical?: number;
  70864. sideOrientation?: number;
  70865. frontUVs?: Vector4;
  70866. backUVs?: Vector4;
  70867. updatable?: boolean;
  70868. }, scene?: Nullable<Scene>): Mesh;
  70869. }
  70870. }
  70871. declare module BABYLON {
  70872. /**
  70873. * Class containing static functions to help procedurally build meshes
  70874. */
  70875. export class TubeBuilder {
  70876. /**
  70877. * Creates a tube mesh.
  70878. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70879. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70880. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70881. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70882. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overrides the parameter `radius`
  70883. * * 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)
  70884. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70885. * * 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
  70886. * * 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
  70887. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70888. * * 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
  70889. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70890. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70891. * @param name defines the name of the mesh
  70892. * @param options defines the options used to create the mesh
  70893. * @param scene defines the hosting scene
  70894. * @returns the tube mesh
  70895. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70896. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70897. */
  70898. static CreateTube(name: string, options: {
  70899. path: Vector3[];
  70900. radius?: number;
  70901. tessellation?: number;
  70902. radiusFunction?: {
  70903. (i: number, distance: number): number;
  70904. };
  70905. cap?: number;
  70906. arc?: number;
  70907. updatable?: boolean;
  70908. sideOrientation?: number;
  70909. frontUVs?: Vector4;
  70910. backUVs?: Vector4;
  70911. instance?: Mesh;
  70912. invertUV?: boolean;
  70913. }, scene?: Nullable<Scene>): Mesh;
  70914. }
  70915. }
  70916. declare module BABYLON {
  70917. /**
  70918. * Class containing static functions to help procedurally build meshes
  70919. */
  70920. export class IcoSphereBuilder {
  70921. /**
  70922. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70923. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70924. * * 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`)
  70925. * * The parameter `subdivisions` sets the number of subdivisions (positive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70926. * * 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
  70927. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70928. * * 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
  70929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70930. * @param name defines the name of the mesh
  70931. * @param options defines the options used to create the mesh
  70932. * @param scene defines the hosting scene
  70933. * @returns the icosahedron mesh
  70934. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70935. */
  70936. static CreateIcoSphere(name: string, options: {
  70937. radius?: number;
  70938. radiusX?: number;
  70939. radiusY?: number;
  70940. radiusZ?: number;
  70941. flat?: boolean;
  70942. subdivisions?: number;
  70943. sideOrientation?: number;
  70944. frontUVs?: Vector4;
  70945. backUVs?: Vector4;
  70946. updatable?: boolean;
  70947. }, scene?: Nullable<Scene>): Mesh;
  70948. }
  70949. }
  70950. declare module BABYLON {
  70951. /**
  70952. * Class containing static functions to help procedurally build meshes
  70953. */
  70954. export class DecalBuilder {
  70955. /**
  70956. * Creates a decal mesh.
  70957. * 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
  70958. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70959. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70960. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70961. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70962. * @param name defines the name of the mesh
  70963. * @param sourceMesh defines the mesh where the decal must be applied
  70964. * @param options defines the options used to create the mesh
  70965. * @param scene defines the hosting scene
  70966. * @returns the decal mesh
  70967. * @see https://doc.babylonjs.com/how_to/decals
  70968. */
  70969. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70970. position?: Vector3;
  70971. normal?: Vector3;
  70972. size?: Vector3;
  70973. angle?: number;
  70974. }): Mesh;
  70975. }
  70976. }
  70977. declare module BABYLON {
  70978. /**
  70979. * Class containing static functions to help procedurally build meshes
  70980. */
  70981. export class MeshBuilder {
  70982. /**
  70983. * Creates a box mesh
  70984. * * The parameter `size` sets the size (float) of each box side (default 1)
  70985. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  70986. * * 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)
  70987. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70988. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70989. * * 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
  70990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70991. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70992. * @param name defines the name of the mesh
  70993. * @param options defines the options used to create the mesh
  70994. * @param scene defines the hosting scene
  70995. * @returns the box mesh
  70996. */
  70997. static CreateBox(name: string, options: {
  70998. size?: number;
  70999. width?: number;
  71000. height?: number;
  71001. depth?: number;
  71002. faceUV?: Vector4[];
  71003. faceColors?: Color4[];
  71004. sideOrientation?: number;
  71005. frontUVs?: Vector4;
  71006. backUVs?: Vector4;
  71007. wrap?: boolean;
  71008. topBaseAt?: number;
  71009. bottomBaseAt?: number;
  71010. updatable?: boolean;
  71011. }, scene?: Nullable<Scene>): Mesh;
  71012. /**
  71013. * Creates a tiled box mesh
  71014. * * faceTiles sets the pattern, tile size and number of tiles for a face
  71015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71016. * @param name defines the name of the mesh
  71017. * @param options defines the options used to create the mesh
  71018. * @param scene defines the hosting scene
  71019. * @returns the tiled box mesh
  71020. */
  71021. static CreateTiledBox(name: string, options: {
  71022. pattern?: number;
  71023. size?: number;
  71024. width?: number;
  71025. height?: number;
  71026. depth: number;
  71027. tileSize?: number;
  71028. tileWidth?: number;
  71029. tileHeight?: number;
  71030. faceUV?: Vector4[];
  71031. faceColors?: Color4[];
  71032. alignHorizontal?: number;
  71033. alignVertical?: number;
  71034. sideOrientation?: number;
  71035. updatable?: boolean;
  71036. }, scene?: Nullable<Scene>): Mesh;
  71037. /**
  71038. * Creates a sphere mesh
  71039. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  71040. * * 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`)
  71041. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  71042. * * 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
  71043. * * 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)
  71044. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71045. * * 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
  71046. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71047. * @param name defines the name of the mesh
  71048. * @param options defines the options used to create the mesh
  71049. * @param scene defines the hosting scene
  71050. * @returns the sphere mesh
  71051. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  71052. */
  71053. static CreateSphere(name: string, options: {
  71054. segments?: number;
  71055. diameter?: number;
  71056. diameterX?: number;
  71057. diameterY?: number;
  71058. diameterZ?: number;
  71059. arc?: number;
  71060. slice?: number;
  71061. sideOrientation?: number;
  71062. frontUVs?: Vector4;
  71063. backUVs?: Vector4;
  71064. updatable?: boolean;
  71065. }, scene?: Nullable<Scene>): Mesh;
  71066. /**
  71067. * Creates a plane polygonal mesh. By default, this is a disc
  71068. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  71069. * * 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
  71070. * * 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
  71071. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71072. * * 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
  71073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71074. * @param name defines the name of the mesh
  71075. * @param options defines the options used to create the mesh
  71076. * @param scene defines the hosting scene
  71077. * @returns the plane polygonal mesh
  71078. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  71079. */
  71080. static CreateDisc(name: string, options: {
  71081. radius?: number;
  71082. tessellation?: number;
  71083. arc?: number;
  71084. updatable?: boolean;
  71085. sideOrientation?: number;
  71086. frontUVs?: Vector4;
  71087. backUVs?: Vector4;
  71088. }, scene?: Nullable<Scene>): Mesh;
  71089. /**
  71090. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  71091. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  71092. * * 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`)
  71093. * * The parameter `subdivisions` sets the number of subdivisions (positive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  71094. * * 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
  71095. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71096. * * 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
  71097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71098. * @param name defines the name of the mesh
  71099. * @param options defines the options used to create the mesh
  71100. * @param scene defines the hosting scene
  71101. * @returns the icosahedron mesh
  71102. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  71103. */
  71104. static CreateIcoSphere(name: string, options: {
  71105. radius?: number;
  71106. radiusX?: number;
  71107. radiusY?: number;
  71108. radiusZ?: number;
  71109. flat?: boolean;
  71110. subdivisions?: number;
  71111. sideOrientation?: number;
  71112. frontUVs?: Vector4;
  71113. backUVs?: Vector4;
  71114. updatable?: boolean;
  71115. }, scene?: Nullable<Scene>): Mesh;
  71116. /**
  71117. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  71118. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  71119. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  71120. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  71121. * * 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
  71122. * * 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
  71123. * * 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
  71124. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71125. * * 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
  71126. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  71127. * * 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
  71128. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  71129. * * 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
  71130. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  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 ribbon mesh
  71136. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  71137. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  71138. */
  71139. static CreateRibbon(name: string, options: {
  71140. pathArray: Vector3[][];
  71141. closeArray?: boolean;
  71142. closePath?: boolean;
  71143. offset?: number;
  71144. updatable?: boolean;
  71145. sideOrientation?: number;
  71146. frontUVs?: Vector4;
  71147. backUVs?: Vector4;
  71148. instance?: Mesh;
  71149. invertUV?: boolean;
  71150. uvs?: Vector2[];
  71151. colors?: Color4[];
  71152. }, scene?: Nullable<Scene>): Mesh;
  71153. /**
  71154. * Creates a cylinder or a cone mesh
  71155. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  71156. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  71157. * * 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.
  71158. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  71159. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  71160. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  71161. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  71162. * * 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).
  71163. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  71164. * * 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).
  71165. * * 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
  71166. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  71167. * * 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
  71168. * * 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.
  71169. * * If `enclose` is false, a ring surface is one element.
  71170. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  71171. * * 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
  71172. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71173. * * 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
  71174. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71175. * @param name defines the name of the mesh
  71176. * @param options defines the options used to create the mesh
  71177. * @param scene defines the hosting scene
  71178. * @returns the cylinder mesh
  71179. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  71180. */
  71181. static CreateCylinder(name: string, options: {
  71182. height?: number;
  71183. diameterTop?: number;
  71184. diameterBottom?: number;
  71185. diameter?: number;
  71186. tessellation?: number;
  71187. subdivisions?: number;
  71188. arc?: number;
  71189. faceColors?: Color4[];
  71190. faceUV?: Vector4[];
  71191. updatable?: boolean;
  71192. hasRings?: boolean;
  71193. enclose?: boolean;
  71194. cap?: number;
  71195. sideOrientation?: number;
  71196. frontUVs?: Vector4;
  71197. backUVs?: Vector4;
  71198. }, scene?: Nullable<Scene>): Mesh;
  71199. /**
  71200. * Creates a torus mesh
  71201. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  71202. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  71203. * * The parameter `tessellation` sets the number of torus sides (positive integer, default 16)
  71204. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71205. * * 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
  71206. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71207. * @param name defines the name of the mesh
  71208. * @param options defines the options used to create the mesh
  71209. * @param scene defines the hosting scene
  71210. * @returns the torus mesh
  71211. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  71212. */
  71213. static CreateTorus(name: string, options: {
  71214. diameter?: number;
  71215. thickness?: number;
  71216. tessellation?: number;
  71217. updatable?: boolean;
  71218. sideOrientation?: number;
  71219. frontUVs?: Vector4;
  71220. backUVs?: Vector4;
  71221. }, scene?: Nullable<Scene>): Mesh;
  71222. /**
  71223. * Creates a torus knot mesh
  71224. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  71225. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  71226. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  71227. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  71228. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71229. * * 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
  71230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71231. * @param name defines the name of the mesh
  71232. * @param options defines the options used to create the mesh
  71233. * @param scene defines the hosting scene
  71234. * @returns the torus knot mesh
  71235. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  71236. */
  71237. static CreateTorusKnot(name: string, options: {
  71238. radius?: number;
  71239. tube?: number;
  71240. radialSegments?: number;
  71241. tubularSegments?: number;
  71242. p?: number;
  71243. q?: number;
  71244. updatable?: boolean;
  71245. sideOrientation?: number;
  71246. frontUVs?: Vector4;
  71247. backUVs?: Vector4;
  71248. }, scene?: Nullable<Scene>): Mesh;
  71249. /**
  71250. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  71251. * * 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
  71252. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  71253. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  71254. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  71255. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  71256. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  71257. * * 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
  71258. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  71259. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71260. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  71261. * @param name defines the name of the new line system
  71262. * @param options defines the options used to create the line system
  71263. * @param scene defines the hosting scene
  71264. * @returns a new line system mesh
  71265. */
  71266. static CreateLineSystem(name: string, options: {
  71267. lines: Vector3[][];
  71268. updatable?: boolean;
  71269. instance?: Nullable<LinesMesh>;
  71270. colors?: Nullable<Color4[][]>;
  71271. useVertexAlpha?: boolean;
  71272. }, scene: Nullable<Scene>): LinesMesh;
  71273. /**
  71274. * Creates a line mesh
  71275. * 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
  71276. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  71277. * * The parameter `points` is an array successive Vector3
  71278. * * 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
  71279. * * The optional parameter `colors` is an array of successive Color4, one per line point
  71280. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  71281. * * When updating an instance, remember that only point positions can change, not the number of points
  71282. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71283. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  71284. * @param name defines the name of the new line system
  71285. * @param options defines the options used to create the line system
  71286. * @param scene defines the hosting scene
  71287. * @returns a new line mesh
  71288. */
  71289. static CreateLines(name: string, options: {
  71290. points: Vector3[];
  71291. updatable?: boolean;
  71292. instance?: Nullable<LinesMesh>;
  71293. colors?: Color4[];
  71294. useVertexAlpha?: boolean;
  71295. }, scene?: Nullable<Scene>): LinesMesh;
  71296. /**
  71297. * Creates a dashed line mesh
  71298. * * 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
  71299. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  71300. * * The parameter `points` is an array successive Vector3
  71301. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  71302. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  71303. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  71304. * * 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
  71305. * * When updating an instance, remember that only point positions can change, not the number of points
  71306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71307. * @param name defines the name of the mesh
  71308. * @param options defines the options used to create the mesh
  71309. * @param scene defines the hosting scene
  71310. * @returns the dashed line mesh
  71311. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  71312. */
  71313. static CreateDashedLines(name: string, options: {
  71314. points: Vector3[];
  71315. dashSize?: number;
  71316. gapSize?: number;
  71317. dashNb?: number;
  71318. updatable?: boolean;
  71319. instance?: LinesMesh;
  71320. }, scene?: Nullable<Scene>): LinesMesh;
  71321. /**
  71322. * 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.
  71323. * * 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.
  71324. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  71325. * * 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.
  71326. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  71327. * * 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
  71328. * * 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
  71329. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  71330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71331. * * 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
  71332. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  71333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71334. * @param name defines the name of the mesh
  71335. * @param options defines the options used to create the mesh
  71336. * @param scene defines the hosting scene
  71337. * @returns the extruded shape mesh
  71338. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  71339. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  71340. */
  71341. static ExtrudeShape(name: string, options: {
  71342. shape: Vector3[];
  71343. path: Vector3[];
  71344. scale?: number;
  71345. rotation?: number;
  71346. cap?: number;
  71347. updatable?: boolean;
  71348. sideOrientation?: number;
  71349. frontUVs?: Vector4;
  71350. backUVs?: Vector4;
  71351. instance?: Mesh;
  71352. invertUV?: boolean;
  71353. }, scene?: Nullable<Scene>): Mesh;
  71354. /**
  71355. * Creates an custom extruded shape mesh.
  71356. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  71357. * * 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.
  71358. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  71359. * * 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
  71360. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  71361. * * 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
  71362. * * It must returns a float value that will be the scale value applied to the shape on each path point
  71363. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  71364. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  71365. * * 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
  71366. * * 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
  71367. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  71368. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71369. * * 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
  71370. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  71371. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71372. * @param name defines the name of the mesh
  71373. * @param options defines the options used to create the mesh
  71374. * @param scene defines the hosting scene
  71375. * @returns the custom extruded shape mesh
  71376. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  71377. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  71378. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  71379. */
  71380. static ExtrudeShapeCustom(name: string, options: {
  71381. shape: Vector3[];
  71382. path: Vector3[];
  71383. scaleFunction?: any;
  71384. rotationFunction?: any;
  71385. ribbonCloseArray?: boolean;
  71386. ribbonClosePath?: boolean;
  71387. cap?: number;
  71388. updatable?: boolean;
  71389. sideOrientation?: number;
  71390. frontUVs?: Vector4;
  71391. backUVs?: Vector4;
  71392. instance?: Mesh;
  71393. invertUV?: boolean;
  71394. }, scene?: Nullable<Scene>): Mesh;
  71395. /**
  71396. * Creates lathe mesh.
  71397. * The lathe is a shape with a symmetry axis : a 2D model shape is rotated around this axis to design the lathe
  71398. * * 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
  71399. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  71400. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  71401. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  71402. * * 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
  71403. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  71404. * * 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
  71405. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71406. * * 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
  71407. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  71408. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71409. * @param name defines the name of the mesh
  71410. * @param options defines the options used to create the mesh
  71411. * @param scene defines the hosting scene
  71412. * @returns the lathe mesh
  71413. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  71414. */
  71415. static CreateLathe(name: string, options: {
  71416. shape: Vector3[];
  71417. radius?: number;
  71418. tessellation?: number;
  71419. clip?: number;
  71420. arc?: number;
  71421. closed?: boolean;
  71422. updatable?: boolean;
  71423. sideOrientation?: number;
  71424. frontUVs?: Vector4;
  71425. backUVs?: Vector4;
  71426. cap?: number;
  71427. invertUV?: boolean;
  71428. }, scene?: Nullable<Scene>): Mesh;
  71429. /**
  71430. * Creates a tiled plane mesh
  71431. * * You can set a limited pattern arrangement with the tiles
  71432. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71433. * * 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
  71434. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71435. * @param name defines the name of the mesh
  71436. * @param options defines the options used to create the mesh
  71437. * @param scene defines the hosting scene
  71438. * @returns the plane mesh
  71439. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  71440. */
  71441. static CreateTiledPlane(name: string, options: {
  71442. pattern?: number;
  71443. tileSize?: number;
  71444. tileWidth?: number;
  71445. tileHeight?: number;
  71446. size?: number;
  71447. width?: number;
  71448. height?: number;
  71449. alignHorizontal?: number;
  71450. alignVertical?: number;
  71451. sideOrientation?: number;
  71452. frontUVs?: Vector4;
  71453. backUVs?: Vector4;
  71454. updatable?: boolean;
  71455. }, scene?: Nullable<Scene>): Mesh;
  71456. /**
  71457. * Creates a plane mesh
  71458. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  71459. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  71460. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  71461. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71462. * * 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
  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. * @param name defines the name of the mesh
  71465. * @param options defines the options used to create the mesh
  71466. * @param scene defines the hosting scene
  71467. * @returns the plane mesh
  71468. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  71469. */
  71470. static CreatePlane(name: string, options: {
  71471. size?: number;
  71472. width?: number;
  71473. height?: number;
  71474. sideOrientation?: number;
  71475. frontUVs?: Vector4;
  71476. backUVs?: Vector4;
  71477. updatable?: boolean;
  71478. sourcePlane?: Plane;
  71479. }, scene?: Nullable<Scene>): Mesh;
  71480. /**
  71481. * Creates a ground mesh
  71482. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  71483. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  71484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71485. * @param name defines the name of the mesh
  71486. * @param options defines the options used to create the mesh
  71487. * @param scene defines the hosting scene
  71488. * @returns the ground mesh
  71489. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  71490. */
  71491. static CreateGround(name: string, options: {
  71492. width?: number;
  71493. height?: number;
  71494. subdivisions?: number;
  71495. subdivisionsX?: number;
  71496. subdivisionsY?: number;
  71497. updatable?: boolean;
  71498. }, scene?: Nullable<Scene>): Mesh;
  71499. /**
  71500. * Creates a tiled ground mesh
  71501. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  71502. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  71503. * * 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
  71504. * * 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
  71505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71506. * @param name defines the name of the mesh
  71507. * @param options defines the options used to create the mesh
  71508. * @param scene defines the hosting scene
  71509. * @returns the tiled ground mesh
  71510. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  71511. */
  71512. static CreateTiledGround(name: string, options: {
  71513. xmin: number;
  71514. zmin: number;
  71515. xmax: number;
  71516. zmax: number;
  71517. subdivisions?: {
  71518. w: number;
  71519. h: number;
  71520. };
  71521. precision?: {
  71522. w: number;
  71523. h: number;
  71524. };
  71525. updatable?: boolean;
  71526. }, scene?: Nullable<Scene>): Mesh;
  71527. /**
  71528. * Creates a ground mesh from a height map
  71529. * * The parameter `url` sets the URL of the height map image resource.
  71530. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  71531. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  71532. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  71533. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  71534. * * 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.
  71535. * * 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).
  71536. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  71537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71538. * @param name defines the name of the mesh
  71539. * @param url defines the url to the height map
  71540. * @param options defines the options used to create the mesh
  71541. * @param scene defines the hosting scene
  71542. * @returns the ground mesh
  71543. * @see https://doc.babylonjs.com/babylon101/height_map
  71544. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  71545. */
  71546. static CreateGroundFromHeightMap(name: string, url: string, options: {
  71547. width?: number;
  71548. height?: number;
  71549. subdivisions?: number;
  71550. minHeight?: number;
  71551. maxHeight?: number;
  71552. colorFilter?: Color3;
  71553. alphaFilter?: number;
  71554. updatable?: boolean;
  71555. onReady?: (mesh: GroundMesh) => void;
  71556. }, scene?: Nullable<Scene>): GroundMesh;
  71557. /**
  71558. * Creates a polygon mesh
  71559. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  71560. * * 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
  71561. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  71562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71563. * * 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)
  71564. * * Remember you can only change the shape positions, not their number when updating a polygon
  71565. * @param name defines the name of the mesh
  71566. * @param options defines the options used to create the mesh
  71567. * @param scene defines the hosting scene
  71568. * @param earcutInjection can be used to inject your own earcut reference
  71569. * @returns the polygon mesh
  71570. */
  71571. static CreatePolygon(name: string, options: {
  71572. shape: Vector3[];
  71573. holes?: Vector3[][];
  71574. depth?: number;
  71575. faceUV?: Vector4[];
  71576. faceColors?: Color4[];
  71577. updatable?: boolean;
  71578. sideOrientation?: number;
  71579. frontUVs?: Vector4;
  71580. backUVs?: Vector4;
  71581. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  71582. /**
  71583. * Creates an extruded polygon mesh, with depth in the Y direction.
  71584. * * 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)
  71585. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  71586. * @param name defines the name of the mesh
  71587. * @param options defines the options used to create the mesh
  71588. * @param scene defines the hosting scene
  71589. * @param earcutInjection can be used to inject your own earcut reference
  71590. * @returns the polygon mesh
  71591. */
  71592. static ExtrudePolygon(name: string, options: {
  71593. shape: Vector3[];
  71594. holes?: Vector3[][];
  71595. depth?: number;
  71596. faceUV?: Vector4[];
  71597. faceColors?: Color4[];
  71598. updatable?: boolean;
  71599. sideOrientation?: number;
  71600. frontUVs?: Vector4;
  71601. backUVs?: Vector4;
  71602. wrap?: boolean;
  71603. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  71604. /**
  71605. * Creates a tube mesh.
  71606. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  71607. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  71608. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  71609. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  71610. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overrides the parameter `radius`
  71611. * * 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)
  71612. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  71613. * * 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
  71614. * * 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
  71615. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71616. * * 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
  71617. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  71618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71619. * @param name defines the name of the mesh
  71620. * @param options defines the options used to create the mesh
  71621. * @param scene defines the hosting scene
  71622. * @returns the tube mesh
  71623. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  71624. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  71625. */
  71626. static CreateTube(name: string, options: {
  71627. path: Vector3[];
  71628. radius?: number;
  71629. tessellation?: number;
  71630. radiusFunction?: {
  71631. (i: number, distance: number): number;
  71632. };
  71633. cap?: number;
  71634. arc?: number;
  71635. updatable?: boolean;
  71636. sideOrientation?: number;
  71637. frontUVs?: Vector4;
  71638. backUVs?: Vector4;
  71639. instance?: Mesh;
  71640. invertUV?: boolean;
  71641. }, scene?: Nullable<Scene>): Mesh;
  71642. /**
  71643. * Creates a polyhedron mesh
  71644. * * 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
  71645. * * The parameter `size` (positive float, default 1) sets the polygon size
  71646. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  71647. * * 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`
  71648. * * 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
  71649. * * 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)`)
  71650. * * 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
  71651. * * 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
  71652. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71653. * * 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
  71654. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71655. * @param name defines the name of the mesh
  71656. * @param options defines the options used to create the mesh
  71657. * @param scene defines the hosting scene
  71658. * @returns the polyhedron mesh
  71659. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  71660. */
  71661. static CreatePolyhedron(name: string, options: {
  71662. type?: number;
  71663. size?: number;
  71664. sizeX?: number;
  71665. sizeY?: number;
  71666. sizeZ?: number;
  71667. custom?: any;
  71668. faceUV?: Vector4[];
  71669. faceColors?: Color4[];
  71670. flat?: boolean;
  71671. updatable?: boolean;
  71672. sideOrientation?: number;
  71673. frontUVs?: Vector4;
  71674. backUVs?: Vector4;
  71675. }, scene?: Nullable<Scene>): Mesh;
  71676. /**
  71677. * Creates a decal mesh.
  71678. * 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
  71679. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  71680. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  71681. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  71682. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  71683. * @param name defines the name of the mesh
  71684. * @param sourceMesh defines the mesh where the decal must be applied
  71685. * @param options defines the options used to create the mesh
  71686. * @param scene defines the hosting scene
  71687. * @returns the decal mesh
  71688. * @see https://doc.babylonjs.com/how_to/decals
  71689. */
  71690. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  71691. position?: Vector3;
  71692. normal?: Vector3;
  71693. size?: Vector3;
  71694. angle?: number;
  71695. }): Mesh;
  71696. /**
  71697. * Creates a Capsule Mesh
  71698. * @param name defines the name of the mesh.
  71699. * @param options the constructors options used to shape the mesh.
  71700. * @param scene defines the scene the mesh is scoped to.
  71701. * @returns the capsule mesh
  71702. * @see https://doc.babylonjs.com/how_to/capsule_shape
  71703. */
  71704. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  71705. }
  71706. }
  71707. declare module BABYLON {
  71708. /**
  71709. * A simplifier interface for future simplification implementations
  71710. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71711. */
  71712. export interface ISimplifier {
  71713. /**
  71714. * Simplification of a given mesh according to the given settings.
  71715. * Since this requires computation, it is assumed that the function runs async.
  71716. * @param settings The settings of the simplification, including quality and distance
  71717. * @param successCallback A callback that will be called after the mesh was simplified.
  71718. * @param errorCallback in case of an error, this callback will be called. optional.
  71719. */
  71720. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  71721. }
  71722. /**
  71723. * Expected simplification settings.
  71724. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  71725. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71726. */
  71727. export interface ISimplificationSettings {
  71728. /**
  71729. * Gets or sets the expected quality
  71730. */
  71731. quality: number;
  71732. /**
  71733. * Gets or sets the distance when this optimized version should be used
  71734. */
  71735. distance: number;
  71736. /**
  71737. * Gets an already optimized mesh
  71738. */
  71739. optimizeMesh?: boolean;
  71740. }
  71741. /**
  71742. * Class used to specify simplification options
  71743. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71744. */
  71745. export class SimplificationSettings implements ISimplificationSettings {
  71746. /** expected quality */
  71747. quality: number;
  71748. /** distance when this optimized version should be used */
  71749. distance: number;
  71750. /** already optimized mesh */
  71751. optimizeMesh?: boolean | undefined;
  71752. /**
  71753. * Creates a SimplificationSettings
  71754. * @param quality expected quality
  71755. * @param distance distance when this optimized version should be used
  71756. * @param optimizeMesh already optimized mesh
  71757. */
  71758. constructor(
  71759. /** expected quality */
  71760. quality: number,
  71761. /** distance when this optimized version should be used */
  71762. distance: number,
  71763. /** already optimized mesh */
  71764. optimizeMesh?: boolean | undefined);
  71765. }
  71766. /**
  71767. * Interface used to define a simplification task
  71768. */
  71769. export interface ISimplificationTask {
  71770. /**
  71771. * Array of settings
  71772. */
  71773. settings: Array<ISimplificationSettings>;
  71774. /**
  71775. * Simplification type
  71776. */
  71777. simplificationType: SimplificationType;
  71778. /**
  71779. * Mesh to simplify
  71780. */
  71781. mesh: Mesh;
  71782. /**
  71783. * Callback called on success
  71784. */
  71785. successCallback?: () => void;
  71786. /**
  71787. * Defines if parallel processing can be used
  71788. */
  71789. parallelProcessing: boolean;
  71790. }
  71791. /**
  71792. * Queue used to order the simplification tasks
  71793. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71794. */
  71795. export class SimplificationQueue {
  71796. private _simplificationArray;
  71797. /**
  71798. * Gets a boolean indicating that the process is still running
  71799. */
  71800. running: boolean;
  71801. /**
  71802. * Creates a new queue
  71803. */
  71804. constructor();
  71805. /**
  71806. * Adds a new simplification task
  71807. * @param task defines a task to add
  71808. */
  71809. addTask(task: ISimplificationTask): void;
  71810. /**
  71811. * Execute next task
  71812. */
  71813. executeNext(): void;
  71814. /**
  71815. * Execute a simplification task
  71816. * @param task defines the task to run
  71817. */
  71818. runSimplification(task: ISimplificationTask): void;
  71819. private getSimplifier;
  71820. }
  71821. /**
  71822. * The implemented types of simplification
  71823. * At the moment only Quadratic Error Decimation is implemented
  71824. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71825. */
  71826. export enum SimplificationType {
  71827. /** Quadratic error decimation */
  71828. QUADRATIC = 0
  71829. }
  71830. /**
  71831. * An implementation of the Quadratic Error simplification algorithm.
  71832. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  71833. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  71834. * @author RaananW
  71835. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71836. */
  71837. export class QuadraticErrorSimplification implements ISimplifier {
  71838. private _mesh;
  71839. private triangles;
  71840. private vertices;
  71841. private references;
  71842. private _reconstructedMesh;
  71843. /** Gets or sets the number pf sync iterations */
  71844. syncIterations: number;
  71845. /** Gets or sets the aggressiveness of the simplifier */
  71846. aggressiveness: number;
  71847. /** Gets or sets the number of allowed iterations for decimation */
  71848. decimationIterations: number;
  71849. /** Gets or sets the espilon to use for bounding box computation */
  71850. boundingBoxEpsilon: number;
  71851. /**
  71852. * Creates a new QuadraticErrorSimplification
  71853. * @param _mesh defines the target mesh
  71854. */
  71855. constructor(_mesh: Mesh);
  71856. /**
  71857. * Simplification of a given mesh according to the given settings.
  71858. * Since this requires computation, it is assumed that the function runs async.
  71859. * @param settings The settings of the simplification, including quality and distance
  71860. * @param successCallback A callback that will be called after the mesh was simplified.
  71861. */
  71862. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  71863. private runDecimation;
  71864. private initWithMesh;
  71865. private init;
  71866. private reconstructMesh;
  71867. private initDecimatedMesh;
  71868. private isFlipped;
  71869. private updateTriangles;
  71870. private identifyBorder;
  71871. private updateMesh;
  71872. private vertexError;
  71873. private calculateError;
  71874. }
  71875. }
  71876. declare module BABYLON {
  71877. interface Scene {
  71878. /** @hidden (Backing field) */
  71879. _simplificationQueue: SimplificationQueue;
  71880. /**
  71881. * Gets or sets the simplification queue attached to the scene
  71882. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71883. */
  71884. simplificationQueue: SimplificationQueue;
  71885. }
  71886. interface Mesh {
  71887. /**
  71888. * Simplify the mesh according to the given array of settings.
  71889. * Function will return immediately and will simplify async
  71890. * @param settings a collection of simplification settings
  71891. * @param parallelProcessing should all levels calculate parallel or one after the other
  71892. * @param simplificationType the type of simplification to run
  71893. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  71894. * @returns the current mesh
  71895. */
  71896. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  71897. }
  71898. /**
  71899. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  71900. * created in a scene
  71901. */
  71902. export class SimplicationQueueSceneComponent implements ISceneComponent {
  71903. /**
  71904. * The component name helpfull to identify the component in the list of scene components.
  71905. */
  71906. readonly name: string;
  71907. /**
  71908. * The scene the component belongs to.
  71909. */
  71910. scene: Scene;
  71911. /**
  71912. * Creates a new instance of the component for the given scene
  71913. * @param scene Defines the scene to register the component in
  71914. */
  71915. constructor(scene: Scene);
  71916. /**
  71917. * Registers the component in a given scene
  71918. */
  71919. register(): void;
  71920. /**
  71921. * Rebuilds the elements related to this component in case of
  71922. * context lost for instance.
  71923. */
  71924. rebuild(): void;
  71925. /**
  71926. * Disposes the component and the associated resources
  71927. */
  71928. dispose(): void;
  71929. private _beforeCameraUpdate;
  71930. }
  71931. }
  71932. declare module BABYLON {
  71933. interface Mesh {
  71934. /**
  71935. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  71936. */
  71937. thinInstanceEnablePicking: boolean;
  71938. /**
  71939. * Creates a new thin instance
  71940. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  71941. * @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
  71942. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  71943. */
  71944. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh?: boolean): number;
  71945. /**
  71946. * Adds the transformation (matrix) of the current mesh as a thin instance
  71947. * @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
  71948. * @returns the thin instance index number
  71949. */
  71950. thinInstanceAddSelf(refresh?: boolean): number;
  71951. /**
  71952. * Registers a custom attribute to be used with thin instances
  71953. * @param kind name of the attribute
  71954. * @param stride size in floats of the attribute
  71955. */
  71956. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  71957. /**
  71958. * Sets the matrix of a thin instance
  71959. * @param index index of the thin instance
  71960. * @param matrix matrix to set
  71961. * @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
  71962. */
  71963. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh?: boolean): void;
  71964. /**
  71965. * Sets the value of a custom attribute for a thin instance
  71966. * @param kind name of the attribute
  71967. * @param index index of the thin instance
  71968. * @param value value to set
  71969. * @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
  71970. */
  71971. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh?: boolean): void;
  71972. /**
  71973. * 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.
  71974. */
  71975. thinInstanceCount: number;
  71976. /**
  71977. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  71978. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  71979. * @param buffer buffer to set
  71980. * @param stride size in floats of each value of the buffer
  71981. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  71982. */
  71983. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride?: number, staticBuffer?: boolean): void;
  71984. /**
  71985. * Gets the list of world matrices
  71986. * @return an array containing all the world matrices from the thin instances
  71987. */
  71988. thinInstanceGetWorldMatrices(): Matrix[];
  71989. /**
  71990. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  71991. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71992. */
  71993. thinInstanceBufferUpdated(kind: string): void;
  71994. /**
  71995. * Applies a partial update to a buffer directly on the GPU
  71996. * 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
  71997. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71998. * @param data the data to set in the GPU buffer
  71999. * @param offset the offset in the GPU buffer where to update the data
  72000. */
  72001. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  72002. /**
  72003. * Refreshes the bounding info, taking into account all the thin instances defined
  72004. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  72005. */
  72006. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo?: boolean): void;
  72007. /** @hidden */
  72008. _thinInstanceInitializeUserStorage(): void;
  72009. /** @hidden */
  72010. _thinInstanceUpdateBufferSize(kind: string, numInstances?: number): void;
  72011. /** @hidden */
  72012. _userThinInstanceBuffersStorage: {
  72013. data: {
  72014. [key: string]: Float32Array;
  72015. };
  72016. sizes: {
  72017. [key: string]: number;
  72018. };
  72019. vertexBuffers: {
  72020. [key: string]: Nullable<VertexBuffer>;
  72021. };
  72022. strides: {
  72023. [key: string]: number;
  72024. };
  72025. };
  72026. }
  72027. }
  72028. declare module BABYLON {
  72029. /**
  72030. * Navigation plugin interface to add navigation constrained by a navigation mesh
  72031. */
  72032. export interface INavigationEnginePlugin {
  72033. /**
  72034. * plugin name
  72035. */
  72036. name: string;
  72037. /**
  72038. * Creates a navigation mesh
  72039. * @param meshes array of all the geometry used to compute the navigation mesh
  72040. * @param parameters bunch of parameters used to filter geometry
  72041. */
  72042. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  72043. /**
  72044. * Create a navigation mesh debug mesh
  72045. * @param scene is where the mesh will be added
  72046. * @returns debug display mesh
  72047. */
  72048. createDebugNavMesh(scene: Scene): Mesh;
  72049. /**
  72050. * Get a navigation mesh constrained position, closest to the parameter position
  72051. * @param position world position
  72052. * @returns the closest point to position constrained by the navigation mesh
  72053. */
  72054. getClosestPoint(position: Vector3): Vector3;
  72055. /**
  72056. * Get a navigation mesh constrained position, closest to the parameter position
  72057. * @param position world position
  72058. * @param result output the closest point to position constrained by the navigation mesh
  72059. */
  72060. getClosestPointToRef(position: Vector3, result: Vector3): void;
  72061. /**
  72062. * Get a navigation mesh constrained position, within a particular radius
  72063. * @param position world position
  72064. * @param maxRadius the maximum distance to the constrained world position
  72065. * @returns the closest point to position constrained by the navigation mesh
  72066. */
  72067. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  72068. /**
  72069. * Get a navigation mesh constrained position, within a particular radius
  72070. * @param position world position
  72071. * @param maxRadius the maximum distance to the constrained world position
  72072. * @param result output the closest point to position constrained by the navigation mesh
  72073. */
  72074. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  72075. /**
  72076. * Compute the final position from a segment made of destination-position
  72077. * @param position world position
  72078. * @param destination world position
  72079. * @returns the resulting point along the navmesh
  72080. */
  72081. moveAlong(position: Vector3, destination: Vector3): Vector3;
  72082. /**
  72083. * Compute the final position from a segment made of destination-position
  72084. * @param position world position
  72085. * @param destination world position
  72086. * @param result output the resulting point along the navmesh
  72087. */
  72088. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  72089. /**
  72090. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  72091. * @param start world position
  72092. * @param end world position
  72093. * @returns array containing world position composing the path
  72094. */
  72095. computePath(start: Vector3, end: Vector3): Vector3[];
  72096. /**
  72097. * If this plugin is supported
  72098. * @returns true if plugin is supported
  72099. */
  72100. isSupported(): boolean;
  72101. /**
  72102. * Create a new Crowd so you can add agents
  72103. * @param maxAgents the maximum agent count in the crowd
  72104. * @param maxAgentRadius the maximum radius an agent can have
  72105. * @param scene to attach the crowd to
  72106. * @returns the crowd you can add agents to
  72107. */
  72108. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  72109. /**
  72110. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  72111. * The queries will try to find a solution within those bounds
  72112. * default is (1,1,1)
  72113. * @param extent x,y,z value that define the extent around the queries point of reference
  72114. */
  72115. setDefaultQueryExtent(extent: Vector3): void;
  72116. /**
  72117. * Get the Bounding box extent specified by setDefaultQueryExtent
  72118. * @returns the box extent values
  72119. */
  72120. getDefaultQueryExtent(): Vector3;
  72121. /**
  72122. * build the navmesh from a previously saved state using getNavmeshData
  72123. * @param data the Uint8Array returned by getNavmeshData
  72124. */
  72125. buildFromNavmeshData(data: Uint8Array): void;
  72126. /**
  72127. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  72128. * @returns data the Uint8Array that can be saved and reused
  72129. */
  72130. getNavmeshData(): Uint8Array;
  72131. /**
  72132. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72133. * @param result output the box extent values
  72134. */
  72135. getDefaultQueryExtentToRef(result: Vector3): void;
  72136. /**
  72137. * Set the time step of the navigation tick update.
  72138. * Default is 1/60.
  72139. * A value of 0 will disable fixed time update
  72140. * @param newTimeStep the new timestep to apply to this world.
  72141. */
  72142. setTimeStep(newTimeStep: number): void;
  72143. /**
  72144. * Get the time step of the navigation tick update.
  72145. * @returns the current time step
  72146. */
  72147. getTimeStep(): number;
  72148. /**
  72149. * If delta time in navigation tick update is greater than the time step
  72150. * a number of sub iterations are done. If more iterations are need to reach deltatime
  72151. * they will be discarded.
  72152. * A value of 0 will set to no maximum and update will use as many substeps as needed
  72153. * @param newStepCount the maximum number of iterations
  72154. */
  72155. setMaximumSubStepCount(newStepCount: number): void;
  72156. /**
  72157. * Get the maximum number of iterations per navigation tick update
  72158. * @returns the maximum number of iterations
  72159. */
  72160. getMaximumSubStepCount(): number;
  72161. /**
  72162. * Creates a cylinder obstacle and add it to the navigation
  72163. * @param position world position
  72164. * @param radius cylinder radius
  72165. * @param height cylinder height
  72166. * @returns the obstacle freshly created
  72167. */
  72168. addCylinderObstacle(position: Vector3, radius: number, height: number): IObstacle;
  72169. /**
  72170. * Creates an oriented box obstacle and add it to the navigation
  72171. * @param position world position
  72172. * @param extent box size
  72173. * @param angle angle in radians of the box orientation on Y axis
  72174. * @returns the obstacle freshly created
  72175. */
  72176. addBoxObstacle(position: Vector3, extent: Vector3, angle: number): IObstacle;
  72177. /**
  72178. * Removes an obstacle created by addCylinderObstacle or addBoxObstacle
  72179. * @param obstacle obstacle to remove from the navigation
  72180. */
  72181. removeObstacle(obstacle: IObstacle): void;
  72182. /**
  72183. * Release all resources
  72184. */
  72185. dispose(): void;
  72186. }
  72187. /**
  72188. * Obstacle interface
  72189. */
  72190. export interface IObstacle {
  72191. }
  72192. /**
  72193. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  72194. */
  72195. export interface ICrowd {
  72196. /**
  72197. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  72198. * You can attach anything to that node. The node position is updated in the scene update tick.
  72199. * @param pos world position that will be constrained by the navigation mesh
  72200. * @param parameters agent parameters
  72201. * @param transform hooked to the agent that will be update by the scene
  72202. * @returns agent index
  72203. */
  72204. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  72205. /**
  72206. * Returns the agent position in world space
  72207. * @param index agent index returned by addAgent
  72208. * @returns world space position
  72209. */
  72210. getAgentPosition(index: number): Vector3;
  72211. /**
  72212. * Gets the agent position result in world space
  72213. * @param index agent index returned by addAgent
  72214. * @param result output world space position
  72215. */
  72216. getAgentPositionToRef(index: number, result: Vector3): void;
  72217. /**
  72218. * Gets the agent velocity in world space
  72219. * @param index agent index returned by addAgent
  72220. * @returns world space velocity
  72221. */
  72222. getAgentVelocity(index: number): Vector3;
  72223. /**
  72224. * Gets the agent velocity result in world space
  72225. * @param index agent index returned by addAgent
  72226. * @param result output world space velocity
  72227. */
  72228. getAgentVelocityToRef(index: number, result: Vector3): void;
  72229. /**
  72230. * Gets the agent next target point on the path
  72231. * @param index agent index returned by addAgent
  72232. * @returns world space position
  72233. */
  72234. getAgentNextTargetPath(index: number): Vector3;
  72235. /**
  72236. * Gets the agent state
  72237. * @param index agent index returned by addAgent
  72238. * @returns agent state
  72239. */
  72240. getAgentState(index: number): number;
  72241. /**
  72242. * returns true if the agent in over an off mesh link connection
  72243. * @param index agent index returned by addAgent
  72244. * @returns true if over an off mesh link connection
  72245. */
  72246. overOffmeshConnection(index: number): boolean;
  72247. /**
  72248. * Gets the agent next target point on the path
  72249. * @param index agent index returned by addAgent
  72250. * @param result output world space position
  72251. */
  72252. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  72253. /**
  72254. * remove a particular agent previously created
  72255. * @param index agent index returned by addAgent
  72256. */
  72257. removeAgent(index: number): void;
  72258. /**
  72259. * get the list of all agents attached to this crowd
  72260. * @returns list of agent indices
  72261. */
  72262. getAgents(): number[];
  72263. /**
  72264. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  72265. * @param deltaTime in seconds
  72266. */
  72267. update(deltaTime: number): void;
  72268. /**
  72269. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  72270. * @param index agent index returned by addAgent
  72271. * @param destination targeted world position
  72272. */
  72273. agentGoto(index: number, destination: Vector3): void;
  72274. /**
  72275. * Teleport the agent to a new position
  72276. * @param index agent index returned by addAgent
  72277. * @param destination targeted world position
  72278. */
  72279. agentTeleport(index: number, destination: Vector3): void;
  72280. /**
  72281. * Update agent parameters
  72282. * @param index agent index returned by addAgent
  72283. * @param parameters agent parameters
  72284. */
  72285. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  72286. /**
  72287. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  72288. * The queries will try to find a solution within those bounds
  72289. * default is (1,1,1)
  72290. * @param extent x,y,z value that define the extent around the queries point of reference
  72291. */
  72292. setDefaultQueryExtent(extent: Vector3): void;
  72293. /**
  72294. * Get the Bounding box extent specified by setDefaultQueryExtent
  72295. * @returns the box extent values
  72296. */
  72297. getDefaultQueryExtent(): Vector3;
  72298. /**
  72299. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72300. * @param result output the box extent values
  72301. */
  72302. getDefaultQueryExtentToRef(result: Vector3): void;
  72303. /**
  72304. * Get the next corner points composing the path (max 4 points)
  72305. * @param index agent index returned by addAgent
  72306. * @returns array containing world position composing the path
  72307. */
  72308. getCorners(index: number): Vector3[];
  72309. /**
  72310. * Release all resources
  72311. */
  72312. dispose(): void;
  72313. }
  72314. /**
  72315. * Configures an agent
  72316. */
  72317. export interface IAgentParameters {
  72318. /**
  72319. * Agent radius. [Limit: >= 0]
  72320. */
  72321. radius: number;
  72322. /**
  72323. * Agent height. [Limit: > 0]
  72324. */
  72325. height: number;
  72326. /**
  72327. * Maximum allowed acceleration. [Limit: >= 0]
  72328. */
  72329. maxAcceleration: number;
  72330. /**
  72331. * Maximum allowed speed. [Limit: >= 0]
  72332. */
  72333. maxSpeed: number;
  72334. /**
  72335. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  72336. */
  72337. collisionQueryRange: number;
  72338. /**
  72339. * The path visibility optimization range. [Limit: > 0]
  72340. */
  72341. pathOptimizationRange: number;
  72342. /**
  72343. * How aggressive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  72344. */
  72345. separationWeight: number;
  72346. }
  72347. /**
  72348. * Configures the navigation mesh creation
  72349. */
  72350. export interface INavMeshParameters {
  72351. /**
  72352. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  72353. */
  72354. cs: number;
  72355. /**
  72356. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  72357. */
  72358. ch: number;
  72359. /**
  72360. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  72361. */
  72362. walkableSlopeAngle: number;
  72363. /**
  72364. * Minimum floor to 'ceiling' height that will still allow the floor area to
  72365. * be considered walkable. [Limit: >= 3] [Units: vx]
  72366. */
  72367. walkableHeight: number;
  72368. /**
  72369. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  72370. */
  72371. walkableClimb: number;
  72372. /**
  72373. * The distance to erode/shrink the walkable area of the heightfield away from
  72374. * obstructions. [Limit: >=0] [Units: vx]
  72375. */
  72376. walkableRadius: number;
  72377. /**
  72378. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  72379. */
  72380. maxEdgeLen: number;
  72381. /**
  72382. * The maximum distance a simplified contour's border edges should deviate
  72383. * the original raw contour. [Limit: >=0] [Units: vx]
  72384. */
  72385. maxSimplificationError: number;
  72386. /**
  72387. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  72388. */
  72389. minRegionArea: number;
  72390. /**
  72391. * Any regions with a span count smaller than this value will, if possible,
  72392. * be merged with larger regions. [Limit: >=0] [Units: vx]
  72393. */
  72394. mergeRegionArea: number;
  72395. /**
  72396. * The maximum number of vertices allowed for polygons generated during the
  72397. * contour to polygon conversion process. [Limit: >= 3]
  72398. */
  72399. maxVertsPerPoly: number;
  72400. /**
  72401. * Sets the sampling distance to use when generating the detail mesh.
  72402. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  72403. */
  72404. detailSampleDist: number;
  72405. /**
  72406. * The maximum distance the detail mesh surface should deviate from heightfield
  72407. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  72408. */
  72409. detailSampleMaxError: number;
  72410. /**
  72411. * If using obstacles, the navmesh must be subdivided internaly by tiles.
  72412. * This member defines the tile cube side length in world units.
  72413. * If no obstacles are needed, leave it undefined or 0.
  72414. */
  72415. tileSize: number;
  72416. /**
  72417. * The size of the non-navigable border around the heightfield.
  72418. */
  72419. borderSize: number;
  72420. }
  72421. }
  72422. declare module BABYLON {
  72423. /**
  72424. * RecastJS navigation plugin
  72425. */
  72426. export class RecastJSPlugin implements INavigationEnginePlugin {
  72427. /**
  72428. * Reference to the Recast library
  72429. */
  72430. bjsRECAST: any;
  72431. /**
  72432. * plugin name
  72433. */
  72434. name: string;
  72435. /**
  72436. * the first navmesh created. We might extend this to support multiple navmeshes
  72437. */
  72438. navMesh: any;
  72439. private _maximumSubStepCount;
  72440. private _timeStep;
  72441. /**
  72442. * Initializes the recastJS plugin
  72443. * @param recastInjection can be used to inject your own recast reference
  72444. */
  72445. constructor(recastInjection?: any);
  72446. /**
  72447. * Set the time step of the navigation tick update.
  72448. * Default is 1/60.
  72449. * A value of 0 will disable fixed time update
  72450. * @param newTimeStep the new timestep to apply to this world.
  72451. */
  72452. setTimeStep(newTimeStep?: number): void;
  72453. /**
  72454. * Get the time step of the navigation tick update.
  72455. * @returns the current time step
  72456. */
  72457. getTimeStep(): number;
  72458. /**
  72459. * If delta time in navigation tick update is greater than the time step
  72460. * a number of sub iterations are done. If more iterations are need to reach deltatime
  72461. * they will be discarded.
  72462. * A value of 0 will set to no maximum and update will use as many substeps as needed
  72463. * @param newStepCount the maximum number of iterations
  72464. */
  72465. setMaximumSubStepCount(newStepCount?: number): void;
  72466. /**
  72467. * Get the maximum number of iterations per navigation tick update
  72468. * @returns the maximum number of iterations
  72469. */
  72470. getMaximumSubStepCount(): number;
  72471. /**
  72472. * Creates a navigation mesh
  72473. * @param meshes array of all the geometry used to compute the navigation mesh
  72474. * @param parameters bunch of parameters used to filter geometry
  72475. */
  72476. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  72477. /**
  72478. * Create a navigation mesh debug mesh
  72479. * @param scene is where the mesh will be added
  72480. * @returns debug display mesh
  72481. */
  72482. createDebugNavMesh(scene: Scene): Mesh;
  72483. /**
  72484. * Get a navigation mesh constrained position, closest to the parameter position
  72485. * @param position world position
  72486. * @returns the closest point to position constrained by the navigation mesh
  72487. */
  72488. getClosestPoint(position: Vector3): Vector3;
  72489. /**
  72490. * Get a navigation mesh constrained position, closest to the parameter position
  72491. * @param position world position
  72492. * @param result output the closest point to position constrained by the navigation mesh
  72493. */
  72494. getClosestPointToRef(position: Vector3, result: Vector3): void;
  72495. /**
  72496. * Get a navigation mesh constrained position, within a particular radius
  72497. * @param position world position
  72498. * @param maxRadius the maximum distance to the constrained world position
  72499. * @returns the closest point to position constrained by the navigation mesh
  72500. */
  72501. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  72502. /**
  72503. * Get a navigation mesh constrained position, within a particular radius
  72504. * @param position world position
  72505. * @param maxRadius the maximum distance to the constrained world position
  72506. * @param result output the closest point to position constrained by the navigation mesh
  72507. */
  72508. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  72509. /**
  72510. * Compute the final position from a segment made of destination-position
  72511. * @param position world position
  72512. * @param destination world position
  72513. * @returns the resulting point along the navmesh
  72514. */
  72515. moveAlong(position: Vector3, destination: Vector3): Vector3;
  72516. /**
  72517. * Compute the final position from a segment made of destination-position
  72518. * @param position world position
  72519. * @param destination world position
  72520. * @param result output the resulting point along the navmesh
  72521. */
  72522. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  72523. /**
  72524. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  72525. * @param start world position
  72526. * @param end world position
  72527. * @returns array containing world position composing the path
  72528. */
  72529. computePath(start: Vector3, end: Vector3): Vector3[];
  72530. /**
  72531. * Create a new Crowd so you can add agents
  72532. * @param maxAgents the maximum agent count in the crowd
  72533. * @param maxAgentRadius the maximum radius an agent can have
  72534. * @param scene to attach the crowd to
  72535. * @returns the crowd you can add agents to
  72536. */
  72537. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  72538. /**
  72539. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  72540. * The queries will try to find a solution within those bounds
  72541. * default is (1,1,1)
  72542. * @param extent x,y,z value that define the extent around the queries point of reference
  72543. */
  72544. setDefaultQueryExtent(extent: Vector3): void;
  72545. /**
  72546. * Get the Bounding box extent specified by setDefaultQueryExtent
  72547. * @returns the box extent values
  72548. */
  72549. getDefaultQueryExtent(): Vector3;
  72550. /**
  72551. * build the navmesh from a previously saved state using getNavmeshData
  72552. * @param data the Uint8Array returned by getNavmeshData
  72553. */
  72554. buildFromNavmeshData(data: Uint8Array): void;
  72555. /**
  72556. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  72557. * @returns data the Uint8Array that can be saved and reused
  72558. */
  72559. getNavmeshData(): Uint8Array;
  72560. /**
  72561. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72562. * @param result output the box extent values
  72563. */
  72564. getDefaultQueryExtentToRef(result: Vector3): void;
  72565. /**
  72566. * Disposes
  72567. */
  72568. dispose(): void;
  72569. /**
  72570. * Creates a cylinder obstacle and add it to the navigation
  72571. * @param position world position
  72572. * @param radius cylinder radius
  72573. * @param height cylinder height
  72574. * @returns the obstacle freshly created
  72575. */
  72576. addCylinderObstacle(position: Vector3, radius: number, height: number): IObstacle;
  72577. /**
  72578. * Creates an oriented box obstacle and add it to the navigation
  72579. * @param position world position
  72580. * @param extent box size
  72581. * @param angle angle in radians of the box orientation on Y axis
  72582. * @returns the obstacle freshly created
  72583. */
  72584. addBoxObstacle(position: Vector3, extent: Vector3, angle: number): IObstacle;
  72585. /**
  72586. * Removes an obstacle created by addCylinderObstacle or addBoxObstacle
  72587. * @param obstacle obstacle to remove from the navigation
  72588. */
  72589. removeObstacle(obstacle: IObstacle): void;
  72590. /**
  72591. * If this plugin is supported
  72592. * @returns true if plugin is supported
  72593. */
  72594. isSupported(): boolean;
  72595. }
  72596. /**
  72597. * Recast detour crowd implementation
  72598. */
  72599. export class RecastJSCrowd implements ICrowd {
  72600. /**
  72601. * Recast/detour plugin
  72602. */
  72603. bjsRECASTPlugin: RecastJSPlugin;
  72604. /**
  72605. * Link to the detour crowd
  72606. */
  72607. recastCrowd: any;
  72608. /**
  72609. * One transform per agent
  72610. */
  72611. transforms: TransformNode[];
  72612. /**
  72613. * All agents created
  72614. */
  72615. agents: number[];
  72616. /**
  72617. * Link to the scene is kept to unregister the crowd from the scene
  72618. */
  72619. private _scene;
  72620. /**
  72621. * Observer for crowd updates
  72622. */
  72623. private _onBeforeAnimationsObserver;
  72624. /**
  72625. * Constructor
  72626. * @param plugin recastJS plugin
  72627. * @param maxAgents the maximum agent count in the crowd
  72628. * @param maxAgentRadius the maximum radius an agent can have
  72629. * @param scene to attach the crowd to
  72630. * @returns the crowd you can add agents to
  72631. */
  72632. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  72633. /**
  72634. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  72635. * You can attach anything to that node. The node position is updated in the scene update tick.
  72636. * @param pos world position that will be constrained by the navigation mesh
  72637. * @param parameters agent parameters
  72638. * @param transform hooked to the agent that will be update by the scene
  72639. * @returns agent index
  72640. */
  72641. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  72642. /**
  72643. * Returns the agent position in world space
  72644. * @param index agent index returned by addAgent
  72645. * @returns world space position
  72646. */
  72647. getAgentPosition(index: number): Vector3;
  72648. /**
  72649. * Returns the agent position result in world space
  72650. * @param index agent index returned by addAgent
  72651. * @param result output world space position
  72652. */
  72653. getAgentPositionToRef(index: number, result: Vector3): void;
  72654. /**
  72655. * Returns the agent velocity in world space
  72656. * @param index agent index returned by addAgent
  72657. * @returns world space velocity
  72658. */
  72659. getAgentVelocity(index: number): Vector3;
  72660. /**
  72661. * Returns the agent velocity result in world space
  72662. * @param index agent index returned by addAgent
  72663. * @param result output world space velocity
  72664. */
  72665. getAgentVelocityToRef(index: number, result: Vector3): void;
  72666. /**
  72667. * Returns the agent next target point on the path
  72668. * @param index agent index returned by addAgent
  72669. * @returns world space position
  72670. */
  72671. getAgentNextTargetPath(index: number): Vector3;
  72672. /**
  72673. * Returns the agent next target point on the path
  72674. * @param index agent index returned by addAgent
  72675. * @param result output world space position
  72676. */
  72677. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  72678. /**
  72679. * Gets the agent state
  72680. * @param index agent index returned by addAgent
  72681. * @returns agent state
  72682. */
  72683. getAgentState(index: number): number;
  72684. /**
  72685. * returns true if the agent in over an off mesh link connection
  72686. * @param index agent index returned by addAgent
  72687. * @returns true if over an off mesh link connection
  72688. */
  72689. overOffmeshConnection(index: number): boolean;
  72690. /**
  72691. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  72692. * @param index agent index returned by addAgent
  72693. * @param destination targeted world position
  72694. */
  72695. agentGoto(index: number, destination: Vector3): void;
  72696. /**
  72697. * Teleport the agent to a new position
  72698. * @param index agent index returned by addAgent
  72699. * @param destination targeted world position
  72700. */
  72701. agentTeleport(index: number, destination: Vector3): void;
  72702. /**
  72703. * Update agent parameters
  72704. * @param index agent index returned by addAgent
  72705. * @param parameters agent parameters
  72706. */
  72707. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  72708. /**
  72709. * remove a particular agent previously created
  72710. * @param index agent index returned by addAgent
  72711. */
  72712. removeAgent(index: number): void;
  72713. /**
  72714. * get the list of all agents attached to this crowd
  72715. * @returns list of agent indices
  72716. */
  72717. getAgents(): number[];
  72718. /**
  72719. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  72720. * @param deltaTime in seconds
  72721. */
  72722. update(deltaTime: number): void;
  72723. /**
  72724. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  72725. * The queries will try to find a solution within those bounds
  72726. * default is (1,1,1)
  72727. * @param extent x,y,z value that define the extent around the queries point of reference
  72728. */
  72729. setDefaultQueryExtent(extent: Vector3): void;
  72730. /**
  72731. * Get the Bounding box extent specified by setDefaultQueryExtent
  72732. * @returns the box extent values
  72733. */
  72734. getDefaultQueryExtent(): Vector3;
  72735. /**
  72736. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72737. * @param result output the box extent values
  72738. */
  72739. getDefaultQueryExtentToRef(result: Vector3): void;
  72740. /**
  72741. * Get the next corner points composing the path (max 4 points)
  72742. * @param index agent index returned by addAgent
  72743. * @returns array containing world position composing the path
  72744. */
  72745. getCorners(index: number): Vector3[];
  72746. /**
  72747. * Release all resources
  72748. */
  72749. dispose(): void;
  72750. }
  72751. }
  72752. declare module BABYLON {
  72753. /**
  72754. * Class used to enable access to IndexedDB
  72755. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  72756. */
  72757. export class Database implements IOfflineProvider {
  72758. private _callbackManifestChecked;
  72759. private _currentSceneUrl;
  72760. private _db;
  72761. private _enableSceneOffline;
  72762. private _enableTexturesOffline;
  72763. private _manifestVersionFound;
  72764. private _mustUpdateRessources;
  72765. private _hasReachedQuota;
  72766. private _isSupported;
  72767. private _idbFactory;
  72768. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  72769. private static IsUASupportingBlobStorage;
  72770. /**
  72771. * Gets a boolean indicating if Database storage is enabled (off by default)
  72772. */
  72773. static IDBStorageEnabled: boolean;
  72774. /**
  72775. * Gets a boolean indicating if scene must be saved in the database
  72776. */
  72777. get enableSceneOffline(): boolean;
  72778. /**
  72779. * Gets a boolean indicating if textures must be saved in the database
  72780. */
  72781. get enableTexturesOffline(): boolean;
  72782. /**
  72783. * Creates a new Database
  72784. * @param urlToScene defines the url to load the scene
  72785. * @param callbackManifestChecked defines the callback to use when manifest is checked
  72786. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  72787. */
  72788. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  72789. private static _ParseURL;
  72790. private static _ReturnFullUrlLocation;
  72791. private _checkManifestFile;
  72792. /**
  72793. * Open the database and make it available
  72794. * @param successCallback defines the callback to call on success
  72795. * @param errorCallback defines the callback to call on error
  72796. */
  72797. open(successCallback: () => void, errorCallback: () => void): void;
  72798. /**
  72799. * Loads an image from the database
  72800. * @param url defines the url to load from
  72801. * @param image defines the target DOM image
  72802. */
  72803. loadImage(url: string, image: HTMLImageElement): void;
  72804. private _loadImageFromDBAsync;
  72805. private _saveImageIntoDBAsync;
  72806. private _checkVersionFromDB;
  72807. private _loadVersionFromDBAsync;
  72808. private _saveVersionIntoDBAsync;
  72809. /**
  72810. * Loads a file from database
  72811. * @param url defines the URL to load from
  72812. * @param sceneLoaded defines a callback to call on success
  72813. * @param progressCallBack defines a callback to call when progress changed
  72814. * @param errorCallback defines a callback to call on error
  72815. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  72816. */
  72817. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  72818. private _loadFileAsync;
  72819. private _saveFileAsync;
  72820. /**
  72821. * Validates if xhr data is correct
  72822. * @param xhr defines the request to validate
  72823. * @param dataType defines the expected data type
  72824. * @returns true if data is correct
  72825. */
  72826. private static _ValidateXHRData;
  72827. }
  72828. }
  72829. declare module BABYLON {
  72830. /** @hidden */
  72831. export var gpuUpdateParticlesPixelShader: {
  72832. name: string;
  72833. shader: string;
  72834. };
  72835. }
  72836. declare module BABYLON {
  72837. /** @hidden */
  72838. export var gpuUpdateParticlesVertexShader: {
  72839. name: string;
  72840. shader: string;
  72841. };
  72842. }
  72843. declare module BABYLON {
  72844. /** @hidden */
  72845. export var clipPlaneFragmentDeclaration2: {
  72846. name: string;
  72847. shader: string;
  72848. };
  72849. }
  72850. declare module BABYLON {
  72851. /** @hidden */
  72852. export var gpuRenderParticlesPixelShader: {
  72853. name: string;
  72854. shader: string;
  72855. };
  72856. }
  72857. declare module BABYLON {
  72858. /** @hidden */
  72859. export var clipPlaneVertexDeclaration2: {
  72860. name: string;
  72861. shader: string;
  72862. };
  72863. }
  72864. declare module BABYLON {
  72865. /** @hidden */
  72866. export var gpuRenderParticlesVertexShader: {
  72867. name: string;
  72868. shader: string;
  72869. };
  72870. }
  72871. declare module BABYLON {
  72872. /**
  72873. * This represents a GPU particle system in Babylon
  72874. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  72875. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  72876. */
  72877. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  72878. /**
  72879. * The layer mask we are rendering the particles through.
  72880. */
  72881. layerMask: number;
  72882. private _capacity;
  72883. private _activeCount;
  72884. private _currentActiveCount;
  72885. private _accumulatedCount;
  72886. private _renderEffect;
  72887. private _updateEffect;
  72888. private _buffer0;
  72889. private _buffer1;
  72890. private _spriteBuffer;
  72891. private _updateVAO;
  72892. private _renderVAO;
  72893. private _targetIndex;
  72894. private _sourceBuffer;
  72895. private _targetBuffer;
  72896. private _currentRenderId;
  72897. private _started;
  72898. private _stopped;
  72899. private _timeDelta;
  72900. private _randomTexture;
  72901. private _randomTexture2;
  72902. private _attributesStrideSize;
  72903. private _updateEffectOptions;
  72904. private _randomTextureSize;
  72905. private _actualFrame;
  72906. private _customEffect;
  72907. private readonly _rawTextureWidth;
  72908. /**
  72909. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  72910. */
  72911. static get IsSupported(): boolean;
  72912. /**
  72913. * An event triggered when the system is disposed.
  72914. */
  72915. onDisposeObservable: Observable<IParticleSystem>;
  72916. /**
  72917. * An event triggered when the system is stopped
  72918. */
  72919. onStoppedObservable: Observable<IParticleSystem>;
  72920. /**
  72921. * Gets the maximum number of particles active at the same time.
  72922. * @returns The max number of active particles.
  72923. */
  72924. getCapacity(): number;
  72925. /**
  72926. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  72927. * to override the particles.
  72928. */
  72929. forceDepthWrite: boolean;
  72930. /**
  72931. * Gets or set the number of active particles
  72932. */
  72933. get activeParticleCount(): number;
  72934. set activeParticleCount(value: number);
  72935. private _preWarmDone;
  72936. /**
  72937. * Specifies if the particles are updated in emitter local space or world space.
  72938. */
  72939. isLocal: boolean;
  72940. /** Gets or sets a matrix to use to compute projection */
  72941. defaultProjectionMatrix: Matrix;
  72942. /**
  72943. * Is this system ready to be used/rendered
  72944. * @return true if the system is ready
  72945. */
  72946. isReady(): boolean;
  72947. /**
  72948. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72949. * @returns True if it has been started, otherwise false.
  72950. */
  72951. isStarted(): boolean;
  72952. /**
  72953. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  72954. * @returns True if it has been stopped, otherwise false.
  72955. */
  72956. isStopped(): boolean;
  72957. /**
  72958. * Gets a boolean indicating that the system is stopping
  72959. * @returns true if the system is currently stopping
  72960. */
  72961. isStopping(): boolean;
  72962. /**
  72963. * Gets the number of particles active at the same time.
  72964. * @returns The number of active particles.
  72965. */
  72966. getActiveCount(): number;
  72967. /**
  72968. * Starts the particle system and begins to emit
  72969. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  72970. */
  72971. start(delay?: number): void;
  72972. /**
  72973. * Stops the particle system.
  72974. */
  72975. stop(): void;
  72976. /**
  72977. * Remove all active particles
  72978. */
  72979. reset(): void;
  72980. /**
  72981. * Returns the string "GPUParticleSystem"
  72982. * @returns a string containing the class name
  72983. */
  72984. getClassName(): string;
  72985. /**
  72986. * Gets the custom effect used to render the particles
  72987. * @param blendMode Blend mode for which the effect should be retrieved
  72988. * @returns The effect
  72989. */
  72990. getCustomEffect(blendMode?: number): Nullable<Effect>;
  72991. /**
  72992. * Sets the custom effect used to render the particles
  72993. * @param effect The effect to set
  72994. * @param blendMode Blend mode for which the effect should be set
  72995. */
  72996. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  72997. /** @hidden */
  72998. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  72999. /**
  73000. * Observable that will be called just before the particles are drawn
  73001. */
  73002. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  73003. /**
  73004. * Gets the name of the particle vertex shader
  73005. */
  73006. get vertexShaderName(): string;
  73007. private _colorGradientsTexture;
  73008. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  73009. /**
  73010. * Adds a new color gradient
  73011. * @param gradient defines the gradient to use (between 0 and 1)
  73012. * @param color1 defines the color to affect to the specified gradient
  73013. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  73014. * @returns the current particle system
  73015. */
  73016. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  73017. private _refreshColorGradient;
  73018. /** Force the system to rebuild all gradients that need to be resync */
  73019. forceRefreshGradients(): void;
  73020. /**
  73021. * Remove a specific color gradient
  73022. * @param gradient defines the gradient to remove
  73023. * @returns the current particle system
  73024. */
  73025. removeColorGradient(gradient: number): GPUParticleSystem;
  73026. private _angularSpeedGradientsTexture;
  73027. private _sizeGradientsTexture;
  73028. private _velocityGradientsTexture;
  73029. private _limitVelocityGradientsTexture;
  73030. private _dragGradientsTexture;
  73031. private _addFactorGradient;
  73032. /**
  73033. * Adds a new size gradient
  73034. * @param gradient defines the gradient to use (between 0 and 1)
  73035. * @param factor defines the size factor to affect to the specified gradient
  73036. * @returns the current particle system
  73037. */
  73038. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  73039. /**
  73040. * Remove a specific size gradient
  73041. * @param gradient defines the gradient to remove
  73042. * @returns the current particle system
  73043. */
  73044. removeSizeGradient(gradient: number): GPUParticleSystem;
  73045. private _refreshFactorGradient;
  73046. /**
  73047. * Adds a new angular speed gradient
  73048. * @param gradient defines the gradient to use (between 0 and 1)
  73049. * @param factor defines the angular speed to affect to the specified gradient
  73050. * @returns the current particle system
  73051. */
  73052. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  73053. /**
  73054. * Remove a specific angular speed gradient
  73055. * @param gradient defines the gradient to remove
  73056. * @returns the current particle system
  73057. */
  73058. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  73059. /**
  73060. * Adds a new velocity gradient
  73061. * @param gradient defines the gradient to use (between 0 and 1)
  73062. * @param factor defines the velocity to affect to the specified gradient
  73063. * @returns the current particle system
  73064. */
  73065. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  73066. /**
  73067. * Remove a specific velocity gradient
  73068. * @param gradient defines the gradient to remove
  73069. * @returns the current particle system
  73070. */
  73071. removeVelocityGradient(gradient: number): GPUParticleSystem;
  73072. /**
  73073. * Adds a new limit velocity gradient
  73074. * @param gradient defines the gradient to use (between 0 and 1)
  73075. * @param factor defines the limit velocity value to affect to the specified gradient
  73076. * @returns the current particle system
  73077. */
  73078. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  73079. /**
  73080. * Remove a specific limit velocity gradient
  73081. * @param gradient defines the gradient to remove
  73082. * @returns the current particle system
  73083. */
  73084. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  73085. /**
  73086. * Adds a new drag gradient
  73087. * @param gradient defines the gradient to use (between 0 and 1)
  73088. * @param factor defines the drag value to affect to the specified gradient
  73089. * @returns the current particle system
  73090. */
  73091. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  73092. /**
  73093. * Remove a specific drag gradient
  73094. * @param gradient defines the gradient to remove
  73095. * @returns the current particle system
  73096. */
  73097. removeDragGradient(gradient: number): GPUParticleSystem;
  73098. /**
  73099. * Not supported by GPUParticleSystem
  73100. * @param gradient defines the gradient to use (between 0 and 1)
  73101. * @param factor defines the emit rate value to affect to the specified gradient
  73102. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73103. * @returns the current particle system
  73104. */
  73105. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73106. /**
  73107. * Not supported by GPUParticleSystem
  73108. * @param gradient defines the gradient to remove
  73109. * @returns the current particle system
  73110. */
  73111. removeEmitRateGradient(gradient: number): IParticleSystem;
  73112. /**
  73113. * Not supported by GPUParticleSystem
  73114. * @param gradient defines the gradient to use (between 0 and 1)
  73115. * @param factor defines the start size value to affect to the specified gradient
  73116. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73117. * @returns the current particle system
  73118. */
  73119. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73120. /**
  73121. * Not supported by GPUParticleSystem
  73122. * @param gradient defines the gradient to remove
  73123. * @returns the current particle system
  73124. */
  73125. removeStartSizeGradient(gradient: number): IParticleSystem;
  73126. /**
  73127. * Not supported by GPUParticleSystem
  73128. * @param gradient defines the gradient to use (between 0 and 1)
  73129. * @param min defines the color remap minimal range
  73130. * @param max defines the color remap maximal range
  73131. * @returns the current particle system
  73132. */
  73133. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73134. /**
  73135. * Not supported by GPUParticleSystem
  73136. * @param gradient defines the gradient to remove
  73137. * @returns the current particle system
  73138. */
  73139. removeColorRemapGradient(): IParticleSystem;
  73140. /**
  73141. * Not supported by GPUParticleSystem
  73142. * @param gradient defines the gradient to use (between 0 and 1)
  73143. * @param min defines the alpha remap minimal range
  73144. * @param max defines the alpha remap maximal range
  73145. * @returns the current particle system
  73146. */
  73147. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73148. /**
  73149. * Not supported by GPUParticleSystem
  73150. * @param gradient defines the gradient to remove
  73151. * @returns the current particle system
  73152. */
  73153. removeAlphaRemapGradient(): IParticleSystem;
  73154. /**
  73155. * Not supported by GPUParticleSystem
  73156. * @param gradient defines the gradient to use (between 0 and 1)
  73157. * @param color defines the color to affect to the specified gradient
  73158. * @returns the current particle system
  73159. */
  73160. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  73161. /**
  73162. * Not supported by GPUParticleSystem
  73163. * @param gradient defines the gradient to remove
  73164. * @returns the current particle system
  73165. */
  73166. removeRampGradient(): IParticleSystem;
  73167. /**
  73168. * Not supported by GPUParticleSystem
  73169. * @returns the list of ramp gradients
  73170. */
  73171. getRampGradients(): Nullable<Array<Color3Gradient>>;
  73172. /**
  73173. * Not supported by GPUParticleSystem
  73174. * Gets or sets a boolean indicating that ramp gradients must be used
  73175. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  73176. */
  73177. get useRampGradients(): boolean;
  73178. set useRampGradients(value: boolean);
  73179. /**
  73180. * Not supported by GPUParticleSystem
  73181. * @param gradient defines the gradient to use (between 0 and 1)
  73182. * @param factor defines the life time factor to affect to the specified gradient
  73183. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73184. * @returns the current particle system
  73185. */
  73186. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73187. /**
  73188. * Not supported by GPUParticleSystem
  73189. * @param gradient defines the gradient to remove
  73190. * @returns the current particle system
  73191. */
  73192. removeLifeTimeGradient(gradient: number): IParticleSystem;
  73193. /**
  73194. * Instantiates a GPU particle system.
  73195. * 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.
  73196. * @param name The name of the particle system
  73197. * @param options The options used to create the system
  73198. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  73199. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  73200. * @param customEffect a custom effect used to change the way particles are rendered by default
  73201. */
  73202. constructor(name: string, options: Partial<{
  73203. capacity: number;
  73204. randomTextureSize: number;
  73205. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  73206. protected _reset(): void;
  73207. private _createUpdateVAO;
  73208. private _createRenderVAO;
  73209. private _initialize;
  73210. /** @hidden */
  73211. _recreateUpdateEffect(): void;
  73212. private _getEffect;
  73213. /**
  73214. * Fill the defines array according to the current settings of the particle system
  73215. * @param defines Array to be updated
  73216. * @param blendMode blend mode to take into account when updating the array
  73217. */
  73218. fillDefines(defines: Array<string>, blendMode?: number): void;
  73219. /**
  73220. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  73221. * @param uniforms Uniforms array to fill
  73222. * @param attributes Attributes array to fill
  73223. * @param samplers Samplers array to fill
  73224. */
  73225. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  73226. /** @hidden */
  73227. _recreateRenderEffect(): Effect;
  73228. /**
  73229. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  73230. * @param preWarm defines if we are in the pre-warmimg phase
  73231. */
  73232. animate(preWarm?: boolean): void;
  73233. private _createFactorGradientTexture;
  73234. private _createSizeGradientTexture;
  73235. private _createAngularSpeedGradientTexture;
  73236. private _createVelocityGradientTexture;
  73237. private _createLimitVelocityGradientTexture;
  73238. private _createDragGradientTexture;
  73239. private _createColorGradientTexture;
  73240. /**
  73241. * Renders the particle system in its current state
  73242. * @param preWarm defines if the system should only update the particles but not render them
  73243. * @returns the current number of particles
  73244. */
  73245. render(preWarm?: boolean): number;
  73246. /**
  73247. * Rebuilds the particle system
  73248. */
  73249. rebuild(): void;
  73250. private _releaseBuffers;
  73251. private _releaseVAOs;
  73252. /**
  73253. * Disposes the particle system and free the associated resources
  73254. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  73255. */
  73256. dispose(disposeTexture?: boolean): void;
  73257. /**
  73258. * Clones the particle system.
  73259. * @param name The name of the cloned object
  73260. * @param newEmitter The new emitter to use
  73261. * @returns the cloned particle system
  73262. */
  73263. clone(name: string, newEmitter: any): GPUParticleSystem;
  73264. /**
  73265. * Serializes the particle system to a JSON object
  73266. * @param serializeTexture defines if the texture must be serialized as well
  73267. * @returns the JSON object
  73268. */
  73269. serialize(serializeTexture?: boolean): any;
  73270. /**
  73271. * Parses a JSON object to create a GPU particle system.
  73272. * @param parsedParticleSystem The JSON object to parse
  73273. * @param sceneOrEngine The scene or the engine to create the particle system in
  73274. * @param rootUrl The root url to use to load external dependencies like texture
  73275. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  73276. * @returns the parsed GPU particle system
  73277. */
  73278. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  73279. }
  73280. }
  73281. declare module BABYLON {
  73282. /**
  73283. * Represents a set of particle systems working together to create a specific effect
  73284. */
  73285. export class ParticleSystemSet implements IDisposable {
  73286. /**
  73287. * Gets or sets base Assets URL
  73288. */
  73289. static BaseAssetsUrl: string;
  73290. private _emitterCreationOptions;
  73291. private _emitterNode;
  73292. /**
  73293. * Gets the particle system list
  73294. */
  73295. systems: IParticleSystem[];
  73296. /**
  73297. * Gets the emitter node used with this set
  73298. */
  73299. get emitterNode(): Nullable<TransformNode>;
  73300. /**
  73301. * Creates a new emitter mesh as a sphere
  73302. * @param options defines the options used to create the sphere
  73303. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  73304. * @param scene defines the hosting scene
  73305. */
  73306. setEmitterAsSphere(options: {
  73307. diameter: number;
  73308. segments: number;
  73309. color: Color3;
  73310. }, renderingGroupId: number, scene: Scene): void;
  73311. /**
  73312. * Starts all particle systems of the set
  73313. * @param emitter defines an optional mesh to use as emitter for the particle systems
  73314. */
  73315. start(emitter?: AbstractMesh): void;
  73316. /**
  73317. * Release all associated resources
  73318. */
  73319. dispose(): void;
  73320. /**
  73321. * Serialize the set into a JSON compatible object
  73322. * @param serializeTexture defines if the texture must be serialized as well
  73323. * @returns a JSON compatible representation of the set
  73324. */
  73325. serialize(serializeTexture?: boolean): any;
  73326. /**
  73327. * Parse a new ParticleSystemSet from a serialized source
  73328. * @param data defines a JSON compatible representation of the set
  73329. * @param scene defines the hosting scene
  73330. * @param gpu defines if we want GPU particles or CPU particles
  73331. * @returns a new ParticleSystemSet
  73332. */
  73333. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  73334. }
  73335. }
  73336. declare module BABYLON {
  73337. /**
  73338. * This class is made for on one-liner static method to help creating particle system set.
  73339. */
  73340. export class ParticleHelper {
  73341. /**
  73342. * Gets or sets base Assets URL
  73343. */
  73344. static BaseAssetsUrl: string;
  73345. /** Define the Url to load snippets */
  73346. static SnippetUrl: string;
  73347. /**
  73348. * Create a default particle system that you can tweak
  73349. * @param emitter defines the emitter to use
  73350. * @param capacity defines the system capacity (default is 500 particles)
  73351. * @param scene defines the hosting scene
  73352. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  73353. * @returns the new Particle system
  73354. */
  73355. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  73356. /**
  73357. * This is the main static method (one-liner) of this helper to create different particle systems
  73358. * @param type This string represents the type to the particle system to create
  73359. * @param scene The scene where the particle system should live
  73360. * @param gpu If the system will use gpu
  73361. * @returns the ParticleSystemSet created
  73362. */
  73363. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  73364. /**
  73365. * Static function used to export a particle system to a ParticleSystemSet variable.
  73366. * Please note that the emitter shape is not exported
  73367. * @param systems defines the particle systems to export
  73368. * @returns the created particle system set
  73369. */
  73370. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  73371. /**
  73372. * Creates a particle system from a snippet saved in a remote file
  73373. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  73374. * @param url defines the url to load from
  73375. * @param scene defines the hosting scene
  73376. * @param gpu If the system will use gpu
  73377. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  73378. * @returns a promise that will resolve to the new particle system
  73379. */
  73380. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  73381. /**
  73382. * Creates a particle system from a snippet saved by the particle system editor
  73383. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  73384. * @param scene defines the hosting scene
  73385. * @param gpu If the system will use gpu
  73386. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  73387. * @returns a promise that will resolve to the new particle system
  73388. */
  73389. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  73390. }
  73391. }
  73392. declare module BABYLON {
  73393. interface Engine {
  73394. /**
  73395. * Create an effect to use with particle systems.
  73396. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  73397. * the particle system for which you want to create a custom effect in the last parameter
  73398. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  73399. * @param uniformsNames defines a list of attribute names
  73400. * @param samplers defines an array of string used to represent textures
  73401. * @param defines defines the string containing the defines to use to compile the shaders
  73402. * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails
  73403. * @param onCompiled defines a function to call when the effect creation is successful
  73404. * @param onError defines a function to call when the effect creation has failed
  73405. * @param particleSystem the particle system you want to create the effect for
  73406. * @returns the new Effect
  73407. */
  73408. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  73409. }
  73410. interface Mesh {
  73411. /**
  73412. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  73413. * @returns an array of IParticleSystem
  73414. */
  73415. getEmittedParticleSystems(): IParticleSystem[];
  73416. /**
  73417. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  73418. * @returns an array of IParticleSystem
  73419. */
  73420. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  73421. }
  73422. }
  73423. declare module BABYLON {
  73424. /** Defines the 4 color options */
  73425. export enum PointColor {
  73426. /** color value */
  73427. Color = 2,
  73428. /** uv value */
  73429. UV = 1,
  73430. /** random value */
  73431. Random = 0,
  73432. /** stated value */
  73433. Stated = 3
  73434. }
  73435. /**
  73436. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  73437. * 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.
  73438. * The PointCloudSystem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  73439. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  73440. *
  73441. * Full documentation here : TO BE ENTERED
  73442. */
  73443. export class PointsCloudSystem implements IDisposable {
  73444. /**
  73445. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  73446. * Example : var p = SPS.particles[i];
  73447. */
  73448. particles: CloudPoint[];
  73449. /**
  73450. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  73451. */
  73452. nbParticles: number;
  73453. /**
  73454. * This a counter for your own usage. It's not set by any SPS functions.
  73455. */
  73456. counter: number;
  73457. /**
  73458. * The PCS name. This name is also given to the underlying mesh.
  73459. */
  73460. name: string;
  73461. /**
  73462. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are available.
  73463. */
  73464. mesh: Mesh;
  73465. /**
  73466. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  73467. * Please read :
  73468. */
  73469. vars: any;
  73470. /**
  73471. * @hidden
  73472. */
  73473. _size: number;
  73474. private _scene;
  73475. private _promises;
  73476. private _positions;
  73477. private _indices;
  73478. private _normals;
  73479. private _colors;
  73480. private _uvs;
  73481. private _indices32;
  73482. private _positions32;
  73483. private _colors32;
  73484. private _uvs32;
  73485. private _updatable;
  73486. private _isVisibilityBoxLocked;
  73487. private _alwaysVisible;
  73488. private _groups;
  73489. private _groupCounter;
  73490. private _computeParticleColor;
  73491. private _computeParticleTexture;
  73492. private _computeParticleRotation;
  73493. private _computeBoundingBox;
  73494. private _isReady;
  73495. /**
  73496. * Creates a PCS (Points Cloud System) object
  73497. * @param name (String) is the PCS name, this will be the underlying mesh name
  73498. * @param pointSize (number) is the size for each point
  73499. * @param scene (Scene) is the scene in which the PCS is added
  73500. * @param options defines the options of the PCS e.g.
  73501. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  73502. */
  73503. constructor(name: string, pointSize: number, scene: Scene, options?: {
  73504. updatable?: boolean;
  73505. });
  73506. /**
  73507. * Builds the PCS underlying mesh. Returns a standard Mesh.
  73508. * If no points were added to the PCS, the returned mesh is just a single point.
  73509. * @returns a promise for the created mesh
  73510. */
  73511. buildMeshAsync(): Promise<Mesh>;
  73512. /**
  73513. * @hidden
  73514. */
  73515. private _buildMesh;
  73516. private _addParticle;
  73517. private _randomUnitVector;
  73518. private _getColorIndicesForCoord;
  73519. private _setPointsColorOrUV;
  73520. private _colorFromTexture;
  73521. private _calculateDensity;
  73522. /**
  73523. * Adds points to the PCS in random positions within a unit sphere
  73524. * @param nb (positive integer) the number of particles to be created from this model
  73525. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  73526. * @returns the number of groups in the system
  73527. */
  73528. addPoints(nb: number, pointFunction?: any): number;
  73529. /**
  73530. * Adds points to the PCS from the surface of the model shape
  73531. * @param mesh is any Mesh object that will be used as a surface model for the points
  73532. * @param nb (positive integer) the number of particles to be created from this model
  73533. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  73534. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  73535. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  73536. * @returns the number of groups in the system
  73537. */
  73538. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  73539. /**
  73540. * Adds points to the PCS inside the model shape
  73541. * @param mesh is any Mesh object that will be used as a surface model for the points
  73542. * @param nb (positive integer) the number of particles to be created from this model
  73543. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  73544. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  73545. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  73546. * @returns the number of groups in the system
  73547. */
  73548. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  73549. /**
  73550. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  73551. * This method calls `updateParticle()` for each particle of the SPS.
  73552. * For an animated SPS, it is usually called within the render loop.
  73553. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  73554. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  73555. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  73556. * @returns the PCS.
  73557. */
  73558. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  73559. /**
  73560. * Disposes the PCS.
  73561. */
  73562. dispose(): void;
  73563. /**
  73564. * Visibility helper : Recomputes the visible size according to the mesh bounding box
  73565. * doc :
  73566. * @returns the PCS.
  73567. */
  73568. refreshVisibleSize(): PointsCloudSystem;
  73569. /**
  73570. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  73571. * @param size the size (float) of the visibility box
  73572. * note : this doesn't lock the PCS mesh bounding box.
  73573. * doc :
  73574. */
  73575. setVisibilityBox(size: number): void;
  73576. /**
  73577. * Gets whether the PCS is always visible or not
  73578. * doc :
  73579. */
  73580. get isAlwaysVisible(): boolean;
  73581. /**
  73582. * Sets the PCS as always visible or not
  73583. * doc :
  73584. */
  73585. set isAlwaysVisible(val: boolean);
  73586. /**
  73587. * Tells to `setParticles()` to compute the particle rotations or not
  73588. * Default value : false. The PCS is faster when it's set to false
  73589. * Note : particle rotations are only applied to parent particles
  73590. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  73591. */
  73592. set computeParticleRotation(val: boolean);
  73593. /**
  73594. * Tells to `setParticles()` to compute the particle colors or not.
  73595. * Default value : true. The PCS is faster when it's set to false.
  73596. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  73597. */
  73598. set computeParticleColor(val: boolean);
  73599. set computeParticleTexture(val: boolean);
  73600. /**
  73601. * Gets if `setParticles()` computes the particle colors or not.
  73602. * Default value : false. The PCS is faster when it's set to false.
  73603. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  73604. */
  73605. get computeParticleColor(): boolean;
  73606. /**
  73607. * Gets if `setParticles()` computes the particle textures or not.
  73608. * Default value : false. The PCS is faster when it's set to false.
  73609. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  73610. */
  73611. get computeParticleTexture(): boolean;
  73612. /**
  73613. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  73614. */
  73615. set computeBoundingBox(val: boolean);
  73616. /**
  73617. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  73618. */
  73619. get computeBoundingBox(): boolean;
  73620. /**
  73621. * This function does nothing. It may be overwritten to set all the particle first values.
  73622. * The PCS doesn't call this function, you may have to call it by your own.
  73623. * doc :
  73624. */
  73625. initParticles(): void;
  73626. /**
  73627. * This function does nothing. It may be overwritten to recycle a particle
  73628. * The PCS doesn't call this function, you can to call it
  73629. * doc :
  73630. * @param particle The particle to recycle
  73631. * @returns the recycled particle
  73632. */
  73633. recycleParticle(particle: CloudPoint): CloudPoint;
  73634. /**
  73635. * Updates a particle : this function should be overwritten by the user.
  73636. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  73637. * doc :
  73638. * @example : just set a particle position or velocity and recycle conditions
  73639. * @param particle The particle to update
  73640. * @returns the updated particle
  73641. */
  73642. updateParticle(particle: CloudPoint): CloudPoint;
  73643. /**
  73644. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  73645. * This does nothing and may be overwritten by the user.
  73646. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  73647. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  73648. * @param update the boolean update value actually passed to setParticles()
  73649. */
  73650. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  73651. /**
  73652. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  73653. * This will be passed three parameters.
  73654. * This does nothing and may be overwritten by the user.
  73655. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  73656. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  73657. * @param update the boolean update value actually passed to setParticles()
  73658. */
  73659. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  73660. }
  73661. }
  73662. declare module BABYLON {
  73663. /**
  73664. * Represents one particle of a points cloud system.
  73665. */
  73666. export class CloudPoint {
  73667. /**
  73668. * particle global index
  73669. */
  73670. idx: number;
  73671. /**
  73672. * The color of the particle
  73673. */
  73674. color: Nullable<Color4>;
  73675. /**
  73676. * The world space position of the particle.
  73677. */
  73678. position: Vector3;
  73679. /**
  73680. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  73681. */
  73682. rotation: Vector3;
  73683. /**
  73684. * The world space rotation quaternion of the particle.
  73685. */
  73686. rotationQuaternion: Nullable<Quaternion>;
  73687. /**
  73688. * The uv of the particle.
  73689. */
  73690. uv: Nullable<Vector2>;
  73691. /**
  73692. * The current speed of the particle.
  73693. */
  73694. velocity: Vector3;
  73695. /**
  73696. * The pivot point in the particle local space.
  73697. */
  73698. pivot: Vector3;
  73699. /**
  73700. * Must the particle be translated from its pivot point in its local space ?
  73701. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  73702. * Default : false
  73703. */
  73704. translateFromPivot: boolean;
  73705. /**
  73706. * Index of this particle in the global "positions" array (Internal use)
  73707. * @hidden
  73708. */
  73709. _pos: number;
  73710. /**
  73711. * @hidden Index of this particle in the global "indices" array (Internal use)
  73712. */
  73713. _ind: number;
  73714. /**
  73715. * Group this particle belongs to
  73716. */
  73717. _group: PointsGroup;
  73718. /**
  73719. * Group id of this particle
  73720. */
  73721. groupId: number;
  73722. /**
  73723. * Index of the particle in its group id (Internal use)
  73724. */
  73725. idxInGroup: number;
  73726. /**
  73727. * @hidden Particle BoundingInfo object (Internal use)
  73728. */
  73729. _boundingInfo: BoundingInfo;
  73730. /**
  73731. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  73732. */
  73733. _pcs: PointsCloudSystem;
  73734. /**
  73735. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  73736. */
  73737. _stillInvisible: boolean;
  73738. /**
  73739. * @hidden Last computed particle rotation matrix
  73740. */
  73741. _rotationMatrix: number[];
  73742. /**
  73743. * Parent particle Id, if any.
  73744. * Default null.
  73745. */
  73746. parentId: Nullable<number>;
  73747. /**
  73748. * @hidden Internal global position in the PCS.
  73749. */
  73750. _globalPosition: Vector3;
  73751. /**
  73752. * Creates a Point Cloud object.
  73753. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  73754. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  73755. * @param group (PointsGroup) is the group the particle belongs to
  73756. * @param groupId (integer) is the group identifier in the PCS.
  73757. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  73758. * @param pcs defines the PCS it is associated to
  73759. */
  73760. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  73761. /**
  73762. * get point size
  73763. */
  73764. get size(): Vector3;
  73765. /**
  73766. * Set point size
  73767. */
  73768. set size(scale: Vector3);
  73769. /**
  73770. * Legacy support, changed quaternion to rotationQuaternion
  73771. */
  73772. get quaternion(): Nullable<Quaternion>;
  73773. /**
  73774. * Legacy support, changed quaternion to rotationQuaternion
  73775. */
  73776. set quaternion(q: Nullable<Quaternion>);
  73777. /**
  73778. * Returns a boolean. True if the particle intersects a mesh, else false
  73779. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  73780. * @param target is the object (point or mesh) what the intersection is computed against
  73781. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bounding sphere is used
  73782. * @returns true if it intersects
  73783. */
  73784. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  73785. /**
  73786. * get the rotation matrix of the particle
  73787. * @hidden
  73788. */
  73789. getRotationMatrix(m: Matrix): void;
  73790. }
  73791. /**
  73792. * Represents a group of points in a points cloud system
  73793. * * PCS internal tool, don't use it manually.
  73794. */
  73795. export class PointsGroup {
  73796. /**
  73797. * The group id
  73798. * @hidden
  73799. */
  73800. groupID: number;
  73801. /**
  73802. * image data for group (internal use)
  73803. * @hidden
  73804. */
  73805. _groupImageData: Nullable<ArrayBufferView>;
  73806. /**
  73807. * Image Width (internal use)
  73808. * @hidden
  73809. */
  73810. _groupImgWidth: number;
  73811. /**
  73812. * Image Height (internal use)
  73813. * @hidden
  73814. */
  73815. _groupImgHeight: number;
  73816. /**
  73817. * Custom position function (internal use)
  73818. * @hidden
  73819. */
  73820. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  73821. /**
  73822. * density per facet for surface points
  73823. * @hidden
  73824. */
  73825. _groupDensity: number[];
  73826. /**
  73827. * Only when points are colored by texture carries pointer to texture list array
  73828. * @hidden
  73829. */
  73830. _textureNb: number;
  73831. /**
  73832. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  73833. * PCS internal tool, don't use it manually.
  73834. * @hidden
  73835. */
  73836. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  73837. }
  73838. }
  73839. declare module BABYLON {
  73840. interface Scene {
  73841. /** @hidden (Backing field) */
  73842. _physicsEngine: Nullable<IPhysicsEngine>;
  73843. /** @hidden */
  73844. _physicsTimeAccumulator: number;
  73845. /**
  73846. * Gets the current physics engine
  73847. * @returns a IPhysicsEngine or null if none attached
  73848. */
  73849. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  73850. /**
  73851. * Enables physics to the current scene
  73852. * @param gravity defines the scene's gravity for the physics engine
  73853. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  73854. * @return a boolean indicating if the physics engine was initialized
  73855. */
  73856. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  73857. /**
  73858. * Disables and disposes the physics engine associated with the scene
  73859. */
  73860. disablePhysicsEngine(): void;
  73861. /**
  73862. * Gets a boolean indicating if there is an active physics engine
  73863. * @returns a boolean indicating if there is an active physics engine
  73864. */
  73865. isPhysicsEnabled(): boolean;
  73866. /**
  73867. * Deletes a physics compound impostor
  73868. * @param compound defines the compound to delete
  73869. */
  73870. deleteCompoundImpostor(compound: any): void;
  73871. /**
  73872. * An event triggered when physic simulation is about to be run
  73873. */
  73874. onBeforePhysicsObservable: Observable<Scene>;
  73875. /**
  73876. * An event triggered when physic simulation has been done
  73877. */
  73878. onAfterPhysicsObservable: Observable<Scene>;
  73879. }
  73880. interface AbstractMesh {
  73881. /** @hidden */
  73882. _physicsImpostor: Nullable<PhysicsImpostor>;
  73883. /**
  73884. * Gets or sets impostor used for physic simulation
  73885. * @see https://doc.babylonjs.com/features/physics_engine
  73886. */
  73887. physicsImpostor: Nullable<PhysicsImpostor>;
  73888. /**
  73889. * Gets the current physics impostor
  73890. * @see https://doc.babylonjs.com/features/physics_engine
  73891. * @returns a physics impostor or null
  73892. */
  73893. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  73894. /** Apply a physic impulse to the mesh
  73895. * @param force defines the force to apply
  73896. * @param contactPoint defines where to apply the force
  73897. * @returns the current mesh
  73898. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  73899. */
  73900. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  73901. /**
  73902. * Creates a physic joint between two meshes
  73903. * @param otherMesh defines the other mesh to use
  73904. * @param pivot1 defines the pivot to use on this mesh
  73905. * @param pivot2 defines the pivot to use on the other mesh
  73906. * @param options defines additional options (can be plugin dependent)
  73907. * @returns the current mesh
  73908. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  73909. */
  73910. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  73911. /** @hidden */
  73912. _disposePhysicsObserver: Nullable<Observer<Node>>;
  73913. }
  73914. /**
  73915. * Defines the physics engine scene component responsible to manage a physics engine
  73916. */
  73917. export class PhysicsEngineSceneComponent implements ISceneComponent {
  73918. /**
  73919. * The component name helpful to identify the component in the list of scene components.
  73920. */
  73921. readonly name: string;
  73922. /**
  73923. * The scene the component belongs to.
  73924. */
  73925. scene: Scene;
  73926. /**
  73927. * Creates a new instance of the component for the given scene
  73928. * @param scene Defines the scene to register the component in
  73929. */
  73930. constructor(scene: Scene);
  73931. /**
  73932. * Registers the component in a given scene
  73933. */
  73934. register(): void;
  73935. /**
  73936. * Rebuilds the elements related to this component in case of
  73937. * context lost for instance.
  73938. */
  73939. rebuild(): void;
  73940. /**
  73941. * Disposes the component and the associated resources
  73942. */
  73943. dispose(): void;
  73944. }
  73945. }
  73946. declare module BABYLON {
  73947. /**
  73948. * A helper for physics simulations
  73949. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73950. */
  73951. export class PhysicsHelper {
  73952. private _scene;
  73953. private _physicsEngine;
  73954. /**
  73955. * Initializes the Physics helper
  73956. * @param scene Babylon.js scene
  73957. */
  73958. constructor(scene: Scene);
  73959. /**
  73960. * Applies a radial explosion impulse
  73961. * @param origin the origin of the explosion
  73962. * @param radiusOrEventOptions the radius or the options of radial explosion
  73963. * @param strength the explosion strength
  73964. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73965. * @returns A physics radial explosion event, or null
  73966. */
  73967. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73968. /**
  73969. * Applies a radial explosion force
  73970. * @param origin the origin of the explosion
  73971. * @param radiusOrEventOptions the radius or the options of radial explosion
  73972. * @param strength the explosion strength
  73973. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73974. * @returns A physics radial explosion event, or null
  73975. */
  73976. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73977. /**
  73978. * Creates a gravitational field
  73979. * @param origin the origin of the explosion
  73980. * @param radiusOrEventOptions the radius or the options of radial explosion
  73981. * @param strength the explosion strength
  73982. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73983. * @returns A physics gravitational field event, or null
  73984. */
  73985. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  73986. /**
  73987. * Creates a physics updraft event
  73988. * @param origin the origin of the updraft
  73989. * @param radiusOrEventOptions the radius or the options of the updraft
  73990. * @param strength the strength of the updraft
  73991. * @param height the height of the updraft
  73992. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  73993. * @returns A physics updraft event, or null
  73994. */
  73995. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  73996. /**
  73997. * Creates a physics vortex event
  73998. * @param origin the of the vortex
  73999. * @param radiusOrEventOptions the radius or the options of the vortex
  74000. * @param strength the strength of the vortex
  74001. * @param height the height of the vortex
  74002. * @returns a Physics vortex event, or null
  74003. * A physics vortex event or null
  74004. */
  74005. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  74006. }
  74007. /**
  74008. * Represents a physics radial explosion event
  74009. */
  74010. class PhysicsRadialExplosionEvent {
  74011. private _scene;
  74012. private _options;
  74013. private _sphere;
  74014. private _dataFetched;
  74015. /**
  74016. * Initializes a radial explosion event
  74017. * @param _scene BabylonJS scene
  74018. * @param _options The options for the vortex event
  74019. */
  74020. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  74021. /**
  74022. * Returns the data related to the radial explosion event (sphere).
  74023. * @returns The radial explosion event data
  74024. */
  74025. getData(): PhysicsRadialExplosionEventData;
  74026. /**
  74027. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  74028. * @param impostor A physics imposter
  74029. * @param origin the origin of the explosion
  74030. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  74031. */
  74032. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  74033. /**
  74034. * Triggers affected impostors callbacks
  74035. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  74036. */
  74037. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  74038. /**
  74039. * Disposes the sphere.
  74040. * @param force Specifies if the sphere should be disposed by force
  74041. */
  74042. dispose(force?: boolean): void;
  74043. /*** Helpers ***/
  74044. private _prepareSphere;
  74045. private _intersectsWithSphere;
  74046. }
  74047. /**
  74048. * Represents a gravitational field event
  74049. */
  74050. class PhysicsGravitationalFieldEvent {
  74051. private _physicsHelper;
  74052. private _scene;
  74053. private _origin;
  74054. private _options;
  74055. private _tickCallback;
  74056. private _sphere;
  74057. private _dataFetched;
  74058. /**
  74059. * Initializes the physics gravitational field event
  74060. * @param _physicsHelper A physics helper
  74061. * @param _scene BabylonJS scene
  74062. * @param _origin The origin position of the gravitational field event
  74063. * @param _options The options for the vortex event
  74064. */
  74065. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  74066. /**
  74067. * Returns the data related to the gravitational field event (sphere).
  74068. * @returns A gravitational field event
  74069. */
  74070. getData(): PhysicsGravitationalFieldEventData;
  74071. /**
  74072. * Enables the gravitational field.
  74073. */
  74074. enable(): void;
  74075. /**
  74076. * Disables the gravitational field.
  74077. */
  74078. disable(): void;
  74079. /**
  74080. * Disposes the sphere.
  74081. * @param force The force to dispose from the gravitational field event
  74082. */
  74083. dispose(force?: boolean): void;
  74084. private _tick;
  74085. }
  74086. /**
  74087. * Represents a physics updraft event
  74088. */
  74089. class PhysicsUpdraftEvent {
  74090. private _scene;
  74091. private _origin;
  74092. private _options;
  74093. private _physicsEngine;
  74094. private _originTop;
  74095. private _originDirection;
  74096. private _tickCallback;
  74097. private _cylinder;
  74098. private _cylinderPosition;
  74099. private _dataFetched;
  74100. /**
  74101. * Initializes the physics updraft event
  74102. * @param _scene BabylonJS scene
  74103. * @param _origin The origin position of the updraft
  74104. * @param _options The options for the updraft event
  74105. */
  74106. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  74107. /**
  74108. * Returns the data related to the updraft event (cylinder).
  74109. * @returns A physics updraft event
  74110. */
  74111. getData(): PhysicsUpdraftEventData;
  74112. /**
  74113. * Enables the updraft.
  74114. */
  74115. enable(): void;
  74116. /**
  74117. * Disables the updraft.
  74118. */
  74119. disable(): void;
  74120. /**
  74121. * Disposes the cylinder.
  74122. * @param force Specifies if the updraft should be disposed by force
  74123. */
  74124. dispose(force?: boolean): void;
  74125. private getImpostorHitData;
  74126. private _tick;
  74127. /*** Helpers ***/
  74128. private _prepareCylinder;
  74129. private _intersectsWithCylinder;
  74130. }
  74131. /**
  74132. * Represents a physics vortex event
  74133. */
  74134. class PhysicsVortexEvent {
  74135. private _scene;
  74136. private _origin;
  74137. private _options;
  74138. private _physicsEngine;
  74139. private _originTop;
  74140. private _tickCallback;
  74141. private _cylinder;
  74142. private _cylinderPosition;
  74143. private _dataFetched;
  74144. /**
  74145. * Initializes the physics vortex event
  74146. * @param _scene The BabylonJS scene
  74147. * @param _origin The origin position of the vortex
  74148. * @param _options The options for the vortex event
  74149. */
  74150. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  74151. /**
  74152. * Returns the data related to the vortex event (cylinder).
  74153. * @returns The physics vortex event data
  74154. */
  74155. getData(): PhysicsVortexEventData;
  74156. /**
  74157. * Enables the vortex.
  74158. */
  74159. enable(): void;
  74160. /**
  74161. * Disables the cortex.
  74162. */
  74163. disable(): void;
  74164. /**
  74165. * Disposes the sphere.
  74166. * @param force
  74167. */
  74168. dispose(force?: boolean): void;
  74169. private getImpostorHitData;
  74170. private _tick;
  74171. /*** Helpers ***/
  74172. private _prepareCylinder;
  74173. private _intersectsWithCylinder;
  74174. }
  74175. /**
  74176. * Options fot the radial explosion event
  74177. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74178. */
  74179. export class PhysicsRadialExplosionEventOptions {
  74180. /**
  74181. * The radius of the sphere for the radial explosion.
  74182. */
  74183. radius: number;
  74184. /**
  74185. * The strength of the explosion.
  74186. */
  74187. strength: number;
  74188. /**
  74189. * The strength of the force in correspondence to the distance of the affected object
  74190. */
  74191. falloff: PhysicsRadialImpulseFalloff;
  74192. /**
  74193. * Sphere options for the radial explosion.
  74194. */
  74195. sphere: {
  74196. segments: number;
  74197. diameter: number;
  74198. };
  74199. /**
  74200. * Sphere options for the radial explosion.
  74201. */
  74202. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  74203. }
  74204. /**
  74205. * Options fot the updraft event
  74206. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74207. */
  74208. export class PhysicsUpdraftEventOptions {
  74209. /**
  74210. * The radius of the cylinder for the vortex
  74211. */
  74212. radius: number;
  74213. /**
  74214. * The strength of the updraft.
  74215. */
  74216. strength: number;
  74217. /**
  74218. * The height of the cylinder for the updraft.
  74219. */
  74220. height: number;
  74221. /**
  74222. * The mode for the the updraft.
  74223. */
  74224. updraftMode: PhysicsUpdraftMode;
  74225. }
  74226. /**
  74227. * Options fot the vortex event
  74228. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74229. */
  74230. export class PhysicsVortexEventOptions {
  74231. /**
  74232. * The radius of the cylinder for the vortex
  74233. */
  74234. radius: number;
  74235. /**
  74236. * The strength of the vortex.
  74237. */
  74238. strength: number;
  74239. /**
  74240. * The height of the cylinder for the vortex.
  74241. */
  74242. height: number;
  74243. /**
  74244. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  74245. */
  74246. centripetalForceThreshold: number;
  74247. /**
  74248. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the threshold.
  74249. */
  74250. centripetalForceMultiplier: number;
  74251. /**
  74252. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the threshold.
  74253. */
  74254. centrifugalForceMultiplier: number;
  74255. /**
  74256. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  74257. */
  74258. updraftForceMultiplier: number;
  74259. }
  74260. /**
  74261. * The strength of the force in correspondence to the distance of the affected object
  74262. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74263. */
  74264. export enum PhysicsRadialImpulseFalloff {
  74265. /** Defines that impulse is constant in strength across it's whole radius */
  74266. Constant = 0,
  74267. /** Defines that impulse gets weaker if it's further from the origin */
  74268. Linear = 1
  74269. }
  74270. /**
  74271. * The strength of the force in correspondence to the distance of the affected object
  74272. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74273. */
  74274. export enum PhysicsUpdraftMode {
  74275. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  74276. Center = 0,
  74277. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  74278. Perpendicular = 1
  74279. }
  74280. /**
  74281. * Interface for a physics hit data
  74282. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74283. */
  74284. export interface PhysicsHitData {
  74285. /**
  74286. * The force applied at the contact point
  74287. */
  74288. force: Vector3;
  74289. /**
  74290. * The contact point
  74291. */
  74292. contactPoint: Vector3;
  74293. /**
  74294. * The distance from the origin to the contact point
  74295. */
  74296. distanceFromOrigin: number;
  74297. }
  74298. /**
  74299. * Interface for radial explosion event data
  74300. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74301. */
  74302. export interface PhysicsRadialExplosionEventData {
  74303. /**
  74304. * A sphere used for the radial explosion event
  74305. */
  74306. sphere: Mesh;
  74307. }
  74308. /**
  74309. * Interface for gravitational field event data
  74310. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74311. */
  74312. export interface PhysicsGravitationalFieldEventData {
  74313. /**
  74314. * A sphere mesh used for the gravitational field event
  74315. */
  74316. sphere: Mesh;
  74317. }
  74318. /**
  74319. * Interface for updraft event data
  74320. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74321. */
  74322. export interface PhysicsUpdraftEventData {
  74323. /**
  74324. * A cylinder used for the updraft event
  74325. */
  74326. cylinder: Mesh;
  74327. }
  74328. /**
  74329. * Interface for vortex event data
  74330. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74331. */
  74332. export interface PhysicsVortexEventData {
  74333. /**
  74334. * A cylinder used for the vortex event
  74335. */
  74336. cylinder: Mesh;
  74337. }
  74338. /**
  74339. * Interface for an affected physics impostor
  74340. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74341. */
  74342. export interface PhysicsAffectedImpostorWithData {
  74343. /**
  74344. * The impostor affected by the effect
  74345. */
  74346. impostor: PhysicsImpostor;
  74347. /**
  74348. * The data about the hit/force from the explosion
  74349. */
  74350. hitData: PhysicsHitData;
  74351. }
  74352. }
  74353. declare module BABYLON {
  74354. /** @hidden */
  74355. export var blackAndWhitePixelShader: {
  74356. name: string;
  74357. shader: string;
  74358. };
  74359. }
  74360. declare module BABYLON {
  74361. /**
  74362. * Post process used to render in black and white
  74363. */
  74364. export class BlackAndWhitePostProcess extends PostProcess {
  74365. /**
  74366. * Linear about to convert he result to black and white (default: 1)
  74367. */
  74368. degree: number;
  74369. /**
  74370. * Gets a string identifying the name of the class
  74371. * @returns "BlackAndWhitePostProcess" string
  74372. */
  74373. getClassName(): string;
  74374. /**
  74375. * Creates a black and white post process
  74376. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  74377. * @param name The name of the effect.
  74378. * @param options The required width/height ratio to downsize to before computing the render pass.
  74379. * @param camera The camera to apply the render pass to.
  74380. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74381. * @param engine The engine which the post process will be applied. (default: current engine)
  74382. * @param reusable If the post process can be reused on the same frame. (default: false)
  74383. */
  74384. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74385. /** @hidden */
  74386. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  74387. }
  74388. }
  74389. declare module BABYLON {
  74390. /**
  74391. * This represents a set of one or more post processes in Babylon.
  74392. * A post process can be used to apply a shader to a texture after it is rendered.
  74393. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74394. */
  74395. export class PostProcessRenderEffect {
  74396. private _postProcesses;
  74397. private _getPostProcesses;
  74398. private _singleInstance;
  74399. private _cameras;
  74400. private _indicesForCamera;
  74401. /**
  74402. * Name of the effect
  74403. * @hidden
  74404. */
  74405. _name: string;
  74406. /**
  74407. * Instantiates a post process render effect.
  74408. * A post process can be used to apply a shader to a texture after it is rendered.
  74409. * @param engine The engine the effect is tied to
  74410. * @param name The name of the effect
  74411. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  74412. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  74413. */
  74414. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  74415. /**
  74416. * Checks if all the post processes in the effect are supported.
  74417. */
  74418. get isSupported(): boolean;
  74419. /**
  74420. * Updates the current state of the effect
  74421. * @hidden
  74422. */
  74423. _update(): void;
  74424. /**
  74425. * Attaches the effect on cameras
  74426. * @param cameras The camera to attach to.
  74427. * @hidden
  74428. */
  74429. _attachCameras(cameras: Camera): void;
  74430. /**
  74431. * Attaches the effect on cameras
  74432. * @param cameras The camera to attach to.
  74433. * @hidden
  74434. */
  74435. _attachCameras(cameras: Camera[]): void;
  74436. /**
  74437. * Detaches the effect on cameras
  74438. * @param cameras The camera to detach from.
  74439. * @hidden
  74440. */
  74441. _detachCameras(cameras: Camera): void;
  74442. /**
  74443. * Detaches the effect on cameras
  74444. * @param cameras The camera to detach from.
  74445. * @hidden
  74446. */
  74447. _detachCameras(cameras: Camera[]): void;
  74448. /**
  74449. * Enables the effect on given cameras
  74450. * @param cameras The camera to enable.
  74451. * @hidden
  74452. */
  74453. _enable(cameras: Camera): void;
  74454. /**
  74455. * Enables the effect on given cameras
  74456. * @param cameras The camera to enable.
  74457. * @hidden
  74458. */
  74459. _enable(cameras: Nullable<Camera[]>): void;
  74460. /**
  74461. * Disables the effect on the given cameras
  74462. * @param cameras The camera to disable.
  74463. * @hidden
  74464. */
  74465. _disable(cameras: Camera): void;
  74466. /**
  74467. * Disables the effect on the given cameras
  74468. * @param cameras The camera to disable.
  74469. * @hidden
  74470. */
  74471. _disable(cameras: Nullable<Camera[]>): void;
  74472. /**
  74473. * Gets a list of the post processes contained in the effect.
  74474. * @param camera The camera to get the post processes on.
  74475. * @returns The list of the post processes in the effect.
  74476. */
  74477. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  74478. }
  74479. }
  74480. declare module BABYLON {
  74481. /** @hidden */
  74482. export var extractHighlightsPixelShader: {
  74483. name: string;
  74484. shader: string;
  74485. };
  74486. }
  74487. declare module BABYLON {
  74488. /**
  74489. * 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.
  74490. */
  74491. export class ExtractHighlightsPostProcess extends PostProcess {
  74492. /**
  74493. * The luminance threshold, pixels below this value will be set to black.
  74494. */
  74495. threshold: number;
  74496. /** @hidden */
  74497. _exposure: number;
  74498. /**
  74499. * Post process which has the input texture to be used when performing highlight extraction
  74500. * @hidden
  74501. */
  74502. _inputPostProcess: Nullable<PostProcess>;
  74503. /**
  74504. * Gets a string identifying the name of the class
  74505. * @returns "ExtractHighlightsPostProcess" string
  74506. */
  74507. getClassName(): string;
  74508. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74509. }
  74510. }
  74511. declare module BABYLON {
  74512. /** @hidden */
  74513. export var bloomMergePixelShader: {
  74514. name: string;
  74515. shader: string;
  74516. };
  74517. }
  74518. declare module BABYLON {
  74519. /**
  74520. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  74521. */
  74522. export class BloomMergePostProcess extends PostProcess {
  74523. /** Weight of the bloom to be added to the original input. */
  74524. weight: number;
  74525. /**
  74526. * Gets a string identifying the name of the class
  74527. * @returns "BloomMergePostProcess" string
  74528. */
  74529. getClassName(): string;
  74530. /**
  74531. * Creates a new instance of @see BloomMergePostProcess
  74532. * @param name The name of the effect.
  74533. * @param originalFromInput Post process which's input will be used for the merge.
  74534. * @param blurred Blurred highlights post process which's output will be used.
  74535. * @param weight Weight of the bloom to be added to the original input.
  74536. * @param options The required width/height ratio to downsize to before computing the render pass.
  74537. * @param camera The camera to apply the render pass to.
  74538. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74539. * @param engine The engine which the post process will be applied. (default: current engine)
  74540. * @param reusable If the post process can be reused on the same frame. (default: false)
  74541. * @param textureType Type of textures used when performing the post process. (default: 0)
  74542. * @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)
  74543. */
  74544. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  74545. /** Weight of the bloom to be added to the original input. */
  74546. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74547. }
  74548. }
  74549. declare module BABYLON {
  74550. /**
  74551. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  74552. */
  74553. export class BloomEffect extends PostProcessRenderEffect {
  74554. private bloomScale;
  74555. /**
  74556. * @hidden Internal
  74557. */
  74558. _effects: Array<PostProcess>;
  74559. /**
  74560. * @hidden Internal
  74561. */
  74562. _downscale: ExtractHighlightsPostProcess;
  74563. private _blurX;
  74564. private _blurY;
  74565. private _merge;
  74566. /**
  74567. * The luminance threshold to find bright areas of the image to bloom.
  74568. */
  74569. get threshold(): number;
  74570. set threshold(value: number);
  74571. /**
  74572. * The strength of the bloom.
  74573. */
  74574. get weight(): number;
  74575. set weight(value: number);
  74576. /**
  74577. * Specifies the size of the bloom blur kernel, relative to the final output size
  74578. */
  74579. get kernel(): number;
  74580. set kernel(value: number);
  74581. /**
  74582. * Creates a new instance of @see BloomEffect
  74583. * @param scene The scene the effect belongs to.
  74584. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  74585. * @param bloomKernel The size of the kernel to be used when applying the blur.
  74586. * @param bloomWeight The the strength of bloom.
  74587. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74588. * @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)
  74589. */
  74590. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  74591. /**
  74592. * Disposes each of the internal effects for a given camera.
  74593. * @param camera The camera to dispose the effect on.
  74594. */
  74595. disposeEffects(camera: Camera): void;
  74596. /**
  74597. * @hidden Internal
  74598. */
  74599. _updateEffects(): void;
  74600. /**
  74601. * Internal
  74602. * @returns if all the contained post processes are ready.
  74603. * @hidden
  74604. */
  74605. _isReady(): boolean;
  74606. }
  74607. }
  74608. declare module BABYLON {
  74609. /** @hidden */
  74610. export var chromaticAberrationPixelShader: {
  74611. name: string;
  74612. shader: string;
  74613. };
  74614. }
  74615. declare module BABYLON {
  74616. /**
  74617. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  74618. */
  74619. export class ChromaticAberrationPostProcess extends PostProcess {
  74620. /**
  74621. * The amount of separation of rgb channels (default: 30)
  74622. */
  74623. aberrationAmount: number;
  74624. /**
  74625. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  74626. */
  74627. radialIntensity: number;
  74628. /**
  74629. * 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))
  74630. */
  74631. direction: Vector2;
  74632. /**
  74633. * 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))
  74634. */
  74635. centerPosition: Vector2;
  74636. /** The width of the screen to apply the effect on */
  74637. screenWidth: number;
  74638. /** The height of the screen to apply the effect on */
  74639. screenHeight: number;
  74640. /**
  74641. * Gets a string identifying the name of the class
  74642. * @returns "ChromaticAberrationPostProcess" string
  74643. */
  74644. getClassName(): string;
  74645. /**
  74646. * Creates a new instance ChromaticAberrationPostProcess
  74647. * @param name The name of the effect.
  74648. * @param screenWidth The width of the screen to apply the effect on.
  74649. * @param screenHeight The height of the screen to apply the effect on.
  74650. * @param options The required width/height ratio to downsize to before computing the render pass.
  74651. * @param camera The camera to apply the render pass to.
  74652. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74653. * @param engine The engine which the post process will be applied. (default: current engine)
  74654. * @param reusable If the post process can be reused on the same frame. (default: false)
  74655. * @param textureType Type of textures used when performing the post process. (default: 0)
  74656. * @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)
  74657. */
  74658. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74659. /** @hidden */
  74660. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  74661. }
  74662. }
  74663. declare module BABYLON {
  74664. /** @hidden */
  74665. export var circleOfConfusionPixelShader: {
  74666. name: string;
  74667. shader: string;
  74668. };
  74669. }
  74670. declare module BABYLON {
  74671. /**
  74672. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  74673. */
  74674. export class CircleOfConfusionPostProcess extends PostProcess {
  74675. /**
  74676. * 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.
  74677. */
  74678. lensSize: number;
  74679. /**
  74680. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74681. */
  74682. fStop: number;
  74683. /**
  74684. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74685. */
  74686. focusDistance: number;
  74687. /**
  74688. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  74689. */
  74690. focalLength: number;
  74691. /**
  74692. * Gets a string identifying the name of the class
  74693. * @returns "CircleOfConfusionPostProcess" string
  74694. */
  74695. getClassName(): string;
  74696. private _depthTexture;
  74697. /**
  74698. * Creates a new instance CircleOfConfusionPostProcess
  74699. * @param name The name of the effect.
  74700. * @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.
  74701. * @param options The required width/height ratio to downsize to before computing the render pass.
  74702. * @param camera The camera to apply the render pass to.
  74703. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74704. * @param engine The engine which the post process will be applied. (default: current engine)
  74705. * @param reusable If the post process can be reused on the same frame. (default: false)
  74706. * @param textureType Type of textures used when performing the post process. (default: 0)
  74707. * @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)
  74708. */
  74709. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74710. /**
  74711. * 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.
  74712. */
  74713. set depthTexture(value: RenderTargetTexture);
  74714. }
  74715. }
  74716. declare module BABYLON {
  74717. /** @hidden */
  74718. export var colorCorrectionPixelShader: {
  74719. name: string;
  74720. shader: string;
  74721. };
  74722. }
  74723. declare module BABYLON {
  74724. /**
  74725. *
  74726. * This post-process allows the modification of rendered colors by using
  74727. * a 'look-up table' (LUT). This effect is also called Color Grading.
  74728. *
  74729. * The object needs to be provided an url to a texture containing the color
  74730. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  74731. * Use an image editing software to tweak the LUT to match your needs.
  74732. *
  74733. * For an example of a color LUT, see here:
  74734. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  74735. * For explanations on color grading, see here:
  74736. * @see http://udn.epicgames.com/Three/ColorGrading.html
  74737. *
  74738. */
  74739. export class ColorCorrectionPostProcess extends PostProcess {
  74740. private _colorTableTexture;
  74741. /**
  74742. * Gets the color table url used to create the LUT texture
  74743. */
  74744. colorTableUrl: string;
  74745. /**
  74746. * Gets a string identifying the name of the class
  74747. * @returns "ColorCorrectionPostProcess" string
  74748. */
  74749. getClassName(): string;
  74750. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74751. /** @hidden */
  74752. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  74753. }
  74754. }
  74755. declare module BABYLON {
  74756. /** @hidden */
  74757. export var convolutionPixelShader: {
  74758. name: string;
  74759. shader: string;
  74760. };
  74761. }
  74762. declare module BABYLON {
  74763. /**
  74764. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  74765. * input texture to perform effects such as edge detection or sharpening
  74766. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74767. */
  74768. export class ConvolutionPostProcess extends PostProcess {
  74769. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  74770. kernel: number[];
  74771. /**
  74772. * Gets a string identifying the name of the class
  74773. * @returns "ConvolutionPostProcess" string
  74774. */
  74775. getClassName(): string;
  74776. /**
  74777. * Creates a new instance ConvolutionPostProcess
  74778. * @param name The name of the effect.
  74779. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  74780. * @param options The required width/height ratio to downsize to before computing the render pass.
  74781. * @param camera The camera to apply the render pass to.
  74782. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74783. * @param engine The engine which the post process will be applied. (default: current engine)
  74784. * @param reusable If the post process can be reused on the same frame. (default: false)
  74785. * @param textureType Type of textures used when performing the post process. (default: 0)
  74786. */
  74787. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74788. /** @hidden */
  74789. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  74790. /**
  74791. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74792. */
  74793. static EdgeDetect0Kernel: number[];
  74794. /**
  74795. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74796. */
  74797. static EdgeDetect1Kernel: number[];
  74798. /**
  74799. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74800. */
  74801. static EdgeDetect2Kernel: number[];
  74802. /**
  74803. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74804. */
  74805. static SharpenKernel: number[];
  74806. /**
  74807. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74808. */
  74809. static EmbossKernel: number[];
  74810. /**
  74811. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74812. */
  74813. static GaussianKernel: number[];
  74814. }
  74815. }
  74816. declare module BABYLON {
  74817. /**
  74818. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  74819. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  74820. * based on samples that have a large difference in distance than the center pixel.
  74821. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  74822. */
  74823. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  74824. /**
  74825. * The direction the blur should be applied
  74826. */
  74827. direction: Vector2;
  74828. /**
  74829. * Gets a string identifying the name of the class
  74830. * @returns "DepthOfFieldBlurPostProcess" string
  74831. */
  74832. getClassName(): string;
  74833. /**
  74834. * Creates a new instance CircleOfConfusionPostProcess
  74835. * @param name The name of the effect.
  74836. * @param scene The scene the effect belongs to.
  74837. * @param direction The direction the blur should be applied.
  74838. * @param kernel The size of the kernel used to blur.
  74839. * @param options The required width/height ratio to downsize to before computing the render pass.
  74840. * @param camera The camera to apply the render pass to.
  74841. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring across edges
  74842. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  74843. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74844. * @param engine The engine which the post process will be applied. (default: current engine)
  74845. * @param reusable If the post process can be reused on the same frame. (default: false)
  74846. * @param textureType Type of textures used when performing the post process. (default: 0)
  74847. * @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)
  74848. */
  74849. 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);
  74850. }
  74851. }
  74852. declare module BABYLON {
  74853. /** @hidden */
  74854. export var depthOfFieldMergePixelShader: {
  74855. name: string;
  74856. shader: string;
  74857. };
  74858. }
  74859. declare module BABYLON {
  74860. /**
  74861. * Options to be set when merging outputs from the default pipeline.
  74862. */
  74863. export class DepthOfFieldMergePostProcessOptions {
  74864. /**
  74865. * The original image to merge on top of
  74866. */
  74867. originalFromInput: PostProcess;
  74868. /**
  74869. * Parameters to perform the merge of the depth of field effect
  74870. */
  74871. depthOfField?: {
  74872. circleOfConfusion: PostProcess;
  74873. blurSteps: Array<PostProcess>;
  74874. };
  74875. /**
  74876. * Parameters to perform the merge of bloom effect
  74877. */
  74878. bloom?: {
  74879. blurred: PostProcess;
  74880. weight: number;
  74881. };
  74882. }
  74883. /**
  74884. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  74885. */
  74886. export class DepthOfFieldMergePostProcess extends PostProcess {
  74887. private blurSteps;
  74888. /**
  74889. * Gets a string identifying the name of the class
  74890. * @returns "DepthOfFieldMergePostProcess" string
  74891. */
  74892. getClassName(): string;
  74893. /**
  74894. * Creates a new instance of DepthOfFieldMergePostProcess
  74895. * @param name The name of the effect.
  74896. * @param originalFromInput Post process which's input will be used for the merge.
  74897. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  74898. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  74899. * @param options The required width/height ratio to downsize to before computing the render pass.
  74900. * @param camera The camera to apply the render pass to.
  74901. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74902. * @param engine The engine which the post process will be applied. (default: current engine)
  74903. * @param reusable If the post process can be reused on the same frame. (default: false)
  74904. * @param textureType Type of textures used when performing the post process. (default: 0)
  74905. * @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)
  74906. */
  74907. 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);
  74908. /**
  74909. * Updates the effect with the current post process compile time values and recompiles the shader.
  74910. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  74911. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  74912. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  74913. * @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
  74914. * @param onCompiled Called when the shader has been compiled.
  74915. * @param onError Called if there is an error when compiling a shader.
  74916. */
  74917. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  74918. }
  74919. }
  74920. declare module BABYLON {
  74921. /**
  74922. * Specifies the level of max blur that should be applied when using the depth of field effect
  74923. */
  74924. export enum DepthOfFieldEffectBlurLevel {
  74925. /**
  74926. * Subtle blur
  74927. */
  74928. Low = 0,
  74929. /**
  74930. * Medium blur
  74931. */
  74932. Medium = 1,
  74933. /**
  74934. * Large blur
  74935. */
  74936. High = 2
  74937. }
  74938. /**
  74939. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  74940. */
  74941. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  74942. private _circleOfConfusion;
  74943. /**
  74944. * @hidden Internal, blurs from high to low
  74945. */
  74946. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  74947. private _depthOfFieldBlurY;
  74948. private _dofMerge;
  74949. /**
  74950. * @hidden Internal post processes in depth of field effect
  74951. */
  74952. _effects: Array<PostProcess>;
  74953. /**
  74954. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  74955. */
  74956. set focalLength(value: number);
  74957. get focalLength(): number;
  74958. /**
  74959. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74960. */
  74961. set fStop(value: number);
  74962. get fStop(): number;
  74963. /**
  74964. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74965. */
  74966. set focusDistance(value: number);
  74967. get focusDistance(): number;
  74968. /**
  74969. * 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.
  74970. */
  74971. set lensSize(value: number);
  74972. get lensSize(): number;
  74973. /**
  74974. * Creates a new instance DepthOfFieldEffect
  74975. * @param scene The scene the effect belongs to.
  74976. * @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.
  74977. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74978. * @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)
  74979. */
  74980. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  74981. /**
  74982. * Get the current class name of the current effect
  74983. * @returns "DepthOfFieldEffect"
  74984. */
  74985. getClassName(): string;
  74986. /**
  74987. * 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.
  74988. */
  74989. set depthTexture(value: RenderTargetTexture);
  74990. /**
  74991. * Disposes each of the internal effects for a given camera.
  74992. * @param camera The camera to dispose the effect on.
  74993. */
  74994. disposeEffects(camera: Camera): void;
  74995. /**
  74996. * @hidden Internal
  74997. */
  74998. _updateEffects(): void;
  74999. /**
  75000. * Internal
  75001. * @returns if all the contained post processes are ready.
  75002. * @hidden
  75003. */
  75004. _isReady(): boolean;
  75005. }
  75006. }
  75007. declare module BABYLON {
  75008. /** @hidden */
  75009. export var displayPassPixelShader: {
  75010. name: string;
  75011. shader: string;
  75012. };
  75013. }
  75014. declare module BABYLON {
  75015. /**
  75016. * DisplayPassPostProcess which produces an output the same as it's input
  75017. */
  75018. export class DisplayPassPostProcess extends PostProcess {
  75019. /**
  75020. * Gets a string identifying the name of the class
  75021. * @returns "DisplayPassPostProcess" string
  75022. */
  75023. getClassName(): string;
  75024. /**
  75025. * Creates the DisplayPassPostProcess
  75026. * @param name The name of the effect.
  75027. * @param options The required width/height ratio to downsize to before computing the render pass.
  75028. * @param camera The camera to apply the render pass to.
  75029. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75030. * @param engine The engine which the post process will be applied. (default: current engine)
  75031. * @param reusable If the post process can be reused on the same frame. (default: false)
  75032. */
  75033. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75034. /** @hidden */
  75035. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  75036. }
  75037. }
  75038. declare module BABYLON {
  75039. /** @hidden */
  75040. export var filterPixelShader: {
  75041. name: string;
  75042. shader: string;
  75043. };
  75044. }
  75045. declare module BABYLON {
  75046. /**
  75047. * Applies a kernel filter to the image
  75048. */
  75049. export class FilterPostProcess extends PostProcess {
  75050. /** The matrix to be applied to the image */
  75051. kernelMatrix: Matrix;
  75052. /**
  75053. * Gets a string identifying the name of the class
  75054. * @returns "FilterPostProcess" string
  75055. */
  75056. getClassName(): string;
  75057. /**
  75058. *
  75059. * @param name The name of the effect.
  75060. * @param kernelMatrix The matrix to be applied to the image
  75061. * @param options The required width/height ratio to downsize to before computing the render pass.
  75062. * @param camera The camera to apply the render pass to.
  75063. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75064. * @param engine The engine which the post process will be applied. (default: current engine)
  75065. * @param reusable If the post process can be reused on the same frame. (default: false)
  75066. */
  75067. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75068. /** @hidden */
  75069. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  75070. }
  75071. }
  75072. declare module BABYLON {
  75073. /** @hidden */
  75074. export var fxaaPixelShader: {
  75075. name: string;
  75076. shader: string;
  75077. };
  75078. }
  75079. declare module BABYLON {
  75080. /** @hidden */
  75081. export var fxaaVertexShader: {
  75082. name: string;
  75083. shader: string;
  75084. };
  75085. }
  75086. declare module BABYLON {
  75087. /**
  75088. * Fxaa post process
  75089. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  75090. */
  75091. export class FxaaPostProcess extends PostProcess {
  75092. /**
  75093. * Gets a string identifying the name of the class
  75094. * @returns "FxaaPostProcess" string
  75095. */
  75096. getClassName(): string;
  75097. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  75098. private _getDefines;
  75099. /** @hidden */
  75100. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  75101. }
  75102. }
  75103. declare module BABYLON {
  75104. /** @hidden */
  75105. export var grainPixelShader: {
  75106. name: string;
  75107. shader: string;
  75108. };
  75109. }
  75110. declare module BABYLON {
  75111. /**
  75112. * The GrainPostProcess adds noise to the image at mid luminance levels
  75113. */
  75114. export class GrainPostProcess extends PostProcess {
  75115. /**
  75116. * The intensity of the grain added (default: 30)
  75117. */
  75118. intensity: number;
  75119. /**
  75120. * If the grain should be randomized on every frame
  75121. */
  75122. animated: boolean;
  75123. /**
  75124. * Gets a string identifying the name of the class
  75125. * @returns "GrainPostProcess" string
  75126. */
  75127. getClassName(): string;
  75128. /**
  75129. * Creates a new instance of @see GrainPostProcess
  75130. * @param name The name of the effect.
  75131. * @param options The required width/height ratio to downsize to before computing the render pass.
  75132. * @param camera The camera to apply the render pass to.
  75133. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75134. * @param engine The engine which the post process will be applied. (default: current engine)
  75135. * @param reusable If the post process can be reused on the same frame. (default: false)
  75136. * @param textureType Type of textures used when performing the post process. (default: 0)
  75137. * @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)
  75138. */
  75139. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75140. /** @hidden */
  75141. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  75142. }
  75143. }
  75144. declare module BABYLON {
  75145. /** @hidden */
  75146. export var highlightsPixelShader: {
  75147. name: string;
  75148. shader: string;
  75149. };
  75150. }
  75151. declare module BABYLON {
  75152. /**
  75153. * Extracts highlights from the image
  75154. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  75155. */
  75156. export class HighlightsPostProcess extends PostProcess {
  75157. /**
  75158. * Gets a string identifying the name of the class
  75159. * @returns "HighlightsPostProcess" string
  75160. */
  75161. getClassName(): string;
  75162. /**
  75163. * Extracts highlights from the image
  75164. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  75165. * @param name The name of the effect.
  75166. * @param options The required width/height ratio to downsize to before computing the render pass.
  75167. * @param camera The camera to apply the render pass to.
  75168. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75169. * @param engine The engine which the post process will be applied. (default: current engine)
  75170. * @param reusable If the post process can be reused on the same frame. (default: false)
  75171. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  75172. */
  75173. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  75174. }
  75175. }
  75176. declare module BABYLON {
  75177. /**
  75178. * Contains all parameters needed for the prepass to perform
  75179. * motion blur
  75180. */
  75181. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  75182. /**
  75183. * Is motion blur enabled
  75184. */
  75185. enabled: boolean;
  75186. /**
  75187. * Name of the configuration
  75188. */
  75189. name: string;
  75190. /**
  75191. * Textures that should be present in the MRT for this effect to work
  75192. */
  75193. readonly texturesRequired: number[];
  75194. }
  75195. }
  75196. declare module BABYLON {
  75197. interface Scene {
  75198. /** @hidden (Backing field) */
  75199. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  75200. /**
  75201. * Gets or Sets the current geometry buffer associated to the scene.
  75202. */
  75203. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  75204. /**
  75205. * Enables a GeometryBufferRender and associates it with the scene
  75206. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  75207. * @returns the GeometryBufferRenderer
  75208. */
  75209. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  75210. /**
  75211. * Disables the GeometryBufferRender associated with the scene
  75212. */
  75213. disableGeometryBufferRenderer(): void;
  75214. }
  75215. /**
  75216. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  75217. * in several rendering techniques.
  75218. */
  75219. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  75220. /**
  75221. * The component name helpful to identify the component in the list of scene components.
  75222. */
  75223. readonly name: string;
  75224. /**
  75225. * The scene the component belongs to.
  75226. */
  75227. scene: Scene;
  75228. /**
  75229. * Creates a new instance of the component for the given scene
  75230. * @param scene Defines the scene to register the component in
  75231. */
  75232. constructor(scene: Scene);
  75233. /**
  75234. * Registers the component in a given scene
  75235. */
  75236. register(): void;
  75237. /**
  75238. * Rebuilds the elements related to this component in case of
  75239. * context lost for instance.
  75240. */
  75241. rebuild(): void;
  75242. /**
  75243. * Disposes the component and the associated resources
  75244. */
  75245. dispose(): void;
  75246. private _gatherRenderTargets;
  75247. }
  75248. }
  75249. declare module BABYLON {
  75250. /** @hidden */
  75251. export var motionBlurPixelShader: {
  75252. name: string;
  75253. shader: string;
  75254. };
  75255. }
  75256. declare module BABYLON {
  75257. /**
  75258. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  75259. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  75260. * As an example, all you have to do is to create the post-process:
  75261. * var mb = new BABYLON.MotionBlurPostProcess(
  75262. * 'mb', // The name of the effect.
  75263. * scene, // The scene containing the objects to blur according to their velocity.
  75264. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  75265. * camera // The camera to apply the render pass to.
  75266. * );
  75267. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  75268. */
  75269. export class MotionBlurPostProcess extends PostProcess {
  75270. /**
  75271. * Defines how much the image is blurred by the movement. Default value is equal to 1
  75272. */
  75273. motionStrength: number;
  75274. /**
  75275. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  75276. */
  75277. get motionBlurSamples(): number;
  75278. /**
  75279. * Sets the number of iterations to be used for motion blur quality
  75280. */
  75281. set motionBlurSamples(samples: number);
  75282. private _motionBlurSamples;
  75283. /**
  75284. * Gets whether or not the motion blur post-process is in object based mode.
  75285. */
  75286. get isObjectBased(): boolean;
  75287. /**
  75288. * Sets whether or not the motion blur post-process is in object based mode.
  75289. */
  75290. set isObjectBased(value: boolean);
  75291. private _isObjectBased;
  75292. private _forceGeometryBuffer;
  75293. private _geometryBufferRenderer;
  75294. private _prePassRenderer;
  75295. private _invViewProjection;
  75296. private _previousViewProjection;
  75297. /**
  75298. * Gets a string identifying the name of the class
  75299. * @returns "MotionBlurPostProcess" string
  75300. */
  75301. getClassName(): string;
  75302. /**
  75303. * Creates a new instance MotionBlurPostProcess
  75304. * @param name The name of the effect.
  75305. * @param scene The scene containing the objects to blur according to their velocity.
  75306. * @param options The required width/height ratio to downsize to before computing the render pass.
  75307. * @param camera The camera to apply the render pass to.
  75308. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75309. * @param engine The engine which the post process will be applied. (default: current engine)
  75310. * @param reusable If the post process can be reused on the same frame. (default: false)
  75311. * @param textureType Type of textures used when performing the post process. (default: 0)
  75312. * @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)
  75313. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  75314. */
  75315. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  75316. /**
  75317. * Excludes the given skinned mesh from computing bones velocities.
  75318. * 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.
  75319. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  75320. */
  75321. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  75322. /**
  75323. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  75324. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  75325. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  75326. */
  75327. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  75328. /**
  75329. * Disposes the post process.
  75330. * @param camera The camera to dispose the post process on.
  75331. */
  75332. dispose(camera?: Camera): void;
  75333. /**
  75334. * Called on the mode changed (object based or screen based).
  75335. */
  75336. private _applyMode;
  75337. /**
  75338. * Called on the effect is applied when the motion blur post-process is in object based mode.
  75339. */
  75340. private _onApplyObjectBased;
  75341. /**
  75342. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  75343. */
  75344. private _onApplyScreenBased;
  75345. /**
  75346. * Called on the effect must be updated (changed mode, samples count, etc.).
  75347. */
  75348. private _updateEffect;
  75349. /** @hidden */
  75350. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  75351. }
  75352. }
  75353. declare module BABYLON {
  75354. /** @hidden */
  75355. export var refractionPixelShader: {
  75356. name: string;
  75357. shader: string;
  75358. };
  75359. }
  75360. declare module BABYLON {
  75361. /**
  75362. * Post process which applies a refraction texture
  75363. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  75364. */
  75365. export class RefractionPostProcess extends PostProcess {
  75366. private _refTexture;
  75367. private _ownRefractionTexture;
  75368. /** the base color of the refraction (used to taint the rendering) */
  75369. color: Color3;
  75370. /** simulated refraction depth */
  75371. depth: number;
  75372. /** the coefficient of the base color (0 to remove base color tainting) */
  75373. colorLevel: number;
  75374. /** Gets the url used to load the refraction texture */
  75375. refractionTextureUrl: string;
  75376. /**
  75377. * Gets or sets the refraction texture
  75378. * Please note that you are responsible for disposing the texture if you set it manually
  75379. */
  75380. get refractionTexture(): Texture;
  75381. set refractionTexture(value: Texture);
  75382. /**
  75383. * Gets a string identifying the name of the class
  75384. * @returns "RefractionPostProcess" string
  75385. */
  75386. getClassName(): string;
  75387. /**
  75388. * Initializes the RefractionPostProcess
  75389. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  75390. * @param name The name of the effect.
  75391. * @param refractionTextureUrl Url of the refraction texture to use
  75392. * @param color the base color of the refraction (used to taint the rendering)
  75393. * @param depth simulated refraction depth
  75394. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  75395. * @param camera The camera to apply the render pass to.
  75396. * @param options The required width/height ratio to downsize to before computing the render pass.
  75397. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75398. * @param engine The engine which the post process will be applied. (default: current engine)
  75399. * @param reusable If the post process can be reused on the same frame. (default: false)
  75400. */
  75401. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75402. /**
  75403. * Disposes of the post process
  75404. * @param camera Camera to dispose post process on
  75405. */
  75406. dispose(camera: Camera): void;
  75407. /** @hidden */
  75408. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  75409. }
  75410. }
  75411. declare module BABYLON {
  75412. /** @hidden */
  75413. export var sharpenPixelShader: {
  75414. name: string;
  75415. shader: string;
  75416. };
  75417. }
  75418. declare module BABYLON {
  75419. /**
  75420. * The SharpenPostProcess applies a sharpen kernel to every pixel
  75421. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  75422. */
  75423. export class SharpenPostProcess extends PostProcess {
  75424. /**
  75425. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  75426. */
  75427. colorAmount: number;
  75428. /**
  75429. * How much sharpness should be applied (default: 0.3)
  75430. */
  75431. edgeAmount: number;
  75432. /**
  75433. * Gets a string identifying the name of the class
  75434. * @returns "SharpenPostProcess" string
  75435. */
  75436. getClassName(): string;
  75437. /**
  75438. * Creates a new instance ConvolutionPostProcess
  75439. * @param name The name of the effect.
  75440. * @param options The required width/height ratio to downsize to before computing the render pass.
  75441. * @param camera The camera to apply the render pass to.
  75442. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75443. * @param engine The engine which the post process will be applied. (default: current engine)
  75444. * @param reusable If the post process can be reused on the same frame. (default: false)
  75445. * @param textureType Type of textures used when performing the post process. (default: 0)
  75446. * @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)
  75447. */
  75448. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75449. /** @hidden */
  75450. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  75451. }
  75452. }
  75453. declare module BABYLON {
  75454. /**
  75455. * PostProcessRenderPipeline
  75456. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75457. */
  75458. export class PostProcessRenderPipeline {
  75459. private engine;
  75460. private _renderEffects;
  75461. private _renderEffectsForIsolatedPass;
  75462. /**
  75463. * List of inspectable custom properties (used by the Inspector)
  75464. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  75465. */
  75466. inspectableCustomProperties: IInspectable[];
  75467. /**
  75468. * @hidden
  75469. */
  75470. protected _cameras: Camera[];
  75471. /** @hidden */
  75472. _name: string;
  75473. /**
  75474. * Gets pipeline name
  75475. */
  75476. get name(): string;
  75477. /** Gets the list of attached cameras */
  75478. get cameras(): Camera[];
  75479. /**
  75480. * Initializes a PostProcessRenderPipeline
  75481. * @param engine engine to add the pipeline to
  75482. * @param name name of the pipeline
  75483. */
  75484. constructor(engine: Engine, name: string);
  75485. /**
  75486. * Gets the class name
  75487. * @returns "PostProcessRenderPipeline"
  75488. */
  75489. getClassName(): string;
  75490. /**
  75491. * If all the render effects in the pipeline are supported
  75492. */
  75493. get isSupported(): boolean;
  75494. /**
  75495. * Adds an effect to the pipeline
  75496. * @param renderEffect the effect to add
  75497. */
  75498. addEffect(renderEffect: PostProcessRenderEffect): void;
  75499. /** @hidden */
  75500. _rebuild(): void;
  75501. /** @hidden */
  75502. _enableEffect(renderEffectName: string, cameras: Camera): void;
  75503. /** @hidden */
  75504. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  75505. /** @hidden */
  75506. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  75507. /** @hidden */
  75508. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  75509. /** @hidden */
  75510. _attachCameras(cameras: Camera, unique: boolean): void;
  75511. /** @hidden */
  75512. _attachCameras(cameras: Camera[], unique: boolean): void;
  75513. /** @hidden */
  75514. _detachCameras(cameras: Camera): void;
  75515. /** @hidden */
  75516. _detachCameras(cameras: Nullable<Camera[]>): void;
  75517. /** @hidden */
  75518. _update(): void;
  75519. /** @hidden */
  75520. _reset(): void;
  75521. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  75522. /**
  75523. * Sets the required values to the prepass renderer.
  75524. * @param prePassRenderer defines the prepass renderer to setup.
  75525. * @returns true if the pre pass is needed.
  75526. */
  75527. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  75528. /**
  75529. * Disposes of the pipeline
  75530. */
  75531. dispose(): void;
  75532. }
  75533. }
  75534. declare module BABYLON {
  75535. /**
  75536. * PostProcessRenderPipelineManager class
  75537. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75538. */
  75539. export class PostProcessRenderPipelineManager {
  75540. private _renderPipelines;
  75541. /**
  75542. * Initializes a PostProcessRenderPipelineManager
  75543. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75544. */
  75545. constructor();
  75546. /**
  75547. * Gets the list of supported render pipelines
  75548. */
  75549. get supportedPipelines(): PostProcessRenderPipeline[];
  75550. /**
  75551. * Adds a pipeline to the manager
  75552. * @param renderPipeline The pipeline to add
  75553. */
  75554. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  75555. /**
  75556. * Attaches a camera to the pipeline
  75557. * @param renderPipelineName The name of the pipeline to attach to
  75558. * @param cameras the camera to attach
  75559. * @param unique if the camera can be attached multiple times to the pipeline
  75560. */
  75561. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  75562. /**
  75563. * Detaches a camera from the pipeline
  75564. * @param renderPipelineName The name of the pipeline to detach from
  75565. * @param cameras the camera to detach
  75566. */
  75567. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  75568. /**
  75569. * Enables an effect by name on a pipeline
  75570. * @param renderPipelineName the name of the pipeline to enable the effect in
  75571. * @param renderEffectName the name of the effect to enable
  75572. * @param cameras the cameras that the effect should be enabled on
  75573. */
  75574. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  75575. /**
  75576. * Disables an effect by name on a pipeline
  75577. * @param renderPipelineName the name of the pipeline to disable the effect in
  75578. * @param renderEffectName the name of the effect to disable
  75579. * @param cameras the cameras that the effect should be disabled on
  75580. */
  75581. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  75582. /**
  75583. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  75584. */
  75585. update(): void;
  75586. /** @hidden */
  75587. _rebuild(): void;
  75588. /**
  75589. * Disposes of the manager and pipelines
  75590. */
  75591. dispose(): void;
  75592. }
  75593. }
  75594. declare module BABYLON {
  75595. interface Scene {
  75596. /** @hidden (Backing field) */
  75597. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  75598. /**
  75599. * Gets the postprocess render pipeline manager
  75600. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75601. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  75602. */
  75603. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  75604. }
  75605. /**
  75606. * Defines the Render Pipeline scene component responsible to rendering pipelines
  75607. */
  75608. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  75609. /**
  75610. * The component name helpful to identify the component in the list of scene components.
  75611. */
  75612. readonly name: string;
  75613. /**
  75614. * The scene the component belongs to.
  75615. */
  75616. scene: Scene;
  75617. /**
  75618. * Creates a new instance of the component for the given scene
  75619. * @param scene Defines the scene to register the component in
  75620. */
  75621. constructor(scene: Scene);
  75622. /**
  75623. * Registers the component in a given scene
  75624. */
  75625. register(): void;
  75626. /**
  75627. * Rebuilds the elements related to this component in case of
  75628. * context lost for instance.
  75629. */
  75630. rebuild(): void;
  75631. /**
  75632. * Disposes the component and the associated resources
  75633. */
  75634. dispose(): void;
  75635. private _gatherRenderTargets;
  75636. }
  75637. }
  75638. declare module BABYLON {
  75639. /**
  75640. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  75641. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  75642. */
  75643. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75644. private _scene;
  75645. private _camerasToBeAttached;
  75646. /**
  75647. * ID of the sharpen post process,
  75648. */
  75649. private readonly SharpenPostProcessId;
  75650. /**
  75651. * @ignore
  75652. * ID of the image processing post process;
  75653. */
  75654. readonly ImageProcessingPostProcessId: string;
  75655. /**
  75656. * @ignore
  75657. * ID of the Fast Approximate Anti-Aliasing post process;
  75658. */
  75659. readonly FxaaPostProcessId: string;
  75660. /**
  75661. * ID of the chromatic aberration post process,
  75662. */
  75663. private readonly ChromaticAberrationPostProcessId;
  75664. /**
  75665. * ID of the grain post process
  75666. */
  75667. private readonly GrainPostProcessId;
  75668. /**
  75669. * Sharpen post process which will apply a sharpen convolution to enhance edges
  75670. */
  75671. sharpen: SharpenPostProcess;
  75672. private _sharpenEffect;
  75673. private bloom;
  75674. /**
  75675. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  75676. */
  75677. depthOfField: DepthOfFieldEffect;
  75678. /**
  75679. * The Fast Approximate Anti-Aliasing post process which attempts to remove aliasing from an image.
  75680. */
  75681. fxaa: FxaaPostProcess;
  75682. /**
  75683. * Image post processing pass used to perform operations such as tone mapping or color grading.
  75684. */
  75685. imageProcessing: ImageProcessingPostProcess;
  75686. /**
  75687. * Chromatic aberration post process which will shift rgb colors in the image
  75688. */
  75689. chromaticAberration: ChromaticAberrationPostProcess;
  75690. private _chromaticAberrationEffect;
  75691. /**
  75692. * Grain post process which add noise to the image
  75693. */
  75694. grain: GrainPostProcess;
  75695. private _grainEffect;
  75696. /**
  75697. * Glow post process which adds a glow to emissive areas of the image
  75698. */
  75699. private _glowLayer;
  75700. /**
  75701. * Animations which can be used to tweak settings over a period of time
  75702. */
  75703. animations: Animation[];
  75704. private _imageProcessingConfigurationObserver;
  75705. private _sharpenEnabled;
  75706. private _bloomEnabled;
  75707. private _depthOfFieldEnabled;
  75708. private _depthOfFieldBlurLevel;
  75709. private _fxaaEnabled;
  75710. private _imageProcessingEnabled;
  75711. private _defaultPipelineTextureType;
  75712. private _bloomScale;
  75713. private _chromaticAberrationEnabled;
  75714. private _grainEnabled;
  75715. private _buildAllowed;
  75716. /**
  75717. * This is triggered each time the pipeline has been built.
  75718. */
  75719. onBuildObservable: Observable<DefaultRenderingPipeline>;
  75720. /**
  75721. * Gets active scene
  75722. */
  75723. get scene(): Scene;
  75724. /**
  75725. * Enable or disable the sharpen process from the pipeline
  75726. */
  75727. set sharpenEnabled(enabled: boolean);
  75728. get sharpenEnabled(): boolean;
  75729. private _resizeObserver;
  75730. private _hardwareScaleLevel;
  75731. private _bloomKernel;
  75732. /**
  75733. * Specifies the size of the bloom blur kernel, relative to the final output size
  75734. */
  75735. get bloomKernel(): number;
  75736. set bloomKernel(value: number);
  75737. /**
  75738. * Specifies the weight of the bloom in the final rendering
  75739. */
  75740. private _bloomWeight;
  75741. /**
  75742. * Specifies the luma threshold for the area that will be blurred by the bloom
  75743. */
  75744. private _bloomThreshold;
  75745. private _hdr;
  75746. /**
  75747. * The strength of the bloom.
  75748. */
  75749. set bloomWeight(value: number);
  75750. get bloomWeight(): number;
  75751. /**
  75752. * The strength of the bloom.
  75753. */
  75754. set bloomThreshold(value: number);
  75755. get bloomThreshold(): number;
  75756. /**
  75757. * The scale of the bloom, lower value will provide better performance.
  75758. */
  75759. set bloomScale(value: number);
  75760. get bloomScale(): number;
  75761. /**
  75762. * Enable or disable the bloom from the pipeline
  75763. */
  75764. set bloomEnabled(enabled: boolean);
  75765. get bloomEnabled(): boolean;
  75766. private _rebuildBloom;
  75767. /**
  75768. * If the depth of field is enabled.
  75769. */
  75770. get depthOfFieldEnabled(): boolean;
  75771. set depthOfFieldEnabled(enabled: boolean);
  75772. /**
  75773. * Blur level of the depth of field effect. (Higher blur will effect performance)
  75774. */
  75775. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  75776. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  75777. /**
  75778. * If the anti aliasing is enabled.
  75779. */
  75780. set fxaaEnabled(enabled: boolean);
  75781. get fxaaEnabled(): boolean;
  75782. private _samples;
  75783. /**
  75784. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75785. */
  75786. set samples(sampleCount: number);
  75787. get samples(): number;
  75788. /**
  75789. * If image processing is enabled.
  75790. */
  75791. set imageProcessingEnabled(enabled: boolean);
  75792. get imageProcessingEnabled(): boolean;
  75793. /**
  75794. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  75795. */
  75796. set glowLayerEnabled(enabled: boolean);
  75797. get glowLayerEnabled(): boolean;
  75798. /**
  75799. * Gets the glow layer (or null if not defined)
  75800. */
  75801. get glowLayer(): Nullable<GlowLayer>;
  75802. /**
  75803. * Enable or disable the chromaticAberration process from the pipeline
  75804. */
  75805. set chromaticAberrationEnabled(enabled: boolean);
  75806. get chromaticAberrationEnabled(): boolean;
  75807. /**
  75808. * Enable or disable the grain process from the pipeline
  75809. */
  75810. set grainEnabled(enabled: boolean);
  75811. get grainEnabled(): boolean;
  75812. /**
  75813. * @constructor
  75814. * @param name - The rendering pipeline name (default: "")
  75815. * @param hdr - If high dynamic range textures should be used (default: true)
  75816. * @param scene - The scene linked to this pipeline (default: the last created scene)
  75817. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  75818. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  75819. */
  75820. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  75821. /**
  75822. * Get the class name
  75823. * @returns "DefaultRenderingPipeline"
  75824. */
  75825. getClassName(): string;
  75826. /**
  75827. * Force the compilation of the entire pipeline.
  75828. */
  75829. prepare(): void;
  75830. private _hasCleared;
  75831. private _prevPostProcess;
  75832. private _prevPrevPostProcess;
  75833. private _setAutoClearAndTextureSharing;
  75834. private _depthOfFieldSceneObserver;
  75835. private _buildPipeline;
  75836. private _disposePostProcesses;
  75837. /**
  75838. * Adds a camera to the pipeline
  75839. * @param camera the camera to be added
  75840. */
  75841. addCamera(camera: Camera): void;
  75842. /**
  75843. * Removes a camera from the pipeline
  75844. * @param camera the camera to remove
  75845. */
  75846. removeCamera(camera: Camera): void;
  75847. /**
  75848. * Dispose of the pipeline and stop all post processes
  75849. */
  75850. dispose(): void;
  75851. /**
  75852. * Serialize the rendering pipeline (Used when exporting)
  75853. * @returns the serialized object
  75854. */
  75855. serialize(): any;
  75856. /**
  75857. * Parse the serialized pipeline
  75858. * @param source Source pipeline.
  75859. * @param scene The scene to load the pipeline to.
  75860. * @param rootUrl The URL of the serialized pipeline.
  75861. * @returns An instantiated pipeline from the serialized object.
  75862. */
  75863. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  75864. }
  75865. }
  75866. declare module BABYLON {
  75867. /** @hidden */
  75868. export var lensHighlightsPixelShader: {
  75869. name: string;
  75870. shader: string;
  75871. };
  75872. }
  75873. declare module BABYLON {
  75874. /** @hidden */
  75875. export var depthOfFieldPixelShader: {
  75876. name: string;
  75877. shader: string;
  75878. };
  75879. }
  75880. declare module BABYLON {
  75881. /**
  75882. * BABYLON.JS Chromatic Aberration GLSL Shader
  75883. * Author: Olivier Guyot
  75884. * Separates very slightly R, G and B colors on the edges of the screen
  75885. * Inspired by Francois Tarlier & Martins Upitis
  75886. */
  75887. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  75888. /**
  75889. * @ignore
  75890. * The chromatic aberration PostProcess id in the pipeline
  75891. */
  75892. LensChromaticAberrationEffect: string;
  75893. /**
  75894. * @ignore
  75895. * The highlights enhancing PostProcess id in the pipeline
  75896. */
  75897. HighlightsEnhancingEffect: string;
  75898. /**
  75899. * @ignore
  75900. * The depth-of-field PostProcess id in the pipeline
  75901. */
  75902. LensDepthOfFieldEffect: string;
  75903. private _scene;
  75904. private _depthTexture;
  75905. private _grainTexture;
  75906. private _chromaticAberrationPostProcess;
  75907. private _highlightsPostProcess;
  75908. private _depthOfFieldPostProcess;
  75909. private _edgeBlur;
  75910. private _grainAmount;
  75911. private _chromaticAberration;
  75912. private _distortion;
  75913. private _highlightsGain;
  75914. private _highlightsThreshold;
  75915. private _dofDistance;
  75916. private _dofAperture;
  75917. private _dofDarken;
  75918. private _dofPentagon;
  75919. private _blurNoise;
  75920. /**
  75921. * @constructor
  75922. *
  75923. * Effect parameters are as follow:
  75924. * {
  75925. * chromatic_aberration: number; // from 0 to x (1 for realism)
  75926. * edge_blur: number; // from 0 to x (1 for realism)
  75927. * distortion: number; // from 0 to x (1 for realism)
  75928. * grain_amount: number; // from 0 to 1
  75929. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  75930. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  75931. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  75932. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  75933. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  75934. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  75935. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  75936. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  75937. * }
  75938. * Note: if an effect parameter is unset, effect is disabled
  75939. *
  75940. * @param name The rendering pipeline name
  75941. * @param parameters - An object containing all parameters (see above)
  75942. * @param scene The scene linked to this pipeline
  75943. * @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)
  75944. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75945. */
  75946. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  75947. /**
  75948. * Get the class name
  75949. * @returns "LensRenderingPipeline"
  75950. */
  75951. getClassName(): string;
  75952. /**
  75953. * Gets associated scene
  75954. */
  75955. get scene(): Scene;
  75956. /**
  75957. * Gets or sets the edge blur
  75958. */
  75959. get edgeBlur(): number;
  75960. set edgeBlur(value: number);
  75961. /**
  75962. * Gets or sets the grain amount
  75963. */
  75964. get grainAmount(): number;
  75965. set grainAmount(value: number);
  75966. /**
  75967. * Gets or sets the chromatic aberration amount
  75968. */
  75969. get chromaticAberration(): number;
  75970. set chromaticAberration(value: number);
  75971. /**
  75972. * Gets or sets the depth of field aperture
  75973. */
  75974. get dofAperture(): number;
  75975. set dofAperture(value: number);
  75976. /**
  75977. * Gets or sets the edge distortion
  75978. */
  75979. get edgeDistortion(): number;
  75980. set edgeDistortion(value: number);
  75981. /**
  75982. * Gets or sets the depth of field distortion
  75983. */
  75984. get dofDistortion(): number;
  75985. set dofDistortion(value: number);
  75986. /**
  75987. * Gets or sets the darken out of focus amount
  75988. */
  75989. get darkenOutOfFocus(): number;
  75990. set darkenOutOfFocus(value: number);
  75991. /**
  75992. * Gets or sets a boolean indicating if blur noise is enabled
  75993. */
  75994. get blurNoise(): boolean;
  75995. set blurNoise(value: boolean);
  75996. /**
  75997. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  75998. */
  75999. get pentagonBokeh(): boolean;
  76000. set pentagonBokeh(value: boolean);
  76001. /**
  76002. * Gets or sets the highlight grain amount
  76003. */
  76004. get highlightsGain(): number;
  76005. set highlightsGain(value: number);
  76006. /**
  76007. * Gets or sets the highlight threshold
  76008. */
  76009. get highlightsThreshold(): number;
  76010. set highlightsThreshold(value: number);
  76011. /**
  76012. * Sets the amount of blur at the edges
  76013. * @param amount blur amount
  76014. */
  76015. setEdgeBlur(amount: number): void;
  76016. /**
  76017. * Sets edge blur to 0
  76018. */
  76019. disableEdgeBlur(): void;
  76020. /**
  76021. * Sets the amount of grain
  76022. * @param amount Amount of grain
  76023. */
  76024. setGrainAmount(amount: number): void;
  76025. /**
  76026. * Set grain amount to 0
  76027. */
  76028. disableGrain(): void;
  76029. /**
  76030. * Sets the chromatic aberration amount
  76031. * @param amount amount of chromatic aberration
  76032. */
  76033. setChromaticAberration(amount: number): void;
  76034. /**
  76035. * Sets chromatic aberration amount to 0
  76036. */
  76037. disableChromaticAberration(): void;
  76038. /**
  76039. * Sets the EdgeDistortion amount
  76040. * @param amount amount of EdgeDistortion
  76041. */
  76042. setEdgeDistortion(amount: number): void;
  76043. /**
  76044. * Sets edge distortion to 0
  76045. */
  76046. disableEdgeDistortion(): void;
  76047. /**
  76048. * Sets the FocusDistance amount
  76049. * @param amount amount of FocusDistance
  76050. */
  76051. setFocusDistance(amount: number): void;
  76052. /**
  76053. * Disables depth of field
  76054. */
  76055. disableDepthOfField(): void;
  76056. /**
  76057. * Sets the Aperture amount
  76058. * @param amount amount of Aperture
  76059. */
  76060. setAperture(amount: number): void;
  76061. /**
  76062. * Sets the DarkenOutOfFocus amount
  76063. * @param amount amount of DarkenOutOfFocus
  76064. */
  76065. setDarkenOutOfFocus(amount: number): void;
  76066. private _pentagonBokehIsEnabled;
  76067. /**
  76068. * Creates a pentagon bokeh effect
  76069. */
  76070. enablePentagonBokeh(): void;
  76071. /**
  76072. * Disables the pentagon bokeh effect
  76073. */
  76074. disablePentagonBokeh(): void;
  76075. /**
  76076. * Enables noise blur
  76077. */
  76078. enableNoiseBlur(): void;
  76079. /**
  76080. * Disables noise blur
  76081. */
  76082. disableNoiseBlur(): void;
  76083. /**
  76084. * Sets the HighlightsGain amount
  76085. * @param amount amount of HighlightsGain
  76086. */
  76087. setHighlightsGain(amount: number): void;
  76088. /**
  76089. * Sets the HighlightsThreshold amount
  76090. * @param amount amount of HighlightsThreshold
  76091. */
  76092. setHighlightsThreshold(amount: number): void;
  76093. /**
  76094. * Disables highlights
  76095. */
  76096. disableHighlights(): void;
  76097. /**
  76098. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  76099. * @param disableDepthRender If the scene's depth rendering should be disabled (default: false)
  76100. */
  76101. dispose(disableDepthRender?: boolean): void;
  76102. private _createChromaticAberrationPostProcess;
  76103. private _createHighlightsPostProcess;
  76104. private _createDepthOfFieldPostProcess;
  76105. private _createGrainTexture;
  76106. }
  76107. }
  76108. declare module BABYLON {
  76109. /**
  76110. * Contains all parameters needed for the prepass to perform
  76111. * screen space subsurface scattering
  76112. */
  76113. export class SSAO2Configuration implements PrePassEffectConfiguration {
  76114. /**
  76115. * Is subsurface enabled
  76116. */
  76117. enabled: boolean;
  76118. /**
  76119. * Name of the configuration
  76120. */
  76121. name: string;
  76122. /**
  76123. * Textures that should be present in the MRT for this effect to work
  76124. */
  76125. readonly texturesRequired: number[];
  76126. }
  76127. }
  76128. declare module BABYLON {
  76129. /** @hidden */
  76130. export var ssao2PixelShader: {
  76131. name: string;
  76132. shader: string;
  76133. };
  76134. }
  76135. declare module BABYLON {
  76136. /** @hidden */
  76137. export var ssaoCombinePixelShader: {
  76138. name: string;
  76139. shader: string;
  76140. };
  76141. }
  76142. declare module BABYLON {
  76143. /**
  76144. * Render pipeline to produce ssao effect
  76145. */
  76146. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  76147. /**
  76148. * @ignore
  76149. * The PassPostProcess id in the pipeline that contains the original scene color
  76150. */
  76151. SSAOOriginalSceneColorEffect: string;
  76152. /**
  76153. * @ignore
  76154. * The SSAO PostProcess id in the pipeline
  76155. */
  76156. SSAORenderEffect: string;
  76157. /**
  76158. * @ignore
  76159. * The horizontal blur PostProcess id in the pipeline
  76160. */
  76161. SSAOBlurHRenderEffect: string;
  76162. /**
  76163. * @ignore
  76164. * The vertical blur PostProcess id in the pipeline
  76165. */
  76166. SSAOBlurVRenderEffect: string;
  76167. /**
  76168. * @ignore
  76169. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  76170. */
  76171. SSAOCombineRenderEffect: string;
  76172. /**
  76173. * The output strength of the SSAO post-process. Default value is 1.0.
  76174. */
  76175. totalStrength: number;
  76176. /**
  76177. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  76178. */
  76179. maxZ: number;
  76180. /**
  76181. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  76182. */
  76183. minZAspect: number;
  76184. private _samples;
  76185. /**
  76186. * Number of samples used for the SSAO calculations. Default value is 8
  76187. */
  76188. set samples(n: number);
  76189. get samples(): number;
  76190. private _textureSamples;
  76191. /**
  76192. * Number of samples to use for antialiasing
  76193. */
  76194. set textureSamples(n: number);
  76195. get textureSamples(): number;
  76196. /**
  76197. * Force rendering the geometry through geometry buffer
  76198. */
  76199. private _forceGeometryBuffer;
  76200. /**
  76201. * Ratio object used for SSAO ratio and blur ratio
  76202. */
  76203. private _ratio;
  76204. /**
  76205. * Dynamically generated sphere sampler.
  76206. */
  76207. private _sampleSphere;
  76208. /**
  76209. * Blur filter offsets
  76210. */
  76211. private _samplerOffsets;
  76212. private _expensiveBlur;
  76213. /**
  76214. * If bilateral blur should be used
  76215. */
  76216. set expensiveBlur(b: boolean);
  76217. get expensiveBlur(): boolean;
  76218. /**
  76219. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  76220. */
  76221. radius: number;
  76222. /**
  76223. * The base color of the SSAO post-process
  76224. * The final result is "base + ssao" between [0, 1]
  76225. */
  76226. base: number;
  76227. /**
  76228. * Support test.
  76229. */
  76230. static get IsSupported(): boolean;
  76231. private _scene;
  76232. private _randomTexture;
  76233. private _originalColorPostProcess;
  76234. private _ssaoPostProcess;
  76235. private _blurHPostProcess;
  76236. private _blurVPostProcess;
  76237. private _ssaoCombinePostProcess;
  76238. private _prePassRenderer;
  76239. /**
  76240. * Gets active scene
  76241. */
  76242. get scene(): Scene;
  76243. /**
  76244. * @constructor
  76245. * @param name The rendering pipeline name
  76246. * @param scene The scene linked to this pipeline
  76247. * @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 }
  76248. * @param cameras The array of cameras that the rendering pipeline will be attached to
  76249. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  76250. */
  76251. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  76252. /**
  76253. * Get the class name
  76254. * @returns "SSAO2RenderingPipeline"
  76255. */
  76256. getClassName(): string;
  76257. /**
  76258. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  76259. */
  76260. dispose(disableGeometryBufferRenderer?: boolean): void;
  76261. private _createBlurPostProcess;
  76262. /** @hidden */
  76263. _rebuild(): void;
  76264. private _bits;
  76265. private _radicalInverse_VdC;
  76266. private _hammersley;
  76267. private _hemisphereSample_uniform;
  76268. private _generateHemisphere;
  76269. private _getDefinesForSSAO;
  76270. private static readonly ORTHO_DEPTH_PROJECTION;
  76271. private static readonly PERSPECTIVE_DEPTH_PROJECTION;
  76272. private _createSSAOPostProcess;
  76273. private _createSSAOCombinePostProcess;
  76274. private _createRandomTexture;
  76275. /**
  76276. * Serialize the rendering pipeline (Used when exporting)
  76277. * @returns the serialized object
  76278. */
  76279. serialize(): any;
  76280. /**
  76281. * Parse the serialized pipeline
  76282. * @param source Source pipeline.
  76283. * @param scene The scene to load the pipeline to.
  76284. * @param rootUrl The URL of the serialized pipeline.
  76285. * @returns An instantiated pipeline from the serialized object.
  76286. */
  76287. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  76288. }
  76289. }
  76290. declare module BABYLON {
  76291. /** @hidden */
  76292. export var ssaoPixelShader: {
  76293. name: string;
  76294. shader: string;
  76295. };
  76296. }
  76297. declare module BABYLON {
  76298. /**
  76299. * Render pipeline to produce ssao effect
  76300. */
  76301. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  76302. /**
  76303. * @ignore
  76304. * The PassPostProcess id in the pipeline that contains the original scene color
  76305. */
  76306. SSAOOriginalSceneColorEffect: string;
  76307. /**
  76308. * @ignore
  76309. * The SSAO PostProcess id in the pipeline
  76310. */
  76311. SSAORenderEffect: string;
  76312. /**
  76313. * @ignore
  76314. * The horizontal blur PostProcess id in the pipeline
  76315. */
  76316. SSAOBlurHRenderEffect: string;
  76317. /**
  76318. * @ignore
  76319. * The vertical blur PostProcess id in the pipeline
  76320. */
  76321. SSAOBlurVRenderEffect: string;
  76322. /**
  76323. * @ignore
  76324. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  76325. */
  76326. SSAOCombineRenderEffect: string;
  76327. /**
  76328. * The output strength of the SSAO post-process. Default value is 1.0.
  76329. */
  76330. totalStrength: number;
  76331. /**
  76332. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  76333. */
  76334. radius: number;
  76335. /**
  76336. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  76337. * Must not be equal to fallOff and superior to fallOff.
  76338. * Default value is 0.0075
  76339. */
  76340. area: number;
  76341. /**
  76342. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  76343. * Must not be equal to area and inferior to area.
  76344. * Default value is 0.000001
  76345. */
  76346. fallOff: number;
  76347. /**
  76348. * The base color of the SSAO post-process
  76349. * The final result is "base + ssao" between [0, 1]
  76350. */
  76351. base: number;
  76352. private _scene;
  76353. private _depthTexture;
  76354. private _randomTexture;
  76355. private _originalColorPostProcess;
  76356. private _ssaoPostProcess;
  76357. private _blurHPostProcess;
  76358. private _blurVPostProcess;
  76359. private _ssaoCombinePostProcess;
  76360. private _firstUpdate;
  76361. /**
  76362. * Gets active scene
  76363. */
  76364. get scene(): Scene;
  76365. /**
  76366. * @constructor
  76367. * @param name - The rendering pipeline name
  76368. * @param scene - The scene linked to this pipeline
  76369. * @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 }
  76370. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  76371. */
  76372. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  76373. /**
  76374. * Get the class name
  76375. * @returns "SSAORenderingPipeline"
  76376. */
  76377. getClassName(): string;
  76378. /**
  76379. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  76380. */
  76381. dispose(disableDepthRender?: boolean): void;
  76382. private _createBlurPostProcess;
  76383. /** @hidden */
  76384. _rebuild(): void;
  76385. private _createSSAOPostProcess;
  76386. private _createSSAOCombinePostProcess;
  76387. private _createRandomTexture;
  76388. }
  76389. }
  76390. declare module BABYLON {
  76391. /**
  76392. * Contains all parameters needed for the prepass to perform
  76393. * screen space reflections
  76394. */
  76395. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  76396. /**
  76397. * Is ssr enabled
  76398. */
  76399. enabled: boolean;
  76400. /**
  76401. * Name of the configuration
  76402. */
  76403. name: string;
  76404. /**
  76405. * Textures that should be present in the MRT for this effect to work
  76406. */
  76407. readonly texturesRequired: number[];
  76408. }
  76409. }
  76410. declare module BABYLON {
  76411. /** @hidden */
  76412. export var screenSpaceReflectionPixelShader: {
  76413. name: string;
  76414. shader: string;
  76415. };
  76416. }
  76417. declare module BABYLON {
  76418. /**
  76419. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  76420. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  76421. */
  76422. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  76423. /**
  76424. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  76425. */
  76426. threshold: number;
  76427. /**
  76428. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  76429. */
  76430. strength: number;
  76431. /**
  76432. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  76433. */
  76434. reflectionSpecularFalloffExponent: number;
  76435. /**
  76436. * 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]
  76437. */
  76438. step: number;
  76439. /**
  76440. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  76441. */
  76442. roughnessFactor: number;
  76443. private _forceGeometryBuffer;
  76444. private _geometryBufferRenderer;
  76445. private _prePassRenderer;
  76446. private _enableSmoothReflections;
  76447. private _reflectionSamples;
  76448. private _smoothSteps;
  76449. /**
  76450. * Gets a string identifying the name of the class
  76451. * @returns "ScreenSpaceReflectionPostProcess" string
  76452. */
  76453. getClassName(): string;
  76454. /**
  76455. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  76456. * @param name The name of the effect.
  76457. * @param scene The scene containing the objects to calculate reflections.
  76458. * @param options The required width/height ratio to downsize to before computing the render pass.
  76459. * @param camera The camera to apply the render pass to.
  76460. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76461. * @param engine The engine which the post process will be applied. (default: current engine)
  76462. * @param reusable If the post process can be reused on the same frame. (default: false)
  76463. * @param textureType Type of textures used when performing the post process. (default: 0)
  76464. * @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)
  76465. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  76466. */
  76467. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  76468. /**
  76469. * Gets whether or not smoothing reflections is enabled.
  76470. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  76471. */
  76472. get enableSmoothReflections(): boolean;
  76473. /**
  76474. * Sets whether or not smoothing reflections is enabled.
  76475. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  76476. */
  76477. set enableSmoothReflections(enabled: boolean);
  76478. /**
  76479. * Gets the number of samples taken while computing reflections. More samples count is high,
  76480. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  76481. */
  76482. get reflectionSamples(): number;
  76483. /**
  76484. * Sets the number of samples taken while computing reflections. More samples count is high,
  76485. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  76486. */
  76487. set reflectionSamples(samples: number);
  76488. /**
  76489. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  76490. * more the post-process will require GPU power and can generate a drop in FPS.
  76491. * Default value (5.0) work pretty well in all cases but can be adjusted.
  76492. */
  76493. get smoothSteps(): number;
  76494. set smoothSteps(steps: number);
  76495. private _updateEffectDefines;
  76496. /** @hidden */
  76497. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  76498. }
  76499. }
  76500. declare module BABYLON {
  76501. /** @hidden */
  76502. export var standardPixelShader: {
  76503. name: string;
  76504. shader: string;
  76505. };
  76506. }
  76507. declare module BABYLON {
  76508. /**
  76509. * Standard rendering pipeline
  76510. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76511. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  76512. */
  76513. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  76514. /**
  76515. * Public members
  76516. */
  76517. /**
  76518. * Post-process which contains the original scene color before the pipeline applies all the effects
  76519. */
  76520. originalPostProcess: Nullable<PostProcess>;
  76521. /**
  76522. * Post-process used to down scale an image x4
  76523. */
  76524. downSampleX4PostProcess: Nullable<PostProcess>;
  76525. /**
  76526. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  76527. */
  76528. brightPassPostProcess: Nullable<PostProcess>;
  76529. /**
  76530. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  76531. */
  76532. blurHPostProcesses: PostProcess[];
  76533. /**
  76534. * Post-process array storing all the vertical blur post-processes used by the pipeline
  76535. */
  76536. blurVPostProcesses: PostProcess[];
  76537. /**
  76538. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  76539. */
  76540. textureAdderPostProcess: Nullable<PostProcess>;
  76541. /**
  76542. * Post-process used to create volumetric lighting effect
  76543. */
  76544. volumetricLightPostProcess: Nullable<PostProcess>;
  76545. /**
  76546. * Post-process used to smooth the previous volumetric light post-process on the X axis
  76547. */
  76548. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  76549. /**
  76550. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  76551. */
  76552. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  76553. /**
  76554. * Post-process used to merge the volumetric light effect and the real scene color
  76555. */
  76556. volumetricLightMergePostProces: Nullable<PostProcess>;
  76557. /**
  76558. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  76559. */
  76560. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  76561. /**
  76562. * Base post-process used to calculate the average luminance of the final image for HDR
  76563. */
  76564. luminancePostProcess: Nullable<PostProcess>;
  76565. /**
  76566. * Post-processes used to create down sample post-processes in order to get
  76567. * the average luminance of the final image for HDR
  76568. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  76569. */
  76570. luminanceDownSamplePostProcesses: PostProcess[];
  76571. /**
  76572. * Post-process used to create a HDR effect (light adaptation)
  76573. */
  76574. hdrPostProcess: Nullable<PostProcess>;
  76575. /**
  76576. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  76577. */
  76578. textureAdderFinalPostProcess: Nullable<PostProcess>;
  76579. /**
  76580. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  76581. */
  76582. lensFlareFinalPostProcess: Nullable<PostProcess>;
  76583. /**
  76584. * Post-process used to merge the final HDR post-process and the real scene color
  76585. */
  76586. hdrFinalPostProcess: Nullable<PostProcess>;
  76587. /**
  76588. * Post-process used to create a lens flare effect
  76589. */
  76590. lensFlarePostProcess: Nullable<PostProcess>;
  76591. /**
  76592. * Post-process that merges the result of the lens flare post-process and the real scene color
  76593. */
  76594. lensFlareComposePostProcess: Nullable<PostProcess>;
  76595. /**
  76596. * Post-process used to create a motion blur effect
  76597. */
  76598. motionBlurPostProcess: Nullable<PostProcess>;
  76599. /**
  76600. * Post-process used to create a depth of field effect
  76601. */
  76602. depthOfFieldPostProcess: Nullable<PostProcess>;
  76603. /**
  76604. * The Fast Approximate Anti-Aliasing post process which attempts to remove aliasing from an image.
  76605. */
  76606. fxaaPostProcess: Nullable<FxaaPostProcess>;
  76607. /**
  76608. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  76609. */
  76610. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  76611. /**
  76612. * Represents the brightness threshold in order to configure the illuminated surfaces
  76613. */
  76614. brightThreshold: number;
  76615. /**
  76616. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  76617. */
  76618. blurWidth: number;
  76619. /**
  76620. * Sets if the blur for highlighted surfaces must be only horizontal
  76621. */
  76622. horizontalBlur: boolean;
  76623. /**
  76624. * Gets the overall exposure used by the pipeline
  76625. */
  76626. get exposure(): number;
  76627. /**
  76628. * Sets the overall exposure used by the pipeline
  76629. */
  76630. set exposure(value: number);
  76631. /**
  76632. * Texture used typically to simulate "dirty" on camera lens
  76633. */
  76634. lensTexture: Nullable<Texture>;
  76635. /**
  76636. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  76637. */
  76638. volumetricLightCoefficient: number;
  76639. /**
  76640. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  76641. */
  76642. volumetricLightPower: number;
  76643. /**
  76644. * Used the set the blur intensity to smooth the volumetric lights
  76645. */
  76646. volumetricLightBlurScale: number;
  76647. /**
  76648. * Light (spot or directional) used to generate the volumetric lights rays
  76649. * The source light must have a shadow generate so the pipeline can get its
  76650. * depth map
  76651. */
  76652. sourceLight: Nullable<SpotLight | DirectionalLight>;
  76653. /**
  76654. * For eye adaptation, represents the minimum luminance the eye can see
  76655. */
  76656. hdrMinimumLuminance: number;
  76657. /**
  76658. * For eye adaptation, represents the decrease luminance speed
  76659. */
  76660. hdrDecreaseRate: number;
  76661. /**
  76662. * For eye adaptation, represents the increase luminance speed
  76663. */
  76664. hdrIncreaseRate: number;
  76665. /**
  76666. * Gets whether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  76667. */
  76668. get hdrAutoExposure(): boolean;
  76669. /**
  76670. * Sets whether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  76671. */
  76672. set hdrAutoExposure(value: boolean);
  76673. /**
  76674. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  76675. */
  76676. lensColorTexture: Nullable<Texture>;
  76677. /**
  76678. * The overall strengh for the lens flare effect
  76679. */
  76680. lensFlareStrength: number;
  76681. /**
  76682. * Dispersion coefficient for lens flare ghosts
  76683. */
  76684. lensFlareGhostDispersal: number;
  76685. /**
  76686. * Main lens flare halo width
  76687. */
  76688. lensFlareHaloWidth: number;
  76689. /**
  76690. * Based on the lens distortion effect, defines how much the lens flare result
  76691. * is distorted
  76692. */
  76693. lensFlareDistortionStrength: number;
  76694. /**
  76695. * Configures the blur intensity used for for lens flare (halo)
  76696. */
  76697. lensFlareBlurWidth: number;
  76698. /**
  76699. * Lens star texture must be used to simulate rays on the flares and is available
  76700. * in the documentation
  76701. */
  76702. lensStarTexture: Nullable<Texture>;
  76703. /**
  76704. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  76705. * flare effect by taking account of the dirt texture
  76706. */
  76707. lensFlareDirtTexture: Nullable<Texture>;
  76708. /**
  76709. * Represents the focal length for the depth of field effect
  76710. */
  76711. depthOfFieldDistance: number;
  76712. /**
  76713. * Represents the blur intensity for the blurred part of the depth of field effect
  76714. */
  76715. depthOfFieldBlurWidth: number;
  76716. /**
  76717. * Gets how much the image is blurred by the movement while using the motion blur post-process
  76718. */
  76719. get motionStrength(): number;
  76720. /**
  76721. * Sets how much the image is blurred by the movement while using the motion blur post-process
  76722. */
  76723. set motionStrength(strength: number);
  76724. /**
  76725. * Gets whether or not the motion blur post-process is object based or screen based.
  76726. */
  76727. get objectBasedMotionBlur(): boolean;
  76728. /**
  76729. * Sets whether or not the motion blur post-process should be object based or screen based
  76730. */
  76731. set objectBasedMotionBlur(value: boolean);
  76732. /**
  76733. * List of animations for the pipeline (IAnimatable implementation)
  76734. */
  76735. animations: Animation[];
  76736. /**
  76737. * Private members
  76738. */
  76739. private _scene;
  76740. private _currentDepthOfFieldSource;
  76741. private _basePostProcess;
  76742. private _fixedExposure;
  76743. private _currentExposure;
  76744. private _hdrAutoExposure;
  76745. private _hdrCurrentLuminance;
  76746. private _motionStrength;
  76747. private _isObjectBasedMotionBlur;
  76748. private _floatTextureType;
  76749. private _camerasToBeAttached;
  76750. private _ratio;
  76751. private _bloomEnabled;
  76752. private _depthOfFieldEnabled;
  76753. private _vlsEnabled;
  76754. private _lensFlareEnabled;
  76755. private _hdrEnabled;
  76756. private _motionBlurEnabled;
  76757. private _fxaaEnabled;
  76758. private _screenSpaceReflectionsEnabled;
  76759. private _motionBlurSamples;
  76760. private _volumetricLightStepsCount;
  76761. private _samples;
  76762. /**
  76763. * @ignore
  76764. * Specifies if the bloom pipeline is enabled
  76765. */
  76766. get BloomEnabled(): boolean;
  76767. set BloomEnabled(enabled: boolean);
  76768. /**
  76769. * @ignore
  76770. * Specifies if the depth of field pipeline is enabled
  76771. */
  76772. get DepthOfFieldEnabled(): boolean;
  76773. set DepthOfFieldEnabled(enabled: boolean);
  76774. /**
  76775. * @ignore
  76776. * Specifies if the lens flare pipeline is enabled
  76777. */
  76778. get LensFlareEnabled(): boolean;
  76779. set LensFlareEnabled(enabled: boolean);
  76780. /**
  76781. * @ignore
  76782. * Specifies if the HDR pipeline is enabled
  76783. */
  76784. get HDREnabled(): boolean;
  76785. set HDREnabled(enabled: boolean);
  76786. /**
  76787. * @ignore
  76788. * Specifies if the volumetric lights scattering effect is enabled
  76789. */
  76790. get VLSEnabled(): boolean;
  76791. set VLSEnabled(enabled: boolean);
  76792. /**
  76793. * @ignore
  76794. * Specifies if the motion blur effect is enabled
  76795. */
  76796. get MotionBlurEnabled(): boolean;
  76797. set MotionBlurEnabled(enabled: boolean);
  76798. /**
  76799. * Specifies if anti-aliasing is enabled
  76800. */
  76801. get fxaaEnabled(): boolean;
  76802. set fxaaEnabled(enabled: boolean);
  76803. /**
  76804. * Specifies if screen space reflections are enabled.
  76805. */
  76806. get screenSpaceReflectionsEnabled(): boolean;
  76807. set screenSpaceReflectionsEnabled(enabled: boolean);
  76808. /**
  76809. * Specifies the number of steps used to calculate the volumetric lights
  76810. * Typically in interval [50, 200]
  76811. */
  76812. get volumetricLightStepsCount(): number;
  76813. set volumetricLightStepsCount(count: number);
  76814. /**
  76815. * Specifies the number of samples used for the motion blur effect
  76816. * Typically in interval [16, 64]
  76817. */
  76818. get motionBlurSamples(): number;
  76819. set motionBlurSamples(samples: number);
  76820. /**
  76821. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  76822. */
  76823. get samples(): number;
  76824. set samples(sampleCount: number);
  76825. /**
  76826. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76827. * @constructor
  76828. * @param name The rendering pipeline name
  76829. * @param scene The scene linked to this pipeline
  76830. * @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)
  76831. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  76832. * @param cameras The array of cameras that the rendering pipeline will be attached to
  76833. */
  76834. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  76835. private _buildPipeline;
  76836. private _createDownSampleX4PostProcess;
  76837. private _createBrightPassPostProcess;
  76838. private _createBlurPostProcesses;
  76839. private _createTextureAdderPostProcess;
  76840. private _createVolumetricLightPostProcess;
  76841. private _createLuminancePostProcesses;
  76842. private _createHdrPostProcess;
  76843. private _createLensFlarePostProcess;
  76844. private _createDepthOfFieldPostProcess;
  76845. private _createMotionBlurPostProcess;
  76846. private _getDepthTexture;
  76847. private _disposePostProcesses;
  76848. /**
  76849. * Dispose of the pipeline and stop all post processes
  76850. */
  76851. dispose(): void;
  76852. /**
  76853. * Serialize the rendering pipeline (Used when exporting)
  76854. * @returns the serialized object
  76855. */
  76856. serialize(): any;
  76857. /**
  76858. * Parse the serialized pipeline
  76859. * @param source Source pipeline.
  76860. * @param scene The scene to load the pipeline to.
  76861. * @param rootUrl The URL of the serialized pipeline.
  76862. * @returns An instantiated pipeline from the serialized object.
  76863. */
  76864. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  76865. /**
  76866. * Luminance steps
  76867. */
  76868. static LuminanceSteps: number;
  76869. }
  76870. }
  76871. declare module BABYLON {
  76872. /** @hidden */
  76873. export var tonemapPixelShader: {
  76874. name: string;
  76875. shader: string;
  76876. };
  76877. }
  76878. declare module BABYLON {
  76879. /** Defines operator used for tonemapping */
  76880. export enum TonemappingOperator {
  76881. /** Hable */
  76882. Hable = 0,
  76883. /** Reinhard */
  76884. Reinhard = 1,
  76885. /** HejiDawson */
  76886. HejiDawson = 2,
  76887. /** Photographic */
  76888. Photographic = 3
  76889. }
  76890. /**
  76891. * Defines a post process to apply tone mapping
  76892. */
  76893. export class TonemapPostProcess extends PostProcess {
  76894. private _operator;
  76895. /** Defines the required exposure adjustment */
  76896. exposureAdjustment: number;
  76897. /**
  76898. * Gets a string identifying the name of the class
  76899. * @returns "TonemapPostProcess" string
  76900. */
  76901. getClassName(): string;
  76902. /**
  76903. * Creates a new TonemapPostProcess
  76904. * @param name defines the name of the postprocess
  76905. * @param _operator defines the operator to use
  76906. * @param exposureAdjustment defines the required exposure adjustement
  76907. * @param camera defines the camera to use (can be null)
  76908. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  76909. * @param engine defines the hosting engine (can be ignore if camera is set)
  76910. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76911. */
  76912. constructor(name: string, _operator: TonemappingOperator,
  76913. /** Defines the required exposure adjustment */
  76914. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  76915. }
  76916. }
  76917. declare module BABYLON {
  76918. /** @hidden */
  76919. export var volumetricLightScatteringPixelShader: {
  76920. name: string;
  76921. shader: string;
  76922. };
  76923. }
  76924. declare module BABYLON {
  76925. /** @hidden */
  76926. export var volumetricLightScatteringPassVertexShader: {
  76927. name: string;
  76928. shader: string;
  76929. };
  76930. }
  76931. declare module BABYLON {
  76932. /** @hidden */
  76933. export var volumetricLightScatteringPassPixelShader: {
  76934. name: string;
  76935. shader: string;
  76936. };
  76937. }
  76938. declare module BABYLON {
  76939. /**
  76940. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  76941. */
  76942. export class VolumetricLightScatteringPostProcess extends PostProcess {
  76943. private _volumetricLightScatteringPass;
  76944. private _volumetricLightScatteringRTT;
  76945. private _viewPort;
  76946. private _screenCoordinates;
  76947. private _cachedDefines;
  76948. /**
  76949. * If not undefined, the mesh position is computed from the attached node position
  76950. */
  76951. attachedNode: {
  76952. position: Vector3;
  76953. };
  76954. /**
  76955. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  76956. */
  76957. customMeshPosition: Vector3;
  76958. /**
  76959. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  76960. */
  76961. useCustomMeshPosition: boolean;
  76962. /**
  76963. * If the post-process should inverse the light scattering direction
  76964. */
  76965. invert: boolean;
  76966. /**
  76967. * The internal mesh used by the post-process
  76968. */
  76969. mesh: Mesh;
  76970. /**
  76971. * @hidden
  76972. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  76973. */
  76974. get useDiffuseColor(): boolean;
  76975. set useDiffuseColor(useDiffuseColor: boolean);
  76976. /**
  76977. * Array containing the excluded meshes not rendered in the internal pass
  76978. */
  76979. excludedMeshes: AbstractMesh[];
  76980. /**
  76981. * Controls the overall intensity of the post-process
  76982. */
  76983. exposure: number;
  76984. /**
  76985. * Dissipates each sample's contribution in range [0, 1]
  76986. */
  76987. decay: number;
  76988. /**
  76989. * Controls the overall intensity of each sample
  76990. */
  76991. weight: number;
  76992. /**
  76993. * Controls the density of each sample
  76994. */
  76995. density: number;
  76996. /**
  76997. * @constructor
  76998. * @param name The post-process name
  76999. * @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)
  77000. * @param camera The camera that the post-process will be attached to
  77001. * @param mesh The mesh used to create the light scattering
  77002. * @param samples The post-process quality, default 100
  77003. * @param samplingModeThe post-process filtering mode
  77004. * @param engine The babylon engine
  77005. * @param reusable If the post-process is reusable
  77006. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  77007. */
  77008. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  77009. /**
  77010. * Returns the string "VolumetricLightScatteringPostProcess"
  77011. * @returns "VolumetricLightScatteringPostProcess"
  77012. */
  77013. getClassName(): string;
  77014. private _isReady;
  77015. /**
  77016. * Sets the new light position for light scattering effect
  77017. * @param position The new custom light position
  77018. */
  77019. setCustomMeshPosition(position: Vector3): void;
  77020. /**
  77021. * Returns the light position for light scattering effect
  77022. * @return Vector3 The custom light position
  77023. */
  77024. getCustomMeshPosition(): Vector3;
  77025. /**
  77026. * Disposes the internal assets and detaches the post-process from the camera
  77027. */
  77028. dispose(camera: Camera): void;
  77029. /**
  77030. * Returns the render target texture used by the post-process
  77031. * @return the render target texture used by the post-process
  77032. */
  77033. getPass(): RenderTargetTexture;
  77034. private _meshExcluded;
  77035. private _createPass;
  77036. private _updateMeshScreenCoordinates;
  77037. /**
  77038. * Creates a default mesh for the Volumeric Light Scattering post-process
  77039. * @param name The mesh name
  77040. * @param scene The scene where to create the mesh
  77041. * @return the default mesh
  77042. */
  77043. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  77044. }
  77045. }
  77046. declare module BABYLON {
  77047. /** @hidden */
  77048. export var screenSpaceCurvaturePixelShader: {
  77049. name: string;
  77050. shader: string;
  77051. };
  77052. }
  77053. declare module BABYLON {
  77054. /**
  77055. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  77056. */
  77057. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  77058. /**
  77059. * Defines how much ridge the curvature effect displays.
  77060. */
  77061. ridge: number;
  77062. /**
  77063. * Defines how much valley the curvature effect displays.
  77064. */
  77065. valley: number;
  77066. private _geometryBufferRenderer;
  77067. /**
  77068. * Gets a string identifying the name of the class
  77069. * @returns "ScreenSpaceCurvaturePostProcess" string
  77070. */
  77071. getClassName(): string;
  77072. /**
  77073. * Creates a new instance ScreenSpaceCurvaturePostProcess
  77074. * @param name The name of the effect.
  77075. * @param scene The scene containing the objects to blur according to their velocity.
  77076. * @param options The required width/height ratio to downsize to before computing the render pass.
  77077. * @param camera The camera to apply the render pass to.
  77078. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77079. * @param engine The engine which the post process will be applied. (default: current engine)
  77080. * @param reusable If the post process can be reused on the same frame. (default: false)
  77081. * @param textureType Type of textures used when performing the post process. (default: 0)
  77082. * @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)
  77083. */
  77084. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  77085. /**
  77086. * Support test.
  77087. */
  77088. static get IsSupported(): boolean;
  77089. /** @hidden */
  77090. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  77091. }
  77092. }
  77093. declare module BABYLON {
  77094. interface Scene {
  77095. /** @hidden (Backing field) */
  77096. _boundingBoxRenderer: BoundingBoxRenderer;
  77097. /** @hidden (Backing field) */
  77098. _forceShowBoundingBoxes: boolean;
  77099. /**
  77100. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  77101. */
  77102. forceShowBoundingBoxes: boolean;
  77103. /**
  77104. * Gets the bounding box renderer associated with the scene
  77105. * @returns a BoundingBoxRenderer
  77106. */
  77107. getBoundingBoxRenderer(): BoundingBoxRenderer;
  77108. }
  77109. interface AbstractMesh {
  77110. /** @hidden (Backing field) */
  77111. _showBoundingBox: boolean;
  77112. /**
  77113. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  77114. */
  77115. showBoundingBox: boolean;
  77116. }
  77117. /**
  77118. * Component responsible of rendering the bounding box of the meshes in a scene.
  77119. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  77120. */
  77121. export class BoundingBoxRenderer implements ISceneComponent {
  77122. /**
  77123. * The component name helpful to identify the component in the list of scene components.
  77124. */
  77125. readonly name: string;
  77126. /**
  77127. * The scene the component belongs to.
  77128. */
  77129. scene: Scene;
  77130. /**
  77131. * Color of the bounding box lines placed in front of an object
  77132. */
  77133. frontColor: Color3;
  77134. /**
  77135. * Color of the bounding box lines placed behind an object
  77136. */
  77137. backColor: Color3;
  77138. /**
  77139. * Defines if the renderer should show the back lines or not
  77140. */
  77141. showBackLines: boolean;
  77142. /**
  77143. * Observable raised before rendering a bounding box
  77144. */
  77145. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  77146. /**
  77147. * Observable raised after rendering a bounding box
  77148. */
  77149. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  77150. /**
  77151. * Observable raised after resources are created
  77152. */
  77153. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  77154. /**
  77155. * When false, no bounding boxes will be rendered
  77156. */
  77157. enabled: boolean;
  77158. /**
  77159. * @hidden
  77160. */
  77161. renderList: SmartArray<BoundingBox>;
  77162. private _colorShader;
  77163. private _vertexBuffers;
  77164. private _indexBuffer;
  77165. private _fillIndexBuffer;
  77166. private _fillIndexData;
  77167. /**
  77168. * Instantiates a new bounding box renderer in a scene.
  77169. * @param scene the scene the renderer renders in
  77170. */
  77171. constructor(scene: Scene);
  77172. /**
  77173. * Registers the component in a given scene
  77174. */
  77175. register(): void;
  77176. private _evaluateSubMesh;
  77177. private _preActiveMesh;
  77178. private _prepareResources;
  77179. private _createIndexBuffer;
  77180. /**
  77181. * Rebuilds the elements related to this component in case of
  77182. * context lost for instance.
  77183. */
  77184. rebuild(): void;
  77185. /**
  77186. * @hidden
  77187. */
  77188. reset(): void;
  77189. /**
  77190. * Render the bounding boxes of a specific rendering group
  77191. * @param renderingGroupId defines the rendering group to render
  77192. */
  77193. render(renderingGroupId: number): void;
  77194. /**
  77195. * In case of occlusion queries, we can render the occlusion bounding box through this method
  77196. * @param mesh Define the mesh to render the occlusion bounding box for
  77197. */
  77198. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  77199. /**
  77200. * Dispose and release the resources attached to this renderer.
  77201. */
  77202. dispose(): void;
  77203. }
  77204. }
  77205. declare module BABYLON {
  77206. interface Scene {
  77207. /** @hidden (Backing field) */
  77208. _depthRenderer: {
  77209. [id: string]: DepthRenderer;
  77210. };
  77211. /**
  77212. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  77213. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  77214. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  77215. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  77216. * @returns the created depth renderer
  77217. */
  77218. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  77219. /**
  77220. * Disables a depth renderer for a given camera
  77221. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  77222. */
  77223. disableDepthRenderer(camera?: Nullable<Camera>): void;
  77224. }
  77225. /**
  77226. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  77227. * in several rendering techniques.
  77228. */
  77229. export class DepthRendererSceneComponent implements ISceneComponent {
  77230. /**
  77231. * The component name helpful to identify the component in the list of scene components.
  77232. */
  77233. readonly name: string;
  77234. /**
  77235. * The scene the component belongs to.
  77236. */
  77237. scene: Scene;
  77238. /**
  77239. * Creates a new instance of the component for the given scene
  77240. * @param scene Defines the scene to register the component in
  77241. */
  77242. constructor(scene: Scene);
  77243. /**
  77244. * Registers the component in a given scene
  77245. */
  77246. register(): void;
  77247. /**
  77248. * Rebuilds the elements related to this component in case of
  77249. * context lost for instance.
  77250. */
  77251. rebuild(): void;
  77252. /**
  77253. * Disposes the component and the associated resources
  77254. */
  77255. dispose(): void;
  77256. private _gatherRenderTargets;
  77257. private _gatherActiveCameraRenderTargets;
  77258. }
  77259. }
  77260. declare module BABYLON {
  77261. interface AbstractScene {
  77262. /** @hidden (Backing field) */
  77263. _prePassRenderer: Nullable<PrePassRenderer>;
  77264. /**
  77265. * Gets or Sets the current prepass renderer associated to the scene.
  77266. */
  77267. prePassRenderer: Nullable<PrePassRenderer>;
  77268. /**
  77269. * Enables the prepass and associates it with the scene
  77270. * @returns the PrePassRenderer
  77271. */
  77272. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  77273. /**
  77274. * Disables the prepass associated with the scene
  77275. */
  77276. disablePrePassRenderer(): void;
  77277. }
  77278. interface RenderTargetTexture {
  77279. /** @hidden */
  77280. _prePassRenderTarget: PrePassRenderTarget;
  77281. }
  77282. /**
  77283. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  77284. * in several rendering techniques.
  77285. */
  77286. export class PrePassRendererSceneComponent implements ISceneComponent {
  77287. /**
  77288. * The component name helpful to identify the component in the list of scene components.
  77289. */
  77290. readonly name: string;
  77291. /**
  77292. * The scene the component belongs to.
  77293. */
  77294. scene: Scene;
  77295. /**
  77296. * Creates a new instance of the component for the given scene
  77297. * @param scene Defines the scene to register the component in
  77298. */
  77299. constructor(scene: Scene);
  77300. /**
  77301. * Registers the component in a given scene
  77302. */
  77303. register(): void;
  77304. private _beforeRenderTargetDraw;
  77305. private _afterRenderTargetDraw;
  77306. private _beforeRenderTargetClearStage;
  77307. private _beforeCameraDraw;
  77308. private _afterCameraDraw;
  77309. private _beforeClearStage;
  77310. private _beforeRenderingMeshStage;
  77311. private _afterRenderingMeshStage;
  77312. /**
  77313. * Rebuilds the elements related to this component in case of
  77314. * context lost for instance.
  77315. */
  77316. rebuild(): void;
  77317. /**
  77318. * Disposes the component and the associated resources
  77319. */
  77320. dispose(): void;
  77321. }
  77322. }
  77323. declare module BABYLON {
  77324. /** @hidden */
  77325. export var fibonacci: {
  77326. name: string;
  77327. shader: string;
  77328. };
  77329. }
  77330. declare module BABYLON {
  77331. /** @hidden */
  77332. export var diffusionProfile: {
  77333. name: string;
  77334. shader: string;
  77335. };
  77336. }
  77337. declare module BABYLON {
  77338. /** @hidden */
  77339. export var subSurfaceScatteringPixelShader: {
  77340. name: string;
  77341. shader: string;
  77342. };
  77343. }
  77344. declare module BABYLON {
  77345. /**
  77346. * Sub surface scattering post process
  77347. */
  77348. export class SubSurfaceScatteringPostProcess extends PostProcess {
  77349. /**
  77350. * Gets a string identifying the name of the class
  77351. * @returns "SubSurfaceScatteringPostProcess" string
  77352. */
  77353. getClassName(): string;
  77354. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  77355. }
  77356. }
  77357. declare module BABYLON {
  77358. /**
  77359. * Contains all parameters needed for the prepass to perform
  77360. * screen space subsurface scattering
  77361. */
  77362. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  77363. /** @hidden */
  77364. static _SceneComponentInitialization: (scene: Scene) => void;
  77365. private _ssDiffusionS;
  77366. private _ssFilterRadii;
  77367. private _ssDiffusionD;
  77368. /**
  77369. * Post process to attach for screen space subsurface scattering
  77370. */
  77371. postProcess: SubSurfaceScatteringPostProcess;
  77372. /**
  77373. * Diffusion profile color for subsurface scattering
  77374. */
  77375. get ssDiffusionS(): number[];
  77376. /**
  77377. * Diffusion profile max color channel value for subsurface scattering
  77378. */
  77379. get ssDiffusionD(): number[];
  77380. /**
  77381. * Diffusion profile filter radius for subsurface scattering
  77382. */
  77383. get ssFilterRadii(): number[];
  77384. /**
  77385. * Is subsurface enabled
  77386. */
  77387. enabled: boolean;
  77388. /**
  77389. * Does the output of this prepass need to go through imageprocessing
  77390. */
  77391. needsImageProcessing: boolean;
  77392. /**
  77393. * Name of the configuration
  77394. */
  77395. name: string;
  77396. /**
  77397. * Diffusion profile colors for subsurface scattering
  77398. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  77399. * See ...
  77400. * Note that you can only store up to 5 of them
  77401. */
  77402. ssDiffusionProfileColors: Color3[];
  77403. /**
  77404. * Defines the ratio real world => scene units.
  77405. * Used for subsurface scattering
  77406. */
  77407. metersPerUnit: number;
  77408. /**
  77409. * Textures that should be present in the MRT for this effect to work
  77410. */
  77411. readonly texturesRequired: number[];
  77412. private _scene;
  77413. /**
  77414. * Builds a subsurface configuration object
  77415. * @param scene The scene
  77416. */
  77417. constructor(scene: Scene);
  77418. /**
  77419. * Adds a new diffusion profile.
  77420. * Useful for more realistic subsurface scattering on diverse materials.
  77421. * @param color The color of the diffusion profile. Should be the average color of the material.
  77422. * @return The index of the diffusion profile for the material subsurface configuration
  77423. */
  77424. addDiffusionProfile(color: Color3): number;
  77425. /**
  77426. * Creates the sss post process
  77427. * @return The created post process
  77428. */
  77429. createPostProcess(): SubSurfaceScatteringPostProcess;
  77430. /**
  77431. * Deletes all diffusion profiles.
  77432. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  77433. */
  77434. clearAllDiffusionProfiles(): void;
  77435. /**
  77436. * Disposes this object
  77437. */
  77438. dispose(): void;
  77439. /**
  77440. * @hidden
  77441. * https://zero-radiance.github.io/post/sampling-diffusion/
  77442. *
  77443. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  77444. * ------------------------------------------------------------------------------------
  77445. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  77446. * PDF[r, phi, s] = r * R[r, phi, s]
  77447. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  77448. * ------------------------------------------------------------------------------------
  77449. * We importance sample the color channel with the widest scattering distance.
  77450. */
  77451. getDiffusionProfileParameters(color: Color3): number;
  77452. /**
  77453. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  77454. * 'u' is the random number (the value of the CDF): [0, 1).
  77455. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  77456. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  77457. */
  77458. private _sampleBurleyDiffusionProfile;
  77459. }
  77460. }
  77461. declare module BABYLON {
  77462. interface AbstractScene {
  77463. /** @hidden (Backing field) */
  77464. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  77465. /**
  77466. * Gets or Sets the current prepass renderer associated to the scene.
  77467. */
  77468. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  77469. /**
  77470. * Enables the subsurface effect for prepass
  77471. * @returns the SubSurfaceConfiguration
  77472. */
  77473. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  77474. /**
  77475. * Disables the subsurface effect for prepass
  77476. */
  77477. disableSubSurfaceForPrePass(): void;
  77478. }
  77479. /**
  77480. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  77481. * in several rendering techniques.
  77482. */
  77483. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  77484. /**
  77485. * The component name helpful to identify the component in the list of scene components.
  77486. */
  77487. readonly name: string;
  77488. /**
  77489. * The scene the component belongs to.
  77490. */
  77491. scene: Scene;
  77492. /**
  77493. * Creates a new instance of the component for the given scene
  77494. * @param scene Defines the scene to register the component in
  77495. */
  77496. constructor(scene: Scene);
  77497. /**
  77498. * Registers the component in a given scene
  77499. */
  77500. register(): void;
  77501. /**
  77502. * Serializes the component data to the specified json object
  77503. * @param serializationObject The object to serialize to
  77504. */
  77505. serialize(serializationObject: any): void;
  77506. /**
  77507. * Adds all the elements from the container to the scene
  77508. * @param container the container holding the elements
  77509. */
  77510. addFromContainer(container: AbstractScene): void;
  77511. /**
  77512. * Removes all the elements in the container from the scene
  77513. * @param container contains the elements to remove
  77514. * @param dispose if the removed element should be disposed (default: false)
  77515. */
  77516. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  77517. /**
  77518. * Rebuilds the elements related to this component in case of
  77519. * context lost for instance.
  77520. */
  77521. rebuild(): void;
  77522. /**
  77523. * Disposes the component and the associated resources
  77524. */
  77525. dispose(): void;
  77526. }
  77527. }
  77528. declare module BABYLON {
  77529. /** @hidden */
  77530. export var outlinePixelShader: {
  77531. name: string;
  77532. shader: string;
  77533. };
  77534. }
  77535. declare module BABYLON {
  77536. /** @hidden */
  77537. export var outlineVertexShader: {
  77538. name: string;
  77539. shader: string;
  77540. };
  77541. }
  77542. declare module BABYLON {
  77543. interface Scene {
  77544. /** @hidden */
  77545. _outlineRenderer: OutlineRenderer;
  77546. /**
  77547. * Gets the outline renderer associated with the scene
  77548. * @returns a OutlineRenderer
  77549. */
  77550. getOutlineRenderer(): OutlineRenderer;
  77551. }
  77552. interface AbstractMesh {
  77553. /** @hidden (Backing field) */
  77554. _renderOutline: boolean;
  77555. /**
  77556. * Gets or sets a boolean indicating if the outline must be rendered as well
  77557. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  77558. */
  77559. renderOutline: boolean;
  77560. /** @hidden (Backing field) */
  77561. _renderOverlay: boolean;
  77562. /**
  77563. * Gets or sets a boolean indicating if the overlay must be rendered as well
  77564. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  77565. */
  77566. renderOverlay: boolean;
  77567. }
  77568. /**
  77569. * This class is responsible to draw the outline/overlay of meshes.
  77570. * It should not be used directly but through the available method on mesh.
  77571. */
  77572. export class OutlineRenderer implements ISceneComponent {
  77573. /**
  77574. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  77575. */
  77576. private static _StencilReference;
  77577. /**
  77578. * The name of the component. Each component must have a unique name.
  77579. */
  77580. name: string;
  77581. /**
  77582. * The scene the component belongs to.
  77583. */
  77584. scene: Scene;
  77585. /**
  77586. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  77587. */
  77588. zOffset: number;
  77589. private _engine;
  77590. private _effect;
  77591. private _cachedDefines;
  77592. private _savedDepthWrite;
  77593. /**
  77594. * Instantiates a new outline renderer. (There could be only one per scene).
  77595. * @param scene Defines the scene it belongs to
  77596. */
  77597. constructor(scene: Scene);
  77598. /**
  77599. * Register the component to one instance of a scene.
  77600. */
  77601. register(): void;
  77602. /**
  77603. * Rebuilds the elements related to this component in case of
  77604. * context lost for instance.
  77605. */
  77606. rebuild(): void;
  77607. /**
  77608. * Disposes the component and the associated resources.
  77609. */
  77610. dispose(): void;
  77611. /**
  77612. * Renders the outline in the canvas.
  77613. * @param subMesh Defines the sumesh to render
  77614. * @param batch Defines the batch of meshes in case of instances
  77615. * @param useOverlay Defines if the rendering is for the overlay or the outline
  77616. */
  77617. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  77618. /**
  77619. * Returns whether or not the outline renderer is ready for a given submesh.
  77620. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  77621. * @param subMesh Defines the submesh to check readiness for
  77622. * @param useInstances Defines whether wee are trying to render instances or not
  77623. * @returns true if ready otherwise false
  77624. */
  77625. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77626. private _beforeRenderingMesh;
  77627. private _afterRenderingMesh;
  77628. }
  77629. }
  77630. declare module BABYLON {
  77631. /**
  77632. * Defines the basic options interface of a Sprite Frame Source Size.
  77633. */
  77634. export interface ISpriteJSONSpriteSourceSize {
  77635. /**
  77636. * number of the original width of the Frame
  77637. */
  77638. w: number;
  77639. /**
  77640. * number of the original height of the Frame
  77641. */
  77642. h: number;
  77643. }
  77644. /**
  77645. * Defines the basic options interface of a Sprite Frame Data.
  77646. */
  77647. export interface ISpriteJSONSpriteFrameData {
  77648. /**
  77649. * number of the x offset of the Frame
  77650. */
  77651. x: number;
  77652. /**
  77653. * number of the y offset of the Frame
  77654. */
  77655. y: number;
  77656. /**
  77657. * number of the width of the Frame
  77658. */
  77659. w: number;
  77660. /**
  77661. * number of the height of the Frame
  77662. */
  77663. h: number;
  77664. }
  77665. /**
  77666. * Defines the basic options interface of a JSON Sprite.
  77667. */
  77668. export interface ISpriteJSONSprite {
  77669. /**
  77670. * string name of the Frame
  77671. */
  77672. filename: string;
  77673. /**
  77674. * ISpriteJSONSpriteFrame basic object of the frame data
  77675. */
  77676. frame: ISpriteJSONSpriteFrameData;
  77677. /**
  77678. * boolean to flag is the frame was rotated.
  77679. */
  77680. rotated: boolean;
  77681. /**
  77682. * boolean to flag is the frame was trimmed.
  77683. */
  77684. trimmed: boolean;
  77685. /**
  77686. * ISpriteJSONSpriteFrame basic object of the source data
  77687. */
  77688. spriteSourceSize: ISpriteJSONSpriteFrameData;
  77689. /**
  77690. * ISpriteJSONSpriteFrame basic object of the source data
  77691. */
  77692. sourceSize: ISpriteJSONSpriteSourceSize;
  77693. }
  77694. /**
  77695. * Defines the basic options interface of a JSON atlas.
  77696. */
  77697. export interface ISpriteJSONAtlas {
  77698. /**
  77699. * Array of objects that contain the frame data.
  77700. */
  77701. frames: Array<ISpriteJSONSprite>;
  77702. /**
  77703. * object basic object containing the sprite meta data.
  77704. */
  77705. meta?: object;
  77706. }
  77707. }
  77708. declare module BABYLON {
  77709. /** @hidden */
  77710. export var spriteMapPixelShader: {
  77711. name: string;
  77712. shader: string;
  77713. };
  77714. }
  77715. declare module BABYLON {
  77716. /** @hidden */
  77717. export var spriteMapVertexShader: {
  77718. name: string;
  77719. shader: string;
  77720. };
  77721. }
  77722. declare module BABYLON {
  77723. /**
  77724. * Defines the basic options interface of a SpriteMap
  77725. */
  77726. export interface ISpriteMapOptions {
  77727. /**
  77728. * Vector2 of the number of cells in the grid.
  77729. */
  77730. stageSize?: Vector2;
  77731. /**
  77732. * Vector2 of the size of the output plane in World Units.
  77733. */
  77734. outputSize?: Vector2;
  77735. /**
  77736. * Vector3 of the position of the output plane in World Units.
  77737. */
  77738. outputPosition?: Vector3;
  77739. /**
  77740. * Vector3 of the rotation of the output plane.
  77741. */
  77742. outputRotation?: Vector3;
  77743. /**
  77744. * number of layers that the system will reserve in resources.
  77745. */
  77746. layerCount?: number;
  77747. /**
  77748. * number of max animation frames a single cell will reserve in resources.
  77749. */
  77750. maxAnimationFrames?: number;
  77751. /**
  77752. * number cell index of the base tile when the system compiles.
  77753. */
  77754. baseTile?: number;
  77755. /**
  77756. * boolean flip the sprite after its been repositioned by the framing data.
  77757. */
  77758. flipU?: boolean;
  77759. /**
  77760. * Vector3 scalar of the global RGB values of the SpriteMap.
  77761. */
  77762. colorMultiply?: Vector3;
  77763. }
  77764. /**
  77765. * Defines the IDisposable interface in order to be cleanable from resources.
  77766. */
  77767. export interface ISpriteMap extends IDisposable {
  77768. /**
  77769. * String name of the SpriteMap.
  77770. */
  77771. name: string;
  77772. /**
  77773. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  77774. */
  77775. atlasJSON: ISpriteJSONAtlas;
  77776. /**
  77777. * Texture of the SpriteMap.
  77778. */
  77779. spriteSheet: Texture;
  77780. /**
  77781. * The parameters to initialize the SpriteMap with.
  77782. */
  77783. options: ISpriteMapOptions;
  77784. }
  77785. /**
  77786. * Class used to manage a grid restricted sprite deployment on an Output plane.
  77787. */
  77788. export class SpriteMap implements ISpriteMap {
  77789. /** The Name of the spriteMap */
  77790. name: string;
  77791. /** The JSON file with the frame and meta data */
  77792. atlasJSON: ISpriteJSONAtlas;
  77793. /** The systems Sprite Sheet Texture */
  77794. spriteSheet: Texture;
  77795. /** Arguments passed with the Constructor */
  77796. options: ISpriteMapOptions;
  77797. /** Public Sprite Storage array, parsed from atlasJSON */
  77798. sprites: Array<ISpriteJSONSprite>;
  77799. /** Returns the Number of Sprites in the System */
  77800. get spriteCount(): number;
  77801. /** Returns the Position of Output Plane*/
  77802. get position(): Vector3;
  77803. /** Returns the Position of Output Plane*/
  77804. set position(v: Vector3);
  77805. /** Returns the Rotation of Output Plane*/
  77806. get rotation(): Vector3;
  77807. /** Returns the Rotation of Output Plane*/
  77808. set rotation(v: Vector3);
  77809. /** Sets the AnimationMap*/
  77810. get animationMap(): RawTexture;
  77811. /** Sets the AnimationMap*/
  77812. set animationMap(v: RawTexture);
  77813. /** Scene that the SpriteMap was created in */
  77814. private _scene;
  77815. /** Texture Buffer of Float32 that holds tile frame data*/
  77816. private _frameMap;
  77817. /** Texture Buffers of Float32 that holds tileMap data*/
  77818. private _tileMaps;
  77819. /** Texture Buffer of Float32 that holds Animation Data*/
  77820. private _animationMap;
  77821. /** Custom ShaderMaterial Central to the System*/
  77822. private _material;
  77823. /** Custom ShaderMaterial Central to the System*/
  77824. private _output;
  77825. /** Systems Time Ticker*/
  77826. private _time;
  77827. /**
  77828. * Creates a new SpriteMap
  77829. * @param name defines the SpriteMaps Name
  77830. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  77831. * @param spriteSheet is the Texture that the Sprites are on.
  77832. * @param options a basic deployment configuration
  77833. * @param scene The Scene that the map is deployed on
  77834. */
  77835. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  77836. /**
  77837. * Returns tileID location
  77838. * @returns Vector2 the cell position ID
  77839. */
  77840. getTileID(): Vector2;
  77841. /**
  77842. * Gets the UV location of the mouse over the SpriteMap.
  77843. * @returns Vector2 the UV position of the mouse interaction
  77844. */
  77845. getMousePosition(): Vector2;
  77846. /**
  77847. * Creates the "frame" texture Buffer
  77848. * -------------------------------------
  77849. * Structure of frames
  77850. * "filename": "Falling-Water-2.png",
  77851. * "frame": {"x":69,"y":103,"w":24,"h":32},
  77852. * "rotated": true,
  77853. * "trimmed": true,
  77854. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  77855. * "sourceSize": {"w":32,"h":32}
  77856. * @returns RawTexture of the frameMap
  77857. */
  77858. private _createFrameBuffer;
  77859. /**
  77860. * Creates the tileMap texture Buffer
  77861. * @param buffer normally and array of numbers, or a false to generate from scratch
  77862. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  77863. * @returns RawTexture of the tileMap
  77864. */
  77865. private _createTileBuffer;
  77866. /**
  77867. * Modifies the data of the tileMaps
  77868. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  77869. * @param pos is the iVector2 Coordinates of the Tile
  77870. * @param tile The SpriteIndex of the new Tile
  77871. */
  77872. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  77873. /**
  77874. * Creates the animationMap texture Buffer
  77875. * @param buffer normally and array of numbers, or a false to generate from scratch
  77876. * @returns RawTexture of the animationMap
  77877. */
  77878. private _createTileAnimationBuffer;
  77879. /**
  77880. * Modifies the data of the animationMap
  77881. * @param cellID is the Index of the Sprite
  77882. * @param _frame is the target Animation frame
  77883. * @param toCell is the Target Index of the next frame of the animation
  77884. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  77885. * @param speed is a global scalar of the time variable on the map.
  77886. */
  77887. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  77888. /**
  77889. * Exports the .tilemaps file
  77890. */
  77891. saveTileMaps(): void;
  77892. /**
  77893. * Imports the .tilemaps file
  77894. * @param url of the .tilemaps file
  77895. */
  77896. loadTileMaps(url: string): void;
  77897. /**
  77898. * Release associated resources
  77899. */
  77900. dispose(): void;
  77901. }
  77902. }
  77903. declare module BABYLON {
  77904. /**
  77905. * Class used to manage multiple sprites of different sizes on the same spritesheet
  77906. * @see https://doc.babylonjs.com/babylon101/sprites
  77907. */
  77908. export class SpritePackedManager extends SpriteManager {
  77909. /** defines the packed manager's name */
  77910. name: string;
  77911. /**
  77912. * Creates a new sprite manager from a packed sprite sheet
  77913. * @param name defines the manager's name
  77914. * @param imgUrl defines the sprite sheet url
  77915. * @param capacity defines the maximum allowed number of sprites
  77916. * @param scene defines the hosting scene
  77917. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  77918. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77919. * @param samplingMode defines the sampling mode to use with spritesheet
  77920. * @param fromPacked set to true; do not alter
  77921. */
  77922. constructor(
  77923. /** defines the packed manager's name */
  77924. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  77925. }
  77926. }
  77927. declare module BABYLON {
  77928. /**
  77929. * Defines the list of states available for a task inside a AssetsManager
  77930. */
  77931. export enum AssetTaskState {
  77932. /**
  77933. * Initialization
  77934. */
  77935. INIT = 0,
  77936. /**
  77937. * Running
  77938. */
  77939. RUNNING = 1,
  77940. /**
  77941. * Done
  77942. */
  77943. DONE = 2,
  77944. /**
  77945. * Error
  77946. */
  77947. ERROR = 3
  77948. }
  77949. /**
  77950. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  77951. */
  77952. export abstract class AbstractAssetTask {
  77953. /**
  77954. * Task name
  77955. */ name: string;
  77956. /**
  77957. * Callback called when the task is successful
  77958. */
  77959. onSuccess: (task: any) => void;
  77960. /**
  77961. * Callback called when the task is not successful
  77962. */
  77963. onError: (task: any, message?: string, exception?: any) => void;
  77964. /**
  77965. * Creates a new AssetsManager
  77966. * @param name defines the name of the task
  77967. */
  77968. constructor(
  77969. /**
  77970. * Task name
  77971. */ name: string);
  77972. private _isCompleted;
  77973. private _taskState;
  77974. private _errorObject;
  77975. /**
  77976. * Get if the task is completed
  77977. */
  77978. get isCompleted(): boolean;
  77979. /**
  77980. * Gets the current state of the task
  77981. */
  77982. get taskState(): AssetTaskState;
  77983. /**
  77984. * Gets the current error object (if task is in error)
  77985. */
  77986. get errorObject(): {
  77987. message?: string;
  77988. exception?: any;
  77989. };
  77990. /**
  77991. * Internal only
  77992. * @hidden
  77993. */
  77994. _setErrorObject(message?: string, exception?: any): void;
  77995. /**
  77996. * Execute the current task
  77997. * @param scene defines the scene where you want your assets to be loaded
  77998. * @param onSuccess is a callback called when the task is successfully executed
  77999. * @param onError is a callback called if an error occurs
  78000. */
  78001. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78002. /**
  78003. * Execute the current task
  78004. * @param scene defines the scene where you want your assets to be loaded
  78005. * @param onSuccess is a callback called when the task is successfully executed
  78006. * @param onError is a callback called if an error occurs
  78007. */
  78008. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78009. /**
  78010. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  78011. * This can be used with failed tasks that have the reason for failure fixed.
  78012. */
  78013. reset(): void;
  78014. private onErrorCallback;
  78015. private onDoneCallback;
  78016. }
  78017. /**
  78018. * Define the interface used by progress events raised during assets loading
  78019. */
  78020. export interface IAssetsProgressEvent {
  78021. /**
  78022. * Defines the number of remaining tasks to process
  78023. */
  78024. remainingCount: number;
  78025. /**
  78026. * Defines the total number of tasks
  78027. */
  78028. totalCount: number;
  78029. /**
  78030. * Defines the task that was just processed
  78031. */
  78032. task: AbstractAssetTask;
  78033. }
  78034. /**
  78035. * Class used to share progress information about assets loading
  78036. */
  78037. export class AssetsProgressEvent implements IAssetsProgressEvent {
  78038. /**
  78039. * Defines the number of remaining tasks to process
  78040. */
  78041. remainingCount: number;
  78042. /**
  78043. * Defines the total number of tasks
  78044. */
  78045. totalCount: number;
  78046. /**
  78047. * Defines the task that was just processed
  78048. */
  78049. task: AbstractAssetTask;
  78050. /**
  78051. * Creates a AssetsProgressEvent
  78052. * @param remainingCount defines the number of remaining tasks to process
  78053. * @param totalCount defines the total number of tasks
  78054. * @param task defines the task that was just processed
  78055. */
  78056. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  78057. }
  78058. /**
  78059. * Define a task used by AssetsManager to load assets into a container
  78060. */
  78061. export class ContainerAssetTask extends AbstractAssetTask {
  78062. /**
  78063. * Defines the name of the task
  78064. */
  78065. name: string;
  78066. /**
  78067. * Defines the list of mesh's names you want to load
  78068. */
  78069. meshesNames: any;
  78070. /**
  78071. * Defines the root url to use as a base to load your meshes and associated resources
  78072. */
  78073. rootUrl: string;
  78074. /**
  78075. * Defines the filename or File of the scene to load from
  78076. */
  78077. sceneFilename: string | File;
  78078. /**
  78079. * Get the loaded asset container
  78080. */
  78081. loadedContainer: AssetContainer;
  78082. /**
  78083. * Gets the list of loaded meshes
  78084. */
  78085. loadedMeshes: Array<AbstractMesh>;
  78086. /**
  78087. * Gets the list of loaded particle systems
  78088. */
  78089. loadedParticleSystems: Array<IParticleSystem>;
  78090. /**
  78091. * Gets the list of loaded skeletons
  78092. */
  78093. loadedSkeletons: Array<Skeleton>;
  78094. /**
  78095. * Gets the list of loaded animation groups
  78096. */
  78097. loadedAnimationGroups: Array<AnimationGroup>;
  78098. /**
  78099. * Callback called when the task is successful
  78100. */
  78101. onSuccess: (task: ContainerAssetTask) => void;
  78102. /**
  78103. * Callback called when the task is successful
  78104. */
  78105. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  78106. /**
  78107. * Creates a new ContainerAssetTask
  78108. * @param name defines the name of the task
  78109. * @param meshesNames defines the list of mesh's names you want to load
  78110. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  78111. * @param sceneFilename defines the filename or File of the scene to load from
  78112. */
  78113. constructor(
  78114. /**
  78115. * Defines the name of the task
  78116. */
  78117. name: string,
  78118. /**
  78119. * Defines the list of mesh's names you want to load
  78120. */
  78121. meshesNames: any,
  78122. /**
  78123. * Defines the root url to use as a base to load your meshes and associated resources
  78124. */
  78125. rootUrl: string,
  78126. /**
  78127. * Defines the filename or File of the scene to load from
  78128. */
  78129. sceneFilename: string | File);
  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 meshes
  78140. */
  78141. export class MeshAssetTask extends AbstractAssetTask {
  78142. /**
  78143. * Defines the name of the task
  78144. */
  78145. name: string;
  78146. /**
  78147. * Defines the list of mesh's names you want to load
  78148. */
  78149. meshesNames: any;
  78150. /**
  78151. * Defines the root url to use as a base to load your meshes and associated resources
  78152. */
  78153. rootUrl: string;
  78154. /**
  78155. * Defines the filename or File of the scene to load from
  78156. */
  78157. sceneFilename: string | File;
  78158. /**
  78159. * Gets the list of loaded meshes
  78160. */
  78161. loadedMeshes: Array<AbstractMesh>;
  78162. /**
  78163. * Gets the list of loaded particle systems
  78164. */
  78165. loadedParticleSystems: Array<IParticleSystem>;
  78166. /**
  78167. * Gets the list of loaded skeletons
  78168. */
  78169. loadedSkeletons: Array<Skeleton>;
  78170. /**
  78171. * Gets the list of loaded animation groups
  78172. */
  78173. loadedAnimationGroups: Array<AnimationGroup>;
  78174. /**
  78175. * Callback called when the task is successful
  78176. */
  78177. onSuccess: (task: MeshAssetTask) => void;
  78178. /**
  78179. * Callback called when the task is successful
  78180. */
  78181. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  78182. /**
  78183. * Creates a new MeshAssetTask
  78184. * @param name defines the name of the task
  78185. * @param meshesNames defines the list of mesh's names you want to load
  78186. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  78187. * @param sceneFilename defines the filename or File of the scene to load from
  78188. */
  78189. constructor(
  78190. /**
  78191. * Defines the name of the task
  78192. */
  78193. name: string,
  78194. /**
  78195. * Defines the list of mesh's names you want to load
  78196. */
  78197. meshesNames: any,
  78198. /**
  78199. * Defines the root url to use as a base to load your meshes and associated resources
  78200. */
  78201. rootUrl: string,
  78202. /**
  78203. * Defines the filename or File of the scene to load from
  78204. */
  78205. sceneFilename: string | File);
  78206. /**
  78207. * Execute the current task
  78208. * @param scene defines the scene where you want your assets to be loaded
  78209. * @param onSuccess is a callback called when the task is successfully executed
  78210. * @param onError is a callback called if an error occurs
  78211. */
  78212. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78213. }
  78214. /**
  78215. * Define a task used by AssetsManager to load text content
  78216. */
  78217. export class TextFileAssetTask extends AbstractAssetTask {
  78218. /**
  78219. * Defines the name of the task
  78220. */
  78221. name: string;
  78222. /**
  78223. * Defines the location of the file to load
  78224. */
  78225. url: string;
  78226. /**
  78227. * Gets the loaded text string
  78228. */
  78229. text: string;
  78230. /**
  78231. * Callback called when the task is successful
  78232. */
  78233. onSuccess: (task: TextFileAssetTask) => void;
  78234. /**
  78235. * Callback called when the task is successful
  78236. */
  78237. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  78238. /**
  78239. * Creates a new TextFileAssetTask object
  78240. * @param name defines the name of the task
  78241. * @param url defines the location of the file to load
  78242. */
  78243. constructor(
  78244. /**
  78245. * Defines the name of the task
  78246. */
  78247. name: string,
  78248. /**
  78249. * Defines the location of the file to load
  78250. */
  78251. url: string);
  78252. /**
  78253. * Execute the current task
  78254. * @param scene defines the scene where you want your assets to be loaded
  78255. * @param onSuccess is a callback called when the task is successfully executed
  78256. * @param onError is a callback called if an error occurs
  78257. */
  78258. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78259. }
  78260. /**
  78261. * Define a task used by AssetsManager to load binary data
  78262. */
  78263. export class BinaryFileAssetTask extends AbstractAssetTask {
  78264. /**
  78265. * Defines the name of the task
  78266. */
  78267. name: string;
  78268. /**
  78269. * Defines the location of the file to load
  78270. */
  78271. url: string;
  78272. /**
  78273. * Gets the lodaded data (as an array buffer)
  78274. */
  78275. data: ArrayBuffer;
  78276. /**
  78277. * Callback called when the task is successful
  78278. */
  78279. onSuccess: (task: BinaryFileAssetTask) => void;
  78280. /**
  78281. * Callback called when the task is successful
  78282. */
  78283. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  78284. /**
  78285. * Creates a new BinaryFileAssetTask object
  78286. * @param name defines the name of the new task
  78287. * @param url defines the location of the file to load
  78288. */
  78289. constructor(
  78290. /**
  78291. * Defines the name of the task
  78292. */
  78293. name: string,
  78294. /**
  78295. * Defines the location of the file to load
  78296. */
  78297. url: string);
  78298. /**
  78299. * Execute the current task
  78300. * @param scene defines the scene where you want your assets to be loaded
  78301. * @param onSuccess is a callback called when the task is successfully executed
  78302. * @param onError is a callback called if an error occurs
  78303. */
  78304. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78305. }
  78306. /**
  78307. * Define a task used by AssetsManager to load images
  78308. */
  78309. export class ImageAssetTask extends AbstractAssetTask {
  78310. /**
  78311. * Defines the name of the task
  78312. */
  78313. name: string;
  78314. /**
  78315. * Defines the location of the image to load
  78316. */
  78317. url: string;
  78318. /**
  78319. * Gets the loaded images
  78320. */
  78321. image: HTMLImageElement;
  78322. /**
  78323. * Callback called when the task is successful
  78324. */
  78325. onSuccess: (task: ImageAssetTask) => void;
  78326. /**
  78327. * Callback called when the task is successful
  78328. */
  78329. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  78330. /**
  78331. * Creates a new ImageAssetTask
  78332. * @param name defines the name of the task
  78333. * @param url defines the location of the image to load
  78334. */
  78335. constructor(
  78336. /**
  78337. * Defines the name of the task
  78338. */
  78339. name: string,
  78340. /**
  78341. * Defines the location of the image to load
  78342. */
  78343. url: string);
  78344. /**
  78345. * Execute the current task
  78346. * @param scene defines the scene where you want your assets to be loaded
  78347. * @param onSuccess is a callback called when the task is successfully executed
  78348. * @param onError is a callback called if an error occurs
  78349. */
  78350. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78351. }
  78352. /**
  78353. * Defines the interface used by texture loading tasks
  78354. */
  78355. export interface ITextureAssetTask<TEX extends BaseTexture> {
  78356. /**
  78357. * Gets the loaded texture
  78358. */
  78359. texture: TEX;
  78360. }
  78361. /**
  78362. * Define a task used by AssetsManager to load 2D textures
  78363. */
  78364. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  78365. /**
  78366. * Defines the name of the task
  78367. */
  78368. name: string;
  78369. /**
  78370. * Defines the location of the file to load
  78371. */
  78372. url: string;
  78373. /**
  78374. * Defines if mipmap should not be generated (default is false)
  78375. */
  78376. noMipmap?: boolean | undefined;
  78377. /**
  78378. * Defines if texture must be inverted on Y axis (default is true)
  78379. */
  78380. invertY: boolean;
  78381. /**
  78382. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78383. */
  78384. samplingMode: number;
  78385. /**
  78386. * Gets the loaded texture
  78387. */
  78388. texture: Texture;
  78389. /**
  78390. * Callback called when the task is successful
  78391. */
  78392. onSuccess: (task: TextureAssetTask) => void;
  78393. /**
  78394. * Callback called when the task is successful
  78395. */
  78396. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  78397. /**
  78398. * Creates a new TextureAssetTask object
  78399. * @param name defines the name of the task
  78400. * @param url defines the location of the file to load
  78401. * @param noMipmap defines if mipmap should not be generated (default is false)
  78402. * @param invertY defines if texture must be inverted on Y axis (default is true)
  78403. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78404. */
  78405. constructor(
  78406. /**
  78407. * Defines the name of the task
  78408. */
  78409. name: string,
  78410. /**
  78411. * Defines the location of the file to load
  78412. */
  78413. url: string,
  78414. /**
  78415. * Defines if mipmap should not be generated (default is false)
  78416. */
  78417. noMipmap?: boolean | undefined,
  78418. /**
  78419. * Defines if texture must be inverted on Y axis (default is true)
  78420. */
  78421. invertY?: boolean,
  78422. /**
  78423. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78424. */
  78425. samplingMode?: number);
  78426. /**
  78427. * Execute the current task
  78428. * @param scene defines the scene where you want your assets to be loaded
  78429. * @param onSuccess is a callback called when the task is successfully executed
  78430. * @param onError is a callback called if an error occurs
  78431. */
  78432. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78433. }
  78434. /**
  78435. * Define a task used by AssetsManager to load cube textures
  78436. */
  78437. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  78438. /**
  78439. * Defines the name of the task
  78440. */
  78441. name: string;
  78442. /**
  78443. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78444. */
  78445. url: string;
  78446. /**
  78447. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78448. */
  78449. extensions?: string[] | undefined;
  78450. /**
  78451. * Defines if mipmaps should not be generated (default is false)
  78452. */
  78453. noMipmap?: boolean | undefined;
  78454. /**
  78455. * Defines the explicit list of files (undefined by default)
  78456. */
  78457. files?: string[] | undefined;
  78458. /**
  78459. * Gets the loaded texture
  78460. */
  78461. texture: CubeTexture;
  78462. /**
  78463. * Callback called when the task is successful
  78464. */
  78465. onSuccess: (task: CubeTextureAssetTask) => void;
  78466. /**
  78467. * Callback called when the task is successful
  78468. */
  78469. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  78470. /**
  78471. * Creates a new CubeTextureAssetTask
  78472. * @param name defines the name of the task
  78473. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78474. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78475. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78476. * @param files defines the explicit list of files (undefined by default)
  78477. */
  78478. constructor(
  78479. /**
  78480. * Defines the name of the task
  78481. */
  78482. name: string,
  78483. /**
  78484. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78485. */
  78486. url: string,
  78487. /**
  78488. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78489. */
  78490. extensions?: string[] | undefined,
  78491. /**
  78492. * Defines if mipmaps should not be generated (default is false)
  78493. */
  78494. noMipmap?: boolean | undefined,
  78495. /**
  78496. * Defines the explicit list of files (undefined by default)
  78497. */
  78498. files?: string[] | undefined);
  78499. /**
  78500. * Execute the current task
  78501. * @param scene defines the scene where you want your assets to be loaded
  78502. * @param onSuccess is a callback called when the task is successfully executed
  78503. * @param onError is a callback called if an error occurs
  78504. */
  78505. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78506. }
  78507. /**
  78508. * Define a task used by AssetsManager to load HDR cube textures
  78509. */
  78510. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  78511. /**
  78512. * Defines the name of the task
  78513. */
  78514. name: string;
  78515. /**
  78516. * Defines the location of the file to load
  78517. */
  78518. url: string;
  78519. /**
  78520. * Defines the desired size (the more it increases the longer the generation will be)
  78521. */
  78522. size: number;
  78523. /**
  78524. * Defines if mipmaps should not be generated (default is false)
  78525. */
  78526. noMipmap: boolean;
  78527. /**
  78528. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78529. */
  78530. generateHarmonics: boolean;
  78531. /**
  78532. * 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)
  78533. */
  78534. gammaSpace: boolean;
  78535. /**
  78536. * Internal Use Only
  78537. */
  78538. reserved: boolean;
  78539. /**
  78540. * Gets the loaded texture
  78541. */
  78542. texture: HDRCubeTexture;
  78543. /**
  78544. * Callback called when the task is successful
  78545. */
  78546. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  78547. /**
  78548. * Callback called when the task is successful
  78549. */
  78550. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  78551. /**
  78552. * Creates a new HDRCubeTextureAssetTask object
  78553. * @param name defines the name of the task
  78554. * @param url defines the location of the file to load
  78555. * @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.
  78556. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78557. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78558. * @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)
  78559. * @param reserved Internal use only
  78560. */
  78561. constructor(
  78562. /**
  78563. * Defines the name of the task
  78564. */
  78565. name: string,
  78566. /**
  78567. * Defines the location of the file to load
  78568. */
  78569. url: string,
  78570. /**
  78571. * Defines the desired size (the more it increases the longer the generation will be)
  78572. */
  78573. size: number,
  78574. /**
  78575. * Defines if mipmaps should not be generated (default is false)
  78576. */
  78577. noMipmap?: boolean,
  78578. /**
  78579. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78580. */
  78581. generateHarmonics?: boolean,
  78582. /**
  78583. * 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)
  78584. */
  78585. gammaSpace?: boolean,
  78586. /**
  78587. * Internal Use Only
  78588. */
  78589. reserved?: boolean);
  78590. /**
  78591. * Execute the current task
  78592. * @param scene defines the scene where you want your assets to be loaded
  78593. * @param onSuccess is a callback called when the task is successfully executed
  78594. * @param onError is a callback called if an error occurs
  78595. */
  78596. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78597. }
  78598. /**
  78599. * Define a task used by AssetsManager to load Equirectangular cube textures
  78600. */
  78601. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  78602. /**
  78603. * Defines the name of the task
  78604. */
  78605. name: string;
  78606. /**
  78607. * Defines the location of the file to load
  78608. */
  78609. url: string;
  78610. /**
  78611. * Defines the desired size (the more it increases the longer the generation will be)
  78612. */
  78613. size: number;
  78614. /**
  78615. * Defines if mipmaps should not be generated (default is false)
  78616. */
  78617. noMipmap: boolean;
  78618. /**
  78619. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78620. * but the standard material would require them in Gamma space) (default is true)
  78621. */
  78622. gammaSpace: boolean;
  78623. /**
  78624. * Gets the loaded texture
  78625. */
  78626. texture: EquiRectangularCubeTexture;
  78627. /**
  78628. * Callback called when the task is successful
  78629. */
  78630. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  78631. /**
  78632. * Callback called when the task is successful
  78633. */
  78634. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  78635. /**
  78636. * Creates a new EquiRectangularCubeTextureAssetTask object
  78637. * @param name defines the name of the task
  78638. * @param url defines the location of the file to load
  78639. * @param size defines the desired size (the more it increases the longer the generation will be)
  78640. * If the size is omitted this implies you are using a preprocessed cubemap.
  78641. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78642. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  78643. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  78644. * (default is true)
  78645. */
  78646. constructor(
  78647. /**
  78648. * Defines the name of the task
  78649. */
  78650. name: string,
  78651. /**
  78652. * Defines the location of the file to load
  78653. */
  78654. url: string,
  78655. /**
  78656. * Defines the desired size (the more it increases the longer the generation will be)
  78657. */
  78658. size: number,
  78659. /**
  78660. * Defines if mipmaps should not be generated (default is false)
  78661. */
  78662. noMipmap?: boolean,
  78663. /**
  78664. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78665. * but the standard material would require them in Gamma space) (default is true)
  78666. */
  78667. gammaSpace?: boolean);
  78668. /**
  78669. * Execute the current task
  78670. * @param scene defines the scene where you want your assets to be loaded
  78671. * @param onSuccess is a callback called when the task is successfully executed
  78672. * @param onError is a callback called if an error occurs
  78673. */
  78674. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78675. }
  78676. /**
  78677. * This class can be used to easily import assets into a scene
  78678. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  78679. */
  78680. export class AssetsManager {
  78681. private _scene;
  78682. private _isLoading;
  78683. protected _tasks: AbstractAssetTask[];
  78684. protected _waitingTasksCount: number;
  78685. protected _totalTasksCount: number;
  78686. /**
  78687. * Callback called when all tasks are processed
  78688. */
  78689. onFinish: (tasks: AbstractAssetTask[]) => void;
  78690. /**
  78691. * Callback called when a task is successful
  78692. */
  78693. onTaskSuccess: (task: AbstractAssetTask) => void;
  78694. /**
  78695. * Callback called when a task had an error
  78696. */
  78697. onTaskError: (task: AbstractAssetTask) => void;
  78698. /**
  78699. * Callback called when a task is done (whatever the result is)
  78700. */
  78701. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  78702. /**
  78703. * Observable called when all tasks are processed
  78704. */
  78705. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  78706. /**
  78707. * Observable called when a task had an error
  78708. */
  78709. onTaskErrorObservable: Observable<AbstractAssetTask>;
  78710. /**
  78711. * Observable called when all tasks were executed
  78712. */
  78713. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  78714. /**
  78715. * Observable called when a task is done (whatever the result is)
  78716. */
  78717. onProgressObservable: Observable<IAssetsProgressEvent>;
  78718. /**
  78719. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  78720. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  78721. */
  78722. useDefaultLoadingScreen: boolean;
  78723. /**
  78724. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  78725. * when all assets have been downloaded.
  78726. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  78727. */
  78728. autoHideLoadingUI: boolean;
  78729. /**
  78730. * Creates a new AssetsManager
  78731. * @param scene defines the scene to work on
  78732. */
  78733. constructor(scene: Scene);
  78734. /**
  78735. * Add a ContainerAssetTask to the list of active tasks
  78736. * @param taskName defines the name of the new task
  78737. * @param meshesNames defines the name of meshes to load
  78738. * @param rootUrl defines the root url to use to locate files
  78739. * @param sceneFilename defines the filename of the scene file
  78740. * @returns a new ContainerAssetTask object
  78741. */
  78742. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  78743. /**
  78744. * Add a MeshAssetTask to the list of active tasks
  78745. * @param taskName defines the name of the new task
  78746. * @param meshesNames defines the name of meshes to load
  78747. * @param rootUrl defines the root url to use to locate files
  78748. * @param sceneFilename defines the filename of the scene file
  78749. * @returns a new MeshAssetTask object
  78750. */
  78751. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  78752. /**
  78753. * Add a TextFileAssetTask to the list of active tasks
  78754. * @param taskName defines the name of the new task
  78755. * @param url defines the url of the file to load
  78756. * @returns a new TextFileAssetTask object
  78757. */
  78758. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  78759. /**
  78760. * Add a BinaryFileAssetTask to the list of active tasks
  78761. * @param taskName defines the name of the new task
  78762. * @param url defines the url of the file to load
  78763. * @returns a new BinaryFileAssetTask object
  78764. */
  78765. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  78766. /**
  78767. * Add a ImageAssetTask to the list of active tasks
  78768. * @param taskName defines the name of the new task
  78769. * @param url defines the url of the file to load
  78770. * @returns a new ImageAssetTask object
  78771. */
  78772. addImageTask(taskName: string, url: string): ImageAssetTask;
  78773. /**
  78774. * Add a TextureAssetTask to the list of active tasks
  78775. * @param taskName defines the name of the new task
  78776. * @param url defines the url of the file to load
  78777. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78778. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  78779. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  78780. * @returns a new TextureAssetTask object
  78781. */
  78782. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  78783. /**
  78784. * Add a CubeTextureAssetTask to the list of active tasks
  78785. * @param taskName defines the name of the new task
  78786. * @param url defines the url of the file to load
  78787. * @param extensions defines the extension to use to load the cube map (can be null)
  78788. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78789. * @param files defines the list of files to load (can be null)
  78790. * @returns a new CubeTextureAssetTask object
  78791. */
  78792. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  78793. /**
  78794. *
  78795. * Add a HDRCubeTextureAssetTask to the list of active tasks
  78796. * @param taskName defines the name of the new task
  78797. * @param url defines the url of the file to load
  78798. * @param size defines the size you want for the cubemap (can be null)
  78799. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78800. * @param generateHarmonics defines if you want to automatically generate (true by default)
  78801. * @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)
  78802. * @param reserved Internal use only
  78803. * @returns a new HDRCubeTextureAssetTask object
  78804. */
  78805. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  78806. /**
  78807. *
  78808. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  78809. * @param taskName defines the name of the new task
  78810. * @param url defines the url of the file to load
  78811. * @param size defines the size you want for the cubemap (can be null)
  78812. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78813. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  78814. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  78815. * @returns a new EquiRectangularCubeTextureAssetTask object
  78816. */
  78817. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  78818. /**
  78819. * Remove a task from the assets manager.
  78820. * @param task the task to remove
  78821. */
  78822. removeTask(task: AbstractAssetTask): void;
  78823. private _decreaseWaitingTasksCount;
  78824. private _runTask;
  78825. /**
  78826. * Reset the AssetsManager and remove all tasks
  78827. * @return the current instance of the AssetsManager
  78828. */
  78829. reset(): AssetsManager;
  78830. /**
  78831. * Start the loading process
  78832. * @return the current instance of the AssetsManager
  78833. */
  78834. load(): AssetsManager;
  78835. /**
  78836. * Start the loading process as an async operation
  78837. * @return a promise returning the list of failed tasks
  78838. */
  78839. loadAsync(): Promise<void>;
  78840. }
  78841. }
  78842. declare module BABYLON {
  78843. /**
  78844. * Wrapper class for promise with external resolve and reject.
  78845. */
  78846. export class Deferred<T> {
  78847. /**
  78848. * The promise associated with this deferred object.
  78849. */
  78850. readonly promise: Promise<T>;
  78851. private _resolve;
  78852. private _reject;
  78853. /**
  78854. * The resolve method of the promise associated with this deferred object.
  78855. */
  78856. get resolve(): (value: T | PromiseLike<T>) => void;
  78857. /**
  78858. * The reject method of the promise associated with this deferred object.
  78859. */
  78860. get reject(): (reason?: any) => void;
  78861. /**
  78862. * Constructor for this deferred object.
  78863. */
  78864. constructor();
  78865. }
  78866. }
  78867. declare module BABYLON {
  78868. /**
  78869. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  78870. */
  78871. export class MeshExploder {
  78872. private _centerMesh;
  78873. private _meshes;
  78874. private _meshesOrigins;
  78875. private _toCenterVectors;
  78876. private _scaledDirection;
  78877. private _newPosition;
  78878. private _centerPosition;
  78879. /**
  78880. * Explodes meshes from a center mesh.
  78881. * @param meshes The meshes to explode.
  78882. * @param centerMesh The mesh to be center of explosion.
  78883. */
  78884. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  78885. private _setCenterMesh;
  78886. /**
  78887. * Get class name
  78888. * @returns "MeshExploder"
  78889. */
  78890. getClassName(): string;
  78891. /**
  78892. * "Exploded meshes"
  78893. * @returns Array of meshes with the centerMesh at index 0.
  78894. */
  78895. getMeshes(): Array<Mesh>;
  78896. /**
  78897. * Explodes meshes giving a specific direction
  78898. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  78899. */
  78900. explode(direction?: number): void;
  78901. }
  78902. }
  78903. declare module BABYLON {
  78904. /**
  78905. * Class used to help managing file picking and drag'n'drop
  78906. */
  78907. export class FilesInput {
  78908. /**
  78909. * List of files ready to be loaded
  78910. */
  78911. static get FilesToLoad(): {
  78912. [key: string]: File;
  78913. };
  78914. /**
  78915. * Callback called when a file is processed
  78916. */
  78917. onProcessFileCallback: (file: File, name: string, extension: string, setSceneFileToLoad: (sceneFile: File) => void) => boolean;
  78918. /**
  78919. * Function used when loading the scene file
  78920. */
  78921. loadAsync: (sceneFile: File, onProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>) => Promise<Scene>;
  78922. private _engine;
  78923. private _currentScene;
  78924. private _sceneLoadedCallback;
  78925. private _progressCallback;
  78926. private _additionalRenderLoopLogicCallback;
  78927. private _textureLoadingCallback;
  78928. private _startingProcessingFilesCallback;
  78929. private _onReloadCallback;
  78930. private _errorCallback;
  78931. private _elementToMonitor;
  78932. private _sceneFileToLoad;
  78933. private _filesToLoad;
  78934. /**
  78935. * Creates a new FilesInput
  78936. * @param engine defines the rendering engine
  78937. * @param scene defines the hosting scene
  78938. * @param sceneLoadedCallback callback called when scene is loaded
  78939. * @param progressCallback callback called to track progress
  78940. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  78941. * @param textureLoadingCallback callback called when a texture is loading
  78942. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  78943. * @param onReloadCallback callback called when a reload is requested
  78944. * @param errorCallback callback call if an error occurs
  78945. */
  78946. 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>);
  78947. private _dragEnterHandler;
  78948. private _dragOverHandler;
  78949. private _dropHandler;
  78950. /**
  78951. * Calls this function to listen to drag'n'drop events on a specific DOM element
  78952. * @param elementToMonitor defines the DOM element to track
  78953. */
  78954. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  78955. /** Gets the current list of files to load */
  78956. get filesToLoad(): File[];
  78957. /**
  78958. * Release all associated resources
  78959. */
  78960. dispose(): void;
  78961. private renderFunction;
  78962. private drag;
  78963. private drop;
  78964. private _traverseFolder;
  78965. private _processFiles;
  78966. /**
  78967. * Load files from a drop event
  78968. * @param event defines the drop event to use as source
  78969. */
  78970. loadFiles(event: any): void;
  78971. private _processReload;
  78972. /**
  78973. * Reload the current scene from the loaded files
  78974. */
  78975. reload(): void;
  78976. }
  78977. }
  78978. declare module BABYLON {
  78979. /**
  78980. * Defines the root class used to create scene optimization to use with SceneOptimizer
  78981. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78982. */
  78983. export class SceneOptimization {
  78984. /**
  78985. * Defines the priority of this optimization (0 by default which means first in the list)
  78986. */
  78987. priority: number;
  78988. /**
  78989. * Gets a string describing the action executed by the current optimization
  78990. * @returns description string
  78991. */
  78992. getDescription(): string;
  78993. /**
  78994. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78995. * @param scene defines the current scene where to apply this optimization
  78996. * @param optimizer defines the current optimizer
  78997. * @returns true if everything that can be done was applied
  78998. */
  78999. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79000. /**
  79001. * Creates the SceneOptimization object
  79002. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  79003. * @param desc defines the description associated with the optimization
  79004. */
  79005. constructor(
  79006. /**
  79007. * Defines the priority of this optimization (0 by default which means first in the list)
  79008. */
  79009. priority?: number);
  79010. }
  79011. /**
  79012. * Defines an optimization used to reduce the size of render target textures
  79013. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79014. */
  79015. export class TextureOptimization extends SceneOptimization {
  79016. /**
  79017. * Defines the priority of this optimization (0 by default which means first in the list)
  79018. */
  79019. priority: number;
  79020. /**
  79021. * 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
  79022. */
  79023. maximumSize: number;
  79024. /**
  79025. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  79026. */
  79027. step: number;
  79028. /**
  79029. * Gets a string describing the action executed by the current optimization
  79030. * @returns description string
  79031. */
  79032. getDescription(): string;
  79033. /**
  79034. * Creates the TextureOptimization object
  79035. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  79036. * @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
  79037. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  79038. */
  79039. constructor(
  79040. /**
  79041. * Defines the priority of this optimization (0 by default which means first in the list)
  79042. */
  79043. priority?: number,
  79044. /**
  79045. * 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
  79046. */
  79047. maximumSize?: number,
  79048. /**
  79049. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  79050. */
  79051. step?: number);
  79052. /**
  79053. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79054. * @param scene defines the current scene where to apply this optimization
  79055. * @param optimizer defines the current optimizer
  79056. * @returns true if everything that can be done was applied
  79057. */
  79058. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79059. }
  79060. /**
  79061. * Defines an optimization used to increase or decrease the rendering resolution
  79062. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79063. */
  79064. export class HardwareScalingOptimization extends SceneOptimization {
  79065. /**
  79066. * Defines the priority of this optimization (0 by default which means first in the list)
  79067. */
  79068. priority: number;
  79069. /**
  79070. * Defines the maximum scale to use (2 by default)
  79071. */
  79072. maximumScale: number;
  79073. /**
  79074. * Defines the step to use between two passes (0.5 by default)
  79075. */
  79076. step: number;
  79077. private _currentScale;
  79078. private _directionOffset;
  79079. /**
  79080. * Gets a string describing the action executed by the current optimization
  79081. * @return description string
  79082. */
  79083. getDescription(): string;
  79084. /**
  79085. * Creates the HardwareScalingOptimization object
  79086. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  79087. * @param maximumScale defines the maximum scale to use (2 by default)
  79088. * @param step defines the step to use between two passes (0.5 by default)
  79089. */
  79090. constructor(
  79091. /**
  79092. * Defines the priority of this optimization (0 by default which means first in the list)
  79093. */
  79094. priority?: number,
  79095. /**
  79096. * Defines the maximum scale to use (2 by default)
  79097. */
  79098. maximumScale?: number,
  79099. /**
  79100. * Defines the step to use between two passes (0.5 by default)
  79101. */
  79102. step?: number);
  79103. /**
  79104. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79105. * @param scene defines the current scene where to apply this optimization
  79106. * @param optimizer defines the current optimizer
  79107. * @returns true if everything that can be done was applied
  79108. */
  79109. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79110. }
  79111. /**
  79112. * Defines an optimization used to remove shadows
  79113. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79114. */
  79115. export class ShadowsOptimization extends SceneOptimization {
  79116. /**
  79117. * Gets a string describing the action executed by the current optimization
  79118. * @return description string
  79119. */
  79120. getDescription(): string;
  79121. /**
  79122. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79123. * @param scene defines the current scene where to apply this optimization
  79124. * @param optimizer defines the current optimizer
  79125. * @returns true if everything that can be done was applied
  79126. */
  79127. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79128. }
  79129. /**
  79130. * Defines an optimization used to turn post-processes off
  79131. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79132. */
  79133. export class PostProcessesOptimization extends SceneOptimization {
  79134. /**
  79135. * Gets a string describing the action executed by the current optimization
  79136. * @return description string
  79137. */
  79138. getDescription(): string;
  79139. /**
  79140. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79141. * @param scene defines the current scene where to apply this optimization
  79142. * @param optimizer defines the current optimizer
  79143. * @returns true if everything that can be done was applied
  79144. */
  79145. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79146. }
  79147. /**
  79148. * Defines an optimization used to turn lens flares off
  79149. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79150. */
  79151. export class LensFlaresOptimization extends SceneOptimization {
  79152. /**
  79153. * Gets a string describing the action executed by the current optimization
  79154. * @return description string
  79155. */
  79156. getDescription(): string;
  79157. /**
  79158. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79159. * @param scene defines the current scene where to apply this optimization
  79160. * @param optimizer defines the current optimizer
  79161. * @returns true if everything that can be done was applied
  79162. */
  79163. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79164. }
  79165. /**
  79166. * Defines an optimization based on user defined callback.
  79167. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79168. */
  79169. export class CustomOptimization extends SceneOptimization {
  79170. /**
  79171. * Callback called to apply the custom optimization.
  79172. */
  79173. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  79174. /**
  79175. * Callback called to get custom description
  79176. */
  79177. onGetDescription: () => string;
  79178. /**
  79179. * Gets a string describing the action executed by the current optimization
  79180. * @returns description string
  79181. */
  79182. getDescription(): string;
  79183. /**
  79184. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79185. * @param scene defines the current scene where to apply this optimization
  79186. * @param optimizer defines the current optimizer
  79187. * @returns true if everything that can be done was applied
  79188. */
  79189. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79190. }
  79191. /**
  79192. * Defines an optimization used to turn particles off
  79193. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79194. */
  79195. export class ParticlesOptimization extends SceneOptimization {
  79196. /**
  79197. * Gets a string describing the action executed by the current optimization
  79198. * @return description string
  79199. */
  79200. getDescription(): string;
  79201. /**
  79202. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79203. * @param scene defines the current scene where to apply this optimization
  79204. * @param optimizer defines the current optimizer
  79205. * @returns true if everything that can be done was applied
  79206. */
  79207. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79208. }
  79209. /**
  79210. * Defines an optimization used to turn render targets off
  79211. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79212. */
  79213. export class RenderTargetsOptimization extends SceneOptimization {
  79214. /**
  79215. * Gets a string describing the action executed by the current optimization
  79216. * @return description string
  79217. */
  79218. getDescription(): string;
  79219. /**
  79220. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79221. * @param scene defines the current scene where to apply this optimization
  79222. * @param optimizer defines the current optimizer
  79223. * @returns true if everything that can be done was applied
  79224. */
  79225. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79226. }
  79227. /**
  79228. * Defines an optimization used to merge meshes with compatible materials
  79229. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79230. */
  79231. export class MergeMeshesOptimization extends SceneOptimization {
  79232. private static _UpdateSelectionTree;
  79233. /**
  79234. * Gets or sets a boolean which defines if optimization octree has to be updated
  79235. */
  79236. static get UpdateSelectionTree(): boolean;
  79237. /**
  79238. * Gets or sets a boolean which defines if optimization octree has to be updated
  79239. */
  79240. static set UpdateSelectionTree(value: boolean);
  79241. /**
  79242. * Gets a string describing the action executed by the current optimization
  79243. * @return description string
  79244. */
  79245. getDescription(): string;
  79246. private _canBeMerged;
  79247. /**
  79248. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79249. * @param scene defines the current scene where to apply this optimization
  79250. * @param optimizer defines the current optimizer
  79251. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  79252. * @returns true if everything that can be done was applied
  79253. */
  79254. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  79255. }
  79256. /**
  79257. * Defines a list of options used by SceneOptimizer
  79258. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79259. */
  79260. export class SceneOptimizerOptions {
  79261. /**
  79262. * Defines the target frame rate to reach (60 by default)
  79263. */
  79264. targetFrameRate: number;
  79265. /**
  79266. * Defines the interval between two checks (2000ms by default)
  79267. */
  79268. trackerDuration: number;
  79269. /**
  79270. * Gets the list of optimizations to apply
  79271. */
  79272. optimizations: SceneOptimization[];
  79273. /**
  79274. * Creates a new list of options used by SceneOptimizer
  79275. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  79276. * @param trackerDuration defines the interval between two checks (2000ms by default)
  79277. */
  79278. constructor(
  79279. /**
  79280. * Defines the target frame rate to reach (60 by default)
  79281. */
  79282. targetFrameRate?: number,
  79283. /**
  79284. * Defines the interval between two checks (2000ms by default)
  79285. */
  79286. trackerDuration?: number);
  79287. /**
  79288. * Add a new optimization
  79289. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  79290. * @returns the current SceneOptimizerOptions
  79291. */
  79292. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  79293. /**
  79294. * Add a new custom optimization
  79295. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  79296. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  79297. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  79298. * @returns the current SceneOptimizerOptions
  79299. */
  79300. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  79301. /**
  79302. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  79303. * @param targetFrameRate defines the target frame rate (60 by default)
  79304. * @returns a SceneOptimizerOptions object
  79305. */
  79306. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79307. /**
  79308. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  79309. * @param targetFrameRate defines the target frame rate (60 by default)
  79310. * @returns a SceneOptimizerOptions object
  79311. */
  79312. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79313. /**
  79314. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  79315. * @param targetFrameRate defines the target frame rate (60 by default)
  79316. * @returns a SceneOptimizerOptions object
  79317. */
  79318. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79319. }
  79320. /**
  79321. * Class used to run optimizations in order to reach a target frame rate
  79322. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79323. */
  79324. export class SceneOptimizer implements IDisposable {
  79325. private _isRunning;
  79326. private _options;
  79327. private _scene;
  79328. private _currentPriorityLevel;
  79329. private _targetFrameRate;
  79330. private _trackerDuration;
  79331. private _currentFrameRate;
  79332. private _sceneDisposeObserver;
  79333. private _improvementMode;
  79334. /**
  79335. * Defines an observable called when the optimizer reaches the target frame rate
  79336. */
  79337. onSuccessObservable: Observable<SceneOptimizer>;
  79338. /**
  79339. * Defines an observable called when the optimizer enables an optimization
  79340. */
  79341. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  79342. /**
  79343. * Defines an observable called when the optimizer is not able to reach the target frame rate
  79344. */
  79345. onFailureObservable: Observable<SceneOptimizer>;
  79346. /**
  79347. * Gets a boolean indicating if the optimizer is in improvement mode
  79348. */
  79349. get isInImprovementMode(): boolean;
  79350. /**
  79351. * Gets the current priority level (0 at start)
  79352. */
  79353. get currentPriorityLevel(): number;
  79354. /**
  79355. * Gets the current frame rate checked by the SceneOptimizer
  79356. */
  79357. get currentFrameRate(): number;
  79358. /**
  79359. * Gets or sets the current target frame rate (60 by default)
  79360. */
  79361. get targetFrameRate(): number;
  79362. /**
  79363. * Gets or sets the current target frame rate (60 by default)
  79364. */
  79365. set targetFrameRate(value: number);
  79366. /**
  79367. * Gets or sets the current interval between two checks (every 2000ms by default)
  79368. */
  79369. get trackerDuration(): number;
  79370. /**
  79371. * Gets or sets the current interval between two checks (every 2000ms by default)
  79372. */
  79373. set trackerDuration(value: number);
  79374. /**
  79375. * Gets the list of active optimizations
  79376. */
  79377. get optimizations(): SceneOptimization[];
  79378. /**
  79379. * Creates a new SceneOptimizer
  79380. * @param scene defines the scene to work on
  79381. * @param options defines the options to use with the SceneOptimizer
  79382. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  79383. * @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)
  79384. */
  79385. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  79386. /**
  79387. * Stops the current optimizer
  79388. */
  79389. stop(): void;
  79390. /**
  79391. * Reset the optimizer to initial step (current priority level = 0)
  79392. */
  79393. reset(): void;
  79394. /**
  79395. * Start the optimizer. By default it will try to reach a specific framerate
  79396. * but if the optimizer is set with improvementMode === true then it will run all optimization while frame rate is above the target frame rate
  79397. */
  79398. start(): void;
  79399. private _checkCurrentState;
  79400. /**
  79401. * Release all resources
  79402. */
  79403. dispose(): void;
  79404. /**
  79405. * Helper function to create a SceneOptimizer with one single line of code
  79406. * @param scene defines the scene to work on
  79407. * @param options defines the options to use with the SceneOptimizer
  79408. * @param onSuccess defines a callback to call on success
  79409. * @param onFailure defines a callback to call on failure
  79410. * @returns the new SceneOptimizer object
  79411. */
  79412. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  79413. }
  79414. }
  79415. declare module BABYLON {
  79416. /**
  79417. * Class used to serialize a scene into a string
  79418. */
  79419. export class SceneSerializer {
  79420. /**
  79421. * Clear cache used by a previous serialization
  79422. */
  79423. static ClearCache(): void;
  79424. /**
  79425. * Serialize a scene into a JSON compatible object
  79426. * Note that if the current engine does not support synchronous texture reading (like WebGPU), you should use SerializeAsync instead
  79427. * as else you may not retrieve the proper base64 encoded texture data (when using the Texture.ForceSerializeBuffers flag)
  79428. * @param scene defines the scene to serialize
  79429. * @returns a JSON compatible object
  79430. */
  79431. static Serialize(scene: Scene): any;
  79432. private static _Serialize;
  79433. /**
  79434. * Serialize a scene into a JSON compatible object
  79435. * @param scene defines the scene to serialize
  79436. * @returns a JSON promise compatible object
  79437. */
  79438. static SerializeAsync(scene: Scene): Promise<any>;
  79439. private static _CollectPromises;
  79440. /**
  79441. * Serialize a mesh into a JSON compatible object
  79442. * @param toSerialize defines the mesh to serialize
  79443. * @param withParents defines if parents must be serialized as well
  79444. * @param withChildren defines if children must be serialized as well
  79445. * @returns a JSON compatible object
  79446. */
  79447. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  79448. }
  79449. }
  79450. declare module BABYLON {
  79451. /**
  79452. * This represents the different options available for the video capture.
  79453. */
  79454. export interface VideoRecorderOptions {
  79455. /** Defines the mime type of the video. */
  79456. mimeType: string;
  79457. /** Defines the FPS the video should be recorded at. */
  79458. fps: number;
  79459. /** Defines the chunk size for the recording data. */
  79460. recordChunckSize: number;
  79461. /** The audio tracks to attach to the recording. */
  79462. audioTracks?: MediaStreamTrack[];
  79463. }
  79464. /**
  79465. * This can help with recording videos from BabylonJS.
  79466. * This is based on the available WebRTC functionalities of the browser.
  79467. *
  79468. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  79469. */
  79470. export class VideoRecorder {
  79471. private static readonly _defaultOptions;
  79472. /**
  79473. * Returns whether or not the VideoRecorder is available in your browser.
  79474. * @param engine Defines the Babylon Engine.
  79475. * @returns true if supported otherwise false.
  79476. */
  79477. static IsSupported(engine: Engine): boolean;
  79478. private readonly _options;
  79479. private _canvas;
  79480. private _mediaRecorder;
  79481. private _recordedChunks;
  79482. private _fileName;
  79483. private _resolve;
  79484. private _reject;
  79485. /**
  79486. * True when a recording is already in progress.
  79487. */
  79488. get isRecording(): boolean;
  79489. /**
  79490. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  79491. * @param engine Defines the BabylonJS Engine you wish to record.
  79492. * @param options Defines options that can be used to customize the capture.
  79493. */
  79494. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  79495. /**
  79496. * Stops the current recording before the default capture timeout passed in the startRecording function.
  79497. */
  79498. stopRecording(): void;
  79499. /**
  79500. * Starts recording the canvas for a max duration specified in parameters.
  79501. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  79502. * If null no automatic download will start and you can rely on the promise to get the data back.
  79503. * @param maxDuration Defines the maximum recording time in seconds.
  79504. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  79505. * @return A promise callback at the end of the recording with the video data in Blob.
  79506. */
  79507. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  79508. /**
  79509. * Releases internal resources used during the recording.
  79510. */
  79511. dispose(): void;
  79512. private _handleDataAvailable;
  79513. private _handleError;
  79514. private _handleStop;
  79515. }
  79516. }
  79517. declare module BABYLON {
  79518. /**
  79519. * Class containing a set of static utilities functions for screenshots
  79520. */
  79521. export class ScreenshotTools {
  79522. /**
  79523. * Captures a screenshot of the current rendering
  79524. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79525. * @param engine defines the rendering engine
  79526. * @param camera defines the source camera
  79527. * @param size This parameter can be set to a single number or to an object with the
  79528. * following (optional) properties: precision, width, height. If a single number is passed,
  79529. * it will be used for both width and height. If an object is passed, the screenshot size
  79530. * will be derived from the parameters. The precision property is a multiplier allowing
  79531. * rendering at a higher or lower resolution
  79532. * @param successCallback defines the callback receives a single parameter which contains the
  79533. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79534. * src parameter of an <img> to display it
  79535. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79536. * Check your browser for supported MIME types
  79537. * @param forceDownload force the system to download the image even if a successCallback is provided
  79538. */
  79539. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, forceDownload?: boolean): void;
  79540. /**
  79541. * Captures a screenshot of the current rendering
  79542. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79543. * @param engine defines the rendering engine
  79544. * @param camera defines the source camera
  79545. * @param size This parameter can be set to a single number or to an object with the
  79546. * following (optional) properties: precision, width, height. If a single number is passed,
  79547. * it will be used for both width and height. If an object is passed, the screenshot size
  79548. * will be derived from the parameters. The precision property is a multiplier allowing
  79549. * rendering at a higher or lower resolution
  79550. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79551. * Check your browser for supported MIME types
  79552. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79553. * to the src parameter of an <img> to display it
  79554. */
  79555. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  79556. /**
  79557. * 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)
  79558. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79559. * @param engine defines the rendering engine
  79560. * @param camera defines the source camera
  79561. * @param width defines the expected width
  79562. * @param height defines the expected height
  79563. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79564. * Check your browser for supported MIME types
  79565. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79566. * to the src parameter of an <img> to display it
  79567. */
  79568. static CreateScreenshotWithResizeAsync(engine: Engine, camera: Camera, width: number, height: number, mimeType?: string): Promise<void>;
  79569. /**
  79570. * Generates an image screenshot from the specified camera.
  79571. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79572. * @param engine The engine to use for rendering
  79573. * @param camera The camera to use for rendering
  79574. * @param size This parameter can be set to a single number or to an object with the
  79575. * following (optional) properties: precision, width, height. If a single number is passed,
  79576. * it will be used for both width and height. If an object is passed, the screenshot size
  79577. * will be derived from the parameters. The precision property is a multiplier allowing
  79578. * rendering at a higher or lower resolution
  79579. * @param successCallback The callback receives a single parameter which contains the
  79580. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79581. * src parameter of an <img> to display it
  79582. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79583. * Check your browser for supported MIME types
  79584. * @param samples Texture samples (default: 1)
  79585. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79586. * @param fileName A name for for the downloaded file.
  79587. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79588. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  79589. */
  79590. 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;
  79591. /**
  79592. * Generates an image screenshot from the specified camera.
  79593. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79594. * @param engine The engine to use for rendering
  79595. * @param camera The camera to use for rendering
  79596. * @param size This parameter can be set to a single number or to an object with the
  79597. * following (optional) properties: precision, width, height. If a single number is passed,
  79598. * it will be used for both width and height. If an object is passed, the screenshot size
  79599. * will be derived from the parameters. The precision property is a multiplier allowing
  79600. * rendering at a higher or lower resolution
  79601. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79602. * Check your browser for supported MIME types
  79603. * @param samples Texture samples (default: 1)
  79604. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79605. * @param fileName A name for for the downloaded file.
  79606. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79607. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79608. * to the src parameter of an <img> to display it
  79609. */
  79610. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  79611. /**
  79612. * Gets height and width for screenshot size
  79613. * @private
  79614. */
  79615. private static _getScreenshotSize;
  79616. }
  79617. }
  79618. declare module BABYLON {
  79619. /**
  79620. * Interface for a data buffer
  79621. */
  79622. export interface IDataBuffer {
  79623. /**
  79624. * Reads bytes from the data buffer.
  79625. * @param byteOffset The byte offset to read
  79626. * @param byteLength The byte length to read
  79627. * @returns A promise that resolves when the bytes are read
  79628. */
  79629. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  79630. /**
  79631. * The byte length of the buffer.
  79632. */
  79633. readonly byteLength: number;
  79634. }
  79635. /**
  79636. * Utility class for reading from a data buffer
  79637. */
  79638. export class DataReader {
  79639. /**
  79640. * The data buffer associated with this data reader.
  79641. */
  79642. readonly buffer: IDataBuffer;
  79643. /**
  79644. * The current byte offset from the beginning of the data buffer.
  79645. */
  79646. byteOffset: number;
  79647. private _dataView;
  79648. private _dataByteOffset;
  79649. /**
  79650. * Constructor
  79651. * @param buffer The buffer to read
  79652. */
  79653. constructor(buffer: IDataBuffer);
  79654. /**
  79655. * Loads the given byte length.
  79656. * @param byteLength The byte length to load
  79657. * @returns A promise that resolves when the load is complete
  79658. */
  79659. loadAsync(byteLength: number): Promise<void>;
  79660. /**
  79661. * Read a unsigned 32-bit integer from the currently loaded data range.
  79662. * @returns The 32-bit integer read
  79663. */
  79664. readUint32(): number;
  79665. /**
  79666. * Read a byte array from the currently loaded data range.
  79667. * @param byteLength The byte length to read
  79668. * @returns The byte array read
  79669. */
  79670. readUint8Array(byteLength: number): Uint8Array;
  79671. /**
  79672. * Read a string from the currently loaded data range.
  79673. * @param byteLength The byte length to read
  79674. * @returns The string read
  79675. */
  79676. readString(byteLength: number): string;
  79677. /**
  79678. * Skips the given byte length the currently loaded data range.
  79679. * @param byteLength The byte length to skip
  79680. */
  79681. skipBytes(byteLength: number): void;
  79682. }
  79683. }
  79684. declare module BABYLON {
  79685. /**
  79686. * Class for storing data to local storage if available or in-memory storage otherwise
  79687. */
  79688. export class DataStorage {
  79689. private static _Storage;
  79690. private static _GetStorage;
  79691. /**
  79692. * Reads a string from the data storage
  79693. * @param key The key to read
  79694. * @param defaultValue The value if the key doesn't exist
  79695. * @returns The string value
  79696. */
  79697. static ReadString(key: string, defaultValue: string): string;
  79698. /**
  79699. * Writes a string to the data storage
  79700. * @param key The key to write
  79701. * @param value The value to write
  79702. */
  79703. static WriteString(key: string, value: string): void;
  79704. /**
  79705. * Reads a boolean from the data storage
  79706. * @param key The key to read
  79707. * @param defaultValue The value if the key doesn't exist
  79708. * @returns The boolean value
  79709. */
  79710. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  79711. /**
  79712. * Writes a boolean to the data storage
  79713. * @param key The key to write
  79714. * @param value The value to write
  79715. */
  79716. static WriteBoolean(key: string, value: boolean): void;
  79717. /**
  79718. * Reads a number from the data storage
  79719. * @param key The key to read
  79720. * @param defaultValue The value if the key doesn't exist
  79721. * @returns The number value
  79722. */
  79723. static ReadNumber(key: string, defaultValue: number): number;
  79724. /**
  79725. * Writes a number to the data storage
  79726. * @param key The key to write
  79727. * @param value The value to write
  79728. */
  79729. static WriteNumber(key: string, value: number): void;
  79730. }
  79731. }
  79732. declare module BABYLON {
  79733. /**
  79734. * Class used to record delta files between 2 scene states
  79735. */
  79736. export class SceneRecorder {
  79737. private _trackedScene;
  79738. private _savedJSON;
  79739. /**
  79740. * Track a given scene. This means the current scene state will be considered the original state
  79741. * @param scene defines the scene to track
  79742. */
  79743. track(scene: Scene): void;
  79744. /**
  79745. * Get the delta between current state and original state
  79746. * @returns a any containing the delta
  79747. */
  79748. getDelta(): any;
  79749. private _compareArray;
  79750. private _compareObjects;
  79751. private _compareCollections;
  79752. private static GetShadowGeneratorById;
  79753. /**
  79754. * Apply a given delta to a given scene
  79755. * @param deltaJSON defines the JSON containing the delta
  79756. * @param scene defines the scene to apply the delta to
  79757. */
  79758. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  79759. private static _ApplyPropertiesToEntity;
  79760. private static _ApplyDeltaForEntity;
  79761. }
  79762. }
  79763. declare module BABYLON {
  79764. /**
  79765. * A 3D trajectory consisting of an order list of vectors describing a
  79766. * path of motion through 3D space.
  79767. */
  79768. export class Trajectory {
  79769. private _points;
  79770. private readonly _segmentLength;
  79771. /**
  79772. * Serialize to JSON.
  79773. * @returns serialized JSON string
  79774. */
  79775. serialize(): string;
  79776. /**
  79777. * Deserialize from JSON.
  79778. * @param json serialized JSON string
  79779. * @returns deserialized Trajectory
  79780. */
  79781. static Deserialize(json: string): Trajectory;
  79782. /**
  79783. * Create a new empty Trajectory.
  79784. * @param segmentLength radius of discretization for Trajectory points
  79785. */
  79786. constructor(segmentLength?: number);
  79787. /**
  79788. * Get the length of the Trajectory.
  79789. * @returns length of the Trajectory
  79790. */
  79791. getLength(): number;
  79792. /**
  79793. * Append a new point to the Trajectory.
  79794. * NOTE: This implementation has many allocations.
  79795. * @param point point to append to the Trajectory
  79796. */
  79797. add(point: DeepImmutable<Vector3>): void;
  79798. /**
  79799. * Create a new Trajectory with a segment length chosen to make it
  79800. * probable that the new Trajectory will have a specified number of
  79801. * segments. This operation is imprecise.
  79802. * @param targetResolution number of segments desired
  79803. * @returns new Trajectory with approximately the requested number of segments
  79804. */
  79805. resampleAtTargetResolution(targetResolution: number): Trajectory;
  79806. /**
  79807. * Convert Trajectory segments into tokenized representation. This
  79808. * representation is an array of numbers where each nth number is the
  79809. * index of the token which is most similar to the nth segment of the
  79810. * Trajectory.
  79811. * @param tokens list of vectors which serve as discrete tokens
  79812. * @returns list of indices of most similar token per segment
  79813. */
  79814. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  79815. private static _forwardDir;
  79816. private static _inverseFromVec;
  79817. private static _upDir;
  79818. private static _fromToVec;
  79819. private static _lookMatrix;
  79820. /**
  79821. * Transform the rotation (i.e., direction) of a segment to isolate
  79822. * the relative transformation represented by the segment. This operation
  79823. * may or may not succeed due to singularities in the equations that define
  79824. * motion relativity in this context.
  79825. * @param priorVec the origin of the prior segment
  79826. * @param fromVec the origin of the current segment
  79827. * @param toVec the destination of the current segment
  79828. * @param result reference to output variable
  79829. * @returns whether or not transformation was successful
  79830. */
  79831. private static _transformSegmentDirToRef;
  79832. private static _bestMatch;
  79833. private static _score;
  79834. private static _bestScore;
  79835. /**
  79836. * Determine which token vector is most similar to the
  79837. * segment vector.
  79838. * @param segment segment vector
  79839. * @param tokens token vector list
  79840. * @returns index of the most similar token to the segment
  79841. */
  79842. private static _tokenizeSegment;
  79843. }
  79844. /**
  79845. * Class representing a set of known, named trajectories to which Trajectories can be
  79846. * added and using which Trajectories can be recognized.
  79847. */
  79848. export class TrajectoryClassifier {
  79849. private _maximumAllowableMatchCost;
  79850. private _vector3Alphabet;
  79851. private _levenshteinAlphabet;
  79852. private _nameToDescribedTrajectory;
  79853. /**
  79854. * Serialize to JSON.
  79855. * @returns JSON serialization
  79856. */
  79857. serialize(): string;
  79858. /**
  79859. * Deserialize from JSON.
  79860. * @param json JSON serialization
  79861. * @returns deserialized TrajectorySet
  79862. */
  79863. static Deserialize(json: string): TrajectoryClassifier;
  79864. /**
  79865. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  79866. * VERY naive, need to be generating these things from known
  79867. * sets. Better version later, probably eliminating this one.
  79868. * @returns auto-generated TrajectorySet
  79869. */
  79870. static Generate(): TrajectoryClassifier;
  79871. private constructor();
  79872. /**
  79873. * Add a new Trajectory to the set with a given name.
  79874. * @param trajectory new Trajectory to be added
  79875. * @param classification name to which to add the Trajectory
  79876. */
  79877. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  79878. /**
  79879. * Remove a known named trajectory and all Trajectories associated with it.
  79880. * @param classification name to remove
  79881. * @returns whether anything was removed
  79882. */
  79883. deleteClassification(classification: string): boolean;
  79884. /**
  79885. * Attempt to recognize a Trajectory from among all the classifications
  79886. * already known to the classifier.
  79887. * @param trajectory Trajectory to be recognized
  79888. * @returns classification of Trajectory if recognized, null otherwise
  79889. */
  79890. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  79891. }
  79892. }
  79893. declare module BABYLON {
  79894. /**
  79895. * An interface for all Hit test features
  79896. */
  79897. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  79898. /**
  79899. * Triggered when new babylon (transformed) hit test results are available
  79900. */
  79901. onHitTestResultObservable: Observable<T[]>;
  79902. }
  79903. /**
  79904. * Options used for hit testing
  79905. */
  79906. export interface IWebXRLegacyHitTestOptions {
  79907. /**
  79908. * Only test when user interacted with the scene. Default - hit test every frame
  79909. */
  79910. testOnPointerDownOnly?: boolean;
  79911. /**
  79912. * The node to use to transform the local results to world coordinates
  79913. */
  79914. worldParentNode?: TransformNode;
  79915. }
  79916. /**
  79917. * Interface defining the babylon result of raycasting/hit-test
  79918. */
  79919. export interface IWebXRLegacyHitResult {
  79920. /**
  79921. * Transformation matrix that can be applied to a node that will put it in the hit point location
  79922. */
  79923. transformationMatrix: Matrix;
  79924. /**
  79925. * The native hit test result
  79926. */
  79927. xrHitResult: XRHitResult | XRHitTestResult;
  79928. }
  79929. /**
  79930. * The currently-working hit-test module.
  79931. * Hit test (or Ray-casting) is used to interact with the real world.
  79932. * For further information read here - https://github.com/immersive-web/hit-test
  79933. */
  79934. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  79935. /**
  79936. * options to use when constructing this feature
  79937. */
  79938. readonly options: IWebXRLegacyHitTestOptions;
  79939. private _direction;
  79940. private _mat;
  79941. private _onSelectEnabled;
  79942. private _origin;
  79943. /**
  79944. * The module's name
  79945. */
  79946. static readonly Name: string;
  79947. /**
  79948. * The (Babylon) version of this module.
  79949. * This is an integer representing the implementation version.
  79950. * This number does not correspond to the WebXR specs version
  79951. */
  79952. static readonly Version: number;
  79953. /**
  79954. * Populated with the last native XR Hit Results
  79955. */
  79956. lastNativeXRHitResults: XRHitResult[];
  79957. /**
  79958. * Triggered when new babylon (transformed) hit test results are available
  79959. */
  79960. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  79961. /**
  79962. * Creates a new instance of the (legacy version) hit test feature
  79963. * @param _xrSessionManager an instance of WebXRSessionManager
  79964. * @param options options to use when constructing this feature
  79965. */
  79966. constructor(_xrSessionManager: WebXRSessionManager,
  79967. /**
  79968. * options to use when constructing this feature
  79969. */
  79970. options?: IWebXRLegacyHitTestOptions);
  79971. /**
  79972. * execute a hit test with an XR Ray
  79973. *
  79974. * @param xrSession a native xrSession that will execute this hit test
  79975. * @param xrRay the ray (position and direction) to use for ray-casting
  79976. * @param referenceSpace native XR reference space to use for the hit-test
  79977. * @param filter filter function that will filter the results
  79978. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79979. */
  79980. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  79981. /**
  79982. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  79983. * @param event the (select) event to use to select with
  79984. * @param referenceSpace the reference space to use for this hit test
  79985. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79986. */
  79987. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  79988. /**
  79989. * attach this feature
  79990. * Will usually be called by the features manager
  79991. *
  79992. * @returns true if successful.
  79993. */
  79994. attach(): boolean;
  79995. /**
  79996. * detach this feature.
  79997. * Will usually be called by the features manager
  79998. *
  79999. * @returns true if successful.
  80000. */
  80001. detach(): boolean;
  80002. /**
  80003. * Dispose this feature and all of the resources attached
  80004. */
  80005. dispose(): void;
  80006. protected _onXRFrame(frame: XRFrame): void;
  80007. private _onHitTestResults;
  80008. private _onSelect;
  80009. }
  80010. }
  80011. declare module BABYLON {
  80012. /**
  80013. * Options used for hit testing (version 2)
  80014. */
  80015. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  80016. /**
  80017. * Do not create a permanent hit test. Will usually be used when only
  80018. * transient inputs are needed.
  80019. */
  80020. disablePermanentHitTest?: boolean;
  80021. /**
  80022. * Enable transient (for example touch-based) hit test inspections
  80023. */
  80024. enableTransientHitTest?: boolean;
  80025. /**
  80026. * Offset ray for the permanent hit test
  80027. */
  80028. offsetRay?: Vector3;
  80029. /**
  80030. * Offset ray for the transient hit test
  80031. */
  80032. transientOffsetRay?: Vector3;
  80033. /**
  80034. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  80035. */
  80036. useReferenceSpace?: boolean;
  80037. /**
  80038. * Override the default entity type(s) of the hit-test result
  80039. */
  80040. entityTypes?: XRHitTestTrackableType[];
  80041. }
  80042. /**
  80043. * Interface defining the babylon result of hit-test
  80044. */
  80045. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  80046. /**
  80047. * The input source that generated this hit test (if transient)
  80048. */
  80049. inputSource?: XRInputSource;
  80050. /**
  80051. * Is this a transient hit test
  80052. */
  80053. isTransient?: boolean;
  80054. /**
  80055. * Position of the hit test result
  80056. */
  80057. position: Vector3;
  80058. /**
  80059. * Rotation of the hit test result
  80060. */
  80061. rotationQuaternion: Quaternion;
  80062. /**
  80063. * The native hit test result
  80064. */
  80065. xrHitResult: XRHitTestResult;
  80066. }
  80067. /**
  80068. * The currently-working hit-test module.
  80069. * Hit test (or Ray-casting) is used to interact with the real world.
  80070. * For further information read here - https://github.com/immersive-web/hit-test
  80071. *
  80072. * Tested on chrome (mobile) 80.
  80073. */
  80074. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  80075. /**
  80076. * options to use when constructing this feature
  80077. */
  80078. readonly options: IWebXRHitTestOptions;
  80079. private _tmpMat;
  80080. private _tmpPos;
  80081. private _tmpQuat;
  80082. private _transientXrHitTestSource;
  80083. private _xrHitTestSource;
  80084. private initHitTestSource;
  80085. /**
  80086. * The module's name
  80087. */
  80088. static readonly Name: string;
  80089. /**
  80090. * The (Babylon) version of this module.
  80091. * This is an integer representing the implementation version.
  80092. * This number does not correspond to the WebXR specs version
  80093. */
  80094. static readonly Version: number;
  80095. /**
  80096. * When set to true, each hit test will have its own position/rotation objects
  80097. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  80098. * the developers will clone them or copy them as they see fit.
  80099. */
  80100. autoCloneTransformation: boolean;
  80101. /**
  80102. * Triggered when new babylon (transformed) hit test results are available
  80103. * Note - this will be called when results come back from the device. It can be an empty array!!
  80104. */
  80105. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  80106. /**
  80107. * Use this to temporarily pause hit test checks.
  80108. */
  80109. paused: boolean;
  80110. /**
  80111. * Creates a new instance of the hit test feature
  80112. * @param _xrSessionManager an instance of WebXRSessionManager
  80113. * @param options options to use when constructing this feature
  80114. */
  80115. constructor(_xrSessionManager: WebXRSessionManager,
  80116. /**
  80117. * options to use when constructing this feature
  80118. */
  80119. options?: IWebXRHitTestOptions);
  80120. /**
  80121. * attach this feature
  80122. * Will usually be called by the features manager
  80123. *
  80124. * @returns true if successful.
  80125. */
  80126. attach(): boolean;
  80127. /**
  80128. * detach this feature.
  80129. * Will usually be called by the features manager
  80130. *
  80131. * @returns true if successful.
  80132. */
  80133. detach(): boolean;
  80134. /**
  80135. * Dispose this feature and all of the resources attached
  80136. */
  80137. dispose(): void;
  80138. protected _onXRFrame(frame: XRFrame): void;
  80139. private _processWebXRHitTestResult;
  80140. }
  80141. }
  80142. declare module BABYLON {
  80143. /**
  80144. * Configuration options of the anchor system
  80145. */
  80146. export interface IWebXRAnchorSystemOptions {
  80147. /**
  80148. * a node that will be used to convert local to world coordinates
  80149. */
  80150. worldParentNode?: TransformNode;
  80151. /**
  80152. * If set to true a reference of the created anchors will be kept until the next session starts
  80153. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  80154. */
  80155. doNotRemoveAnchorsOnSessionEnded?: boolean;
  80156. }
  80157. /**
  80158. * A babylon container for an XR Anchor
  80159. */
  80160. export interface IWebXRAnchor {
  80161. /**
  80162. * A babylon-assigned ID for this anchor
  80163. */
  80164. id: number;
  80165. /**
  80166. * Transformation matrix to apply to an object attached to this anchor
  80167. */
  80168. transformationMatrix: Matrix;
  80169. /**
  80170. * The native anchor object
  80171. */
  80172. xrAnchor: XRAnchor;
  80173. /**
  80174. * if defined, this object will be constantly updated by the anchor's position and rotation
  80175. */
  80176. attachedNode?: TransformNode;
  80177. /**
  80178. * Remove this anchor from the scene
  80179. */
  80180. remove(): void;
  80181. }
  80182. /**
  80183. * An implementation of the anchor system for WebXR.
  80184. * For further information see https://github.com/immersive-web/anchors/
  80185. */
  80186. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  80187. private _options;
  80188. private _lastFrameDetected;
  80189. private _trackedAnchors;
  80190. private _referenceSpaceForFrameAnchors;
  80191. private _futureAnchors;
  80192. /**
  80193. * The module's name
  80194. */
  80195. static readonly Name: string;
  80196. /**
  80197. * The (Babylon) version of this module.
  80198. * This is an integer representing the implementation version.
  80199. * This number does not correspond to the WebXR specs version
  80200. */
  80201. static readonly Version: number;
  80202. /**
  80203. * Observers registered here will be executed when a new anchor was added to the session
  80204. */
  80205. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  80206. /**
  80207. * Observers registered here will be executed when an anchor was removed from the session
  80208. */
  80209. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  80210. /**
  80211. * Observers registered here will be executed when an existing anchor updates
  80212. * This can execute N times every frame
  80213. */
  80214. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  80215. /**
  80216. * Set the reference space to use for anchor creation, when not using a hit test.
  80217. * Will default to the session's reference space if not defined
  80218. */
  80219. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  80220. /**
  80221. * constructs a new anchor system
  80222. * @param _xrSessionManager an instance of WebXRSessionManager
  80223. * @param _options configuration object for this feature
  80224. */
  80225. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  80226. private _tmpVector;
  80227. private _tmpQuaternion;
  80228. private _populateTmpTransformation;
  80229. /**
  80230. * Create a new anchor point using a hit test result at a specific point in the scene
  80231. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  80232. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  80233. *
  80234. * @param hitTestResult The hit test result to use for this anchor creation
  80235. * @param position an optional position offset for this anchor
  80236. * @param rotationQuaternion an optional rotation offset for this anchor
  80237. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  80238. */
  80239. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  80240. /**
  80241. * Add a new anchor at a specific position and rotation
  80242. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  80243. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  80244. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  80245. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  80246. *
  80247. * @param position the position in which to add an anchor
  80248. * @param rotationQuaternion an optional rotation for the anchor transformation
  80249. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  80250. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  80251. */
  80252. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  80253. /**
  80254. * Get the list of anchors currently being tracked by the system
  80255. */
  80256. get anchors(): IWebXRAnchor[];
  80257. /**
  80258. * detach this feature.
  80259. * Will usually be called by the features manager
  80260. *
  80261. * @returns true if successful.
  80262. */
  80263. detach(): boolean;
  80264. /**
  80265. * Dispose this feature and all of the resources attached
  80266. */
  80267. dispose(): void;
  80268. protected _onXRFrame(frame: XRFrame): void;
  80269. /**
  80270. * avoiding using Array.find for global support.
  80271. * @param xrAnchor the plane to find in the array
  80272. */
  80273. private _findIndexInAnchorArray;
  80274. private _updateAnchorWithXRFrame;
  80275. private _createAnchorAtTransformation;
  80276. }
  80277. }
  80278. declare module BABYLON {
  80279. /**
  80280. * Options used in the plane detector module
  80281. */
  80282. export interface IWebXRPlaneDetectorOptions {
  80283. /**
  80284. * The node to use to transform the local results to world coordinates
  80285. */
  80286. worldParentNode?: TransformNode;
  80287. /**
  80288. * If set to true a reference of the created planes will be kept until the next session starts
  80289. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  80290. */
  80291. doNotRemovePlanesOnSessionEnded?: boolean;
  80292. /**
  80293. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  80294. */
  80295. preferredDetectorOptions?: XRGeometryDetectorOptions;
  80296. }
  80297. /**
  80298. * A babylon interface for a WebXR plane.
  80299. * A Plane is actually a polygon, built from N points in space
  80300. *
  80301. * Supported in chrome 79, not supported in canary 81 ATM
  80302. */
  80303. export interface IWebXRPlane {
  80304. /**
  80305. * a babylon-assigned ID for this polygon
  80306. */
  80307. id: number;
  80308. /**
  80309. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  80310. */
  80311. polygonDefinition: Array<Vector3>;
  80312. /**
  80313. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  80314. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  80315. */
  80316. transformationMatrix: Matrix;
  80317. /**
  80318. * the native xr-plane object
  80319. */
  80320. xrPlane: XRPlane;
  80321. }
  80322. /**
  80323. * The plane detector is used to detect planes in the real world when in AR
  80324. * For more information see https://github.com/immersive-web/real-world-geometry/
  80325. */
  80326. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  80327. private _options;
  80328. private _detectedPlanes;
  80329. private _enabled;
  80330. private _lastFrameDetected;
  80331. /**
  80332. * The module's name
  80333. */
  80334. static readonly Name: string;
  80335. /**
  80336. * The (Babylon) version of this module.
  80337. * This is an integer representing the implementation version.
  80338. * This number does not correspond to the WebXR specs version
  80339. */
  80340. static readonly Version: number;
  80341. /**
  80342. * Observers registered here will be executed when a new plane was added to the session
  80343. */
  80344. onPlaneAddedObservable: Observable<IWebXRPlane>;
  80345. /**
  80346. * Observers registered here will be executed when a plane is no longer detected in the session
  80347. */
  80348. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  80349. /**
  80350. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  80351. * This can execute N times every frame
  80352. */
  80353. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  80354. /**
  80355. * construct a new Plane Detector
  80356. * @param _xrSessionManager an instance of xr Session manager
  80357. * @param _options configuration to use when constructing this feature
  80358. */
  80359. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  80360. /**
  80361. * detach this feature.
  80362. * Will usually be called by the features manager
  80363. *
  80364. * @returns true if successful.
  80365. */
  80366. detach(): boolean;
  80367. /**
  80368. * Dispose this feature and all of the resources attached
  80369. */
  80370. dispose(): void;
  80371. /**
  80372. * Check if the needed objects are defined.
  80373. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80374. */
  80375. isCompatible(): boolean;
  80376. protected _onXRFrame(frame: XRFrame): void;
  80377. private _init;
  80378. private _updatePlaneWithXRPlane;
  80379. /**
  80380. * avoiding using Array.find for global support.
  80381. * @param xrPlane the plane to find in the array
  80382. */
  80383. private _findIndexInPlaneArray;
  80384. }
  80385. }
  80386. declare module BABYLON {
  80387. /**
  80388. * Options interface for the background remover plugin
  80389. */
  80390. export interface IWebXRBackgroundRemoverOptions {
  80391. /**
  80392. * Further background meshes to disable when entering AR
  80393. */
  80394. backgroundMeshes?: AbstractMesh[];
  80395. /**
  80396. * flags to configure the removal of the environment helper.
  80397. * If not set, the entire background will be removed. If set, flags should be set as well.
  80398. */
  80399. environmentHelperRemovalFlags?: {
  80400. /**
  80401. * Should the skybox be removed (default false)
  80402. */
  80403. skyBox?: boolean;
  80404. /**
  80405. * Should the ground be removed (default false)
  80406. */
  80407. ground?: boolean;
  80408. };
  80409. /**
  80410. * don't disable the environment helper
  80411. */
  80412. ignoreEnvironmentHelper?: boolean;
  80413. }
  80414. /**
  80415. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  80416. */
  80417. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  80418. /**
  80419. * read-only options to be used in this module
  80420. */
  80421. readonly options: IWebXRBackgroundRemoverOptions;
  80422. /**
  80423. * The module's name
  80424. */
  80425. static readonly Name: string;
  80426. /**
  80427. * The (Babylon) version of this module.
  80428. * This is an integer representing the implementation version.
  80429. * This number does not correspond to the WebXR specs version
  80430. */
  80431. static readonly Version: number;
  80432. /**
  80433. * registered observers will be triggered when the background state changes
  80434. */
  80435. onBackgroundStateChangedObservable: Observable<boolean>;
  80436. /**
  80437. * constructs a new background remover module
  80438. * @param _xrSessionManager the session manager for this module
  80439. * @param options read-only options to be used in this module
  80440. */
  80441. constructor(_xrSessionManager: WebXRSessionManager,
  80442. /**
  80443. * read-only options to be used in this module
  80444. */
  80445. options?: IWebXRBackgroundRemoverOptions);
  80446. /**
  80447. * attach this feature
  80448. * Will usually be called by the features manager
  80449. *
  80450. * @returns true if successful.
  80451. */
  80452. attach(): boolean;
  80453. /**
  80454. * detach this feature.
  80455. * Will usually be called by the features manager
  80456. *
  80457. * @returns true if successful.
  80458. */
  80459. detach(): boolean;
  80460. /**
  80461. * Dispose this feature and all of the resources attached
  80462. */
  80463. dispose(): void;
  80464. protected _onXRFrame(_xrFrame: XRFrame): void;
  80465. private _setBackgroundState;
  80466. }
  80467. }
  80468. declare module BABYLON {
  80469. /**
  80470. * Options for the controller physics feature
  80471. */
  80472. export class IWebXRControllerPhysicsOptions {
  80473. /**
  80474. * Should the headset get its own impostor
  80475. */
  80476. enableHeadsetImpostor?: boolean;
  80477. /**
  80478. * Optional parameters for the headset impostor
  80479. */
  80480. headsetImpostorParams?: {
  80481. /**
  80482. * The type of impostor to create. Default is sphere
  80483. */
  80484. impostorType: number;
  80485. /**
  80486. * the size of the impostor. Defaults to 10cm
  80487. */
  80488. impostorSize?: number | {
  80489. width: number;
  80490. height: number;
  80491. depth: number;
  80492. };
  80493. /**
  80494. * Friction definitions
  80495. */
  80496. friction?: number;
  80497. /**
  80498. * Restitution
  80499. */
  80500. restitution?: number;
  80501. };
  80502. /**
  80503. * The physics properties of the future impostors
  80504. */
  80505. physicsProperties?: {
  80506. /**
  80507. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  80508. * Note that this requires a physics engine that supports mesh impostors!
  80509. */
  80510. useControllerMesh?: boolean;
  80511. /**
  80512. * The type of impostor to create. Default is sphere
  80513. */
  80514. impostorType?: number;
  80515. /**
  80516. * the size of the impostor. Defaults to 10cm
  80517. */
  80518. impostorSize?: number | {
  80519. width: number;
  80520. height: number;
  80521. depth: number;
  80522. };
  80523. /**
  80524. * Friction definitions
  80525. */
  80526. friction?: number;
  80527. /**
  80528. * Restitution
  80529. */
  80530. restitution?: number;
  80531. };
  80532. /**
  80533. * the xr input to use with this pointer selection
  80534. */
  80535. xrInput: WebXRInput;
  80536. }
  80537. /**
  80538. * Add physics impostor to your webxr controllers,
  80539. * including naive calculation of their linear and angular velocity
  80540. */
  80541. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  80542. private readonly _options;
  80543. private _attachController;
  80544. private _controllers;
  80545. private _debugMode;
  80546. private _delta;
  80547. private _headsetImpostor?;
  80548. private _headsetMesh?;
  80549. private _lastTimestamp;
  80550. private _tmpQuaternion;
  80551. private _tmpVector;
  80552. /**
  80553. * The module's name
  80554. */
  80555. static readonly Name: string;
  80556. /**
  80557. * The (Babylon) version of this module.
  80558. * This is an integer representing the implementation version.
  80559. * This number does not correspond to the webxr specs version
  80560. */
  80561. static readonly Version: number;
  80562. /**
  80563. * Construct a new Controller Physics Feature
  80564. * @param _xrSessionManager the corresponding xr session manager
  80565. * @param _options options to create this feature with
  80566. */
  80567. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  80568. /**
  80569. * @hidden
  80570. * enable debugging - will show console outputs and the impostor mesh
  80571. */
  80572. _enablePhysicsDebug(): void;
  80573. /**
  80574. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  80575. * @param xrController the controller to add
  80576. */
  80577. addController(xrController: WebXRInputSource): void;
  80578. /**
  80579. * attach this feature
  80580. * Will usually be called by the features manager
  80581. *
  80582. * @returns true if successful.
  80583. */
  80584. attach(): boolean;
  80585. /**
  80586. * detach this feature.
  80587. * Will usually be called by the features manager
  80588. *
  80589. * @returns true if successful.
  80590. */
  80591. detach(): boolean;
  80592. /**
  80593. * Get the headset impostor, if enabled
  80594. * @returns the impostor
  80595. */
  80596. getHeadsetImpostor(): PhysicsImpostor | undefined;
  80597. /**
  80598. * Get the physics impostor of a specific controller.
  80599. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  80600. * @param controller the controller or the controller id of which to get the impostor
  80601. * @returns the impostor or null
  80602. */
  80603. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  80604. /**
  80605. * Update the physics properties provided in the constructor
  80606. * @param newProperties the new properties object
  80607. */
  80608. setPhysicsProperties(newProperties: {
  80609. impostorType?: number;
  80610. impostorSize?: number | {
  80611. width: number;
  80612. height: number;
  80613. depth: number;
  80614. };
  80615. friction?: number;
  80616. restitution?: number;
  80617. }): void;
  80618. protected _onXRFrame(_xrFrame: any): void;
  80619. private _detachController;
  80620. }
  80621. }
  80622. declare module BABYLON {
  80623. /**
  80624. * A babylon interface for a "WebXR" feature point.
  80625. * Represents the position and confidence value of a given feature point.
  80626. */
  80627. export interface IWebXRFeaturePoint {
  80628. /**
  80629. * Represents the position of the feature point in world space.
  80630. */
  80631. position: Vector3;
  80632. /**
  80633. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  80634. */
  80635. confidenceValue: number;
  80636. }
  80637. /**
  80638. * The feature point system is used to detect feature points from real world geometry.
  80639. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  80640. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  80641. */
  80642. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  80643. private _enabled;
  80644. private _featurePointCloud;
  80645. /**
  80646. * The module's name
  80647. */
  80648. static readonly Name: string;
  80649. /**
  80650. * The (Babylon) version of this module.
  80651. * This is an integer representing the implementation version.
  80652. * This number does not correspond to the WebXR specs version
  80653. */
  80654. static readonly Version: number;
  80655. /**
  80656. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  80657. * Will notify the observers about which feature points have been added.
  80658. */
  80659. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  80660. /**
  80661. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  80662. * Will notify the observers about which feature points have been updated.
  80663. */
  80664. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  80665. /**
  80666. * The current feature point cloud maintained across frames.
  80667. */
  80668. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  80669. /**
  80670. * construct the feature point system
  80671. * @param _xrSessionManager an instance of xr Session manager
  80672. */
  80673. constructor(_xrSessionManager: WebXRSessionManager);
  80674. /**
  80675. * Detach this feature.
  80676. * Will usually be called by the features manager
  80677. *
  80678. * @returns true if successful.
  80679. */
  80680. detach(): boolean;
  80681. /**
  80682. * Dispose this feature and all of the resources attached
  80683. */
  80684. dispose(): void;
  80685. /**
  80686. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  80687. */
  80688. protected _onXRFrame(frame: XRFrame): void;
  80689. /**
  80690. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  80691. */
  80692. private _init;
  80693. }
  80694. }
  80695. declare module BABYLON {
  80696. /**
  80697. * Configuration interface for the hand tracking feature
  80698. */
  80699. export interface IWebXRHandTrackingOptions {
  80700. /**
  80701. * The xrInput that will be used as source for new hands
  80702. */
  80703. xrInput: WebXRInput;
  80704. /**
  80705. * Configuration object for the joint meshes
  80706. */
  80707. jointMeshes?: {
  80708. /**
  80709. * Should the meshes created be invisible (defaults to false)
  80710. */
  80711. invisible?: boolean;
  80712. /**
  80713. * A source mesh to be used to create instances. Defaults to a sphere.
  80714. * This mesh will be the source for all other (25) meshes.
  80715. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  80716. */
  80717. sourceMesh?: Mesh;
  80718. /**
  80719. * This function will be called after a mesh was created for a specific joint.
  80720. * Using this function you can either manipulate the instance or return a new mesh.
  80721. * When returning a new mesh the instance created before will be disposed
  80722. */
  80723. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  80724. /**
  80725. * Should the source mesh stay visible. Defaults to false
  80726. */
  80727. keepOriginalVisible?: boolean;
  80728. /**
  80729. * Scale factor for all instances (defaults to 2)
  80730. */
  80731. scaleFactor?: number;
  80732. /**
  80733. * Should each instance have its own physics impostor
  80734. */
  80735. enablePhysics?: boolean;
  80736. /**
  80737. * If enabled, override default physics properties
  80738. */
  80739. physicsProps?: {
  80740. friction?: number;
  80741. restitution?: number;
  80742. impostorType?: number;
  80743. };
  80744. /**
  80745. * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).
  80746. */
  80747. disableDefaultHandMesh?: boolean;
  80748. /**
  80749. * a rigged hand-mesh that will be updated according to the XRHand data provided. This will override the default hand mesh
  80750. */
  80751. handMeshes?: {
  80752. right: AbstractMesh;
  80753. left: AbstractMesh;
  80754. };
  80755. /**
  80756. * Are the meshes prepared for a left-handed system. Default hand meshes are right-handed.
  80757. */
  80758. leftHandedSystemMeshes?: boolean;
  80759. /**
  80760. * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh
  80761. */
  80762. rigMapping?: {
  80763. right: string[];
  80764. left: string[];
  80765. };
  80766. /**
  80767. * The utilityLayer scene that contains the 3D UI elements. Passing this in turns on near interactions with the index finger tip
  80768. */
  80769. sceneForNearInteraction?: Scene;
  80770. };
  80771. }
  80772. /**
  80773. * Parts of the hands divided to writs and finger names
  80774. */
  80775. export const enum HandPart {
  80776. /**
  80777. * HandPart - Wrist
  80778. */
  80779. WRIST = "wrist",
  80780. /**
  80781. * HandPart - The thumb
  80782. */
  80783. THUMB = "thumb",
  80784. /**
  80785. * HandPart - Index finger
  80786. */
  80787. INDEX = "index",
  80788. /**
  80789. * HandPart - Middle finger
  80790. */
  80791. MIDDLE = "middle",
  80792. /**
  80793. * HandPart - Ring finger
  80794. */
  80795. RING = "ring",
  80796. /**
  80797. * HandPart - Little finger
  80798. */
  80799. LITTLE = "little"
  80800. }
  80801. /**
  80802. * Representing a single hand (with its corresponding native XRHand object)
  80803. */
  80804. export class WebXRHand implements IDisposable {
  80805. /** the controller to which the hand correlates */
  80806. readonly xrController: WebXRInputSource;
  80807. /** the meshes to be used to track the hand joints */
  80808. readonly trackedMeshes: AbstractMesh[];
  80809. private _handMesh?;
  80810. private _rigMapping?;
  80811. private _nearInteractionMesh?;
  80812. private _leftHandedMeshes?;
  80813. private _scene;
  80814. private _defaultHandMesh;
  80815. private _transformNodeMapping;
  80816. private _boneMapping;
  80817. private _useBones;
  80818. /**
  80819. * Hand-parts definition (key is HandPart)
  80820. */
  80821. handPartsDefinition: {
  80822. [key: string]: number[];
  80823. };
  80824. /**
  80825. * Observers will be triggered when the mesh for this hand was initialized.
  80826. */
  80827. onHandMeshReadyObservable: Observable<WebXRHand>;
  80828. /**
  80829. * Populate the HandPartsDefinition object.
  80830. * This is called as a side effect since certain browsers don't have XRHand defined.
  80831. */
  80832. private generateHandPartsDefinition;
  80833. /**
  80834. * Construct a new hand object
  80835. * @param xrController the controller to which the hand correlates
  80836. * @param trackedMeshes the meshes to be used to track the hand joints
  80837. * @param _handMesh an optional hand mesh. if not provided, ours will be used
  80838. * @param _rigMapping an optional rig mapping for the hand mesh. if not provided, ours will be used
  80839. * @param disableDefaultHandMesh should the default mesh creation be disabled
  80840. * @param _nearInteractionMesh as optional mesh used for near interaction collision checking
  80841. * @param _leftHandedMeshes are the hand meshes left-handed-system meshes
  80842. */
  80843. constructor(
  80844. /** the controller to which the hand correlates */
  80845. xrController: WebXRInputSource,
  80846. /** the meshes to be used to track the hand joints */
  80847. trackedMeshes: AbstractMesh[], _handMesh?: AbstractMesh | undefined, _rigMapping?: string[] | undefined, disableDefaultHandMesh?: boolean, _nearInteractionMesh?: AbstractMesh | null | undefined, _leftHandedMeshes?: boolean | undefined);
  80848. /**
  80849. * Get the hand mesh. It is possible that the hand mesh is not yet ready!
  80850. */
  80851. get handMesh(): AbstractMesh | undefined;
  80852. /**
  80853. * Update this hand from the latest xr frame
  80854. * @param xrFrame xrFrame to update from
  80855. * @param referenceSpace The current viewer reference space
  80856. * @param scaleFactor optional scale factor for the meshes
  80857. */
  80858. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  80859. /**
  80860. * Get meshes of part of the hand
  80861. * @param part the part of hand to get
  80862. * @returns An array of meshes that correlate to the hand part requested
  80863. */
  80864. getHandPartMeshes(part: HandPart): AbstractMesh[];
  80865. /**
  80866. * Dispose this Hand object
  80867. */
  80868. dispose(): void;
  80869. private _generateDefaultHandMesh;
  80870. }
  80871. /**
  80872. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  80873. */
  80874. export class WebXRHandTracking extends WebXRAbstractFeature {
  80875. /**
  80876. * options to use when constructing this feature
  80877. */
  80878. readonly options: IWebXRHandTrackingOptions;
  80879. private static _idCounter;
  80880. /**
  80881. * The module's name
  80882. */
  80883. static readonly Name: string;
  80884. /**
  80885. * The (Babylon) version of this module.
  80886. * This is an integer representing the implementation version.
  80887. * This number does not correspond to the WebXR specs version
  80888. */
  80889. static readonly Version: number;
  80890. /**
  80891. * This observable will notify registered observers when a new hand object was added and initialized
  80892. */
  80893. onHandAddedObservable: Observable<WebXRHand>;
  80894. /**
  80895. * This observable will notify its observers right before the hand object is disposed
  80896. */
  80897. onHandRemovedObservable: Observable<WebXRHand>;
  80898. private _hands;
  80899. /**
  80900. * Creates a new instance of the hit test feature
  80901. * @param _xrSessionManager an instance of WebXRSessionManager
  80902. * @param options options to use when constructing this feature
  80903. */
  80904. constructor(_xrSessionManager: WebXRSessionManager,
  80905. /**
  80906. * options to use when constructing this feature
  80907. */
  80908. options: IWebXRHandTrackingOptions);
  80909. /**
  80910. * Check if the needed objects are defined.
  80911. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80912. */
  80913. isCompatible(): boolean;
  80914. /**
  80915. * attach this feature
  80916. * Will usually be called by the features manager
  80917. *
  80918. * @returns true if successful.
  80919. */
  80920. attach(): boolean;
  80921. /**
  80922. * detach this feature.
  80923. * Will usually be called by the features manager
  80924. *
  80925. * @returns true if successful.
  80926. */
  80927. detach(): boolean;
  80928. /**
  80929. * Dispose this feature and all of the resources attached
  80930. */
  80931. dispose(): void;
  80932. /**
  80933. * Get the hand object according to the controller id
  80934. * @param controllerId the controller id to which we want to get the hand
  80935. * @returns null if not found or the WebXRHand object if found
  80936. */
  80937. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  80938. /**
  80939. * Get a hand object according to the requested handedness
  80940. * @param handedness the handedness to request
  80941. * @returns null if not found or the WebXRHand object if found
  80942. */
  80943. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  80944. protected _onXRFrame(_xrFrame: XRFrame): void;
  80945. private _attachHand;
  80946. private _detachHand;
  80947. }
  80948. }
  80949. declare module BABYLON {
  80950. /**
  80951. * Options used in the mesh detector module
  80952. */
  80953. export interface IWebXRMeshDetectorOptions {
  80954. /**
  80955. * The node to use to transform the local results to world coordinates
  80956. */
  80957. worldParentNode?: TransformNode;
  80958. /**
  80959. * If set to true a reference of the created meshes will be kept until the next session starts
  80960. * If not defined, meshes will be removed from the array when the feature is detached or the session ended.
  80961. */
  80962. doNotRemoveMeshesOnSessionEnded?: boolean;
  80963. /**
  80964. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  80965. */
  80966. preferredDetectorOptions?: XRGeometryDetectorOptions;
  80967. /**
  80968. * If set to true, WebXRMeshDetector will convert coordinate systems for meshes.
  80969. * If not defined, mesh conversions from right handed to left handed coordinate systems won't be conducted.
  80970. * Right handed mesh data will be available through IWebXRVertexData.xrMesh.
  80971. */
  80972. convertCoordinateSystems?: boolean;
  80973. }
  80974. /**
  80975. * A babylon interface for a XR mesh's vertex data.
  80976. *
  80977. * Currently not supported by WebXR, available only with BabylonNative
  80978. */
  80979. export interface IWebXRVertexData {
  80980. /**
  80981. * A babylon-assigned ID for this mesh
  80982. */
  80983. id: number;
  80984. /**
  80985. * Data required for constructing a mesh in Babylon.js.
  80986. */
  80987. xrMesh: XRMesh;
  80988. /**
  80989. * The node to use to transform the local results to world coordinates.
  80990. * WorldParentNode will only exist if it was declared in the IWebXRMeshDetectorOptions.
  80991. */
  80992. worldParentNode?: TransformNode;
  80993. /**
  80994. * An array of vertex positions in babylon space. right/left hand system is taken into account.
  80995. * Positions will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  80996. */
  80997. positions?: Float32Array;
  80998. /**
  80999. * An array of indices in babylon space. Indices have a counterclockwise winding order.
  81000. * Indices will only be populated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  81001. */
  81002. indices?: Uint32Array;
  81003. /**
  81004. * An array of vertex normals in babylon space. right/left hand system is taken into account.
  81005. * Normals will not be calculated if convertCoordinateSystems is undefined in the IWebXRMeshDetectorOptions.
  81006. * Different platforms may or may not support mesh normals when convertCoordinateSystems is set to true.
  81007. */
  81008. normals?: Float32Array;
  81009. /**
  81010. * A transformation matrix to apply on the mesh that will be built using the meshDefinition.
  81011. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module.
  81012. * TransformationMatrix will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  81013. */
  81014. transformationMatrix?: Matrix;
  81015. }
  81016. /**
  81017. * The mesh detector is used to detect meshes in the real world when in AR
  81018. */
  81019. export class WebXRMeshDetector extends WebXRAbstractFeature {
  81020. private _options;
  81021. private _detectedMeshes;
  81022. /**
  81023. * The module's name
  81024. */
  81025. static readonly Name: string;
  81026. /**
  81027. * The (Babylon) version of this module.
  81028. * This is an integer representing the implementation version.
  81029. * This number does not correspond to the WebXR specs version
  81030. */
  81031. static readonly Version: number;
  81032. /**
  81033. * Observers registered here will be executed when a new mesh was added to the session
  81034. */
  81035. onMeshAddedObservable: Observable<IWebXRVertexData>;
  81036. /**
  81037. * Observers registered here will be executed when a mesh is no longer detected in the session
  81038. */
  81039. onMeshRemovedObservable: Observable<IWebXRVertexData>;
  81040. /**
  81041. * Observers registered here will be executed when an existing mesh updates
  81042. */
  81043. onMeshUpdatedObservable: Observable<IWebXRVertexData>;
  81044. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRMeshDetectorOptions);
  81045. detach(): boolean;
  81046. dispose(): void;
  81047. protected _onXRFrame(frame: XRFrame): void;
  81048. private _init;
  81049. private _updateVertexDataWithXRMesh;
  81050. }
  81051. }
  81052. declare module BABYLON {
  81053. /**
  81054. * Options interface for the background remover plugin
  81055. */
  81056. export interface IWebXRImageTrackingOptions {
  81057. /**
  81058. * A required array with images to track
  81059. */
  81060. images: {
  81061. /**
  81062. * The source of the image. can be a URL or an image bitmap
  81063. */
  81064. src: string | ImageBitmap;
  81065. /**
  81066. * The estimated width in the real world (in meters)
  81067. */
  81068. estimatedRealWorldWidth: number;
  81069. }[];
  81070. }
  81071. /**
  81072. * An object representing an image tracked by the system
  81073. */
  81074. export interface IWebXRTrackedImage {
  81075. /**
  81076. * The ID of this image (which is the same as the position in the array that was used to initialize the feature)
  81077. */
  81078. id: number;
  81079. /**
  81080. * Is the transformation provided emulated. If it is, the system "guesses" its real position. Otherwise it can be considered as exact position.
  81081. */
  81082. emulated?: boolean;
  81083. /**
  81084. * Just in case it is needed - the image bitmap that is being tracked
  81085. */
  81086. originalBitmap: ImageBitmap;
  81087. /**
  81088. * The native XR result image tracking result, untouched
  81089. */
  81090. xrTrackingResult?: XRImageTrackingResult;
  81091. /**
  81092. * Width in real world (meters)
  81093. */
  81094. realWorldWidth?: number;
  81095. /**
  81096. * A transformation matrix of this current image in the current reference space.
  81097. */
  81098. transformationMatrix: Matrix;
  81099. /**
  81100. * The width/height ratio of this image. can be used to calculate the size of the detected object/image
  81101. */
  81102. ratio?: number;
  81103. }
  81104. /**
  81105. * Image tracking for immersive AR sessions.
  81106. * Providing a list of images and their estimated widths will enable tracking those images in the real world.
  81107. */
  81108. export class WebXRImageTracking extends WebXRAbstractFeature {
  81109. /**
  81110. * read-only options to be used in this module
  81111. */
  81112. readonly options: IWebXRImageTrackingOptions;
  81113. /**
  81114. * The module's name
  81115. */
  81116. static readonly Name: string;
  81117. /**
  81118. * The (Babylon) version of this module.
  81119. * This is an integer representing the implementation version.
  81120. * This number does not correspond to the WebXR specs version
  81121. */
  81122. static readonly Version: number;
  81123. /**
  81124. * This will be triggered if the underlying system deems an image untrackable.
  81125. * The index is the index of the image from the array used to initialize the feature.
  81126. */
  81127. onUntrackableImageFoundObservable: Observable<number>;
  81128. /**
  81129. * An image was deemed trackable, and the system will start tracking it.
  81130. */
  81131. onTrackableImageFoundObservable: Observable<IWebXRTrackedImage>;
  81132. /**
  81133. * The image was found and its state was updated.
  81134. */
  81135. onTrackedImageUpdatedObservable: Observable<IWebXRTrackedImage>;
  81136. private _trackedImages;
  81137. private _originalTrackingRequest;
  81138. /**
  81139. * constructs the image tracking feature
  81140. * @param _xrSessionManager the session manager for this module
  81141. * @param options read-only options to be used in this module
  81142. */
  81143. constructor(_xrSessionManager: WebXRSessionManager,
  81144. /**
  81145. * read-only options to be used in this module
  81146. */
  81147. options: IWebXRImageTrackingOptions);
  81148. /**
  81149. * attach this feature
  81150. * Will usually be called by the features manager
  81151. *
  81152. * @returns true if successful.
  81153. */
  81154. attach(): boolean;
  81155. /**
  81156. * detach this feature.
  81157. * Will usually be called by the features manager
  81158. *
  81159. * @returns true if successful.
  81160. */
  81161. detach(): boolean;
  81162. /**
  81163. * Check if the needed objects are defined.
  81164. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  81165. */
  81166. isCompatible(): boolean;
  81167. /**
  81168. * Get a tracked image by its ID.
  81169. *
  81170. * @param id the id of the image to load (position in the init array)
  81171. * @returns a trackable image, if exists in this location
  81172. */
  81173. getTrackedImageById(id: number): Nullable<IWebXRTrackedImage>;
  81174. /**
  81175. * Dispose this feature and all of the resources attached
  81176. */
  81177. dispose(): void;
  81178. /**
  81179. * Extends the session init object if needed
  81180. * @returns augmentation object fo the xr session init object.
  81181. */
  81182. getXRSessionInitExtension(): Promise<Partial<XRSessionInit>>;
  81183. protected _onXRFrame(_xrFrame: XRFrame): void;
  81184. private _init;
  81185. }
  81186. }
  81187. declare module BABYLON {
  81188. /**
  81189. * The motion controller class for all microsoft mixed reality controllers
  81190. */
  81191. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  81192. protected readonly _mapping: {
  81193. defaultButton: {
  81194. valueNodeName: string;
  81195. unpressedNodeName: string;
  81196. pressedNodeName: string;
  81197. };
  81198. defaultAxis: {
  81199. valueNodeName: string;
  81200. minNodeName: string;
  81201. maxNodeName: string;
  81202. };
  81203. buttons: {
  81204. "xr-standard-trigger": {
  81205. rootNodeName: string;
  81206. componentProperty: string;
  81207. states: string[];
  81208. };
  81209. "xr-standard-squeeze": {
  81210. rootNodeName: string;
  81211. componentProperty: string;
  81212. states: string[];
  81213. };
  81214. "xr-standard-touchpad": {
  81215. rootNodeName: string;
  81216. labelAnchorNodeName: string;
  81217. touchPointNodeName: string;
  81218. };
  81219. "xr-standard-thumbstick": {
  81220. rootNodeName: string;
  81221. componentProperty: string;
  81222. states: string[];
  81223. };
  81224. };
  81225. axes: {
  81226. "xr-standard-touchpad": {
  81227. "x-axis": {
  81228. rootNodeName: string;
  81229. };
  81230. "y-axis": {
  81231. rootNodeName: string;
  81232. };
  81233. };
  81234. "xr-standard-thumbstick": {
  81235. "x-axis": {
  81236. rootNodeName: string;
  81237. };
  81238. "y-axis": {
  81239. rootNodeName: string;
  81240. };
  81241. };
  81242. };
  81243. };
  81244. /**
  81245. * The base url used to load the left and right controller models
  81246. */
  81247. static MODEL_BASE_URL: string;
  81248. /**
  81249. * The name of the left controller model file
  81250. */
  81251. static MODEL_LEFT_FILENAME: string;
  81252. /**
  81253. * The name of the right controller model file
  81254. */
  81255. static MODEL_RIGHT_FILENAME: string;
  81256. profileId: string;
  81257. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  81258. protected _getFilenameAndPath(): {
  81259. filename: string;
  81260. path: string;
  81261. };
  81262. protected _getModelLoadingConstraints(): boolean;
  81263. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  81264. protected _setRootMesh(meshes: AbstractMesh[]): void;
  81265. protected _updateModel(): void;
  81266. }
  81267. }
  81268. declare module BABYLON {
  81269. /**
  81270. * The motion controller class for oculus touch (quest, rift).
  81271. * This class supports legacy mapping as well the standard xr mapping
  81272. */
  81273. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  81274. private _forceLegacyControllers;
  81275. private _modelRootNode;
  81276. /**
  81277. * The base url used to load the left and right controller models
  81278. */
  81279. static MODEL_BASE_URL: string;
  81280. /**
  81281. * The name of the left controller model file
  81282. */
  81283. static MODEL_LEFT_FILENAME: string;
  81284. /**
  81285. * The name of the right controller model file
  81286. */
  81287. static MODEL_RIGHT_FILENAME: string;
  81288. /**
  81289. * Base Url for the Quest controller model.
  81290. */
  81291. static QUEST_MODEL_BASE_URL: string;
  81292. profileId: string;
  81293. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  81294. protected _getFilenameAndPath(): {
  81295. filename: string;
  81296. path: string;
  81297. };
  81298. protected _getModelLoadingConstraints(): boolean;
  81299. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  81300. protected _setRootMesh(meshes: AbstractMesh[]): void;
  81301. protected _updateModel(): void;
  81302. /**
  81303. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  81304. * between the touch and touch 2.
  81305. */
  81306. private _isQuest;
  81307. }
  81308. }
  81309. declare module BABYLON {
  81310. /**
  81311. * The motion controller class for the standard HTC-Vive controllers
  81312. */
  81313. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  81314. private _modelRootNode;
  81315. /**
  81316. * The base url used to load the left and right controller models
  81317. */
  81318. static MODEL_BASE_URL: string;
  81319. /**
  81320. * File name for the controller model.
  81321. */
  81322. static MODEL_FILENAME: string;
  81323. profileId: string;
  81324. /**
  81325. * Create a new Vive motion controller object
  81326. * @param scene the scene to use to create this controller
  81327. * @param gamepadObject the corresponding gamepad object
  81328. * @param handedness the handedness of the controller
  81329. */
  81330. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  81331. protected _getFilenameAndPath(): {
  81332. filename: string;
  81333. path: string;
  81334. };
  81335. protected _getModelLoadingConstraints(): boolean;
  81336. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  81337. protected _setRootMesh(meshes: AbstractMesh[]): void;
  81338. protected _updateModel(): void;
  81339. }
  81340. }
  81341. declare module BABYLON {
  81342. /** @hidden */
  81343. export class WebGPUCacheRenderPipelineString extends WebGPUCacheRenderPipeline {
  81344. private static _Cache;
  81345. protected _getRenderPipeline(param: {
  81346. token: any;
  81347. pipeline: Nullable<GPURenderPipeline>;
  81348. }): void;
  81349. protected _setRenderPipeline(param: {
  81350. token: any;
  81351. pipeline: Nullable<GPURenderPipeline>;
  81352. }): void;
  81353. }
  81354. }
  81355. declare module BABYLON {
  81356. /** @hidden */
  81357. export var blurPixelShader: {
  81358. name: string;
  81359. shader: string;
  81360. };
  81361. }
  81362. declare module BABYLON {
  81363. /** @hidden */
  81364. export var pointCloudVertexDeclaration: {
  81365. name: string;
  81366. shader: string;
  81367. };
  81368. }
  81369. // Mixins
  81370. interface Window {
  81371. mozIndexedDB: IDBFactory;
  81372. webkitIndexedDB: IDBFactory;
  81373. msIndexedDB: IDBFactory;
  81374. webkitURL: typeof URL;
  81375. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  81376. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  81377. WebGLRenderingContext: WebGLRenderingContext;
  81378. MSGesture: MSGesture;
  81379. CANNON: any;
  81380. AudioContext: AudioContext;
  81381. webkitAudioContext: AudioContext;
  81382. PointerEvent: any;
  81383. Math: Math;
  81384. Uint8Array: Uint8ArrayConstructor;
  81385. Float32Array: Float32ArrayConstructor;
  81386. mozURL: typeof URL;
  81387. msURL: typeof URL;
  81388. VRFrameData: any; // WebVR, from specs 1.1
  81389. DracoDecoderModule: any;
  81390. setImmediate(handler: (...args: any[]) => void): number;
  81391. }
  81392. interface HTMLCanvasElement {
  81393. requestPointerLock(): void;
  81394. msRequestPointerLock?(): void;
  81395. mozRequestPointerLock?(): void;
  81396. webkitRequestPointerLock?(): void;
  81397. /** Track whether a record is in progress */
  81398. isRecording: boolean;
  81399. /** Capture Stream method defined by some browsers */
  81400. captureStream(fps?: number): MediaStream;
  81401. }
  81402. interface CanvasRenderingContext2D {
  81403. msImageSmoothingEnabled: boolean;
  81404. }
  81405. interface MouseEvent {
  81406. mozMovementX: number;
  81407. mozMovementY: number;
  81408. webkitMovementX: number;
  81409. webkitMovementY: number;
  81410. msMovementX: number;
  81411. msMovementY: number;
  81412. }
  81413. interface Navigator {
  81414. mozGetVRDevices: (any: any) => any;
  81415. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  81416. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  81417. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  81418. webkitGetGamepads(): Gamepad[];
  81419. msGetGamepads(): Gamepad[];
  81420. webkitGamepads(): Gamepad[];
  81421. }
  81422. interface HTMLVideoElement {
  81423. mozSrcObject: any;
  81424. }
  81425. interface Math {
  81426. fround(x: number): number;
  81427. imul(a: number, b: number): number;
  81428. log2(x: number): number;
  81429. }
  81430. interface WebGLRenderingContext {
  81431. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  81432. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  81433. vertexAttribDivisor(index: number, divisor: number): void;
  81434. createVertexArray(): any;
  81435. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  81436. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  81437. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  81438. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  81439. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  81440. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  81441. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  81442. // Queries
  81443. createQuery(): WebGLQuery;
  81444. deleteQuery(query: WebGLQuery): void;
  81445. beginQuery(target: number, query: WebGLQuery): void;
  81446. endQuery(target: number): void;
  81447. getQueryParameter(query: WebGLQuery, pname: number): any;
  81448. getQuery(target: number, pname: number): any;
  81449. MAX_SAMPLES: number;
  81450. RGBA8: number;
  81451. READ_FRAMEBUFFER: number;
  81452. DRAW_FRAMEBUFFER: number;
  81453. UNIFORM_BUFFER: number;
  81454. HALF_FLOAT_OES: number;
  81455. RGBA16F: number;
  81456. RGBA32F: number;
  81457. R32F: number;
  81458. RG32F: number;
  81459. RGB32F: number;
  81460. R16F: number;
  81461. RG16F: number;
  81462. RGB16F: number;
  81463. RED: number;
  81464. RG: number;
  81465. R8: number;
  81466. RG8: number;
  81467. UNSIGNED_INT_24_8: number;
  81468. DEPTH24_STENCIL8: number;
  81469. MIN: number;
  81470. MAX: number;
  81471. /* Multiple Render Targets */
  81472. drawBuffers(buffers: number[]): void;
  81473. readBuffer(src: number): void;
  81474. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  81475. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  81476. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  81477. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  81478. // Occlusion Query
  81479. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  81480. ANY_SAMPLES_PASSED: number;
  81481. QUERY_RESULT_AVAILABLE: number;
  81482. QUERY_RESULT: number;
  81483. }
  81484. interface WebGLProgram {
  81485. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  81486. }
  81487. interface EXT_disjoint_timer_query {
  81488. QUERY_COUNTER_BITS_EXT: number;
  81489. TIME_ELAPSED_EXT: number;
  81490. TIMESTAMP_EXT: number;
  81491. GPU_DISJOINT_EXT: number;
  81492. QUERY_RESULT_EXT: number;
  81493. QUERY_RESULT_AVAILABLE_EXT: number;
  81494. queryCounterEXT(query: WebGLQuery, target: number): void;
  81495. createQueryEXT(): WebGLQuery;
  81496. beginQueryEXT(target: number, query: WebGLQuery): void;
  81497. endQueryEXT(target: number): void;
  81498. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  81499. deleteQueryEXT(query: WebGLQuery): void;
  81500. }
  81501. interface WebGLUniformLocation {
  81502. _currentState: any;
  81503. }
  81504. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  81505. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  81506. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  81507. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  81508. interface WebGLRenderingContext {
  81509. readonly RASTERIZER_DISCARD: number;
  81510. readonly DEPTH_COMPONENT24: number;
  81511. readonly TEXTURE_3D: number;
  81512. readonly TEXTURE_2D_ARRAY: number;
  81513. readonly TEXTURE_COMPARE_FUNC: number;
  81514. readonly TEXTURE_COMPARE_MODE: number;
  81515. readonly COMPARE_REF_TO_TEXTURE: number;
  81516. readonly TEXTURE_WRAP_R: number;
  81517. readonly HALF_FLOAT: number;
  81518. readonly RGB8: number;
  81519. readonly RED_INTEGER: number;
  81520. readonly RG_INTEGER: number;
  81521. readonly RGB_INTEGER: number;
  81522. readonly RGBA_INTEGER: number;
  81523. readonly R8_SNORM: number;
  81524. readonly RG8_SNORM: number;
  81525. readonly RGB8_SNORM: number;
  81526. readonly RGBA8_SNORM: number;
  81527. readonly R8I: number;
  81528. readonly RG8I: number;
  81529. readonly RGB8I: number;
  81530. readonly RGBA8I: number;
  81531. readonly R8UI: number;
  81532. readonly RG8UI: number;
  81533. readonly RGB8UI: number;
  81534. readonly RGBA8UI: number;
  81535. readonly R16I: number;
  81536. readonly RG16I: number;
  81537. readonly RGB16I: number;
  81538. readonly RGBA16I: number;
  81539. readonly R16UI: number;
  81540. readonly RG16UI: number;
  81541. readonly RGB16UI: number;
  81542. readonly RGBA16UI: number;
  81543. readonly R32I: number;
  81544. readonly RG32I: number;
  81545. readonly RGB32I: number;
  81546. readonly RGBA32I: number;
  81547. readonly R32UI: number;
  81548. readonly RG32UI: number;
  81549. readonly RGB32UI: number;
  81550. readonly RGBA32UI: number;
  81551. readonly RGB10_A2UI: number;
  81552. readonly R11F_G11F_B10F: number;
  81553. readonly RGB9_E5: number;
  81554. readonly RGB10_A2: number;
  81555. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  81556. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  81557. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  81558. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  81559. readonly DEPTH_COMPONENT32F: number;
  81560. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  81561. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  81562. 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;
  81563. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  81564. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  81565. readonly TRANSFORM_FEEDBACK: number;
  81566. readonly INTERLEAVED_ATTRIBS: number;
  81567. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  81568. createTransformFeedback(): WebGLTransformFeedback;
  81569. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  81570. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  81571. beginTransformFeedback(primitiveMode: number): void;
  81572. endTransformFeedback(): void;
  81573. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  81574. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  81575. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  81576. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  81577. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  81578. }
  81579. interface ImageBitmap {
  81580. readonly width: number;
  81581. readonly height: number;
  81582. close(): void;
  81583. }
  81584. interface WebGLQuery extends WebGLObject {
  81585. }
  81586. declare var WebGLQuery: {
  81587. prototype: WebGLQuery;
  81588. new(): WebGLQuery;
  81589. };
  81590. interface WebGLSampler extends WebGLObject {
  81591. }
  81592. declare var WebGLSampler: {
  81593. prototype: WebGLSampler;
  81594. new(): WebGLSampler;
  81595. };
  81596. interface WebGLSync extends WebGLObject {
  81597. }
  81598. declare var WebGLSync: {
  81599. prototype: WebGLSync;
  81600. new(): WebGLSync;
  81601. };
  81602. interface WebGLTransformFeedback extends WebGLObject {
  81603. }
  81604. declare var WebGLTransformFeedback: {
  81605. prototype: WebGLTransformFeedback;
  81606. new(): WebGLTransformFeedback;
  81607. };
  81608. interface WebGLVertexArrayObject extends WebGLObject {
  81609. }
  81610. declare var WebGLVertexArrayObject: {
  81611. prototype: WebGLVertexArrayObject;
  81612. new(): WebGLVertexArrayObject;
  81613. };
  81614. interface Navigator {
  81615. readonly gpu: GPU | undefined;
  81616. }
  81617. interface GPUColorDict {
  81618. a: number;
  81619. b: number;
  81620. g: number;
  81621. r: number;
  81622. }
  81623. type GPUColor = [number, number, number, number] | GPUColorDict;
  81624. interface GPUOrigin2DDict {
  81625. x?: number;
  81626. y?: number;
  81627. }
  81628. type GPUOrigin2D = [number, number] | GPUOrigin2DDict;
  81629. interface GPUOrigin3DDict {
  81630. x?: number;
  81631. y?: number;
  81632. z?: number;
  81633. }
  81634. type GPUOrigin3D = [number, number, number] | GPUOrigin3DDict;
  81635. interface GPUExtent3DDict {
  81636. width: number;
  81637. height: number;
  81638. depth: number;
  81639. }
  81640. type GPUExtent3D = [number, number, number] | GPUExtent3DDict;
  81641. type GPUBindingResource =
  81642. | GPUSampler
  81643. | GPUTextureView
  81644. | GPUBufferBinding;
  81645. type GPUExtensionName =
  81646. | "texture-compression-bc"
  81647. | "timestamp-query"
  81648. | "pipeline-statistics-query"
  81649. | "depth-clamping"
  81650. | "depth24unorm-stencil8"
  81651. | "depth32float-stencil8";
  81652. type GPUAddressMode = "clamp-to-edge" | "repeat" | "mirror-repeat";
  81653. type GPUBindingType =
  81654. | "uniform-buffer"
  81655. | "storage-buffer"
  81656. | "readonly-storage-buffer"
  81657. | "sampler"
  81658. | "comparison-sampler"
  81659. | "sampled-texture"
  81660. | "readonly-storage-texture"
  81661. | "writeonly-storage-texture";
  81662. type GPUBlendFactor =
  81663. | "zero"
  81664. | "one"
  81665. | "src-color"
  81666. | "one-minus-src-color"
  81667. | "src-alpha"
  81668. | "one-minus-src-alpha"
  81669. | "dst-color"
  81670. | "one-minus-dst-color"
  81671. | "dst-alpha"
  81672. | "one-minus-dst-alpha"
  81673. | "src-alpha-saturated"
  81674. | "blend-color"
  81675. | "one-minus-blend-color";
  81676. type GPUBlendOperation =
  81677. | "add"
  81678. | "subtract"
  81679. | "reverse-subtract"
  81680. | "min"
  81681. | "max";
  81682. type GPUCompareFunction =
  81683. | "never"
  81684. | "less"
  81685. | "equal"
  81686. | "less-equal"
  81687. | "greater"
  81688. | "not-equal"
  81689. | "greater-equal"
  81690. | "always";
  81691. type GPUCullMode = "none" | "front" | "back";
  81692. type GPUFilterMode = "nearest" | "linear";
  81693. type GPUFrontFace = "ccw" | "cw";
  81694. type GPUIndexFormat = "uint16" | "uint32";
  81695. type GPUInputStepMode = "vertex" | "instance";
  81696. type GPULoadOp = "load";
  81697. type GPUPrimitiveTopology =
  81698. | "point-list"
  81699. | "line-list"
  81700. | "line-strip"
  81701. | "triangle-list"
  81702. | "triangle-strip";
  81703. type GPUStencilOperation =
  81704. | "keep"
  81705. | "zero"
  81706. | "replace"
  81707. | "invert"
  81708. | "increment-clamp"
  81709. | "decrement-clamp"
  81710. | "increment-wrap"
  81711. | "decrement-wrap";
  81712. type GPUStoreOp = "store" | "clear";
  81713. type GPUTextureDimension = "1d" | "2d" | "3d";
  81714. type GPUTextureFormat =
  81715. | "r8unorm"
  81716. | "r8snorm"
  81717. | "r8uint"
  81718. | "r8sint"
  81719. | "r16uint"
  81720. | "r16sint"
  81721. | "r16float"
  81722. | "rg8unorm"
  81723. | "rg8snorm"
  81724. | "rg8uint"
  81725. | "rg8sint"
  81726. | "r32uint"
  81727. | "r32sint"
  81728. | "r32float"
  81729. | "rg16uint"
  81730. | "rg16sint"
  81731. | "rg16float"
  81732. | "rgba8unorm"
  81733. | "rgba8unorm-srgb"
  81734. | "rgba8snorm"
  81735. | "rgba8uint"
  81736. | "rgba8sint"
  81737. | "bgra8unorm"
  81738. | "bgra8unorm-srgb"
  81739. | "rgb9e5ufloat"
  81740. | "rgb10a2unorm"
  81741. | "rg11b10ufloat"
  81742. | "rg32uint"
  81743. | "rg32sint"
  81744. | "rg32float"
  81745. | "rgba16uint"
  81746. | "rgba16sint"
  81747. | "rgba16float"
  81748. | "rgba32uint"
  81749. | "rgba32sint"
  81750. | "rgba32float"
  81751. | "stencil8"
  81752. | "depth16unorm"
  81753. | "depth24plus"
  81754. | "depth24plus-stencil8"
  81755. | "depth32float"
  81756. | "bc1-rgba-unorm"
  81757. | "bc1-rgba-unorm-srgb"
  81758. | "bc2-rgba-unorm"
  81759. | "bc2-rgba-unorm-srgb"
  81760. | "bc3-rgba-unorm"
  81761. | "bc3-rgba-unorm-srgb"
  81762. | "bc4-r-unorm"
  81763. | "bc4-r-snorm"
  81764. | "bc5-rg-unorm"
  81765. | "bc5-rg-snorm"
  81766. | "bc6h-rgb-ufloat"
  81767. | "bc6h-rgb-float"
  81768. | "bc7-rgba-unorm"
  81769. | "bc7-rgba-unorm-srgb"
  81770. | "depth24unorm-stencil8"
  81771. | "depth32float-stencil8";
  81772. type GPUTextureComponentType = "float" | "sint" | "uint" | "depth-comparison";
  81773. type GPUTextureViewDimension =
  81774. | "1d"
  81775. | "2d"
  81776. | "2d-array"
  81777. | "cube"
  81778. | "cube-array"
  81779. | "3d";
  81780. type GPUVertexFormat =
  81781. | "uchar2"
  81782. | "uchar4"
  81783. | "char2"
  81784. | "char4"
  81785. | "uchar2norm"
  81786. | "uchar4norm"
  81787. | "char2norm"
  81788. | "char4norm"
  81789. | "ushort2"
  81790. | "ushort4"
  81791. | "short2"
  81792. | "short4"
  81793. | "ushort2norm"
  81794. | "ushort4norm"
  81795. | "short2norm"
  81796. | "short4norm"
  81797. | "half2"
  81798. | "half4"
  81799. | "float"
  81800. | "float2"
  81801. | "float3"
  81802. | "float4"
  81803. | "uint"
  81804. | "uint2"
  81805. | "uint3"
  81806. | "uint4"
  81807. | "int"
  81808. | "int2"
  81809. | "int3"
  81810. | "int4";
  81811. type GPUTextureAspect = "all" | "stencil-only" | "depth-only";
  81812. type GPUBufferUsageFlags = number;
  81813. type GPUColorWriteFlags = number;
  81814. type GPUShaderStageFlags = number;
  81815. type GPUTextureUsageFlags = number;
  81816. type GPUMapModeFlags = number;
  81817. interface GPUBindGroupEntry {
  81818. binding: number;
  81819. resource: GPUBindingResource;
  81820. }
  81821. interface GPUBindGroupDescriptor extends GPUObjectDescriptorBase {
  81822. layout: GPUBindGroupLayout;
  81823. entries: Iterable<GPUBindGroupEntry>;
  81824. }
  81825. interface GPUBindGroupLayoutEntry {
  81826. binding: number;
  81827. visibility: GPUShaderStageFlags;
  81828. type: GPUBindingType;
  81829. hasDynamicOffset?: boolean;
  81830. minBufferBindingSize?: number;
  81831. viewDimension?: GPUTextureViewDimension;
  81832. textureComponentType?: GPUTextureComponentType;
  81833. storageTextureFormat?: GPUTextureFormat;
  81834. }
  81835. interface GPUBindGroupLayoutDescriptor
  81836. extends GPUObjectDescriptorBase {
  81837. entries: Iterable<GPUBindGroupLayoutEntry>;
  81838. }
  81839. interface GPUBlendDescriptor {
  81840. dstFactor?: GPUBlendFactor;
  81841. operation?: GPUBlendOperation;
  81842. srcFactor?: GPUBlendFactor;
  81843. }
  81844. interface GPUColorStateDescriptor {
  81845. format: GPUTextureFormat;
  81846. alphaBlend?: GPUBlendDescriptor;
  81847. colorBlend?: GPUBlendDescriptor;
  81848. writeMask?: GPUColorWriteFlags;
  81849. }
  81850. interface GPUBufferBinding {
  81851. buffer: GPUBuffer;
  81852. offset?: number;
  81853. size?: number;
  81854. }
  81855. interface GPUTextureDataLayout {
  81856. offset?: number;
  81857. bytesPerRow: number;
  81858. rowsPerImage?: number;
  81859. }
  81860. interface GPUBufferCopyView extends GPUTextureDataLayout {
  81861. buffer: GPUBuffer;
  81862. }
  81863. interface GPUTextureCopyView {
  81864. texture: GPUTexture;
  81865. mipLevel?: number;
  81866. origin?: GPUOrigin3D;
  81867. }
  81868. interface GPUImageBitmapCopyView {
  81869. imageBitmap: ImageBitmap;
  81870. origin?: GPUOrigin2D;
  81871. }
  81872. interface GPUBufferDescriptor extends GPUObjectDescriptorBase {
  81873. size: number;
  81874. usage: GPUBufferUsageFlags;
  81875. mappedAtCreation?: boolean;
  81876. }
  81877. interface GPUCommandEncoderDescriptor extends GPUObjectDescriptorBase {
  81878. label?: string;
  81879. measureExecutionTime?: boolean;
  81880. }
  81881. interface GPUComputePipelineDescriptor
  81882. extends GPUPipelineDescriptorBase {
  81883. computeStage: GPUProgrammableStageDescriptor;
  81884. }
  81885. interface GPUDepthStencilStateDescriptor {
  81886. format: GPUTextureFormat;
  81887. depthWriteEnabled?: boolean;
  81888. depthCompare?: GPUCompareFunction;
  81889. stencilFront?: GPUStencilStateFaceDescriptor;
  81890. stencilBack?: GPUStencilStateFaceDescriptor;
  81891. stencilReadMask?: number;
  81892. stencilWriteMask?: number;
  81893. }
  81894. interface GPUDeviceDescriptor extends GPUObjectDescriptorBase {
  81895. extensions?: Iterable<GPUExtensionName>;
  81896. limits?: GPULimits;
  81897. }
  81898. interface GPUFenceDescriptor extends GPUObjectDescriptorBase {
  81899. initialValue?: number;
  81900. label?: string;
  81901. signalQueue?: GPUQueue;
  81902. }
  81903. interface GPUVertexAttributeDescriptor {
  81904. format: GPUVertexFormat;
  81905. offset: number;
  81906. shaderLocation: number;
  81907. }
  81908. interface GPUVertexBufferLayoutDescriptor {
  81909. arrayStride: number;
  81910. stepMode?: GPUInputStepMode;
  81911. attributes: Iterable<GPUVertexAttributeDescriptor>;
  81912. }
  81913. interface GPUVertexStateDescriptor {
  81914. indexFormat?: GPUIndexFormat;
  81915. vertexBuffers?: Iterable<GPUVertexBufferLayoutDescriptor>;
  81916. }
  81917. interface GPULimits {
  81918. maxBindGroups?: number;
  81919. maxDynamicUniformBuffersPerPipelineLayout?: number;
  81920. maxDynamicStorageBuffersPerPipelineLayout?: number;
  81921. maxSampledTexturesPerShaderStage?: number;
  81922. maxSamplersPerShaderStage?: number;
  81923. maxStorageBuffersPerShaderStage?: number;
  81924. maxStorageTexturesPerShaderStage?: number;
  81925. maxUniformBuffersPerShaderStage?: number;
  81926. maxUniformBufferBindingSize?: number;
  81927. }
  81928. interface GPUPipelineDescriptorBase {
  81929. label?: string;
  81930. layout?: GPUPipelineLayout;
  81931. }
  81932. interface GPUPipelineLayoutDescriptor extends GPUObjectDescriptorBase {
  81933. bindGroupLayouts: Iterable<GPUBindGroupLayout>;
  81934. }
  81935. interface GPUProgrammableStageDescriptor {
  81936. module: GPUShaderModule;
  81937. entryPoint: string;
  81938. }
  81939. interface GPURasterizationStateDescriptor {
  81940. frontFace?: GPUFrontFace;
  81941. cullMode?: GPUCullMode;
  81942. clampDepth?: boolean;
  81943. depthBias?: number;
  81944. depthBiasSlopeScale?: number;
  81945. depthBiasClamp?: number;
  81946. }
  81947. interface GPURenderPassColorAttachmentDescriptor {
  81948. attachment: GPUTextureView;
  81949. resolveTarget?: GPUTextureView;
  81950. loadValue: GPULoadOp | GPUColor;
  81951. storeOp?: GPUStoreOp;
  81952. }
  81953. interface GPURenderPassDepthStencilAttachmentDescriptor {
  81954. attachment: GPUTextureView;
  81955. depthLoadValue: GPULoadOp | number;
  81956. depthStoreOp: GPUStoreOp;
  81957. depthReadOnly?: boolean;
  81958. stencilLoadValue: GPULoadOp | number;
  81959. stencilStoreOp: GPUStoreOp;
  81960. stencilReadOnly?: boolean;
  81961. }
  81962. interface GPURenderPassDescriptor extends GPUObjectDescriptorBase {
  81963. colorAttachments: Iterable<GPURenderPassColorAttachmentDescriptor>;
  81964. depthStencilAttachment?: GPURenderPassDepthStencilAttachmentDescriptor;
  81965. }
  81966. interface GPURenderPipelineDescriptor
  81967. extends GPUPipelineDescriptorBase {
  81968. vertexStage: GPUProgrammableStageDescriptor;
  81969. fragmentStage?: GPUProgrammableStageDescriptor;
  81970. primitiveTopology: GPUPrimitiveTopology;
  81971. rasterizationState?: GPURasterizationStateDescriptor;
  81972. colorStates: Iterable<GPUColorStateDescriptor>;
  81973. depthStencilState?: GPUDepthStencilStateDescriptor;
  81974. vertexState?: GPUVertexStateDescriptor;
  81975. sampleCount?: number;
  81976. sampleMask?: number;
  81977. alphaToCoverageEnabled?: boolean;
  81978. }
  81979. interface GPUSamplerDescriptor extends GPUObjectDescriptorBase {
  81980. addressModeU?: GPUAddressMode;
  81981. addressModeV?: GPUAddressMode;
  81982. addressModeW?: GPUAddressMode;
  81983. magFilter?: GPUFilterMode;
  81984. minFilter?: GPUFilterMode;
  81985. mipmapFilter?: GPUFilterMode;
  81986. lodMinClamp?: number;
  81987. lodMaxClamp?: number;
  81988. compare?: GPUCompareFunction;
  81989. maxAnisotropy?: number;
  81990. }
  81991. interface GPUShaderModuleDescriptor extends GPUObjectDescriptorBase {
  81992. code: Uint32Array | string;
  81993. label?: string;
  81994. sourceMap?: object;
  81995. }
  81996. interface GPUStencilStateFaceDescriptor {
  81997. compare?: GPUCompareFunction;
  81998. depthFailOp?: GPUStencilOperation;
  81999. passOp?: GPUStencilOperation;
  82000. failOp?: GPUStencilOperation;
  82001. }
  82002. interface GPUSwapChainDescriptor extends GPUObjectDescriptorBase {
  82003. device: GPUDevice;
  82004. format: GPUTextureFormat;
  82005. usage?: GPUTextureUsageFlags;
  82006. }
  82007. interface GPUTextureDescriptor extends GPUObjectDescriptorBase {
  82008. size: GPUExtent3D;
  82009. mipLevelCount?: number;
  82010. sampleCount?: number;
  82011. dimension?: GPUTextureDimension;
  82012. format: GPUTextureFormat;
  82013. usage: GPUTextureUsageFlags;
  82014. }
  82015. interface GPUTextureViewDescriptor extends GPUObjectDescriptorBase {
  82016. format?: GPUTextureFormat;
  82017. dimension?: GPUTextureViewDimension;
  82018. aspect?: GPUTextureAspect;
  82019. baseArrayLayer?: number;
  82020. baseMipLevel?: number;
  82021. arrayLayerCount?: number;
  82022. mipLevelCount?: number;
  82023. }
  82024. declare class GPUAdapter {
  82025. // https://michalzalecki.com/nominal-typing-in-typescript/#approach-1-class-with-a-private-property
  82026. private __brand: void;
  82027. readonly name: string;
  82028. readonly extensions: GPUExtensionName[];
  82029. readonly limits: Required<GPULimits>;
  82030. requestDevice(descriptor?: GPUDeviceDescriptor): Promise<GPUDevice | null>;
  82031. }
  82032. declare class GPUBindGroup implements GPUObjectBase {
  82033. private __brand: void;
  82034. label: string | undefined;
  82035. }
  82036. declare class GPUBindGroupLayout implements GPUObjectBase {
  82037. private __brand: void;
  82038. label: string | undefined;
  82039. }
  82040. declare class GPUBuffer implements GPUObjectBase {
  82041. private __brand: void;
  82042. label: string | undefined;
  82043. destroy(): void;
  82044. unmap(): void;
  82045. mapAsync(mode: GPUMapModeFlags, offset?: number, size?: number): Promise<void>;
  82046. getMappedRange(offset?: number, size?: number): ArrayBuffer;
  82047. }
  82048. declare class GPUCommandBuffer implements GPUObjectBase {
  82049. private __brand: void;
  82050. label: string | undefined;
  82051. readonly executionTime: Promise<number>;
  82052. }
  82053. interface GPUCommandBufferDescriptor extends GPUObjectDescriptorBase { }
  82054. declare class GPUCommandEncoder implements GPUObjectBase {
  82055. private __brand: void;
  82056. label: string | undefined;
  82057. beginComputePass(
  82058. descriptor?: GPUComputePassDescriptor
  82059. ): GPUComputePassEncoder;
  82060. beginRenderPass(descriptor: GPURenderPassDescriptor): GPURenderPassEncoder;
  82061. copyBufferToBuffer(
  82062. source: GPUBuffer,
  82063. sourceOffset: number,
  82064. destination: GPUBuffer,
  82065. destinationOffset: number,
  82066. size: number
  82067. ): void;
  82068. copyBufferToTexture(
  82069. source: GPUBufferCopyView,
  82070. destination: GPUTextureCopyView,
  82071. copySize: GPUExtent3D
  82072. ): void;
  82073. copyTextureToBuffer(
  82074. source: GPUTextureCopyView,
  82075. destination: GPUBufferCopyView,
  82076. copySize: GPUExtent3D
  82077. ): void;
  82078. copyTextureToTexture(
  82079. source: GPUTextureCopyView,
  82080. destination: GPUTextureCopyView,
  82081. copySize: GPUExtent3D
  82082. ): void;
  82083. finish(descriptor?: GPUCommandBufferDescriptor): GPUCommandBuffer;
  82084. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  82085. popDebugGroup(): void;
  82086. pushDebugGroup(groupLabel: string): void;
  82087. insertDebugMarker(markerLabel: string): void;
  82088. }
  82089. interface GPUComputePassDescriptor extends GPUObjectDescriptorBase { }
  82090. declare class GPUComputePassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder {
  82091. private __brand: void;
  82092. label: string | undefined;
  82093. setBindGroup(
  82094. index: number,
  82095. bindGroup: GPUBindGroup,
  82096. dynamicOffsets?: Iterable<number>
  82097. ): void;
  82098. popDebugGroup(): void;
  82099. pushDebugGroup(groupLabel: string): void;
  82100. insertDebugMarker(markerLabel: string): void;
  82101. setPipeline(pipeline: GPUComputePipeline): void;
  82102. dispatch(x: number, y?: number, z?: number): void;
  82103. dispatchIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  82104. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  82105. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  82106. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  82107. endPass(): void;
  82108. }
  82109. declare class GPUComputePipeline implements GPUPipelineBase {
  82110. private __brand: void;
  82111. label: string | undefined;
  82112. getBindGroupLayout(index: number): GPUBindGroupLayout;
  82113. }
  82114. interface GPUObjectBase {
  82115. label: string | undefined;
  82116. }
  82117. interface GPUObjectDescriptorBase {
  82118. label?: string;
  82119. }
  82120. // SwapChain / CanvasContext
  82121. declare class GPUCanvasContext {
  82122. private __brand: void;
  82123. configureSwapChain(descriptor: GPUSwapChainDescriptor): GPUSwapChain;
  82124. getSwapChainPreferredFormat(device: GPUDevice): Promise<GPUTextureFormat>;
  82125. }
  82126. declare class GPUDevice extends EventTarget implements GPUObjectBase {
  82127. private __brand: void;
  82128. label: string | undefined;
  82129. readonly adapter: GPUAdapter;
  82130. readonly extensions: GPUExtensionName[];
  82131. readonly limits: Required<GPULimits>;
  82132. createBindGroup(descriptor: GPUBindGroupDescriptor): GPUBindGroup;
  82133. createBindGroupLayout(
  82134. descriptor: GPUBindGroupLayoutDescriptor
  82135. ): GPUBindGroupLayout;
  82136. createBuffer(descriptor: GPUBufferDescriptor): GPUBuffer;
  82137. createPipelineLayout(
  82138. descriptor: GPUPipelineLayoutDescriptor
  82139. ): GPUPipelineLayout;
  82140. createSampler(descriptor?: GPUSamplerDescriptor): GPUSampler;
  82141. createShaderModule(descriptor: GPUShaderModuleDescriptor): GPUShaderModule;
  82142. createTexture(descriptor: GPUTextureDescriptor): GPUTexture;
  82143. createComputePipeline(
  82144. descriptor: GPUComputePipelineDescriptor
  82145. ): GPUComputePipeline;
  82146. createRenderPipeline(
  82147. descriptor: GPURenderPipelineDescriptor
  82148. ): GPURenderPipeline;
  82149. createReadyComputePipeline(
  82150. descriptor: GPUComputePipelineDescriptor
  82151. ): Promise<GPUComputePipeline>;
  82152. createReadyRenderPipeline(
  82153. descriptor: GPURenderPipelineDescriptor
  82154. ): Promise<GPURenderPipeline>;
  82155. createCommandEncoder(
  82156. descriptor?: GPUCommandEncoderDescriptor
  82157. ): GPUCommandEncoder;
  82158. createRenderBundleEncoder(
  82159. descriptor: GPURenderBundleEncoderDescriptor
  82160. ): GPURenderBundleEncoder;
  82161. createQuerySet(descriptor: GPUQuerySetDescriptor): GPUQuerySet;
  82162. defaultQueue: GPUQueue;
  82163. pushErrorScope(filter: GPUErrorFilter): void;
  82164. popErrorScope(): Promise<GPUError | null>;
  82165. onuncapturederror: Event | undefined;
  82166. readonly lost: Promise<GPUDeviceLostInfo>;
  82167. }
  82168. declare class GPUFence implements GPUObjectBase {
  82169. private __brand: void;
  82170. label: string | undefined;
  82171. getCompletedValue(): number;
  82172. onCompletion(completionValue: number): Promise<void>;
  82173. }
  82174. interface GPUPipelineBase extends GPUObjectBase {
  82175. getBindGroupLayout(index: number): GPUBindGroupLayout;
  82176. }
  82177. declare class GPUPipelineLayout implements GPUObjectBase {
  82178. private __brand: void;
  82179. label: string | undefined;
  82180. }
  82181. interface GPUProgrammablePassEncoder {
  82182. setBindGroup(
  82183. index: number,
  82184. bindGroup: GPUBindGroup,
  82185. dynamicOffsets?: Iterable<number>
  82186. ): void;
  82187. popDebugGroup(): void;
  82188. pushDebugGroup(groupLabel: string): void;
  82189. insertDebugMarker(markerLabel: string): void;
  82190. }
  82191. declare class GPUQueue implements GPUObjectBase {
  82192. private __brand: void;
  82193. label: string | undefined;
  82194. signal(fence: GPUFence, signalValue: number): void;
  82195. submit(commandBuffers: Iterable<GPUCommandBuffer>): void;
  82196. createFence(descriptor?: GPUFenceDescriptor): GPUFence;
  82197. writeBuffer(buffer: GPUBuffer,
  82198. bufferOffset: number,
  82199. data: BufferSource | ArrayBuffer,
  82200. dataOffset?: number,
  82201. size?: number): void;
  82202. writeTexture(destination: GPUTextureCopyView,
  82203. data: BufferSource | ArrayBuffer,
  82204. dataLayout: GPUTextureDataLayout,
  82205. size: GPUExtent3D): void;
  82206. copyImageBitmapToTexture(
  82207. source: GPUImageBitmapCopyView,
  82208. destination: GPUTextureCopyView,
  82209. copySize: GPUExtent3D
  82210. ): void;
  82211. }
  82212. type GPUQueryType =
  82213. | "occlusion"
  82214. | "timestamp"
  82215. | "pipeline-statistics";
  82216. type GPUPipelineStatisticName =
  82217. | "vertex-shader-invocations"
  82218. | "clipper-invocations"
  82219. | "clipper-primitives-out"
  82220. | "fragment-shader-invocations"
  82221. | "compute-shader-invocations";
  82222. interface GPUQuerySetDescriptor extends GPUObjectDescriptorBase {
  82223. type: GPUQueryType;
  82224. count: number;
  82225. pipelineStatistics?: Iterable<GPUPipelineStatisticName>;
  82226. }
  82227. declare class GPUQuerySet implements GPUObjectBase {
  82228. private __brand: void;
  82229. label: string | undefined;
  82230. destroy(): void;
  82231. }
  82232. interface GPURenderEncoderBase {
  82233. setPipeline(pipeline: GPURenderPipeline): void;
  82234. setIndexBuffer(buffer: GPUBuffer, offset?: number, size?: number): void;
  82235. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  82236. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number, size?: number): void;
  82237. draw(
  82238. vertexCount: number,
  82239. instanceCount?: number,
  82240. firstVertex?: number,
  82241. firstInstance?: number
  82242. ): void;
  82243. drawIndexed(
  82244. indexCount: number,
  82245. instanceCount?: number,
  82246. firstIndex?: number,
  82247. baseVertex?: number,
  82248. firstInstance?: number
  82249. ): void;
  82250. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  82251. drawIndexedIndirect(
  82252. indirectBuffer: GPUBuffer,
  82253. indirectOffset: number
  82254. ): void;
  82255. }
  82256. declare class GPURenderPassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder, GPURenderEncoderBase {
  82257. private __brand: void;
  82258. label: string | undefined;
  82259. setBindGroup(
  82260. index: number,
  82261. bindGroup: GPUBindGroup,
  82262. dynamicOffsets?: Iterable<number>
  82263. ): void;
  82264. popDebugGroup(): void;
  82265. pushDebugGroup(groupLabel: string): void;
  82266. insertDebugMarker(markerLabel: string): void;
  82267. setPipeline(pipeline: GPURenderPipeline): void;
  82268. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  82269. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  82270. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  82271. draw(
  82272. vertexCount: number,
  82273. instanceCount?: number,
  82274. firstVertex?: number,
  82275. firstInstance?: number
  82276. ): void;
  82277. drawIndexed(
  82278. indexCount: number,
  82279. instanceCount?: number,
  82280. firstIndex?: number,
  82281. baseVertex?: number,
  82282. firstInstance?: number
  82283. ): void;
  82284. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  82285. drawIndexedIndirect(
  82286. indirectBuffer: GPUBuffer,
  82287. indirectOffset: number
  82288. ): void;
  82289. setViewport(
  82290. x: number,
  82291. y: number,
  82292. width: number,
  82293. height: number,
  82294. minDepth: number,
  82295. maxDepth: number
  82296. ): void;
  82297. setScissorRect(x: number, y: number, width: number, height: number): void;
  82298. setBlendColor(color: GPUColor): void;
  82299. setStencilReference(reference: number): void;
  82300. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  82301. beginOcclusionQuery(queryIndex: number): void;
  82302. endOcclusionQuery(): void;
  82303. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  82304. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  82305. executeBundles(bundles: Iterable<GPURenderBundle>): void;
  82306. endPass(): void;
  82307. }
  82308. interface GPURenderBundleDescriptor extends GPUObjectDescriptorBase { }
  82309. declare class GPURenderBundle implements GPUObjectBase {
  82310. private __brand: void;
  82311. label: string | undefined;
  82312. }
  82313. declare class GPURenderBundleEncoder implements GPURenderEncoderBase {
  82314. private __brand: void;
  82315. label: string | undefined;
  82316. setBindGroup(
  82317. index: number,
  82318. bindGroup: GPUBindGroup,
  82319. dynamicOffsets?: Iterable<number>
  82320. ): void;
  82321. popDebugGroup(): void;
  82322. pushDebugGroup(groupLabel: string): void;
  82323. insertDebugMarker(markerLabel: string): void;
  82324. setPipeline(pipeline: GPURenderPipeline): void;
  82325. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  82326. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  82327. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  82328. draw(
  82329. vertexCount: number,
  82330. instanceCount?: number,
  82331. firstVertex?: number,
  82332. firstInstance?: number
  82333. ): void;
  82334. drawIndexed(
  82335. indexCount: number,
  82336. instanceCount?: number,
  82337. firstIndex?: number,
  82338. baseVertex?: number,
  82339. firstInstance?: number
  82340. ): void;
  82341. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  82342. drawIndexedIndirect(
  82343. indirectBuffer: GPUBuffer,
  82344. indirectOffset: number
  82345. ): void;
  82346. finish(descriptor?: GPURenderBundleDescriptor): GPURenderBundle;
  82347. }
  82348. interface GPURenderBundleEncoderDescriptor
  82349. extends GPUObjectDescriptorBase {
  82350. colorFormats: Iterable<GPUTextureFormat>;
  82351. depthStencilFormat?: GPUTextureFormat;
  82352. sampleCount?: number;
  82353. }
  82354. declare class GPURenderPipeline implements GPUPipelineBase {
  82355. private __brand: void;
  82356. label: string | undefined;
  82357. getBindGroupLayout(index: number): GPUBindGroupLayout;
  82358. }
  82359. declare class GPUSampler implements GPUObjectBase {
  82360. private __brand: void;
  82361. label: string | undefined;
  82362. }
  82363. type GPUCompilationMessageType =
  82364. | "error"
  82365. | "warning"
  82366. | "info";
  82367. interface GPUCompilationMessage {
  82368. readonly message: string;
  82369. readonly type: GPUCompilationMessageType;
  82370. readonly lineNum: number;
  82371. readonly linePos: number;
  82372. }
  82373. interface GPUCompilationInfo {
  82374. readonly messages: readonly GPUCompilationMessage[];
  82375. }
  82376. declare class GPUShaderModule implements GPUObjectBase {
  82377. private __brand: void;
  82378. label: string | undefined;
  82379. compilationInfo(): Promise<GPUCompilationInfo>;
  82380. }
  82381. declare class GPUSwapChain implements GPUObjectBase {
  82382. private __brand: void;
  82383. label: string | undefined;
  82384. getCurrentTexture(): GPUTexture;
  82385. }
  82386. declare class GPUTexture implements GPUObjectBase {
  82387. private __brand: void;
  82388. label: string | undefined;
  82389. createView(descriptor?: GPUTextureViewDescriptor): GPUTextureView;
  82390. destroy(): void;
  82391. }
  82392. declare class GPUTextureView implements GPUObjectBase {
  82393. private __brand: void;
  82394. label: string | undefined;
  82395. }
  82396. type GPUPowerPreference = "low-power" | "high-performance";
  82397. interface GPURequestAdapterOptions {
  82398. powerPreference?: GPUPowerPreference;
  82399. }
  82400. declare class GPU {
  82401. private __brand: void;
  82402. requestAdapter(options?: GPURequestAdapterOptions): Promise<GPUAdapter | null>;
  82403. }
  82404. // ****************************************************************************
  82405. // ERROR SCOPES
  82406. // ****************************************************************************
  82407. type GPUErrorFilter = "out-of-memory" | "validation";
  82408. declare class GPUOutOfMemoryError {
  82409. private __brand: void;
  82410. constructor();
  82411. }
  82412. declare class GPUValidationError {
  82413. private __brand: void;
  82414. constructor(message: string);
  82415. readonly message: string;
  82416. }
  82417. type GPUError = GPUOutOfMemoryError | GPUValidationError;
  82418. // ****************************************************************************
  82419. // TELEMETRY
  82420. // ****************************************************************************
  82421. declare class GPUUncapturedErrorEvent extends Event {
  82422. private __brand: void;
  82423. constructor(
  82424. type: string,
  82425. gpuUncapturedErrorEventInitDict: GPUUncapturedErrorEventInit
  82426. );
  82427. readonly error: GPUError;
  82428. }
  82429. interface GPUUncapturedErrorEventInit extends EventInit {
  82430. error: GPUError;
  82431. }
  82432. declare class GPUDeviceLostInfo {
  82433. private __brand: void;
  82434. readonly message: string;
  82435. }
  82436. // Type definitions for WebVR API
  82437. // Project: https://w3c.github.io/webvr/
  82438. // Definitions by: six a <https://github.com/lostfictions>
  82439. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  82440. interface VRDisplay extends EventTarget {
  82441. /**
  82442. * Dictionary of capabilities describing the VRDisplay.
  82443. */
  82444. readonly capabilities: VRDisplayCapabilities;
  82445. /**
  82446. * z-depth defining the far plane of the eye view frustum
  82447. * enables mapping of values in the render target depth
  82448. * attachment to scene coordinates. Initially set to 10000.0.
  82449. */
  82450. depthFar: number;
  82451. /**
  82452. * z-depth defining the near plane of the eye view frustum
  82453. * enables mapping of values in the render target depth
  82454. * attachment to scene coordinates. Initially set to 0.01.
  82455. */
  82456. depthNear: number;
  82457. /**
  82458. * An identifier for this distinct VRDisplay. Used as an
  82459. * association point in the Gamepad API.
  82460. */
  82461. readonly displayId: number;
  82462. /**
  82463. * A display name, a user-readable name identifying it.
  82464. */
  82465. readonly displayName: string;
  82466. readonly isConnected: boolean;
  82467. readonly isPresenting: boolean;
  82468. /**
  82469. * If this VRDisplay supports room-scale experiences, the optional
  82470. * stage attribute contains details on the room-scale parameters.
  82471. */
  82472. readonly stageParameters: VRStageParameters | null;
  82473. /**
  82474. * Passing the value returned by `requestAnimationFrame` to
  82475. * `cancelAnimationFrame` will unregister the callback.
  82476. * @param handle Define the hanle of the request to cancel
  82477. */
  82478. cancelAnimationFrame(handle: number): void;
  82479. /**
  82480. * Stops presenting to the VRDisplay.
  82481. * @returns a promise to know when it stopped
  82482. */
  82483. exitPresent(): Promise<void>;
  82484. /**
  82485. * Return the current VREyeParameters for the given eye.
  82486. * @param whichEye Define the eye we want the parameter for
  82487. * @returns the eye parameters
  82488. */
  82489. getEyeParameters(whichEye: string): VREyeParameters;
  82490. /**
  82491. * Populates the passed VRFrameData with the information required to render
  82492. * the current frame.
  82493. * @param frameData Define the data structure to populate
  82494. * @returns true if ok otherwise false
  82495. */
  82496. getFrameData(frameData: VRFrameData): boolean;
  82497. /**
  82498. * Get the layers currently being presented.
  82499. * @returns the list of VR layers
  82500. */
  82501. getLayers(): VRLayer[];
  82502. /**
  82503. * Return a VRPose containing the future predicted pose of the VRDisplay
  82504. * when the current frame will be presented. The value returned will not
  82505. * change until JavaScript has returned control to the browser.
  82506. *
  82507. * The VRPose will contain the position, orientation, velocity,
  82508. * and acceleration of each of these properties.
  82509. * @returns the pose object
  82510. */
  82511. getPose(): VRPose;
  82512. /**
  82513. * Return the current instantaneous pose of the VRDisplay, with no
  82514. * prediction applied.
  82515. * @returns the current instantaneous pose
  82516. */
  82517. getImmediatePose(): VRPose;
  82518. /**
  82519. * The callback passed to `requestAnimationFrame` will be called
  82520. * any time a new frame should be rendered. When the VRDisplay is
  82521. * presenting the callback will be called at the native refresh
  82522. * rate of the HMD. When not presenting this function acts
  82523. * identically to how window.requestAnimationFrame acts. Content should
  82524. * make no assumptions of frame rate or vsync behavior as the HMD runs
  82525. * asynchronously from other displays and at differing refresh rates.
  82526. * @param callback Define the action to run next frame
  82527. * @returns the request handle it
  82528. */
  82529. requestAnimationFrame(callback: FrameRequestCallback): number;
  82530. /**
  82531. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  82532. * Repeat calls while already presenting will update the VRLayers being displayed.
  82533. * @param layers Define the list of layer to present
  82534. * @returns a promise to know when the request has been fulfilled
  82535. */
  82536. requestPresent(layers: VRLayer[]): Promise<void>;
  82537. /**
  82538. * Reset the pose for this display, treating its current position and
  82539. * orientation as the "origin/zero" values. VRPose.position,
  82540. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  82541. * updated when calling resetPose(). This should be called in only
  82542. * sitting-space experiences.
  82543. */
  82544. resetPose(): void;
  82545. /**
  82546. * The VRLayer provided to the VRDisplay will be captured and presented
  82547. * in the HMD. Calling this function has the same effect on the source
  82548. * canvas as any other operation that uses its source image, and canvases
  82549. * created without preserveDrawingBuffer set to true will be cleared.
  82550. * @param pose Define the pose to submit
  82551. */
  82552. submitFrame(pose?: VRPose): void;
  82553. }
  82554. declare var VRDisplay: {
  82555. prototype: VRDisplay;
  82556. new(): VRDisplay;
  82557. };
  82558. interface VRLayer {
  82559. leftBounds?: number[] | Float32Array | null;
  82560. rightBounds?: number[] | Float32Array | null;
  82561. source?: HTMLCanvasElement | null;
  82562. }
  82563. interface VRDisplayCapabilities {
  82564. readonly canPresent: boolean;
  82565. readonly hasExternalDisplay: boolean;
  82566. readonly hasOrientation: boolean;
  82567. readonly hasPosition: boolean;
  82568. readonly maxLayers: number;
  82569. }
  82570. interface VREyeParameters {
  82571. /** @deprecated */
  82572. readonly fieldOfView: VRFieldOfView;
  82573. readonly offset: Float32Array;
  82574. readonly renderHeight: number;
  82575. readonly renderWidth: number;
  82576. }
  82577. interface VRFieldOfView {
  82578. readonly downDegrees: number;
  82579. readonly leftDegrees: number;
  82580. readonly rightDegrees: number;
  82581. readonly upDegrees: number;
  82582. }
  82583. interface VRFrameData {
  82584. readonly leftProjectionMatrix: Float32Array;
  82585. readonly leftViewMatrix: Float32Array;
  82586. readonly pose: VRPose;
  82587. readonly rightProjectionMatrix: Float32Array;
  82588. readonly rightViewMatrix: Float32Array;
  82589. readonly timestamp: number;
  82590. }
  82591. interface VRPose {
  82592. readonly angularAcceleration: Float32Array | null;
  82593. readonly angularVelocity: Float32Array | null;
  82594. readonly linearAcceleration: Float32Array | null;
  82595. readonly linearVelocity: Float32Array | null;
  82596. readonly orientation: Float32Array | null;
  82597. readonly position: Float32Array | null;
  82598. readonly timestamp: number;
  82599. }
  82600. interface VRStageParameters {
  82601. sittingToStandingTransform?: Float32Array;
  82602. sizeX?: number;
  82603. sizeY?: number;
  82604. }
  82605. interface Navigator {
  82606. getVRDisplays(): Promise<VRDisplay[]>;
  82607. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  82608. }
  82609. interface Window {
  82610. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  82611. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  82612. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  82613. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  82614. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  82615. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  82616. }
  82617. interface Gamepad {
  82618. readonly displayId: number;
  82619. }
  82620. /**
  82621. * Available session modes
  82622. */
  82623. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  82624. /**
  82625. * Reference space types
  82626. */
  82627. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  82628. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  82629. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  82630. /**
  82631. * Handedness types
  82632. */
  82633. type XRHandedness = "none" | "left" | "right";
  82634. /**
  82635. * InputSource target ray modes
  82636. */
  82637. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  82638. /**
  82639. * Eye types
  82640. */
  82641. type XREye = "none" | "left" | "right";
  82642. /**
  82643. * Type of XR events available
  82644. */
  82645. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  82646. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  82647. type XRPlaneSet = Set<XRPlane>;
  82648. type XRAnchorSet = Set<XRAnchor>;
  82649. type XREventHandler = (callback: any) => void;
  82650. interface XRLayer extends EventTarget {}
  82651. interface XRSessionInit {
  82652. optionalFeatures?: string[];
  82653. requiredFeatures?: string[];
  82654. trackedImages?: XRTrackedImageInit[];
  82655. }
  82656. interface XRSessionEvent extends Event {
  82657. readonly session: XRSession;
  82658. }
  82659. interface XRSystem {
  82660. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  82661. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  82662. }
  82663. interface XRViewport {
  82664. readonly x: number;
  82665. readonly y: number;
  82666. readonly width: number;
  82667. readonly height: number;
  82668. }
  82669. interface XRWebGLLayerInit {
  82670. antialias?: boolean;
  82671. depth?: boolean;
  82672. stencil?: boolean;
  82673. alpha?: boolean;
  82674. multiview?: boolean;
  82675. framebufferScaleFactor?: number;
  82676. }
  82677. declare class XRWebGLLayer {
  82678. static getNativeFramebufferScaleFactor(session: XRSession): number;
  82679. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  82680. readonly antialias: boolean;
  82681. readonly framebuffer: WebGLFramebuffer;
  82682. readonly framebufferWidth: number;
  82683. readonly framebufferHeight: number;
  82684. readonly ignoreDepthValues: boolean;
  82685. getViewport: (view: XRView) => XRViewport;
  82686. }
  82687. // tslint:disable-next-line no-empty-interface
  82688. interface XRSpace extends EventTarget {}
  82689. interface XRRenderState {
  82690. readonly baseLayer?: XRWebGLLayer;
  82691. readonly depthFar: number;
  82692. readonly depthNear: number;
  82693. readonly inlineVerticalFieldOfView?: number;
  82694. }
  82695. interface XRRenderStateInit extends XRRenderState {
  82696. baseLayer: XRWebGLLayer;
  82697. depthFar: number;
  82698. depthNear: number;
  82699. inlineVerticalFieldOfView?: number;
  82700. layers?: XRLayer[];
  82701. }
  82702. interface XRReferenceSpace extends XRSpace {
  82703. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  82704. onreset: XREventHandler;
  82705. }
  82706. interface XRBoundedReferenceSpace extends XRSpace {
  82707. readonly boundsGeometry: DOMPointReadOnly[];
  82708. }
  82709. interface XRInputSource {
  82710. readonly handedness: XRHandedness;
  82711. readonly targetRayMode: XRTargetRayMode;
  82712. readonly targetRaySpace: XRSpace;
  82713. readonly gripSpace?: XRSpace;
  82714. readonly gamepad?: Gamepad;
  82715. readonly profiles: Array<string>;
  82716. readonly hand?: XRHand;
  82717. }
  82718. interface XRPose {
  82719. readonly transform: XRRigidTransform;
  82720. readonly emulatedPosition: boolean;
  82721. }
  82722. interface XRWorldInformation {
  82723. detectedPlanes?: XRPlaneSet;
  82724. }
  82725. interface XRFrame {
  82726. readonly session: XRSession;
  82727. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  82728. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  82729. // AR
  82730. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  82731. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  82732. // Anchors
  82733. trackedAnchors?: XRAnchorSet;
  82734. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  82735. // World geometries
  82736. worldInformation?: XRWorldInformation;
  82737. // Hand tracking
  82738. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  82739. // Image tracking
  82740. getImageTrackingResults?(): Array<XRImageTrackingResult>;
  82741. }
  82742. interface XRInputSourceEvent extends Event {
  82743. readonly frame: XRFrame;
  82744. readonly inputSource: XRInputSource;
  82745. }
  82746. type XRInputSourceArray = XRInputSource[];
  82747. interface XRSession {
  82748. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  82749. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  82750. /**
  82751. * Returns a list of this session's XRInputSources, each representing an input device
  82752. * used to control the camera and/or scene.
  82753. */
  82754. readonly inputSources: Array<XRInputSource>;
  82755. /**
  82756. * object which contains options affecting how the imagery is rendered.
  82757. * This includes things such as the near and far clipping planes
  82758. */
  82759. readonly renderState: XRRenderState;
  82760. readonly visibilityState: XRVisibilityState;
  82761. /**
  82762. * Removes a callback from the animation frame painting callback from
  82763. * XRSession's set of animation frame rendering callbacks, given the
  82764. * identifying handle returned by a previous call to requestAnimationFrame().
  82765. */
  82766. cancelAnimationFrame: (handle: number) => void;
  82767. /**
  82768. * Ends the WebXR session. Returns a promise which resolves when the
  82769. * session has been shut down.
  82770. */
  82771. end(): Promise<void>;
  82772. /**
  82773. * Schedules the specified method to be called the next time the user agent
  82774. * is working on rendering an animation frame for the WebXR device. Returns an
  82775. * integer value which can be used to identify the request for the purposes of
  82776. * canceling the callback using cancelAnimationFrame(). This method is comparable
  82777. * to the Window.requestAnimationFrame() method.
  82778. */
  82779. requestAnimationFrame: XRFrameRequestCallback;
  82780. /**
  82781. * Requests that a new XRReferenceSpace of the specified type be created.
  82782. * Returns a promise which resolves with the XRReferenceSpace or
  82783. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  82784. * the requested space type isn't supported by the device.
  82785. */
  82786. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  82787. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  82788. onend: XREventHandler;
  82789. oninputsourceschange: XREventHandler;
  82790. onselect: XREventHandler;
  82791. onselectstart: XREventHandler;
  82792. onselectend: XREventHandler;
  82793. onsqueeze: XREventHandler;
  82794. onsqueezestart: XREventHandler;
  82795. onsqueezeend: XREventHandler;
  82796. onvisibilitychange: XREventHandler;
  82797. // hit test
  82798. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  82799. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  82800. // legacy AR hit test
  82801. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  82802. // legacy plane detection
  82803. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  82804. // image tracking
  82805. getTrackedImageScores?(): XRImageTrackingScore[];
  82806. }
  82807. interface XRViewerPose extends XRPose {
  82808. readonly views: Array<XRView>;
  82809. }
  82810. declare class XRRigidTransform {
  82811. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  82812. position: DOMPointReadOnly;
  82813. orientation: DOMPointReadOnly;
  82814. matrix: Float32Array;
  82815. inverse: XRRigidTransform;
  82816. }
  82817. interface XRView {
  82818. readonly eye: XREye;
  82819. readonly projectionMatrix: Float32Array;
  82820. readonly transform: XRRigidTransform;
  82821. readonly recommendedViewportScale?: number;
  82822. requestViewportScale(scale: number): void;
  82823. }
  82824. interface XRInputSourceChangeEvent extends Event {
  82825. session: XRSession;
  82826. removed: Array<XRInputSource>;
  82827. added: Array<XRInputSource>;
  82828. }
  82829. // Experimental/Draft features
  82830. declare class XRRay {
  82831. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  82832. origin: DOMPointReadOnly;
  82833. direction: DOMPointReadOnly;
  82834. matrix: Float32Array;
  82835. }
  82836. declare enum XRHitTestTrackableType {
  82837. "point",
  82838. "plane",
  82839. "mesh",
  82840. }
  82841. interface XRHitResult {
  82842. hitMatrix: Float32Array;
  82843. }
  82844. interface XRTransientInputHitTestResult {
  82845. readonly inputSource: XRInputSource;
  82846. readonly results: Array<XRHitTestResult>;
  82847. }
  82848. interface XRHitTestResult {
  82849. getPose(baseSpace: XRSpace): XRPose | undefined;
  82850. // When anchor system is enabled
  82851. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  82852. }
  82853. interface XRHitTestSource {
  82854. cancel(): void;
  82855. }
  82856. interface XRTransientInputHitTestSource {
  82857. cancel(): void;
  82858. }
  82859. interface XRHitTestOptionsInit {
  82860. space: XRSpace;
  82861. entityTypes?: Array<XRHitTestTrackableType>;
  82862. offsetRay?: XRRay;
  82863. }
  82864. interface XRTransientInputHitTestOptionsInit {
  82865. profile: string;
  82866. entityTypes?: Array<XRHitTestTrackableType>;
  82867. offsetRay?: XRRay;
  82868. }
  82869. interface XRAnchor {
  82870. anchorSpace: XRSpace;
  82871. delete(): void;
  82872. }
  82873. interface XRPlane {
  82874. orientation: "Horizontal" | "Vertical";
  82875. planeSpace: XRSpace;
  82876. polygon: Array<DOMPointReadOnly>;
  82877. lastChangedTime: number;
  82878. }
  82879. interface XRJointSpace extends XRSpace {}
  82880. interface XRJointPose extends XRPose {
  82881. radius: number | undefined;
  82882. }
  82883. interface XRHand extends Iterable<XRJointSpace> {
  82884. readonly length: number;
  82885. [index: number]: XRJointSpace;
  82886. readonly WRIST: number;
  82887. readonly THUMB_METACARPAL: number;
  82888. readonly THUMB_PHALANX_PROXIMAL: number;
  82889. readonly THUMB_PHALANX_DISTAL: number;
  82890. readonly THUMB_PHALANX_TIP: number;
  82891. readonly INDEX_METACARPAL: number;
  82892. readonly INDEX_PHALANX_PROXIMAL: number;
  82893. readonly INDEX_PHALANX_INTERMEDIATE: number;
  82894. readonly INDEX_PHALANX_DISTAL: number;
  82895. readonly INDEX_PHALANX_TIP: number;
  82896. readonly MIDDLE_METACARPAL: number;
  82897. readonly MIDDLE_PHALANX_PROXIMAL: number;
  82898. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  82899. readonly MIDDLE_PHALANX_DISTAL: number;
  82900. readonly MIDDLE_PHALANX_TIP: number;
  82901. readonly RING_METACARPAL: number;
  82902. readonly RING_PHALANX_PROXIMAL: number;
  82903. readonly RING_PHALANX_INTERMEDIATE: number;
  82904. readonly RING_PHALANX_DISTAL: number;
  82905. readonly RING_PHALANX_TIP: number;
  82906. readonly LITTLE_METACARPAL: number;
  82907. readonly LITTLE_PHALANX_PROXIMAL: number;
  82908. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  82909. readonly LITTLE_PHALANX_DISTAL: number;
  82910. readonly LITTLE_PHALANX_TIP: number;
  82911. }
  82912. type XRImageTrackingState = "tracked" | "emulated";
  82913. type XRImageTrackingScore = "untrackable" | "trackable";
  82914. interface XRTrackedImageInit {
  82915. image: ImageBitmap;
  82916. widthInMeters: number;
  82917. }
  82918. interface XRImageTrackingResult {
  82919. readonly imageSpace: XRSpace;
  82920. readonly index: number;
  82921. readonly trackingState: XRImageTrackingState;
  82922. readonly measuredWidthInMeters: number;
  82923. }
  82924. // This file contains native only extensions for WebXR. These APIs are not supported in the browser yet.
  82925. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  82926. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  82927. type XRSceneObjectType = "unknown" | "background" | "wall" | "floor" | "ceiling" | "platform";
  82928. interface XRSceneObject {
  82929. type: XRSceneObjectType;
  82930. }
  82931. interface XRFieldOfView {
  82932. angleLeft: number;
  82933. angleRight: number;
  82934. angleUp: number;
  82935. angleDown: number;
  82936. }
  82937. interface XRFrustum {
  82938. position: DOMPointReadOnly;
  82939. orientation: DOMPointReadOnly;
  82940. fieldOfView: XRFieldOfView;
  82941. farDistance: number;
  82942. }
  82943. interface XRPlane {
  82944. parentSceneObject?: XRSceneObject;
  82945. }
  82946. interface XRMesh {
  82947. meshSpace: XRSpace;
  82948. positions: Float32Array;
  82949. indices: Uint32Array;
  82950. normals?: Float32Array;
  82951. lastChangedTime: number;
  82952. parentSceneObject?: XRSceneObject;
  82953. }
  82954. interface XRFrustumDetectionBoundary {
  82955. type: "frustum";
  82956. frustum: XRFrustum;
  82957. }
  82958. interface XRSphereDetectionBoundary {
  82959. type: "sphere";
  82960. radius: number;
  82961. }
  82962. interface XRBoxDetectionBoundary {
  82963. type: "box";
  82964. extent: DOMPointReadOnly;
  82965. }
  82966. type XRDetectionBoundary = XRFrustumDetectionBoundary | XRSphereDetectionBoundary | XRBoxDetectionBoundary;
  82967. interface XRGeometryDetectorOptions {
  82968. detectionBoundary?: XRDetectionBoundary;
  82969. updateInterval?: number;
  82970. }
  82971. interface XRSession {
  82972. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  82973. trySetPreferredPlaneDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  82974. trySetMeshDetectorEnabled(enabled: boolean): boolean;
  82975. trySetPreferredMeshDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  82976. }
  82977. interface XRFrame {
  82978. featurePointCloud?: Array<number>;
  82979. }
  82980. type XRMeshSet = Set<XRMesh>;
  82981. interface XRWorldInformation {
  82982. detectedMeshes?: XRMeshSet;
  82983. }
  82984. /**
  82985. * @ignore
  82986. */
  82987. declare module BABYLON.GLTF2.Exporter {
  82988. }
  82989. /**
  82990. * @ignore
  82991. */
  82992. declare module BABYLON.GLTF1 {
  82993. }
  82994. declare module BABYLON.GUI {
  82995. /**
  82996. * Interface used to define a control that can receive focus
  82997. */
  82998. export interface IFocusableControl {
  82999. /**
  83000. * Function called when the control receives the focus
  83001. */
  83002. onFocus(): void;
  83003. /**
  83004. * Function called when the control loses the focus
  83005. */
  83006. onBlur(): void;
  83007. /**
  83008. * Function called to let the control handle keyboard events
  83009. * @param evt defines the current keyboard event
  83010. */
  83011. processKeyboard(evt: BABYLON.IKeyboardEvent): void;
  83012. /**
  83013. * Function called to get the list of controls that should not steal the focus from this control
  83014. * @returns an array of controls
  83015. */
  83016. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  83017. /**
  83018. * Function to focus the control programmatically
  83019. */
  83020. focus(): void;
  83021. /**
  83022. * Function to unfocus the control programmatically
  83023. */
  83024. blur(): void;
  83025. }
  83026. }
  83027. declare module BABYLON.GUI {
  83028. /**
  83029. * Class used to specific a value and its associated unit
  83030. */
  83031. export class ValueAndUnit {
  83032. /** defines the unit to store */
  83033. unit: number;
  83034. /** defines a boolean indicating if the value can be negative */
  83035. negativeValueAllowed: boolean;
  83036. private _value;
  83037. private _originalUnit;
  83038. /**
  83039. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  83040. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  83041. */
  83042. ignoreAdaptiveScaling: boolean;
  83043. /**
  83044. * Creates a new ValueAndUnit
  83045. * @param value defines the value to store
  83046. * @param unit defines the unit to store
  83047. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  83048. */
  83049. constructor(value: number,
  83050. /** defines the unit to store */
  83051. unit?: number,
  83052. /** defines a boolean indicating if the value can be negative */
  83053. negativeValueAllowed?: boolean);
  83054. /** Gets a boolean indicating if the value is a percentage */
  83055. get isPercentage(): boolean;
  83056. /** Gets a boolean indicating if the value is store as pixel */
  83057. get isPixel(): boolean;
  83058. /** Gets direct internal value */
  83059. get internalValue(): number;
  83060. /**
  83061. * Gets value as pixel
  83062. * @param host defines the root host
  83063. * @param refValue defines the reference value for percentages
  83064. * @returns the value as pixel
  83065. */
  83066. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  83067. /**
  83068. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  83069. * @param value defines the value to store
  83070. * @param unit defines the unit to store
  83071. * @returns the current ValueAndUnit
  83072. */
  83073. updateInPlace(value: number, unit?: number): ValueAndUnit;
  83074. /**
  83075. * Gets the value accordingly to its unit
  83076. * @param host defines the root host
  83077. * @returns the value
  83078. */
  83079. getValue(host: AdvancedDynamicTexture): number;
  83080. /**
  83081. * Gets a string representation of the value
  83082. * @param host defines the root host
  83083. * @param decimals defines an optional number of decimals to display
  83084. * @returns a string
  83085. */
  83086. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  83087. /**
  83088. * Store a value parsed from a string
  83089. * @param source defines the source string
  83090. * @returns true if the value was successfully parsed
  83091. */
  83092. fromString(source: string | number): boolean;
  83093. private static _Regex;
  83094. private static _UNITMODE_PERCENTAGE;
  83095. private static _UNITMODE_PIXEL;
  83096. /** UNITMODE_PERCENTAGE */
  83097. static get UNITMODE_PERCENTAGE(): number;
  83098. /** UNITMODE_PIXEL */
  83099. static get UNITMODE_PIXEL(): number;
  83100. }
  83101. }
  83102. declare module BABYLON.GUI {
  83103. /**
  83104. * Define a style used by control to automatically setup properties based on a template.
  83105. * Only support font related properties so far
  83106. */
  83107. export class Style implements BABYLON.IDisposable {
  83108. private _fontFamily;
  83109. private _fontStyle;
  83110. private _fontWeight;
  83111. /** @hidden */
  83112. _host: AdvancedDynamicTexture;
  83113. /** @hidden */
  83114. _fontSize: ValueAndUnit;
  83115. /**
  83116. * BABYLON.Observable raised when the style values are changed
  83117. */
  83118. onChangedObservable: BABYLON.Observable<Style>;
  83119. /**
  83120. * Creates a new style object
  83121. * @param host defines the AdvancedDynamicTexture which hosts this style
  83122. */
  83123. constructor(host: AdvancedDynamicTexture);
  83124. /**
  83125. * Gets or sets the font size
  83126. */
  83127. get fontSize(): string | number;
  83128. set fontSize(value: string | number);
  83129. /**
  83130. * Gets or sets the font family
  83131. */
  83132. get fontFamily(): string;
  83133. set fontFamily(value: string);
  83134. /**
  83135. * Gets or sets the font style
  83136. */
  83137. get fontStyle(): string;
  83138. set fontStyle(value: string);
  83139. /** Gets or sets font weight */
  83140. get fontWeight(): string;
  83141. set fontWeight(value: string);
  83142. /** Dispose all associated resources */
  83143. dispose(): void;
  83144. }
  83145. }
  83146. declare module BABYLON.GUI {
  83147. /**
  83148. * Class used to transport BABYLON.Vector2 information for pointer events
  83149. */
  83150. export class Vector2WithInfo extends BABYLON.Vector2 {
  83151. /** defines the current mouse button index */
  83152. buttonIndex: number;
  83153. /**
  83154. * Creates a new Vector2WithInfo
  83155. * @param source defines the vector2 data to transport
  83156. * @param buttonIndex defines the current mouse button index
  83157. */
  83158. constructor(source: BABYLON.Vector2,
  83159. /** defines the current mouse button index */
  83160. buttonIndex?: number);
  83161. }
  83162. /** Class used to provide 2D matrix features */
  83163. export class Matrix2D {
  83164. /** Gets the internal array of 6 floats used to store matrix data */
  83165. m: Float32Array;
  83166. /**
  83167. * Creates a new matrix
  83168. * @param m00 defines value for (0, 0)
  83169. * @param m01 defines value for (0, 1)
  83170. * @param m10 defines value for (1, 0)
  83171. * @param m11 defines value for (1, 1)
  83172. * @param m20 defines value for (2, 0)
  83173. * @param m21 defines value for (2, 1)
  83174. */
  83175. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  83176. /**
  83177. * Fills the matrix from direct values
  83178. * @param m00 defines value for (0, 0)
  83179. * @param m01 defines value for (0, 1)
  83180. * @param m10 defines value for (1, 0)
  83181. * @param m11 defines value for (1, 1)
  83182. * @param m20 defines value for (2, 0)
  83183. * @param m21 defines value for (2, 1)
  83184. * @returns the current modified matrix
  83185. */
  83186. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  83187. /**
  83188. * Gets matrix determinant
  83189. * @returns the determinant
  83190. */
  83191. determinant(): number;
  83192. /**
  83193. * Inverses the matrix and stores it in a target matrix
  83194. * @param result defines the target matrix
  83195. * @returns the current matrix
  83196. */
  83197. invertToRef(result: Matrix2D): Matrix2D;
  83198. /**
  83199. * Multiplies the current matrix with another one
  83200. * @param other defines the second operand
  83201. * @param result defines the target matrix
  83202. * @returns the current matrix
  83203. */
  83204. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  83205. /**
  83206. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  83207. * @param x defines the x coordinate to transform
  83208. * @param y defines the x coordinate to transform
  83209. * @param result defines the target vector2
  83210. * @returns the current matrix
  83211. */
  83212. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  83213. /**
  83214. * Creates an identity matrix
  83215. * @returns a new matrix
  83216. */
  83217. static Identity(): Matrix2D;
  83218. /**
  83219. * Creates a translation matrix and stores it in a target matrix
  83220. * @param x defines the x coordinate of the translation
  83221. * @param y defines the y coordinate of the translation
  83222. * @param result defines the target matrix
  83223. */
  83224. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  83225. /**
  83226. * Creates a scaling matrix and stores it in a target matrix
  83227. * @param x defines the x coordinate of the scaling
  83228. * @param y defines the y coordinate of the scaling
  83229. * @param result defines the target matrix
  83230. */
  83231. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  83232. /**
  83233. * Creates a rotation matrix and stores it in a target matrix
  83234. * @param angle defines the rotation angle
  83235. * @param result defines the target matrix
  83236. */
  83237. static RotationToRef(angle: number, result: Matrix2D): void;
  83238. private static _TempPreTranslationMatrix;
  83239. private static _TempPostTranslationMatrix;
  83240. private static _TempRotationMatrix;
  83241. private static _TempScalingMatrix;
  83242. private static _TempCompose0;
  83243. private static _TempCompose1;
  83244. private static _TempCompose2;
  83245. /**
  83246. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  83247. * @param tx defines the x coordinate of the translation
  83248. * @param ty defines the y coordinate of the translation
  83249. * @param angle defines the rotation angle
  83250. * @param scaleX defines the x coordinate of the scaling
  83251. * @param scaleY defines the y coordinate of the scaling
  83252. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  83253. * @param result defines the target matrix
  83254. */
  83255. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  83256. }
  83257. }
  83258. declare module BABYLON.GUI {
  83259. /**
  83260. * Class used to store 2D control sizes
  83261. */
  83262. export class Measure {
  83263. /** defines left coordinate */
  83264. left: number;
  83265. /** defines top coordinate */
  83266. top: number;
  83267. /** defines width dimension */
  83268. width: number;
  83269. /** defines height dimension */
  83270. height: number;
  83271. /**
  83272. * Creates a new measure
  83273. * @param left defines left coordinate
  83274. * @param top defines top coordinate
  83275. * @param width defines width dimension
  83276. * @param height defines height dimension
  83277. */
  83278. constructor(
  83279. /** defines left coordinate */
  83280. left: number,
  83281. /** defines top coordinate */
  83282. top: number,
  83283. /** defines width dimension */
  83284. width: number,
  83285. /** defines height dimension */
  83286. height: number);
  83287. /**
  83288. * Copy from another measure
  83289. * @param other defines the other measure to copy from
  83290. */
  83291. copyFrom(other: Measure): void;
  83292. /**
  83293. * Copy from a group of 4 floats
  83294. * @param left defines left coordinate
  83295. * @param top defines top coordinate
  83296. * @param width defines width dimension
  83297. * @param height defines height dimension
  83298. */
  83299. copyFromFloats(left: number, top: number, width: number, height: number): void;
  83300. /**
  83301. * Computes the axis aligned bounding box measure for two given measures
  83302. * @param a Input measure
  83303. * @param b Input measure
  83304. * @param result the resulting bounding measure
  83305. */
  83306. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  83307. /**
  83308. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  83309. * @param transform the matrix to transform the measure before computing the AABB
  83310. * @param addX number to add to left
  83311. * @param addY number to add to top
  83312. * @param addWidth number to add to width
  83313. * @param addHeight number to add to height
  83314. * @param result the resulting AABB
  83315. */
  83316. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  83317. /**
  83318. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  83319. * @param transform the matrix to transform the measure before computing the AABB
  83320. * @param result the resulting AABB
  83321. */
  83322. transformToRef(transform: Matrix2D, result: Measure): void;
  83323. /**
  83324. * Check equality between this measure and another one
  83325. * @param other defines the other measures
  83326. * @returns true if both measures are equals
  83327. */
  83328. isEqualsTo(other: Measure): boolean;
  83329. /**
  83330. * Creates an empty measure
  83331. * @returns a new measure
  83332. */
  83333. static Empty(): Measure;
  83334. }
  83335. }
  83336. declare module BABYLON.GUI {
  83337. /**
  83338. * Class used to create texture to support 2D GUI elements
  83339. * @see https://doc.babylonjs.com/how_to/gui
  83340. */
  83341. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  83342. /** Define the Uurl to load snippets */
  83343. static SnippetUrl: string;
  83344. /** Snippet ID if the content was created from the snippet server */
  83345. snippetId: string;
  83346. private _isDirty;
  83347. private _renderObserver;
  83348. private _resizeObserver;
  83349. private _preKeyboardObserver;
  83350. private _pointerMoveObserver;
  83351. private _pointerObserver;
  83352. private _canvasPointerOutObserver;
  83353. private _canvasBlurObserver;
  83354. private _background;
  83355. /** @hidden */
  83356. _rootContainer: Container;
  83357. /** @hidden */
  83358. _lastPickedControl: Control;
  83359. /** @hidden */
  83360. _lastControlOver: {
  83361. [pointerId: number]: Control;
  83362. };
  83363. /** @hidden */
  83364. _lastControlDown: {
  83365. [pointerId: number]: Control;
  83366. };
  83367. /** @hidden */
  83368. _capturingControl: {
  83369. [pointerId: number]: Control;
  83370. };
  83371. /** @hidden */
  83372. _shouldBlockPointer: boolean;
  83373. /** @hidden */
  83374. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  83375. /** @hidden */
  83376. _linkedControls: Control[];
  83377. private _isFullscreen;
  83378. private _fullscreenViewport;
  83379. private _idealWidth;
  83380. private _idealHeight;
  83381. private _useSmallestIdeal;
  83382. private _renderAtIdealSize;
  83383. private _focusedControl;
  83384. private _blockNextFocusCheck;
  83385. private _renderScale;
  83386. private _rootElement;
  83387. private _cursorChanged;
  83388. private _defaultMousePointerId;
  83389. /** @hidden */
  83390. _numLayoutCalls: number;
  83391. /** Gets the number of layout calls made the last time the ADT has been rendered */
  83392. get numLayoutCalls(): number;
  83393. /** @hidden */
  83394. _numRenderCalls: number;
  83395. /** Gets the number of render calls made the last time the ADT has been rendered */
  83396. get numRenderCalls(): number;
  83397. /**
  83398. * Define type to string to ensure compatibility across browsers
  83399. * Safari doesn't support DataTransfer constructor
  83400. */
  83401. private _clipboardData;
  83402. /**
  83403. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  83404. */
  83405. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  83406. /**
  83407. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  83408. */
  83409. onControlPickedObservable: BABYLON.Observable<Control>;
  83410. /**
  83411. * BABYLON.Observable event triggered before layout is evaluated
  83412. */
  83413. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  83414. /**
  83415. * BABYLON.Observable event triggered after the layout was evaluated
  83416. */
  83417. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  83418. /**
  83419. * BABYLON.Observable event triggered before the texture is rendered
  83420. */
  83421. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  83422. /**
  83423. * BABYLON.Observable event triggered after the texture was rendered
  83424. */
  83425. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  83426. /**
  83427. * Gets or sets a boolean defining if alpha is stored as premultiplied
  83428. */
  83429. premulAlpha: boolean;
  83430. /**
  83431. * Gets or sets a boolean indicating that the canvas must be reverted on Y when updating the texture
  83432. */
  83433. applyYInversionOnUpdate: boolean;
  83434. /**
  83435. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  83436. * Useful when you want more antialiasing
  83437. */
  83438. get renderScale(): number;
  83439. set renderScale(value: number);
  83440. /** Gets or sets the background color */
  83441. get background(): string;
  83442. set background(value: string);
  83443. /**
  83444. * Gets or sets the ideal width used to design controls.
  83445. * The GUI will then rescale everything accordingly
  83446. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  83447. */
  83448. get idealWidth(): number;
  83449. set idealWidth(value: number);
  83450. /**
  83451. * Gets or sets the ideal height used to design controls.
  83452. * The GUI will then rescale everything accordingly
  83453. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  83454. */
  83455. get idealHeight(): number;
  83456. set idealHeight(value: number);
  83457. /**
  83458. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  83459. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  83460. */
  83461. get useSmallestIdeal(): boolean;
  83462. set useSmallestIdeal(value: boolean);
  83463. /**
  83464. * Gets or sets a boolean indicating if adaptive scaling must be used
  83465. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  83466. */
  83467. get renderAtIdealSize(): boolean;
  83468. set renderAtIdealSize(value: boolean);
  83469. /**
  83470. * Gets the ratio used when in "ideal mode"
  83471. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  83472. * */
  83473. get idealRatio(): number;
  83474. /**
  83475. * Gets the underlying layer used to render the texture when in fullscreen mode
  83476. */
  83477. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  83478. /**
  83479. * Gets the root container control
  83480. */
  83481. get rootContainer(): Container;
  83482. /**
  83483. * Returns an array containing the root container.
  83484. * This is mostly used to let the Inspector introspects the ADT
  83485. * @returns an array containing the rootContainer
  83486. */
  83487. getChildren(): Array<Container>;
  83488. /**
  83489. * Will return all controls that are inside this texture
  83490. * @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
  83491. * @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
  83492. * @return all child controls
  83493. */
  83494. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  83495. /**
  83496. * Gets or sets the current focused control
  83497. */
  83498. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  83499. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  83500. /**
  83501. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  83502. */
  83503. get isForeground(): boolean;
  83504. set isForeground(value: boolean);
  83505. /**
  83506. * Gets or set information about clipboardData
  83507. */
  83508. get clipboardData(): string;
  83509. set clipboardData(value: string);
  83510. /**
  83511. * Creates a new AdvancedDynamicTexture
  83512. * @param name defines the name of the texture
  83513. * @param width defines the width of the texture
  83514. * @param height defines the height of the texture
  83515. * @param scene defines the hosting scene
  83516. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  83517. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83518. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  83519. */
  83520. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  83521. /**
  83522. * Get the current class name of the texture useful for serialization or dynamic coding.
  83523. * @returns "AdvancedDynamicTexture"
  83524. */
  83525. getClassName(): string;
  83526. /**
  83527. * Function used to execute a function on all controls
  83528. * @param func defines the function to execute
  83529. * @param container defines the container where controls belong. If null the root container will be used
  83530. */
  83531. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  83532. private _useInvalidateRectOptimization;
  83533. /**
  83534. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  83535. */
  83536. get useInvalidateRectOptimization(): boolean;
  83537. set useInvalidateRectOptimization(value: boolean);
  83538. private _invalidatedRectangle;
  83539. /**
  83540. * Invalidates a rectangle area on the gui texture
  83541. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  83542. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  83543. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  83544. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  83545. */
  83546. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  83547. /**
  83548. * Marks the texture as dirty forcing a complete update
  83549. */
  83550. markAsDirty(): void;
  83551. /**
  83552. * Helper function used to create a new style
  83553. * @returns a new style
  83554. * @see https://doc.babylonjs.com/how_to/gui#styles
  83555. */
  83556. createStyle(): Style;
  83557. /**
  83558. * Adds a new control to the root container
  83559. * @param control defines the control to add
  83560. * @returns the current texture
  83561. */
  83562. addControl(control: Control): AdvancedDynamicTexture;
  83563. /**
  83564. * Removes a control from the root container
  83565. * @param control defines the control to remove
  83566. * @returns the current texture
  83567. */
  83568. removeControl(control: Control): AdvancedDynamicTexture;
  83569. /**
  83570. * Release all resources
  83571. */
  83572. dispose(): void;
  83573. private _onResize;
  83574. /** @hidden */
  83575. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  83576. /**
  83577. * Get screen coordinates for a vector3
  83578. * @param position defines the position to project
  83579. * @param worldMatrix defines the world matrix to use
  83580. * @returns the projected position
  83581. */
  83582. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  83583. /**
  83584. * Get screen coordinates for a vector3
  83585. * @param position defines the position to project
  83586. * @param worldMatrix defines the world matrix to use
  83587. * @returns the projected position with Z
  83588. */
  83589. getProjectedPositionWithZ(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector3;
  83590. private _checkUpdate;
  83591. private _clearMeasure;
  83592. private _render;
  83593. /** @hidden */
  83594. _changeCursor(cursor: string): void;
  83595. /** @hidden */
  83596. _registerLastControlDown(control: Control, pointerId: number): void;
  83597. private _doPicking;
  83598. /** @hidden */
  83599. _cleanControlAfterRemovalFromList(list: {
  83600. [pointerId: number]: Control;
  83601. }, control: Control): void;
  83602. /** @hidden */
  83603. _cleanControlAfterRemoval(control: Control): void;
  83604. /** Attach to all scene events required to support pointer events */
  83605. attach(): void;
  83606. /** @hidden */
  83607. private onClipboardCopy;
  83608. /** @hidden */
  83609. private onClipboardCut;
  83610. /** @hidden */
  83611. private onClipboardPaste;
  83612. /**
  83613. * Register the clipboard Events onto the canvas
  83614. */
  83615. registerClipboardEvents(): void;
  83616. /**
  83617. * Unregister the clipboard Events from the canvas
  83618. */
  83619. unRegisterClipboardEvents(): void;
  83620. /**
  83621. * Connect the texture to a hosting mesh to enable interactions
  83622. * @param mesh defines the mesh to attach to
  83623. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  83624. */
  83625. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  83626. /**
  83627. * Move the focus to a specific control
  83628. * @param control defines the control which will receive the focus
  83629. */
  83630. moveFocusToControl(control: IFocusableControl): void;
  83631. private _manageFocus;
  83632. private _attachToOnPointerOut;
  83633. private _attachToOnBlur;
  83634. /**
  83635. * Serializes the entire GUI system
  83636. * @returns an object with the JSON serialized data
  83637. */
  83638. serializeContent(): any;
  83639. /**
  83640. * Recreate the content of the ADT from a JSON object
  83641. * @param serializedObject define the JSON serialized object to restore from
  83642. */
  83643. parseContent(serializedObject: any): void;
  83644. /**
  83645. * Recreate the content of the ADT from a snippet saved by the GUI editor
  83646. * @param snippetId defines the snippet to load
  83647. * @returns a promise that will resolve on success
  83648. */
  83649. parseFromSnippetAsync(snippetId: string): Promise<void>;
  83650. /**
  83651. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  83652. * @param mesh defines the mesh which will receive the texture
  83653. * @param width defines the texture width (1024 by default)
  83654. * @param height defines the texture height (1024 by default)
  83655. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  83656. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  83657. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  83658. * @returns a new AdvancedDynamicTexture
  83659. */
  83660. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  83661. /**
  83662. * 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
  83663. * @param mesh defines the mesh which will receive the texture
  83664. * @param width defines the texture width (1024 by default)
  83665. * @param height defines the texture height (1024 by default)
  83666. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  83667. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  83668. * @returns a new AdvancedDynamicTexture
  83669. */
  83670. static CreateForMeshTexture(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  83671. /**
  83672. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  83673. * In this mode the texture will rely on a layer for its rendering.
  83674. * This allows it to be treated like any other layer.
  83675. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  83676. * LayerMask is set through advancedTexture.layer.layerMask
  83677. * @param name defines name for the texture
  83678. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  83679. * @param scene defines the hsoting scene
  83680. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  83681. * @returns a new AdvancedDynamicTexture
  83682. */
  83683. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  83684. }
  83685. }
  83686. declare module BABYLON.GUI {
  83687. /**
  83688. * Root class used for all 2D controls
  83689. * @see https://doc.babylonjs.com/how_to/gui#controls
  83690. */
  83691. export class Control {
  83692. /** defines the name of the control */
  83693. name?: string | undefined;
  83694. /**
  83695. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  83696. */
  83697. static AllowAlphaInheritance: boolean;
  83698. private _alpha;
  83699. private _alphaSet;
  83700. private _zIndex;
  83701. /** @hidden */
  83702. _host: AdvancedDynamicTexture;
  83703. /** Gets or sets the control parent */
  83704. parent: BABYLON.Nullable<Container>;
  83705. /** @hidden */
  83706. _currentMeasure: Measure;
  83707. private _fontFamily;
  83708. private _fontStyle;
  83709. private _fontWeight;
  83710. private _fontSize;
  83711. private _font;
  83712. /** @hidden */
  83713. _width: ValueAndUnit;
  83714. /** @hidden */
  83715. _height: ValueAndUnit;
  83716. /** @hidden */
  83717. protected _fontOffset: {
  83718. ascent: number;
  83719. height: number;
  83720. descent: number;
  83721. };
  83722. private _color;
  83723. private _style;
  83724. private _styleObserver;
  83725. /** @hidden */
  83726. protected _horizontalAlignment: number;
  83727. /** @hidden */
  83728. protected _verticalAlignment: number;
  83729. /** @hidden */
  83730. protected _isDirty: boolean;
  83731. /** @hidden */
  83732. protected _wasDirty: boolean;
  83733. /** @hidden */
  83734. _tempParentMeasure: Measure;
  83735. /** @hidden */
  83736. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  83737. /** @hidden */
  83738. protected _cachedParentMeasure: Measure;
  83739. private _paddingLeft;
  83740. private _paddingRight;
  83741. private _paddingTop;
  83742. private _paddingBottom;
  83743. /** @hidden */
  83744. _left: ValueAndUnit;
  83745. /** @hidden */
  83746. _top: ValueAndUnit;
  83747. private _scaleX;
  83748. private _scaleY;
  83749. private _rotation;
  83750. private _transformCenterX;
  83751. private _transformCenterY;
  83752. /** @hidden */
  83753. _transformMatrix: Matrix2D;
  83754. /** @hidden */
  83755. protected _invertTransformMatrix: Matrix2D;
  83756. /** @hidden */
  83757. protected _transformedPosition: BABYLON.Vector2;
  83758. private _isMatrixDirty;
  83759. private _cachedOffsetX;
  83760. private _cachedOffsetY;
  83761. private _isVisible;
  83762. private _isHighlighted;
  83763. /** @hidden */
  83764. _linkedMesh: BABYLON.Nullable<BABYLON.TransformNode>;
  83765. private _fontSet;
  83766. private _dummyVector2;
  83767. private _downCount;
  83768. private _enterCount;
  83769. private _doNotRender;
  83770. private _downPointerIds;
  83771. protected _isEnabled: boolean;
  83772. protected _disabledColor: string;
  83773. protected _disabledColorItem: string;
  83774. /** @hidden */
  83775. protected _rebuildLayout: boolean;
  83776. /** @hidden */
  83777. _customData: any;
  83778. /** @hidden */
  83779. _isClipped: boolean;
  83780. /** @hidden */
  83781. _automaticSize: boolean;
  83782. /** @hidden */
  83783. _tag: any;
  83784. /**
  83785. * 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
  83786. */
  83787. uniqueId: number;
  83788. /**
  83789. * Gets or sets an object used to store user defined information for the node
  83790. */
  83791. metadata: any;
  83792. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  83793. isHitTestVisible: boolean;
  83794. /** Gets or sets a boolean indicating if the control can block pointer events */
  83795. isPointerBlocker: boolean;
  83796. /** Gets or sets a boolean indicating if the control can be focusable */
  83797. isFocusInvisible: boolean;
  83798. /**
  83799. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  83800. * 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
  83801. */
  83802. clipChildren: boolean;
  83803. /**
  83804. * Gets or sets a boolean indicating that control content must be clipped
  83805. * 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
  83806. */
  83807. clipContent: boolean;
  83808. /**
  83809. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  83810. */
  83811. useBitmapCache: boolean;
  83812. private _cacheData;
  83813. private _shadowOffsetX;
  83814. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  83815. get shadowOffsetX(): number;
  83816. set shadowOffsetX(value: number);
  83817. private _shadowOffsetY;
  83818. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  83819. get shadowOffsetY(): number;
  83820. set shadowOffsetY(value: number);
  83821. private _shadowBlur;
  83822. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  83823. get shadowBlur(): number;
  83824. set shadowBlur(value: number);
  83825. private _shadowColor;
  83826. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  83827. get shadowColor(): string;
  83828. set shadowColor(value: string);
  83829. /** Gets or sets the cursor to use when the control is hovered */
  83830. hoverCursor: string;
  83831. /** @hidden */
  83832. protected _linkOffsetX: ValueAndUnit;
  83833. /** @hidden */
  83834. protected _linkOffsetY: ValueAndUnit;
  83835. /** Gets the control type name */
  83836. get typeName(): string;
  83837. /**
  83838. * Get the current class name of the control.
  83839. * @returns current class name
  83840. */
  83841. getClassName(): string;
  83842. /**
  83843. * An event triggered when pointer wheel is scrolled
  83844. */
  83845. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  83846. /**
  83847. * An event triggered when the pointer move over the control.
  83848. */
  83849. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  83850. /**
  83851. * An event triggered when the pointer move out of the control.
  83852. */
  83853. onPointerOutObservable: BABYLON.Observable<Control>;
  83854. /**
  83855. * An event triggered when the pointer taps the control
  83856. */
  83857. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  83858. /**
  83859. * An event triggered when pointer up
  83860. */
  83861. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  83862. /**
  83863. * An event triggered when a control is clicked on
  83864. */
  83865. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  83866. /**
  83867. * An event triggered when pointer enters the control
  83868. */
  83869. onPointerEnterObservable: BABYLON.Observable<Control>;
  83870. /**
  83871. * An event triggered when the control is marked as dirty
  83872. */
  83873. onDirtyObservable: BABYLON.Observable<Control>;
  83874. /**
  83875. * An event triggered before drawing the control
  83876. */
  83877. onBeforeDrawObservable: BABYLON.Observable<Control>;
  83878. /**
  83879. * An event triggered after the control was drawn
  83880. */
  83881. onAfterDrawObservable: BABYLON.Observable<Control>;
  83882. /**
  83883. * An event triggered when the control has been disposed
  83884. */
  83885. onDisposeObservable: BABYLON.Observable<Control>;
  83886. /**
  83887. * Get the hosting AdvancedDynamicTexture
  83888. */
  83889. get host(): AdvancedDynamicTexture;
  83890. /** Gets or set information about font offsets (used to render and align text) */
  83891. get fontOffset(): {
  83892. ascent: number;
  83893. height: number;
  83894. descent: number;
  83895. };
  83896. set fontOffset(offset: {
  83897. ascent: number;
  83898. height: number;
  83899. descent: number;
  83900. });
  83901. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  83902. get alpha(): number;
  83903. set alpha(value: number);
  83904. /**
  83905. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  83906. */
  83907. get isHighlighted(): boolean;
  83908. set isHighlighted(value: boolean);
  83909. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  83910. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83911. */
  83912. get scaleX(): number;
  83913. set scaleX(value: number);
  83914. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  83915. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83916. */
  83917. get scaleY(): number;
  83918. set scaleY(value: number);
  83919. /** Gets or sets the rotation angle (0 by default)
  83920. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83921. */
  83922. get rotation(): number;
  83923. set rotation(value: number);
  83924. /** Gets or sets the transformation center on Y axis (0 by default)
  83925. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83926. */
  83927. get transformCenterY(): number;
  83928. set transformCenterY(value: number);
  83929. /** Gets or sets the transformation center on X axis (0 by default)
  83930. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83931. */
  83932. get transformCenterX(): number;
  83933. set transformCenterX(value: number);
  83934. /**
  83935. * Gets or sets the horizontal alignment
  83936. * @see https://doc.babylonjs.com/how_to/gui#alignments
  83937. */
  83938. get horizontalAlignment(): number;
  83939. set horizontalAlignment(value: number);
  83940. /**
  83941. * Gets or sets the vertical alignment
  83942. * @see https://doc.babylonjs.com/how_to/gui#alignments
  83943. */
  83944. get verticalAlignment(): number;
  83945. set verticalAlignment(value: number);
  83946. /**
  83947. * Gets or sets a fixed ratio for this control.
  83948. * When different from 0, the ratio is used to compute the "second" dimension.
  83949. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  83950. * second dimension is computed as first dimension * fixedRatio
  83951. */
  83952. fixedRatio: number;
  83953. private _fixedRatioMasterIsWidth;
  83954. /**
  83955. * Gets or sets control width
  83956. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83957. */
  83958. get width(): string | number;
  83959. set width(value: string | number);
  83960. /**
  83961. * Gets or sets the control width in pixel
  83962. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83963. */
  83964. get widthInPixels(): number;
  83965. set widthInPixels(value: number);
  83966. /**
  83967. * Gets or sets control height
  83968. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83969. */
  83970. get height(): string | number;
  83971. set height(value: string | number);
  83972. /**
  83973. * Gets or sets control height in pixel
  83974. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83975. */
  83976. get heightInPixels(): number;
  83977. set heightInPixels(value: number);
  83978. /** Gets or set font family */
  83979. get fontFamily(): string;
  83980. set fontFamily(value: string);
  83981. /** Gets or sets font style */
  83982. get fontStyle(): string;
  83983. set fontStyle(value: string);
  83984. /** Gets or sets font weight */
  83985. get fontWeight(): string;
  83986. set fontWeight(value: string);
  83987. /**
  83988. * Gets or sets style
  83989. * @see https://doc.babylonjs.com/how_to/gui#styles
  83990. */
  83991. get style(): BABYLON.Nullable<Style>;
  83992. set style(value: BABYLON.Nullable<Style>);
  83993. /** @hidden */
  83994. get _isFontSizeInPercentage(): boolean;
  83995. /** Gets or sets font size in pixels */
  83996. get fontSizeInPixels(): number;
  83997. set fontSizeInPixels(value: number);
  83998. /** Gets or sets font size */
  83999. get fontSize(): string | number;
  84000. set fontSize(value: string | number);
  84001. /** Gets or sets foreground color */
  84002. get color(): string;
  84003. set color(value: string);
  84004. /** Gets or sets z index which is used to reorder controls on the z axis */
  84005. get zIndex(): number;
  84006. set zIndex(value: number);
  84007. /** Gets or sets a boolean indicating if the control can be rendered */
  84008. get notRenderable(): boolean;
  84009. set notRenderable(value: boolean);
  84010. /** Gets or sets a boolean indicating if the control is visible */
  84011. get isVisible(): boolean;
  84012. set isVisible(value: boolean);
  84013. /** Gets a boolean indicating that the control needs to update its rendering */
  84014. get isDirty(): boolean;
  84015. /**
  84016. * Gets the current linked mesh (or null if none)
  84017. */
  84018. get linkedMesh(): BABYLON.Nullable<BABYLON.TransformNode>;
  84019. /**
  84020. * Gets or sets a value indicating the padding to use on the left of the control
  84021. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84022. */
  84023. get paddingLeft(): string | number;
  84024. set paddingLeft(value: string | number);
  84025. /**
  84026. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  84027. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84028. */
  84029. get paddingLeftInPixels(): number;
  84030. set paddingLeftInPixels(value: number);
  84031. /**
  84032. * Gets or sets a value indicating the padding to use on the right of the control
  84033. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84034. */
  84035. get paddingRight(): string | number;
  84036. set paddingRight(value: string | number);
  84037. /**
  84038. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  84039. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84040. */
  84041. get paddingRightInPixels(): number;
  84042. set paddingRightInPixels(value: number);
  84043. /**
  84044. * Gets or sets a value indicating the padding to use on the top of the control
  84045. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84046. */
  84047. get paddingTop(): string | number;
  84048. set paddingTop(value: string | number);
  84049. /**
  84050. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  84051. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84052. */
  84053. get paddingTopInPixels(): number;
  84054. set paddingTopInPixels(value: number);
  84055. /**
  84056. * Gets or sets a value indicating the padding to use on the bottom of the control
  84057. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84058. */
  84059. get paddingBottom(): string | number;
  84060. set paddingBottom(value: string | number);
  84061. /**
  84062. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  84063. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84064. */
  84065. get paddingBottomInPixels(): number;
  84066. set paddingBottomInPixels(value: number);
  84067. /**
  84068. * Gets or sets a value indicating the left coordinate of the control
  84069. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84070. */
  84071. get left(): string | number;
  84072. set left(value: string | number);
  84073. /**
  84074. * Gets or sets a value indicating the left coordinate in pixels of the control
  84075. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84076. */
  84077. get leftInPixels(): number;
  84078. set leftInPixels(value: number);
  84079. /**
  84080. * Gets or sets a value indicating the top coordinate of the control
  84081. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84082. */
  84083. get top(): string | number;
  84084. set top(value: string | number);
  84085. /**
  84086. * Gets or sets a value indicating the top coordinate in pixels of the control
  84087. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84088. */
  84089. get topInPixels(): number;
  84090. set topInPixels(value: number);
  84091. /**
  84092. * Gets or sets a value indicating the offset on X axis to the linked mesh
  84093. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  84094. */
  84095. get linkOffsetX(): string | number;
  84096. set linkOffsetX(value: string | number);
  84097. /**
  84098. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  84099. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  84100. */
  84101. get linkOffsetXInPixels(): number;
  84102. set linkOffsetXInPixels(value: number);
  84103. /**
  84104. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  84105. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  84106. */
  84107. get linkOffsetY(): string | number;
  84108. set linkOffsetY(value: string | number);
  84109. /**
  84110. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  84111. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  84112. */
  84113. get linkOffsetYInPixels(): number;
  84114. set linkOffsetYInPixels(value: number);
  84115. /** Gets the center coordinate on X axis */
  84116. get centerX(): number;
  84117. /** Gets the center coordinate on Y axis */
  84118. get centerY(): number;
  84119. /** Gets or sets if control is Enabled */
  84120. get isEnabled(): boolean;
  84121. set isEnabled(value: boolean);
  84122. /** Gets or sets background color of control if it's disabled */
  84123. get disabledColor(): string;
  84124. set disabledColor(value: string);
  84125. /** Gets or sets front color of control if it's disabled */
  84126. get disabledColorItem(): string;
  84127. set disabledColorItem(value: string);
  84128. /**
  84129. * Creates a new control
  84130. * @param name defines the name of the control
  84131. */
  84132. constructor(
  84133. /** defines the name of the control */
  84134. name?: string | undefined);
  84135. /** @hidden */
  84136. protected _getTypeName(): string;
  84137. /**
  84138. * Gets the first ascendant in the hierarchy of the given type
  84139. * @param className defines the required type
  84140. * @returns the ascendant or null if not found
  84141. */
  84142. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  84143. /** @hidden */
  84144. _resetFontCache(): void;
  84145. /**
  84146. * Determines if a container is an ascendant of the current control
  84147. * @param container defines the container to look for
  84148. * @returns true if the container is one of the ascendant of the control
  84149. */
  84150. isAscendant(container: Control): boolean;
  84151. /**
  84152. * Gets coordinates in local control space
  84153. * @param globalCoordinates defines the coordinates to transform
  84154. * @returns the new coordinates in local space
  84155. */
  84156. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  84157. /**
  84158. * Gets coordinates in local control space
  84159. * @param globalCoordinates defines the coordinates to transform
  84160. * @param result defines the target vector2 where to store the result
  84161. * @returns the current control
  84162. */
  84163. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  84164. /**
  84165. * Gets coordinates in parent local control space
  84166. * @param globalCoordinates defines the coordinates to transform
  84167. * @returns the new coordinates in parent local space
  84168. */
  84169. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  84170. /**
  84171. * Move the current control to a vector3 position projected onto the screen.
  84172. * @param position defines the target position
  84173. * @param scene defines the hosting scene
  84174. */
  84175. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  84176. /**
  84177. * Will store all controls that have this control as ascendant in a given array
  84178. * @param results defines the array where to store the descendants
  84179. * @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
  84180. * @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
  84181. */
  84182. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  84183. /**
  84184. * Will return all controls that have this control as ascendant
  84185. * @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
  84186. * @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
  84187. * @return all child controls
  84188. */
  84189. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  84190. /**
  84191. * Link current control with a target mesh
  84192. * @param mesh defines the mesh to link with
  84193. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  84194. */
  84195. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.TransformNode>): void;
  84196. /**
  84197. * Shorthand funtion to set the top, right, bottom, and left padding values on the control.
  84198. * @param { string | number} paddingTop - The value of the top padding.
  84199. * @param { string | number} paddingRight - The value of the right padding. If omitted, top is used.
  84200. * @param { string | number} paddingBottom - The value of the bottom padding. If omitted, top is used.
  84201. * @param { string | number} paddingLeft - The value of the left padding. If omitted, right is used.
  84202. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84203. */
  84204. setPadding(paddingTop: string | number, paddingRight?: string | number, paddingBottom?: string | number, paddingLeft?: string | number): void;
  84205. /**
  84206. * Shorthand funtion to set the top, right, bottom, and left padding values in pixels on the control.
  84207. * @param { number} paddingTop - The value in pixels of the top padding.
  84208. * @param { number} paddingRight - The value in pixels of the right padding. If omitted, top is used.
  84209. * @param { number} paddingBottom - The value in pixels of the bottom padding. If omitted, top is used.
  84210. * @param { number} paddingLeft - The value in pixels of the left padding. If omitted, right is used.
  84211. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84212. */
  84213. setPaddingInPixels(paddingTop: number, paddingRight?: number, paddingBottom?: number, paddingLeft?: number): void;
  84214. /** @hidden */
  84215. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  84216. /** @hidden */
  84217. _offsetLeft(offset: number): void;
  84218. /** @hidden */
  84219. _offsetTop(offset: number): void;
  84220. /** @hidden */
  84221. _markMatrixAsDirty(): void;
  84222. /** @hidden */
  84223. _flagDescendantsAsMatrixDirty(): void;
  84224. /** @hidden */
  84225. _intersectsRect(rect: Measure): boolean;
  84226. /** @hidden */
  84227. protected invalidateRect(): void;
  84228. /** @hidden */
  84229. _markAsDirty(force?: boolean): void;
  84230. /** @hidden */
  84231. _markAllAsDirty(): void;
  84232. /** @hidden */
  84233. _link(host: AdvancedDynamicTexture): void;
  84234. /** @hidden */
  84235. protected _transform(context?: CanvasRenderingContext2D): void;
  84236. /** @hidden */
  84237. _renderHighlight(context: CanvasRenderingContext2D): void;
  84238. /** @hidden */
  84239. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  84240. /** @hidden */
  84241. protected _applyStates(context: CanvasRenderingContext2D): void;
  84242. /** @hidden */
  84243. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  84244. /** @hidden */
  84245. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84246. protected _evaluateClippingState(parentMeasure: Measure): void;
  84247. /** @hidden */
  84248. _measure(): void;
  84249. /** @hidden */
  84250. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84251. /** @hidden */
  84252. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84253. /** @hidden */
  84254. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84255. /** @hidden */
  84256. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  84257. private static _ClipMeasure;
  84258. private _tmpMeasureA;
  84259. private _clip;
  84260. /** @hidden */
  84261. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  84262. /** @hidden */
  84263. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84264. /**
  84265. * Tests if a given coordinates belong to the current control
  84266. * @param x defines x coordinate to test
  84267. * @param y defines y coordinate to test
  84268. * @returns true if the coordinates are inside the control
  84269. */
  84270. contains(x: number, y: number): boolean;
  84271. /** @hidden */
  84272. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  84273. /** @hidden */
  84274. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  84275. /** @hidden */
  84276. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  84277. /** @hidden */
  84278. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  84279. /** @hidden */
  84280. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84281. /** @hidden */
  84282. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  84283. /** @hidden */
  84284. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  84285. /** @hidden */
  84286. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  84287. /** @hidden */
  84288. _onCanvasBlur(): void;
  84289. /** @hidden */
  84290. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  84291. private _prepareFont;
  84292. /**
  84293. * Serializes the current control
  84294. * @param serializationObject defined the JSON serialized object
  84295. */
  84296. serialize(serializationObject: any): void;
  84297. /** @hidden */
  84298. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  84299. /** Releases associated resources */
  84300. dispose(): void;
  84301. private static _HORIZONTAL_ALIGNMENT_LEFT;
  84302. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  84303. private static _HORIZONTAL_ALIGNMENT_CENTER;
  84304. private static _VERTICAL_ALIGNMENT_TOP;
  84305. private static _VERTICAL_ALIGNMENT_BOTTOM;
  84306. private static _VERTICAL_ALIGNMENT_CENTER;
  84307. /** HORIZONTAL_ALIGNMENT_LEFT */
  84308. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  84309. /** HORIZONTAL_ALIGNMENT_RIGHT */
  84310. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  84311. /** HORIZONTAL_ALIGNMENT_CENTER */
  84312. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  84313. /** VERTICAL_ALIGNMENT_TOP */
  84314. static get VERTICAL_ALIGNMENT_TOP(): number;
  84315. /** VERTICAL_ALIGNMENT_BOTTOM */
  84316. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  84317. /** VERTICAL_ALIGNMENT_CENTER */
  84318. static get VERTICAL_ALIGNMENT_CENTER(): number;
  84319. private static _FontHeightSizes;
  84320. /** @hidden */
  84321. static _GetFontOffset(font: string): {
  84322. ascent: number;
  84323. height: number;
  84324. descent: number;
  84325. };
  84326. /**
  84327. * Creates a Control from parsed data
  84328. * @param serializedObject defines parsed data
  84329. * @param host defines the hosting AdvancedDynamicTexture
  84330. * @returns a new Control
  84331. */
  84332. static Parse(serializedObject: any, host: AdvancedDynamicTexture): Control;
  84333. /**
  84334. * Creates a stack panel that can be used to render headers
  84335. * @param control defines the control to associate with the header
  84336. * @param text defines the text of the header
  84337. * @param size defines the size of the header
  84338. * @param options defines options used to configure the header
  84339. * @returns a new StackPanel
  84340. * @ignore
  84341. * @hidden
  84342. */
  84343. static AddHeader: (control: Control, text: string, size: string | number, options: {
  84344. isHorizontal: boolean;
  84345. controlFirst: boolean;
  84346. }) => any;
  84347. /** @hidden */
  84348. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  84349. }
  84350. }
  84351. declare module BABYLON.GUI {
  84352. /**
  84353. * Root class for 2D containers
  84354. * @see https://doc.babylonjs.com/how_to/gui#containers
  84355. */
  84356. export class Container extends Control {
  84357. name?: string | undefined;
  84358. /** @hidden */
  84359. _children: Control[];
  84360. /** @hidden */
  84361. protected _measureForChildren: Measure;
  84362. /** @hidden */
  84363. protected _background: string;
  84364. /** @hidden */
  84365. protected _adaptWidthToChildren: boolean;
  84366. /** @hidden */
  84367. protected _adaptHeightToChildren: boolean;
  84368. /**
  84369. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  84370. */
  84371. logLayoutCycleErrors: boolean;
  84372. /**
  84373. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  84374. */
  84375. maxLayoutCycle: number;
  84376. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  84377. get adaptHeightToChildren(): boolean;
  84378. set adaptHeightToChildren(value: boolean);
  84379. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  84380. get adaptWidthToChildren(): boolean;
  84381. set adaptWidthToChildren(value: boolean);
  84382. /** Gets or sets background color */
  84383. get background(): string;
  84384. set background(value: string);
  84385. /** Gets the list of children */
  84386. get children(): Control[];
  84387. /**
  84388. * Creates a new Container
  84389. * @param name defines the name of the container
  84390. */
  84391. constructor(name?: string | undefined);
  84392. protected _getTypeName(): string;
  84393. _flagDescendantsAsMatrixDirty(): void;
  84394. /**
  84395. * Gets a child using its name
  84396. * @param name defines the child name to look for
  84397. * @returns the child control if found
  84398. */
  84399. getChildByName(name: string): BABYLON.Nullable<Control>;
  84400. /**
  84401. * Gets a child using its type and its name
  84402. * @param name defines the child name to look for
  84403. * @param type defines the child type to look for
  84404. * @returns the child control if found
  84405. */
  84406. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  84407. /**
  84408. * Search for a specific control in children
  84409. * @param control defines the control to look for
  84410. * @returns true if the control is in child list
  84411. */
  84412. containsControl(control: Control): boolean;
  84413. /**
  84414. * Adds a new control to the current container
  84415. * @param control defines the control to add
  84416. * @returns the current container
  84417. */
  84418. addControl(control: BABYLON.Nullable<Control>): Container;
  84419. /**
  84420. * Removes all controls from the current container
  84421. * @returns the current container
  84422. */
  84423. clearControls(): Container;
  84424. /**
  84425. * Removes a control from the current container
  84426. * @param control defines the control to remove
  84427. * @returns the current container
  84428. */
  84429. removeControl(control: Control): Container;
  84430. /** @hidden */
  84431. _reOrderControl(control: Control): void;
  84432. /** @hidden */
  84433. _offsetLeft(offset: number): void;
  84434. /** @hidden */
  84435. _offsetTop(offset: number): void;
  84436. /** @hidden */
  84437. _markAllAsDirty(): void;
  84438. /** @hidden */
  84439. protected _localDraw(context: CanvasRenderingContext2D): void;
  84440. /** @hidden */
  84441. _link(host: AdvancedDynamicTexture): void;
  84442. /** @hidden */
  84443. protected _beforeLayout(): void;
  84444. /** @hidden */
  84445. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84446. /** @hidden */
  84447. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  84448. protected _postMeasure(): void;
  84449. /** @hidden */
  84450. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  84451. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  84452. /** @hidden */
  84453. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  84454. /** @hidden */
  84455. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84456. /**
  84457. * Serializes the current control
  84458. * @param serializationObject defined the JSON serialized object
  84459. */
  84460. serialize(serializationObject: any): void;
  84461. /** Releases associated resources */
  84462. dispose(): void;
  84463. /** @hidden */
  84464. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  84465. }
  84466. }
  84467. declare module BABYLON.GUI {
  84468. /** Class used to create rectangle container */
  84469. export class Rectangle extends Container {
  84470. name?: string | undefined;
  84471. private _thickness;
  84472. private _cornerRadius;
  84473. /** Gets or sets border thickness */
  84474. get thickness(): number;
  84475. set thickness(value: number);
  84476. /** Gets or sets the corner radius angle */
  84477. get cornerRadius(): number;
  84478. set cornerRadius(value: number);
  84479. /**
  84480. * Creates a new Rectangle
  84481. * @param name defines the control name
  84482. */
  84483. constructor(name?: string | undefined);
  84484. protected _getTypeName(): string;
  84485. protected _localDraw(context: CanvasRenderingContext2D): void;
  84486. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84487. private _drawRoundedRect;
  84488. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  84489. }
  84490. }
  84491. declare module BABYLON.GUI {
  84492. /**
  84493. * Enum that determines the text-wrapping mode to use.
  84494. */
  84495. export enum TextWrapping {
  84496. /**
  84497. * Clip the text when it's larger than Control.width; this is the default mode.
  84498. */
  84499. Clip = 0,
  84500. /**
  84501. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  84502. */
  84503. WordWrap = 1,
  84504. /**
  84505. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  84506. */
  84507. Ellipsis = 2
  84508. }
  84509. /**
  84510. * Class used to create text block control
  84511. */
  84512. export class TextBlock extends Control {
  84513. /**
  84514. * Defines the name of the control
  84515. */
  84516. name?: string | undefined;
  84517. private _text;
  84518. private _textWrapping;
  84519. private _textHorizontalAlignment;
  84520. private _textVerticalAlignment;
  84521. private _lines;
  84522. private _resizeToFit;
  84523. private _lineSpacing;
  84524. private _outlineWidth;
  84525. private _outlineColor;
  84526. private _underline;
  84527. private _lineThrough;
  84528. /**
  84529. * An event triggered after the text is changed
  84530. */
  84531. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  84532. /**
  84533. * An event triggered after the text was broken up into lines
  84534. */
  84535. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  84536. /**
  84537. * Function used to split a string into words. By default, a string is split at each space character found
  84538. */
  84539. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  84540. /**
  84541. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  84542. */
  84543. get lines(): any[];
  84544. /**
  84545. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  84546. */
  84547. get resizeToFit(): boolean;
  84548. /**
  84549. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  84550. */
  84551. set resizeToFit(value: boolean);
  84552. /**
  84553. * Gets or sets a boolean indicating if text must be wrapped
  84554. */
  84555. get textWrapping(): TextWrapping | boolean;
  84556. /**
  84557. * Gets or sets a boolean indicating if text must be wrapped
  84558. */
  84559. set textWrapping(value: TextWrapping | boolean);
  84560. /**
  84561. * Gets or sets text to display
  84562. */
  84563. get text(): string;
  84564. /**
  84565. * Gets or sets text to display
  84566. */
  84567. set text(value: string);
  84568. /**
  84569. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  84570. */
  84571. get textHorizontalAlignment(): number;
  84572. /**
  84573. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  84574. */
  84575. set textHorizontalAlignment(value: number);
  84576. /**
  84577. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  84578. */
  84579. get textVerticalAlignment(): number;
  84580. /**
  84581. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  84582. */
  84583. set textVerticalAlignment(value: number);
  84584. /**
  84585. * Gets or sets line spacing value
  84586. */
  84587. set lineSpacing(value: string | number);
  84588. /**
  84589. * Gets or sets line spacing value
  84590. */
  84591. get lineSpacing(): string | number;
  84592. /**
  84593. * Gets or sets outlineWidth of the text to display
  84594. */
  84595. get outlineWidth(): number;
  84596. /**
  84597. * Gets or sets outlineWidth of the text to display
  84598. */
  84599. set outlineWidth(value: number);
  84600. /**
  84601. * Gets or sets a boolean indicating that text must have underline
  84602. */
  84603. get underline(): boolean;
  84604. /**
  84605. * Gets or sets a boolean indicating that text must have underline
  84606. */
  84607. set underline(value: boolean);
  84608. /**
  84609. * Gets or sets an boolean indicating that text must be crossed out
  84610. */
  84611. get lineThrough(): boolean;
  84612. /**
  84613. * Gets or sets an boolean indicating that text must be crossed out
  84614. */
  84615. set lineThrough(value: boolean);
  84616. /**
  84617. * Gets or sets outlineColor of the text to display
  84618. */
  84619. get outlineColor(): string;
  84620. /**
  84621. * Gets or sets outlineColor of the text to display
  84622. */
  84623. set outlineColor(value: string);
  84624. /**
  84625. * Creates a new TextBlock object
  84626. * @param name defines the name of the control
  84627. * @param text defines the text to display (emptry string by default)
  84628. */
  84629. constructor(
  84630. /**
  84631. * Defines the name of the control
  84632. */
  84633. name?: string | undefined, text?: string);
  84634. protected _getTypeName(): string;
  84635. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84636. private _drawText;
  84637. /** @hidden */
  84638. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84639. protected _applyStates(context: CanvasRenderingContext2D): void;
  84640. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  84641. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  84642. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  84643. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  84644. protected _renderLines(context: CanvasRenderingContext2D): void;
  84645. /**
  84646. * Given a width constraint applied on the text block, find the expected height
  84647. * @returns expected height
  84648. */
  84649. computeExpectedHeight(): number;
  84650. dispose(): void;
  84651. }
  84652. }
  84653. declare module BABYLON.GUI {
  84654. /**
  84655. * Class used to create 2D images
  84656. */
  84657. export class Image extends Control {
  84658. name?: string | undefined;
  84659. private _workingCanvas;
  84660. private _domImage;
  84661. private _imageWidth;
  84662. private _imageHeight;
  84663. private _loaded;
  84664. private _stretch;
  84665. private _source;
  84666. private _autoScale;
  84667. private _sourceLeft;
  84668. private _sourceTop;
  84669. private _sourceWidth;
  84670. private _sourceHeight;
  84671. private _svgAttributesComputationCompleted;
  84672. private _isSVG;
  84673. private _cellWidth;
  84674. private _cellHeight;
  84675. private _cellId;
  84676. private _sliceLeft;
  84677. private _sliceRight;
  84678. private _sliceTop;
  84679. private _sliceBottom;
  84680. private _populateNinePatchSlicesFromImage;
  84681. private _detectPointerOnOpaqueOnly;
  84682. private _imageDataCache;
  84683. /**
  84684. * BABYLON.Observable notified when the content is loaded
  84685. */
  84686. onImageLoadedObservable: BABYLON.Observable<Image>;
  84687. /**
  84688. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  84689. */
  84690. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  84691. /**
  84692. * Gets a boolean indicating that the content is loaded
  84693. */
  84694. get isLoaded(): boolean;
  84695. /**
  84696. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  84697. * Beware using this as this will comsume more memory as the image has to be stored twice
  84698. */
  84699. get detectPointerOnOpaqueOnly(): boolean;
  84700. set detectPointerOnOpaqueOnly(value: boolean);
  84701. /**
  84702. * Gets or sets the left value for slicing (9-patch)
  84703. */
  84704. get sliceLeft(): number;
  84705. set sliceLeft(value: number);
  84706. /**
  84707. * Gets or sets the right value for slicing (9-patch)
  84708. */
  84709. get sliceRight(): number;
  84710. set sliceRight(value: number);
  84711. /**
  84712. * Gets or sets the top value for slicing (9-patch)
  84713. */
  84714. get sliceTop(): number;
  84715. set sliceTop(value: number);
  84716. /**
  84717. * Gets or sets the bottom value for slicing (9-patch)
  84718. */
  84719. get sliceBottom(): number;
  84720. set sliceBottom(value: number);
  84721. /**
  84722. * Gets or sets the left coordinate in the source image
  84723. */
  84724. get sourceLeft(): number;
  84725. set sourceLeft(value: number);
  84726. /**
  84727. * Gets or sets the top coordinate in the source image
  84728. */
  84729. get sourceTop(): number;
  84730. set sourceTop(value: number);
  84731. /**
  84732. * Gets or sets the width to capture in the source image
  84733. */
  84734. get sourceWidth(): number;
  84735. set sourceWidth(value: number);
  84736. /**
  84737. * Gets or sets the height to capture in the source image
  84738. */
  84739. get sourceHeight(): number;
  84740. set sourceHeight(value: number);
  84741. /**
  84742. * Gets the image width
  84743. */
  84744. get imageWidth(): number;
  84745. /**
  84746. * Gets the image height
  84747. */
  84748. get imageHeight(): number;
  84749. /**
  84750. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  84751. */
  84752. get populateNinePatchSlicesFromImage(): boolean;
  84753. set populateNinePatchSlicesFromImage(value: boolean);
  84754. /** Indicates if the format of the image is SVG */
  84755. get isSVG(): boolean;
  84756. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  84757. get svgAttributesComputationCompleted(): boolean;
  84758. /**
  84759. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  84760. * @see https://doc.babylonjs.com/how_to/gui#image
  84761. */
  84762. get autoScale(): boolean;
  84763. set autoScale(value: boolean);
  84764. /** Gets or sets the streching mode used by the image */
  84765. get stretch(): number;
  84766. set stretch(value: number);
  84767. /** @hidden */
  84768. _rotate90(n: number, preserveProperties?: boolean): Image;
  84769. private _handleRotationForSVGImage;
  84770. private _rotate90SourceProperties;
  84771. private _extractNinePatchSliceDataFromImage;
  84772. /**
  84773. * Gets or sets the internal DOM image used to render the control
  84774. */
  84775. set domImage(value: HTMLImageElement);
  84776. get domImage(): HTMLImageElement;
  84777. private _onImageLoaded;
  84778. /**
  84779. * Gets the image source url
  84780. */
  84781. get source(): BABYLON.Nullable<string>;
  84782. /**
  84783. * Gets or sets image source url
  84784. */
  84785. set source(value: BABYLON.Nullable<string>);
  84786. /**
  84787. * Checks for svg document with icon id present
  84788. */
  84789. private _svgCheck;
  84790. /**
  84791. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  84792. * given external svg file and icon id
  84793. */
  84794. private _getSVGAttribs;
  84795. /**
  84796. * Gets or sets the cell width to use when animation sheet is enabled
  84797. * @see https://doc.babylonjs.com/how_to/gui#image
  84798. */
  84799. get cellWidth(): number;
  84800. set cellWidth(value: number);
  84801. /**
  84802. * Gets or sets the cell height to use when animation sheet is enabled
  84803. * @see https://doc.babylonjs.com/how_to/gui#image
  84804. */
  84805. get cellHeight(): number;
  84806. set cellHeight(value: number);
  84807. /**
  84808. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  84809. * @see https://doc.babylonjs.com/how_to/gui#image
  84810. */
  84811. get cellId(): number;
  84812. set cellId(value: number);
  84813. /**
  84814. * Creates a new Image
  84815. * @param name defines the control name
  84816. * @param url defines the image url
  84817. */
  84818. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  84819. /**
  84820. * Tests if a given coordinates belong to the current control
  84821. * @param x defines x coordinate to test
  84822. * @param y defines y coordinate to test
  84823. * @returns true if the coordinates are inside the control
  84824. */
  84825. contains(x: number, y: number): boolean;
  84826. protected _getTypeName(): string;
  84827. /** Force the control to synchronize with its content */
  84828. synchronizeSizeWithContent(): void;
  84829. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84830. private _prepareWorkingCanvasForOpaqueDetection;
  84831. private _drawImage;
  84832. _draw(context: CanvasRenderingContext2D): void;
  84833. private _renderNinePatch;
  84834. dispose(): void;
  84835. /** STRETCH_NONE */
  84836. static readonly STRETCH_NONE: number;
  84837. /** STRETCH_FILL */
  84838. static readonly STRETCH_FILL: number;
  84839. /** STRETCH_UNIFORM */
  84840. static readonly STRETCH_UNIFORM: number;
  84841. /** STRETCH_EXTEND */
  84842. static readonly STRETCH_EXTEND: number;
  84843. /** NINE_PATCH */
  84844. static readonly STRETCH_NINE_PATCH: number;
  84845. }
  84846. }
  84847. declare module BABYLON.GUI {
  84848. /**
  84849. * Class used to create 2D buttons
  84850. */
  84851. export class Button extends Rectangle {
  84852. name?: string | undefined;
  84853. /**
  84854. * Function called to generate a pointer enter animation
  84855. */
  84856. pointerEnterAnimation: () => void;
  84857. /**
  84858. * Function called to generate a pointer out animation
  84859. */
  84860. pointerOutAnimation: () => void;
  84861. /**
  84862. * Function called to generate a pointer down animation
  84863. */
  84864. pointerDownAnimation: () => void;
  84865. /**
  84866. * Function called to generate a pointer up animation
  84867. */
  84868. pointerUpAnimation: () => void;
  84869. /**
  84870. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  84871. */
  84872. delegatePickingToChildren: boolean;
  84873. private _image;
  84874. /**
  84875. * Returns the image part of the button (if any)
  84876. */
  84877. get image(): BABYLON.Nullable<Image>;
  84878. private _textBlock;
  84879. /**
  84880. * Returns the image part of the button (if any)
  84881. */
  84882. get textBlock(): BABYLON.Nullable<TextBlock>;
  84883. /**
  84884. * Creates a new Button
  84885. * @param name defines the name of the button
  84886. */
  84887. constructor(name?: string | undefined);
  84888. protected _getTypeName(): string;
  84889. /** @hidden */
  84890. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  84891. /** @hidden */
  84892. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  84893. /** @hidden */
  84894. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  84895. /** @hidden */
  84896. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84897. /** @hidden */
  84898. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  84899. /**
  84900. * Creates a new button made with an image and a text
  84901. * @param name defines the name of the button
  84902. * @param text defines the text of the button
  84903. * @param imageUrl defines the url of the image
  84904. * @returns a new Button
  84905. */
  84906. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  84907. /**
  84908. * Creates a new button made with an image
  84909. * @param name defines the name of the button
  84910. * @param imageUrl defines the url of the image
  84911. * @returns a new Button
  84912. */
  84913. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  84914. /**
  84915. * Creates a new button made with a text
  84916. * @param name defines the name of the button
  84917. * @param text defines the text of the button
  84918. * @returns a new Button
  84919. */
  84920. static CreateSimpleButton(name: string, text: string): Button;
  84921. /**
  84922. * Creates a new button made with an image and a centered text
  84923. * @param name defines the name of the button
  84924. * @param text defines the text of the button
  84925. * @param imageUrl defines the url of the image
  84926. * @returns a new Button
  84927. */
  84928. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  84929. }
  84930. }
  84931. declare module BABYLON.GUI {
  84932. /**
  84933. * Class used to create a 2D stack panel container
  84934. */
  84935. export class StackPanel extends Container {
  84936. name?: string | undefined;
  84937. private _isVertical;
  84938. private _manualWidth;
  84939. private _manualHeight;
  84940. private _doNotTrackManualChanges;
  84941. /**
  84942. * Gets or sets a boolean indicating that layou warnings should be ignored
  84943. */
  84944. ignoreLayoutWarnings: boolean;
  84945. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  84946. get isVertical(): boolean;
  84947. set isVertical(value: boolean);
  84948. /**
  84949. * Gets or sets panel width.
  84950. * This value should not be set when in horizontal mode as it will be computed automatically
  84951. */
  84952. set width(value: string | number);
  84953. get width(): string | number;
  84954. /**
  84955. * Gets or sets panel height.
  84956. * This value should not be set when in vertical mode as it will be computed automatically
  84957. */
  84958. set height(value: string | number);
  84959. get height(): string | number;
  84960. /**
  84961. * Creates a new StackPanel
  84962. * @param name defines control name
  84963. */
  84964. constructor(name?: string | undefined);
  84965. protected _getTypeName(): string;
  84966. /** @hidden */
  84967. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84968. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84969. protected _postMeasure(): void;
  84970. /**
  84971. * Serializes the current control
  84972. * @param serializationObject defined the JSON serialized object
  84973. */
  84974. serialize(serializationObject: any): void;
  84975. /** @hidden */
  84976. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  84977. }
  84978. }
  84979. declare module BABYLON.GUI {
  84980. /**
  84981. * Class used to represent a 2D checkbox
  84982. */
  84983. export class Checkbox extends Control {
  84984. name?: string | undefined;
  84985. private _isChecked;
  84986. private _background;
  84987. private _checkSizeRatio;
  84988. private _thickness;
  84989. /** Gets or sets border thickness */
  84990. get thickness(): number;
  84991. set thickness(value: number);
  84992. /**
  84993. * BABYLON.Observable raised when isChecked property changes
  84994. */
  84995. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  84996. /** Gets or sets a value indicating the ratio between overall size and check size */
  84997. get checkSizeRatio(): number;
  84998. set checkSizeRatio(value: number);
  84999. /** Gets or sets background color */
  85000. get background(): string;
  85001. set background(value: string);
  85002. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  85003. get isChecked(): boolean;
  85004. set isChecked(value: boolean);
  85005. /**
  85006. * Creates a new CheckBox
  85007. * @param name defines the control name
  85008. */
  85009. constructor(name?: string | undefined);
  85010. protected _getTypeName(): string;
  85011. /** @hidden */
  85012. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85013. /** @hidden */
  85014. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85015. /**
  85016. * Utility function to easily create a checkbox with a header
  85017. * @param title defines the label to use for the header
  85018. * @param onValueChanged defines the callback to call when value changes
  85019. * @returns a StackPanel containing the checkbox and a textBlock
  85020. */
  85021. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  85022. }
  85023. }
  85024. declare module BABYLON.GUI {
  85025. /**
  85026. * Class used to store key control properties
  85027. */
  85028. export class KeyPropertySet {
  85029. /** Width */
  85030. width?: string;
  85031. /** Height */
  85032. height?: string;
  85033. /** Left padding */
  85034. paddingLeft?: string;
  85035. /** Right padding */
  85036. paddingRight?: string;
  85037. /** Top padding */
  85038. paddingTop?: string;
  85039. /** Bottom padding */
  85040. paddingBottom?: string;
  85041. /** Foreground color */
  85042. color?: string;
  85043. /** Background color */
  85044. background?: string;
  85045. }
  85046. /**
  85047. * Class used to create virtual keyboard
  85048. */
  85049. export class VirtualKeyboard extends StackPanel {
  85050. /** BABYLON.Observable raised when a key is pressed */
  85051. onKeyPressObservable: BABYLON.Observable<string>;
  85052. /** Gets or sets default key button width */
  85053. defaultButtonWidth: string;
  85054. /** Gets or sets default key button height */
  85055. defaultButtonHeight: string;
  85056. /** Gets or sets default key button left padding */
  85057. defaultButtonPaddingLeft: string;
  85058. /** Gets or sets default key button right padding */
  85059. defaultButtonPaddingRight: string;
  85060. /** Gets or sets default key button top padding */
  85061. defaultButtonPaddingTop: string;
  85062. /** Gets or sets default key button bottom padding */
  85063. defaultButtonPaddingBottom: string;
  85064. /** Gets or sets default key button foreground color */
  85065. defaultButtonColor: string;
  85066. /** Gets or sets default key button background color */
  85067. defaultButtonBackground: string;
  85068. /** Gets or sets shift button foreground color */
  85069. shiftButtonColor: string;
  85070. /** Gets or sets shift button thickness*/
  85071. selectedShiftThickness: number;
  85072. /** Gets shift key state */
  85073. shiftState: number;
  85074. protected _getTypeName(): string;
  85075. private _createKey;
  85076. /**
  85077. * Adds a new row of keys
  85078. * @param keys defines the list of keys to add
  85079. * @param propertySets defines the associated property sets
  85080. */
  85081. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  85082. /**
  85083. * Set the shift key to a specific state
  85084. * @param shiftState defines the new shift state
  85085. */
  85086. applyShiftState(shiftState: number): void;
  85087. private _currentlyConnectedInputText;
  85088. private _connectedInputTexts;
  85089. private _onKeyPressObserver;
  85090. /** Gets the input text control currently attached to the keyboard */
  85091. get connectedInputText(): BABYLON.Nullable<InputText>;
  85092. /**
  85093. * Connects the keyboard with an input text control
  85094. *
  85095. * @param input defines the target control
  85096. */
  85097. connect(input: InputText): void;
  85098. /**
  85099. * Disconnects the keyboard from connected InputText controls
  85100. *
  85101. * @param input optionally defines a target control, otherwise all are disconnected
  85102. */
  85103. disconnect(input?: InputText): void;
  85104. private _removeConnectedInputObservables;
  85105. /**
  85106. * Release all resources
  85107. */
  85108. dispose(): void;
  85109. /**
  85110. * Creates a new keyboard using a default layout
  85111. *
  85112. * @param name defines control name
  85113. * @returns a new VirtualKeyboard
  85114. */
  85115. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  85116. }
  85117. }
  85118. declare module BABYLON.GUI {
  85119. /** @hidden */
  85120. export class TextWrapper {
  85121. private _text;
  85122. private _characters;
  85123. get text(): string;
  85124. set text(txt: string);
  85125. get length(): number;
  85126. removePart(idxStart: number, idxEnd: number, insertTxt?: string): void;
  85127. charAt(idx: number): string;
  85128. substr(from: number, length?: number): string;
  85129. substring(from: number, to?: number): string;
  85130. isWord(index: number): boolean;
  85131. }
  85132. }
  85133. declare module BABYLON.GUI {
  85134. /**
  85135. * Class used to create input text control
  85136. */
  85137. export class InputText extends Control implements IFocusableControl {
  85138. name?: string | undefined;
  85139. private _textWrapper;
  85140. private _placeholderText;
  85141. private _background;
  85142. private _focusedBackground;
  85143. private _focusedColor;
  85144. private _placeholderColor;
  85145. private _thickness;
  85146. private _margin;
  85147. private _autoStretchWidth;
  85148. private _maxWidth;
  85149. private _isFocused;
  85150. private _blinkTimeout;
  85151. private _blinkIsEven;
  85152. private _cursorOffset;
  85153. private _scrollLeft;
  85154. private _textWidth;
  85155. private _clickedCoordinate;
  85156. private _deadKey;
  85157. private _addKey;
  85158. private _currentKey;
  85159. private _isTextHighlightOn;
  85160. private _textHighlightColor;
  85161. private _highligherOpacity;
  85162. private _highlightedText;
  85163. private _startHighlightIndex;
  85164. private _endHighlightIndex;
  85165. private _cursorIndex;
  85166. private _onFocusSelectAll;
  85167. private _isPointerDown;
  85168. private _onClipboardObserver;
  85169. private _onPointerDblTapObserver;
  85170. /** @hidden */
  85171. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  85172. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  85173. promptMessage: string;
  85174. /** Force disable prompt on mobile device */
  85175. disableMobilePrompt: boolean;
  85176. /** BABYLON.Observable raised when the text changes */
  85177. onTextChangedObservable: BABYLON.Observable<InputText>;
  85178. /** BABYLON.Observable raised just before an entered character is to be added */
  85179. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  85180. /** BABYLON.Observable raised when the control gets the focus */
  85181. onFocusObservable: BABYLON.Observable<InputText>;
  85182. /** BABYLON.Observable raised when the control loses the focus */
  85183. onBlurObservable: BABYLON.Observable<InputText>;
  85184. /**Observable raised when the text is highlighted */
  85185. onTextHighlightObservable: BABYLON.Observable<InputText>;
  85186. /**Observable raised when copy event is triggered */
  85187. onTextCopyObservable: BABYLON.Observable<InputText>;
  85188. /** BABYLON.Observable raised when cut event is triggered */
  85189. onTextCutObservable: BABYLON.Observable<InputText>;
  85190. /** BABYLON.Observable raised when paste event is triggered */
  85191. onTextPasteObservable: BABYLON.Observable<InputText>;
  85192. /** BABYLON.Observable raised when a key event was processed */
  85193. onKeyboardEventProcessedObservable: BABYLON.Observable<BABYLON.IKeyboardEvent>;
  85194. /** Gets or sets the maximum width allowed by the control */
  85195. get maxWidth(): string | number;
  85196. /** Gets the maximum width allowed by the control in pixels */
  85197. get maxWidthInPixels(): number;
  85198. set maxWidth(value: string | number);
  85199. /** Gets or sets the text highlighter transparency; default: 0.4 */
  85200. get highligherOpacity(): number;
  85201. set highligherOpacity(value: number);
  85202. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  85203. get onFocusSelectAll(): boolean;
  85204. set onFocusSelectAll(value: boolean);
  85205. /** Gets or sets the text hightlight color */
  85206. get textHighlightColor(): string;
  85207. set textHighlightColor(value: string);
  85208. /** Gets or sets control margin */
  85209. get margin(): string;
  85210. /** Gets control margin in pixels */
  85211. get marginInPixels(): number;
  85212. set margin(value: string);
  85213. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  85214. get autoStretchWidth(): boolean;
  85215. set autoStretchWidth(value: boolean);
  85216. /** Gets or sets border thickness */
  85217. get thickness(): number;
  85218. set thickness(value: number);
  85219. /** Gets or sets the background color when focused */
  85220. get focusedBackground(): string;
  85221. set focusedBackground(value: string);
  85222. /** Gets or sets the background color when focused */
  85223. get focusedColor(): string;
  85224. set focusedColor(value: string);
  85225. /** Gets or sets the background color */
  85226. get background(): string;
  85227. set background(value: string);
  85228. /** Gets or sets the placeholder color */
  85229. get placeholderColor(): string;
  85230. set placeholderColor(value: string);
  85231. /** Gets or sets the text displayed when the control is empty */
  85232. get placeholderText(): string;
  85233. set placeholderText(value: string);
  85234. /** Gets or sets the dead key flag */
  85235. get deadKey(): boolean;
  85236. set deadKey(flag: boolean);
  85237. /** Gets or sets the highlight text */
  85238. get highlightedText(): string;
  85239. set highlightedText(text: string);
  85240. /** Gets or sets if the current key should be added */
  85241. get addKey(): boolean;
  85242. set addKey(flag: boolean);
  85243. /** Gets or sets the value of the current key being entered */
  85244. get currentKey(): string;
  85245. set currentKey(key: string);
  85246. /** Gets or sets the text displayed in the control */
  85247. get text(): string;
  85248. set text(value: string);
  85249. private _textHasChanged;
  85250. /** Gets or sets control width */
  85251. get width(): string | number;
  85252. set width(value: string | number);
  85253. /**
  85254. * Creates a new InputText
  85255. * @param name defines the control name
  85256. * @param text defines the text of the control
  85257. */
  85258. constructor(name?: string | undefined, text?: string);
  85259. /** @hidden */
  85260. onBlur(): void;
  85261. /** @hidden */
  85262. onFocus(): void;
  85263. /**
  85264. * Function to focus an inputText programmatically
  85265. */
  85266. focus(): void;
  85267. /**
  85268. * Function to unfocus an inputText programmatically
  85269. */
  85270. blur(): void;
  85271. protected _getTypeName(): string;
  85272. /**
  85273. * Function called to get the list of controls that should not steal the focus from this control
  85274. * @returns an array of controls
  85275. */
  85276. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  85277. /** @hidden */
  85278. processKey(keyCode: number, key?: string, evt?: BABYLON.IKeyboardEvent): void;
  85279. /** @hidden */
  85280. private _updateValueFromCursorIndex;
  85281. /** @hidden */
  85282. private _processDblClick;
  85283. /** @hidden */
  85284. private _selectAllText;
  85285. /**
  85286. * Handles the keyboard event
  85287. * @param evt Defines the KeyboardEvent
  85288. */
  85289. processKeyboard(evt: BABYLON.IKeyboardEvent): void;
  85290. /** @hidden */
  85291. private _onCopyText;
  85292. /** @hidden */
  85293. private _onCutText;
  85294. /** @hidden */
  85295. private _onPasteText;
  85296. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85297. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85298. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  85299. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  85300. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  85301. dispose(): void;
  85302. }
  85303. }
  85304. declare module BABYLON.GUI {
  85305. /**
  85306. * Class used to create a 2D grid container
  85307. */
  85308. export class Grid extends Container {
  85309. name?: string | undefined;
  85310. private _rowDefinitions;
  85311. private _columnDefinitions;
  85312. private _cells;
  85313. private _childControls;
  85314. /**
  85315. * Gets the number of columns
  85316. */
  85317. get columnCount(): number;
  85318. /**
  85319. * Gets the number of rows
  85320. */
  85321. get rowCount(): number;
  85322. /** Gets the list of children */
  85323. get children(): Control[];
  85324. /** Gets the list of cells (e.g. the containers) */
  85325. get cells(): {
  85326. [key: string]: Container;
  85327. };
  85328. /**
  85329. * Gets the definition of a specific row
  85330. * @param index defines the index of the row
  85331. * @returns the row definition
  85332. */
  85333. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  85334. /**
  85335. * Gets the definition of a specific column
  85336. * @param index defines the index of the column
  85337. * @returns the column definition
  85338. */
  85339. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  85340. /**
  85341. * Adds a new row to the grid
  85342. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  85343. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  85344. * @returns the current grid
  85345. */
  85346. addRowDefinition(height: number, isPixel?: boolean): Grid;
  85347. /**
  85348. * Adds a new column to the grid
  85349. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  85350. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  85351. * @returns the current grid
  85352. */
  85353. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  85354. /**
  85355. * Update a row definition
  85356. * @param index defines the index of the row to update
  85357. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  85358. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  85359. * @returns the current grid
  85360. */
  85361. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  85362. /**
  85363. * Update a column definition
  85364. * @param index defines the index of the column to update
  85365. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  85366. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  85367. * @returns the current grid
  85368. */
  85369. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  85370. /**
  85371. * Gets the list of children stored in a specific cell
  85372. * @param row defines the row to check
  85373. * @param column defines the column to check
  85374. * @returns the list of controls
  85375. */
  85376. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  85377. /**
  85378. * Gets a string representing the child cell info (row x column)
  85379. * @param child defines the control to get info from
  85380. * @returns a string containing the child cell info (row x column)
  85381. */
  85382. getChildCellInfo(child: Control): string;
  85383. private _removeCell;
  85384. private _offsetCell;
  85385. /**
  85386. * Remove a column definition at specified index
  85387. * @param index defines the index of the column to remove
  85388. * @returns the current grid
  85389. */
  85390. removeColumnDefinition(index: number): Grid;
  85391. /**
  85392. * Remove a row definition at specified index
  85393. * @param index defines the index of the row to remove
  85394. * @returns the current grid
  85395. */
  85396. removeRowDefinition(index: number): Grid;
  85397. /**
  85398. * Adds a new control to the current grid
  85399. * @param control defines the control to add
  85400. * @param row defines the row where to add the control (0 by default)
  85401. * @param column defines the column where to add the control (0 by default)
  85402. * @returns the current grid
  85403. */
  85404. addControl(control: Control, row?: number, column?: number): Grid;
  85405. /**
  85406. * Removes a control from the current container
  85407. * @param control defines the control to remove
  85408. * @returns the current container
  85409. */
  85410. removeControl(control: Control): Container;
  85411. /**
  85412. * Creates a new Grid
  85413. * @param name defines control name
  85414. */
  85415. constructor(name?: string | undefined);
  85416. protected _getTypeName(): string;
  85417. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  85418. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85419. _flagDescendantsAsMatrixDirty(): void;
  85420. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  85421. /** Releases associated resources */
  85422. dispose(): void;
  85423. }
  85424. }
  85425. declare module BABYLON.GUI {
  85426. /** Class used to create color pickers */
  85427. export class ColorPicker extends Control {
  85428. name?: string | undefined;
  85429. private static _Epsilon;
  85430. private _colorWheelCanvas;
  85431. private _value;
  85432. private _tmpColor;
  85433. private _pointerStartedOnSquare;
  85434. private _pointerStartedOnWheel;
  85435. private _squareLeft;
  85436. private _squareTop;
  85437. private _squareSize;
  85438. private _h;
  85439. private _s;
  85440. private _v;
  85441. private _lastPointerDownID;
  85442. /**
  85443. * BABYLON.Observable raised when the value changes
  85444. */
  85445. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  85446. /** Gets or sets the color of the color picker */
  85447. get value(): BABYLON.Color3;
  85448. set value(value: BABYLON.Color3);
  85449. /**
  85450. * Gets or sets control width
  85451. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  85452. */
  85453. get width(): string | number;
  85454. set width(value: string | number);
  85455. /**
  85456. * Gets or sets control height
  85457. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  85458. */
  85459. get height(): string | number;
  85460. /** Gets or sets control height */
  85461. set height(value: string | number);
  85462. /** Gets or sets control size */
  85463. get size(): string | number;
  85464. set size(value: string | number);
  85465. /**
  85466. * Creates a new ColorPicker
  85467. * @param name defines the control name
  85468. */
  85469. constructor(name?: string | undefined);
  85470. protected _getTypeName(): string;
  85471. /** @hidden */
  85472. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85473. private _updateSquareProps;
  85474. private _drawGradientSquare;
  85475. private _drawCircle;
  85476. private _createColorWheelCanvas;
  85477. /** @hidden */
  85478. _draw(context: CanvasRenderingContext2D): void;
  85479. private _pointerIsDown;
  85480. private _updateValueFromPointer;
  85481. private _isPointOnSquare;
  85482. private _isPointOnWheel;
  85483. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85484. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  85485. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  85486. _onCanvasBlur(): void;
  85487. /**
  85488. * This function expands the color picker by creating a color picker dialog with manual
  85489. * color value input and the ability to save colors into an array to be used later in
  85490. * subsequent launches of the dialogue.
  85491. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  85492. * @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.
  85493. * @returns picked color as a hex string and the saved colors array as hex strings.
  85494. */
  85495. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  85496. pickerWidth?: string;
  85497. pickerHeight?: string;
  85498. headerHeight?: string;
  85499. lastColor?: string;
  85500. swatchLimit?: number;
  85501. numSwatchesPerLine?: number;
  85502. savedColors?: Array<string>;
  85503. }): Promise<{
  85504. savedColors?: string[];
  85505. pickedColor: string;
  85506. }>;
  85507. }
  85508. }
  85509. declare module BABYLON.GUI {
  85510. /** Class used to create 2D ellipse containers */
  85511. export class Ellipse extends Container {
  85512. name?: string | undefined;
  85513. private _thickness;
  85514. /** Gets or sets border thickness */
  85515. get thickness(): number;
  85516. set thickness(value: number);
  85517. /**
  85518. * Creates a new Ellipse
  85519. * @param name defines the control name
  85520. */
  85521. constructor(name?: string | undefined);
  85522. protected _getTypeName(): string;
  85523. protected _localDraw(context: CanvasRenderingContext2D): void;
  85524. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85525. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  85526. }
  85527. }
  85528. declare module BABYLON.GUI {
  85529. /**
  85530. * Class used to create a focusable button that can easily handle keyboard events
  85531. */
  85532. export class FocusableButton extends Button implements IFocusableControl {
  85533. name?: string | undefined;
  85534. /** Highlight color when button is focused */
  85535. focusedColor: BABYLON.Nullable<string>;
  85536. private _isFocused;
  85537. private _unfocusedColor;
  85538. /** BABYLON.Observable raised when the control gets the focus */
  85539. onFocusObservable: BABYLON.Observable<Button>;
  85540. /** BABYLON.Observable raised when the control loses the focus */
  85541. onBlurObservable: BABYLON.Observable<Button>;
  85542. /** BABYLON.Observable raised when a key event was processed */
  85543. onKeyboardEventProcessedObservable: BABYLON.Observable<BABYLON.IKeyboardEvent>;
  85544. constructor(name?: string | undefined);
  85545. /** @hidden */
  85546. onBlur(): void;
  85547. /** @hidden */
  85548. onFocus(): void;
  85549. /**
  85550. * Function called to get the list of controls that should not steal the focus from this control
  85551. * @returns an array of controls
  85552. */
  85553. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  85554. /**
  85555. * Function to focus a button programmatically
  85556. */
  85557. focus(): void;
  85558. /**
  85559. * Function to unfocus a button programmatically
  85560. */
  85561. blur(): void;
  85562. /**
  85563. * Handles the keyboard event
  85564. * @param evt Defines the KeyboardEvent
  85565. */
  85566. processKeyboard(evt: BABYLON.IKeyboardEvent): void;
  85567. /** @hidden */
  85568. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85569. /** @hidden */
  85570. displose(): void;
  85571. }
  85572. }
  85573. declare module BABYLON.GUI {
  85574. /**
  85575. * Class used to create a password control
  85576. */
  85577. export class InputPassword extends InputText {
  85578. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  85579. }
  85580. }
  85581. declare module BABYLON.GUI {
  85582. /** Class used to render 2D lines */
  85583. export class Line extends Control {
  85584. name?: string | undefined;
  85585. private _lineWidth;
  85586. private _x1;
  85587. private _y1;
  85588. private _x2;
  85589. private _y2;
  85590. private _dash;
  85591. private _connectedControl;
  85592. private _connectedControlDirtyObserver;
  85593. /** Gets or sets the dash pattern */
  85594. get dash(): Array<number>;
  85595. set dash(value: Array<number>);
  85596. /** Gets or sets the control connected with the line end */
  85597. get connectedControl(): Control;
  85598. set connectedControl(value: Control);
  85599. /** Gets or sets start coordinates on X axis */
  85600. get x1(): string | number;
  85601. set x1(value: string | number);
  85602. /** Gets or sets start coordinates on Y axis */
  85603. get y1(): string | number;
  85604. set y1(value: string | number);
  85605. /** Gets or sets end coordinates on X axis */
  85606. get x2(): string | number;
  85607. set x2(value: string | number);
  85608. /** Gets or sets end coordinates on Y axis */
  85609. get y2(): string | number;
  85610. set y2(value: string | number);
  85611. /** Gets or sets line width */
  85612. get lineWidth(): number;
  85613. set lineWidth(value: number);
  85614. /** Gets or sets horizontal alignment */
  85615. set horizontalAlignment(value: number);
  85616. /** Gets or sets vertical alignment */
  85617. set verticalAlignment(value: number);
  85618. private get _effectiveX2();
  85619. private get _effectiveY2();
  85620. /**
  85621. * Creates a new Line
  85622. * @param name defines the control name
  85623. */
  85624. constructor(name?: string | undefined);
  85625. protected _getTypeName(): string;
  85626. _draw(context: CanvasRenderingContext2D): void;
  85627. _measure(): void;
  85628. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85629. /**
  85630. * Move one end of the line given 3D cartesian coordinates.
  85631. * @param position Targeted world position
  85632. * @param scene BABYLON.Scene
  85633. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  85634. */
  85635. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  85636. /**
  85637. * Move one end of the line to a position in screen absolute space.
  85638. * @param projectedPosition Position in screen absolute space (X, Y)
  85639. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  85640. */
  85641. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  85642. }
  85643. }
  85644. declare module BABYLON.GUI {
  85645. /**
  85646. * Class used to store a point for a MultiLine object.
  85647. * The point can be pure 2D coordinates, a mesh or a control
  85648. */
  85649. export class MultiLinePoint {
  85650. private _multiLine;
  85651. private _x;
  85652. private _y;
  85653. private _control;
  85654. private _mesh;
  85655. private _controlObserver;
  85656. private _meshObserver;
  85657. /** @hidden */
  85658. _point: BABYLON.Vector3;
  85659. /**
  85660. * Creates a new MultiLinePoint
  85661. * @param multiLine defines the source MultiLine object
  85662. */
  85663. constructor(multiLine: MultiLine);
  85664. /** Gets or sets x coordinate */
  85665. get x(): string | number;
  85666. set x(value: string | number);
  85667. /** Gets or sets y coordinate */
  85668. get y(): string | number;
  85669. set y(value: string | number);
  85670. /** Gets or sets the control associated with this point */
  85671. get control(): BABYLON.Nullable<Control>;
  85672. set control(value: BABYLON.Nullable<Control>);
  85673. /** Gets or sets the mesh associated with this point */
  85674. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  85675. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  85676. /** Resets links */
  85677. resetLinks(): void;
  85678. /**
  85679. * Gets a translation vector with Z component
  85680. * @returns the translation vector
  85681. */
  85682. translate(): BABYLON.Vector3;
  85683. private _translatePoint;
  85684. /** Release associated resources */
  85685. dispose(): void;
  85686. }
  85687. }
  85688. declare module BABYLON.GUI {
  85689. /**
  85690. * Class used to create multi line control
  85691. */
  85692. export class MultiLine extends Control {
  85693. name?: string | undefined;
  85694. private _lineWidth;
  85695. private _dash;
  85696. private _points;
  85697. private _minX;
  85698. private _minY;
  85699. private _maxX;
  85700. private _maxY;
  85701. /**
  85702. * Creates a new MultiLine
  85703. * @param name defines the control name
  85704. */
  85705. constructor(name?: string | undefined);
  85706. /** Gets or sets dash pattern */
  85707. get dash(): Array<number>;
  85708. set dash(value: Array<number>);
  85709. /**
  85710. * Gets point stored at specified index
  85711. * @param index defines the index to look for
  85712. * @returns the requested point if found
  85713. */
  85714. getAt(index: number): MultiLinePoint;
  85715. /** Function called when a point is updated */
  85716. onPointUpdate: () => void;
  85717. /**
  85718. * Adds new points to the point collection
  85719. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  85720. * @returns the list of created MultiLinePoint
  85721. */
  85722. add(...items: (AbstractMesh | Control | {
  85723. x: string | number;
  85724. y: string | number;
  85725. })[]): MultiLinePoint[];
  85726. /**
  85727. * Adds a new point to the point collection
  85728. * @param item defines the item (mesh, control or 2d coordiantes) to add
  85729. * @returns the created MultiLinePoint
  85730. */
  85731. push(item?: (AbstractMesh | Control | {
  85732. x: string | number;
  85733. y: string | number;
  85734. })): MultiLinePoint;
  85735. /**
  85736. * Remove a specific value or point from the active point collection
  85737. * @param value defines the value or point to remove
  85738. */
  85739. remove(value: number | MultiLinePoint): void;
  85740. /**
  85741. * Resets this object to initial state (no point)
  85742. */
  85743. reset(): void;
  85744. /**
  85745. * Resets all links
  85746. */
  85747. resetLinks(): void;
  85748. /** Gets or sets line width */
  85749. get lineWidth(): number;
  85750. set lineWidth(value: number);
  85751. set horizontalAlignment(value: number);
  85752. set verticalAlignment(value: number);
  85753. protected _getTypeName(): string;
  85754. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85755. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85756. _measure(): void;
  85757. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85758. dispose(): void;
  85759. }
  85760. }
  85761. declare module BABYLON.GUI {
  85762. /**
  85763. * Class used to create radio button controls
  85764. */
  85765. export class RadioButton extends Control {
  85766. name?: string | undefined;
  85767. private _isChecked;
  85768. private _background;
  85769. private _checkSizeRatio;
  85770. private _thickness;
  85771. /** Gets or sets border thickness */
  85772. get thickness(): number;
  85773. set thickness(value: number);
  85774. /** Gets or sets group name */
  85775. group: string;
  85776. /** BABYLON.Observable raised when isChecked is changed */
  85777. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  85778. /** Gets or sets a value indicating the ratio between overall size and check size */
  85779. get checkSizeRatio(): number;
  85780. set checkSizeRatio(value: number);
  85781. /** Gets or sets background color */
  85782. get background(): string;
  85783. set background(value: string);
  85784. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  85785. get isChecked(): boolean;
  85786. set isChecked(value: boolean);
  85787. /**
  85788. * Creates a new RadioButton
  85789. * @param name defines the control name
  85790. */
  85791. constructor(name?: string | undefined);
  85792. protected _getTypeName(): string;
  85793. _draw(context: CanvasRenderingContext2D): void;
  85794. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85795. /**
  85796. * Utility function to easily create a radio button with a header
  85797. * @param title defines the label to use for the header
  85798. * @param group defines the group to use for the radio button
  85799. * @param isChecked defines the initial state of the radio button
  85800. * @param onValueChanged defines the callback to call when value changes
  85801. * @returns a StackPanel containing the radio button and a textBlock
  85802. */
  85803. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  85804. }
  85805. }
  85806. declare module BABYLON.GUI {
  85807. /**
  85808. * Class used to create slider controls
  85809. */
  85810. export class BaseSlider extends Control {
  85811. name?: string | undefined;
  85812. protected _thumbWidth: ValueAndUnit;
  85813. private _minimum;
  85814. private _maximum;
  85815. private _value;
  85816. private _isVertical;
  85817. protected _barOffset: ValueAndUnit;
  85818. private _isThumbClamped;
  85819. protected _displayThumb: boolean;
  85820. private _step;
  85821. private _lastPointerDownID;
  85822. protected _effectiveBarOffset: number;
  85823. protected _renderLeft: number;
  85824. protected _renderTop: number;
  85825. protected _renderWidth: number;
  85826. protected _renderHeight: number;
  85827. protected _backgroundBoxLength: number;
  85828. protected _backgroundBoxThickness: number;
  85829. protected _effectiveThumbThickness: number;
  85830. /** BABYLON.Observable raised when the sldier value changes */
  85831. onValueChangedObservable: BABYLON.Observable<number>;
  85832. /** Gets or sets a boolean indicating if the thumb must be rendered */
  85833. get displayThumb(): boolean;
  85834. set displayThumb(value: boolean);
  85835. /** Gets or sets a step to apply to values (0 by default) */
  85836. get step(): number;
  85837. set step(value: number);
  85838. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  85839. get barOffset(): string | number;
  85840. /** Gets main bar offset in pixels*/
  85841. get barOffsetInPixels(): number;
  85842. set barOffset(value: string | number);
  85843. /** Gets or sets thumb width */
  85844. get thumbWidth(): string | number;
  85845. /** Gets thumb width in pixels */
  85846. get thumbWidthInPixels(): number;
  85847. set thumbWidth(value: string | number);
  85848. /** Gets or sets minimum value */
  85849. get minimum(): number;
  85850. set minimum(value: number);
  85851. /** Gets or sets maximum value */
  85852. get maximum(): number;
  85853. set maximum(value: number);
  85854. /** Gets or sets current value */
  85855. get value(): number;
  85856. set value(value: number);
  85857. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  85858. get isVertical(): boolean;
  85859. set isVertical(value: boolean);
  85860. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  85861. get isThumbClamped(): boolean;
  85862. set isThumbClamped(value: boolean);
  85863. /**
  85864. * Creates a new BaseSlider
  85865. * @param name defines the control name
  85866. */
  85867. constructor(name?: string | undefined);
  85868. protected _getTypeName(): string;
  85869. protected _getThumbPosition(): number;
  85870. protected _getThumbThickness(type: string): number;
  85871. protected _prepareRenderingData(type: string): void;
  85872. private _pointerIsDown;
  85873. /** @hidden */
  85874. protected _updateValueFromPointer(x: number, y: number): void;
  85875. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85876. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  85877. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  85878. _onCanvasBlur(): void;
  85879. }
  85880. }
  85881. declare module BABYLON.GUI {
  85882. /**
  85883. * Class used to create slider controls
  85884. */
  85885. export class Slider extends BaseSlider {
  85886. name?: string | undefined;
  85887. private _background;
  85888. private _borderColor;
  85889. private _thumbColor;
  85890. private _isThumbCircle;
  85891. protected _displayValueBar: boolean;
  85892. /** Gets or sets a boolean indicating if the value bar must be rendered */
  85893. get displayValueBar(): boolean;
  85894. set displayValueBar(value: boolean);
  85895. /** Gets or sets border color */
  85896. get borderColor(): string;
  85897. set borderColor(value: string);
  85898. /** Gets or sets background color */
  85899. get background(): string;
  85900. set background(value: string);
  85901. /** Gets or sets thumb's color */
  85902. get thumbColor(): string;
  85903. set thumbColor(value: string);
  85904. /** Gets or sets a boolean indicating if the thumb should be round or square */
  85905. get isThumbCircle(): boolean;
  85906. set isThumbCircle(value: boolean);
  85907. /**
  85908. * Creates a new Slider
  85909. * @param name defines the control name
  85910. */
  85911. constructor(name?: string | undefined);
  85912. protected _getTypeName(): string;
  85913. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85914. }
  85915. }
  85916. declare module BABYLON.GUI {
  85917. /** Class used to create a RadioGroup
  85918. * which contains groups of radio buttons
  85919. */
  85920. export class SelectorGroup {
  85921. /** name of SelectorGroup */
  85922. name: string;
  85923. private _groupPanel;
  85924. private _selectors;
  85925. private _groupHeader;
  85926. /**
  85927. * Creates a new SelectorGroup
  85928. * @param name of group, used as a group heading
  85929. */
  85930. constructor(
  85931. /** name of SelectorGroup */
  85932. name: string);
  85933. /** Gets the groupPanel of the SelectorGroup */
  85934. get groupPanel(): StackPanel;
  85935. /** Gets the selectors array */
  85936. get selectors(): StackPanel[];
  85937. /** Gets and sets the group header */
  85938. get header(): string;
  85939. set header(label: string);
  85940. /** @hidden */
  85941. private _addGroupHeader;
  85942. /** @hidden*/
  85943. _getSelector(selectorNb: number): StackPanel | undefined;
  85944. /** Removes the selector at the given position
  85945. * @param selectorNb the position of the selector within the group
  85946. */
  85947. removeSelector(selectorNb: number): void;
  85948. }
  85949. /** Class used to create a CheckboxGroup
  85950. * which contains groups of checkbox buttons
  85951. */
  85952. export class CheckboxGroup extends SelectorGroup {
  85953. /** Adds a checkbox as a control
  85954. * @param text is the label for the selector
  85955. * @param func is the function called when the Selector is checked
  85956. * @param checked is true when Selector is checked
  85957. */
  85958. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  85959. /** @hidden */
  85960. _setSelectorLabel(selectorNb: number, label: string): void;
  85961. /** @hidden */
  85962. _setSelectorLabelColor(selectorNb: number, color: string): void;
  85963. /** @hidden */
  85964. _setSelectorButtonColor(selectorNb: number, color: string): void;
  85965. /** @hidden */
  85966. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  85967. }
  85968. /** Class used to create a RadioGroup
  85969. * which contains groups of radio buttons
  85970. */
  85971. export class RadioGroup extends SelectorGroup {
  85972. private _selectNb;
  85973. /** Adds a radio button as a control
  85974. * @param label is the label for the selector
  85975. * @param func is the function called when the Selector is checked
  85976. * @param checked is true when Selector is checked
  85977. */
  85978. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  85979. /** @hidden */
  85980. _setSelectorLabel(selectorNb: number, label: string): void;
  85981. /** @hidden */
  85982. _setSelectorLabelColor(selectorNb: number, color: string): void;
  85983. /** @hidden */
  85984. _setSelectorButtonColor(selectorNb: number, color: string): void;
  85985. /** @hidden */
  85986. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  85987. }
  85988. /** Class used to create a SliderGroup
  85989. * which contains groups of slider buttons
  85990. */
  85991. export class SliderGroup extends SelectorGroup {
  85992. /**
  85993. * Adds a slider to the SelectorGroup
  85994. * @param label is the label for the SliderBar
  85995. * @param func is the function called when the Slider moves
  85996. * @param unit is a string describing the units used, eg degrees or metres
  85997. * @param min is the minimum value for the Slider
  85998. * @param max is the maximum value for the Slider
  85999. * @param value is the start value for the Slider between min and max
  86000. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  86001. */
  86002. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  86003. /** @hidden */
  86004. _setSelectorLabel(selectorNb: number, label: string): void;
  86005. /** @hidden */
  86006. _setSelectorLabelColor(selectorNb: number, color: string): void;
  86007. /** @hidden */
  86008. _setSelectorButtonColor(selectorNb: number, color: string): void;
  86009. /** @hidden */
  86010. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  86011. }
  86012. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  86013. * @see https://doc.babylonjs.com/how_to/selector
  86014. */
  86015. export class SelectionPanel extends Rectangle {
  86016. /** name of SelectionPanel */
  86017. name: string;
  86018. /** an array of SelectionGroups */
  86019. groups: SelectorGroup[];
  86020. private _panel;
  86021. private _buttonColor;
  86022. private _buttonBackground;
  86023. private _headerColor;
  86024. private _barColor;
  86025. private _barHeight;
  86026. private _spacerHeight;
  86027. private _labelColor;
  86028. private _groups;
  86029. private _bars;
  86030. /**
  86031. * Creates a new SelectionPanel
  86032. * @param name of SelectionPanel
  86033. * @param groups is an array of SelectionGroups
  86034. */
  86035. constructor(
  86036. /** name of SelectionPanel */
  86037. name: string,
  86038. /** an array of SelectionGroups */
  86039. groups?: SelectorGroup[]);
  86040. protected _getTypeName(): string;
  86041. /** Gets the (stack) panel of the SelectionPanel */
  86042. get panel(): StackPanel;
  86043. /** Gets or sets the headerColor */
  86044. get headerColor(): string;
  86045. set headerColor(color: string);
  86046. private _setHeaderColor;
  86047. /** Gets or sets the button color */
  86048. get buttonColor(): string;
  86049. set buttonColor(color: string);
  86050. private _setbuttonColor;
  86051. /** Gets or sets the label color */
  86052. get labelColor(): string;
  86053. set labelColor(color: string);
  86054. private _setLabelColor;
  86055. /** Gets or sets the button background */
  86056. get buttonBackground(): string;
  86057. set buttonBackground(color: string);
  86058. private _setButtonBackground;
  86059. /** Gets or sets the color of separator bar */
  86060. get barColor(): string;
  86061. set barColor(color: string);
  86062. private _setBarColor;
  86063. /** Gets or sets the height of separator bar */
  86064. get barHeight(): string;
  86065. set barHeight(value: string);
  86066. private _setBarHeight;
  86067. /** Gets or sets the height of spacers*/
  86068. get spacerHeight(): string;
  86069. set spacerHeight(value: string);
  86070. private _setSpacerHeight;
  86071. /** Adds a bar between groups */
  86072. private _addSpacer;
  86073. /** Add a group to the selection panel
  86074. * @param group is the selector group to add
  86075. */
  86076. addGroup(group: SelectorGroup): void;
  86077. /** Remove the group from the given position
  86078. * @param groupNb is the position of the group in the list
  86079. */
  86080. removeGroup(groupNb: number): void;
  86081. /** Change a group header label
  86082. * @param label is the new group header label
  86083. * @param groupNb is the number of the group to relabel
  86084. * */
  86085. setHeaderName(label: string, groupNb: number): void;
  86086. /** Change selector label to the one given
  86087. * @param label is the new selector label
  86088. * @param groupNb is the number of the groupcontaining the selector
  86089. * @param selectorNb is the number of the selector within a group to relabel
  86090. * */
  86091. relabel(label: string, groupNb: number, selectorNb: number): void;
  86092. /** For a given group position remove the selector at the given position
  86093. * @param groupNb is the number of the group to remove the selector from
  86094. * @param selectorNb is the number of the selector within the group
  86095. */
  86096. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  86097. /** For a given group position of correct type add a checkbox button
  86098. * @param groupNb is the number of the group to remove the selector from
  86099. * @param label is the label for the selector
  86100. * @param func is the function called when the Selector is checked
  86101. * @param checked is true when Selector is checked
  86102. */
  86103. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  86104. /** For a given group position of correct type add a radio button
  86105. * @param groupNb is the number of the group to remove the selector from
  86106. * @param label is the label for the selector
  86107. * @param func is the function called when the Selector is checked
  86108. * @param checked is true when Selector is checked
  86109. */
  86110. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  86111. /**
  86112. * For a given slider group add a slider
  86113. * @param groupNb is the number of the group to add the slider to
  86114. * @param label is the label for the Slider
  86115. * @param func is the function called when the Slider moves
  86116. * @param unit is a string describing the units used, eg degrees or metres
  86117. * @param min is the minimum value for the Slider
  86118. * @param max is the maximum value for the Slider
  86119. * @param value is the start value for the Slider between min and max
  86120. * @param onVal is the function used to format the value displayed, eg radians to degrees
  86121. */
  86122. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  86123. }
  86124. }
  86125. declare module BABYLON.GUI {
  86126. /**
  86127. * Class used to hold a the container for ScrollViewer
  86128. * @hidden
  86129. */
  86130. export class _ScrollViewerWindow extends Container {
  86131. parentClientWidth: number;
  86132. parentClientHeight: number;
  86133. private _freezeControls;
  86134. private _parentMeasure;
  86135. private _oldLeft;
  86136. private _oldTop;
  86137. get freezeControls(): boolean;
  86138. set freezeControls(value: boolean);
  86139. private _bucketWidth;
  86140. private _bucketHeight;
  86141. private _buckets;
  86142. private _bucketLen;
  86143. get bucketWidth(): number;
  86144. get bucketHeight(): number;
  86145. setBucketSizes(width: number, height: number): void;
  86146. private _useBuckets;
  86147. private _makeBuckets;
  86148. private _dispatchInBuckets;
  86149. private _updateMeasures;
  86150. private _updateChildrenMeasures;
  86151. private _restoreMeasures;
  86152. /**
  86153. * Creates a new ScrollViewerWindow
  86154. * @param name of ScrollViewerWindow
  86155. */
  86156. constructor(name?: string);
  86157. protected _getTypeName(): string;
  86158. /** @hidden */
  86159. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  86160. /** @hidden */
  86161. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  86162. private _scrollChildren;
  86163. private _scrollChildrenWithBuckets;
  86164. /** @hidden */
  86165. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  86166. protected _postMeasure(): void;
  86167. }
  86168. }
  86169. declare module BABYLON.GUI {
  86170. /**
  86171. * Class used to create slider controls
  86172. */
  86173. export class ScrollBar extends BaseSlider {
  86174. name?: string | undefined;
  86175. private _background;
  86176. private _borderColor;
  86177. private _tempMeasure;
  86178. /** Gets or sets border color */
  86179. get borderColor(): string;
  86180. set borderColor(value: string);
  86181. /** Gets or sets background color */
  86182. get background(): string;
  86183. set background(value: string);
  86184. /**
  86185. * Creates a new Slider
  86186. * @param name defines the control name
  86187. */
  86188. constructor(name?: string | undefined);
  86189. protected _getTypeName(): string;
  86190. protected _getThumbThickness(): number;
  86191. _draw(context: CanvasRenderingContext2D): void;
  86192. private _first;
  86193. private _originX;
  86194. private _originY;
  86195. /** @hidden */
  86196. protected _updateValueFromPointer(x: number, y: number): void;
  86197. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  86198. }
  86199. }
  86200. declare module BABYLON.GUI {
  86201. /**
  86202. * Class used to create slider controls
  86203. */
  86204. export class ImageScrollBar extends BaseSlider {
  86205. name?: string | undefined;
  86206. private _backgroundBaseImage;
  86207. private _backgroundImage;
  86208. private _thumbImage;
  86209. private _thumbBaseImage;
  86210. private _thumbLength;
  86211. private _thumbHeight;
  86212. private _barImageHeight;
  86213. private _tempMeasure;
  86214. /** Number of 90° rotation to apply on the images when in vertical mode */
  86215. num90RotationInVerticalMode: number;
  86216. /**
  86217. * Gets or sets the image used to render the background for horizontal bar
  86218. */
  86219. get backgroundImage(): Image;
  86220. set backgroundImage(value: Image);
  86221. /**
  86222. * Gets or sets the image used to render the thumb
  86223. */
  86224. get thumbImage(): Image;
  86225. set thumbImage(value: Image);
  86226. /**
  86227. * Gets or sets the length of the thumb
  86228. */
  86229. get thumbLength(): number;
  86230. set thumbLength(value: number);
  86231. /**
  86232. * Gets or sets the height of the thumb
  86233. */
  86234. get thumbHeight(): number;
  86235. set thumbHeight(value: number);
  86236. /**
  86237. * Gets or sets the height of the bar image
  86238. */
  86239. get barImageHeight(): number;
  86240. set barImageHeight(value: number);
  86241. /**
  86242. * Creates a new ImageScrollBar
  86243. * @param name defines the control name
  86244. */
  86245. constructor(name?: string | undefined);
  86246. protected _getTypeName(): string;
  86247. protected _getThumbThickness(): number;
  86248. _draw(context: CanvasRenderingContext2D): void;
  86249. private _first;
  86250. private _originX;
  86251. private _originY;
  86252. /** @hidden */
  86253. protected _updateValueFromPointer(x: number, y: number): void;
  86254. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  86255. }
  86256. }
  86257. declare module BABYLON.GUI {
  86258. /**
  86259. * Class used to hold a viewer window and sliders in a grid
  86260. */
  86261. export class ScrollViewer extends Rectangle {
  86262. private _grid;
  86263. private _horizontalBarSpace;
  86264. private _verticalBarSpace;
  86265. private _dragSpace;
  86266. private _horizontalBar;
  86267. private _verticalBar;
  86268. private _barColor;
  86269. private _barBackground;
  86270. private _barImage;
  86271. private _horizontalBarImage;
  86272. private _verticalBarImage;
  86273. private _barBackgroundImage;
  86274. private _horizontalBarBackgroundImage;
  86275. private _verticalBarBackgroundImage;
  86276. private _barSize;
  86277. private _window;
  86278. private _pointerIsOver;
  86279. private _wheelPrecision;
  86280. private _onWheelObserver;
  86281. private _clientWidth;
  86282. private _clientHeight;
  86283. private _useImageBar;
  86284. private _thumbLength;
  86285. private _thumbHeight;
  86286. private _barImageHeight;
  86287. private _horizontalBarImageHeight;
  86288. private _verticalBarImageHeight;
  86289. private _oldWindowContentsWidth;
  86290. private _oldWindowContentsHeight;
  86291. /**
  86292. * Gets the horizontal scrollbar
  86293. */
  86294. get horizontalBar(): ScrollBar | ImageScrollBar;
  86295. /**
  86296. * Gets the vertical scrollbar
  86297. */
  86298. get verticalBar(): ScrollBar | ImageScrollBar;
  86299. /**
  86300. * Adds a new control to the current container
  86301. * @param control defines the control to add
  86302. * @returns the current container
  86303. */
  86304. addControl(control: BABYLON.Nullable<Control>): Container;
  86305. /**
  86306. * Removes a control from the current container
  86307. * @param control defines the control to remove
  86308. * @returns the current container
  86309. */
  86310. removeControl(control: Control): Container;
  86311. /** Gets the list of children */
  86312. get children(): Control[];
  86313. _flagDescendantsAsMatrixDirty(): void;
  86314. /**
  86315. * Freezes or unfreezes the controls in the window.
  86316. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  86317. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  86318. */
  86319. get freezeControls(): boolean;
  86320. set freezeControls(value: boolean);
  86321. /** Gets the bucket width */
  86322. get bucketWidth(): number;
  86323. /** Gets the bucket height */
  86324. get bucketHeight(): number;
  86325. /**
  86326. * Sets the bucket sizes.
  86327. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  86328. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  86329. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  86330. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  86331. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  86332. * used), that's why it is not enabled by default.
  86333. * @param width width of the bucket
  86334. * @param height height of the bucket
  86335. */
  86336. setBucketSizes(width: number, height: number): void;
  86337. private _forceHorizontalBar;
  86338. private _forceVerticalBar;
  86339. /**
  86340. * Forces the horizontal scroll bar to be displayed
  86341. */
  86342. get forceHorizontalBar(): boolean;
  86343. set forceHorizontalBar(value: boolean);
  86344. /**
  86345. * Forces the vertical scroll bar to be displayed
  86346. */
  86347. get forceVerticalBar(): boolean;
  86348. set forceVerticalBar(value: boolean);
  86349. /**
  86350. * Creates a new ScrollViewer
  86351. * @param name of ScrollViewer
  86352. */
  86353. constructor(name?: string, isImageBased?: boolean);
  86354. /** Reset the scroll viewer window to initial size */
  86355. resetWindow(): void;
  86356. protected _getTypeName(): string;
  86357. private _buildClientSizes;
  86358. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  86359. protected _postMeasure(): void;
  86360. /**
  86361. * Gets or sets the mouse wheel precision
  86362. * from 0 to 1 with a default value of 0.05
  86363. * */
  86364. get wheelPrecision(): number;
  86365. set wheelPrecision(value: number);
  86366. /** Gets or sets the scroll bar container background color */
  86367. get scrollBackground(): string;
  86368. set scrollBackground(color: string);
  86369. /** Gets or sets the bar color */
  86370. get barColor(): string;
  86371. set barColor(color: string);
  86372. /** Gets or sets the bar image */
  86373. get thumbImage(): Image;
  86374. set thumbImage(value: Image);
  86375. /** Gets or sets the horizontal bar image */
  86376. get horizontalThumbImage(): Image;
  86377. set horizontalThumbImage(value: Image);
  86378. /** Gets or sets the vertical bar image */
  86379. get verticalThumbImage(): Image;
  86380. set verticalThumbImage(value: Image);
  86381. /** Gets or sets the size of the bar */
  86382. get barSize(): number;
  86383. set barSize(value: number);
  86384. /** Gets or sets the length of the thumb */
  86385. get thumbLength(): number;
  86386. set thumbLength(value: number);
  86387. /** Gets or sets the height of the thumb */
  86388. get thumbHeight(): number;
  86389. set thumbHeight(value: number);
  86390. /** Gets or sets the height of the bar image */
  86391. get barImageHeight(): number;
  86392. set barImageHeight(value: number);
  86393. /** Gets or sets the height of the horizontal bar image */
  86394. get horizontalBarImageHeight(): number;
  86395. set horizontalBarImageHeight(value: number);
  86396. /** Gets or sets the height of the vertical bar image */
  86397. get verticalBarImageHeight(): number;
  86398. set verticalBarImageHeight(value: number);
  86399. /** Gets or sets the bar background */
  86400. get barBackground(): string;
  86401. set barBackground(color: string);
  86402. /** Gets or sets the bar background image */
  86403. get barImage(): Image;
  86404. set barImage(value: Image);
  86405. /** Gets or sets the horizontal bar background image */
  86406. get horizontalBarImage(): Image;
  86407. set horizontalBarImage(value: Image);
  86408. /** Gets or sets the vertical bar background image */
  86409. get verticalBarImage(): Image;
  86410. set verticalBarImage(value: Image);
  86411. private _setWindowPosition;
  86412. /** @hidden */
  86413. private _updateScroller;
  86414. _link(host: AdvancedDynamicTexture): void;
  86415. /** @hidden */
  86416. private _addBar;
  86417. /** @hidden */
  86418. private _attachWheel;
  86419. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  86420. /** Releases associated resources */
  86421. dispose(): void;
  86422. }
  86423. }
  86424. declare module BABYLON.GUI {
  86425. /**
  86426. * Class used to create toggle buttons
  86427. */
  86428. export class ToggleButton extends Rectangle {
  86429. name?: string | undefined;
  86430. /**
  86431. * Function called to generate the toActive animation
  86432. */
  86433. toActiveAnimation: () => void;
  86434. /**
  86435. * Function called to generate the toInactive animation
  86436. */
  86437. toInactiveAnimation: () => void;
  86438. /**
  86439. * Function called to generate a pointer enter animation when the toggle button is active.
  86440. */
  86441. pointerEnterActiveAnimation: () => void;
  86442. /**
  86443. * Function called to generate a pointer out animation when the toggle button is active.
  86444. */
  86445. pointerOutActiveAnimation: () => void;
  86446. /**
  86447. * Function called to generate a pointer down animation when the toggle button is active.
  86448. */
  86449. pointerDownActiveAnimation: () => void;
  86450. /**
  86451. * Function called to generate a pointer up animation when the toggle button is active.
  86452. */
  86453. pointerUpActiveAnimation: () => void;
  86454. /**
  86455. * Function called to generate a pointer enter animation when the toggle button is inactive.
  86456. */
  86457. pointerEnterInactiveAnimation: () => void;
  86458. /**
  86459. * Function called to generate a pointer out animation when the toggle button is inactive.
  86460. */
  86461. pointerOutInactiveAnimation: () => void;
  86462. /**
  86463. * Function called to generate a pointer down animation when the toggle button is inactive.
  86464. */
  86465. pointerDownInactiveAnimation: () => void;
  86466. /**
  86467. * Function called to generate a pointer up animation when the toggle button is inactive.
  86468. */
  86469. pointerUpInactiveAnimation: () => void;
  86470. /** BABYLON.Observable raised when isActive is changed */
  86471. onIsActiveChangedObservable: BABYLON.Observable<boolean>;
  86472. /**
  86473. * 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
  86474. */
  86475. delegatePickingToChildren: boolean;
  86476. private _image;
  86477. /**
  86478. * Returns the ToggleButton's image control if it exists
  86479. */
  86480. get image(): BABYLON.Nullable<Image>;
  86481. private _textBlock;
  86482. /**
  86483. * Returns the ToggleButton's child TextBlock control if it exists
  86484. */
  86485. get textBlock(): BABYLON.Nullable<TextBlock>;
  86486. private _group;
  86487. /** Gets or sets group name this toggle button belongs to */
  86488. get group(): string;
  86489. set group(value: string);
  86490. private _isActive;
  86491. /** Gets or sets a boolean indicating if the toogle button is active or not */
  86492. get isActive(): boolean;
  86493. set isActive(value: boolean);
  86494. /**
  86495. * Creates a new ToggleButton
  86496. * @param name defines the control name
  86497. * @param group defines the toggle group this toggle belongs to
  86498. */
  86499. constructor(name?: string | undefined, group?: string);
  86500. protected _getTypeName(): string;
  86501. /** @hidden */
  86502. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  86503. /** @hidden */
  86504. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  86505. /** @hidden */
  86506. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  86507. /** @hidden */
  86508. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  86509. /** @hidden */
  86510. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  86511. }
  86512. }
  86513. declare module BABYLON.GUI {
  86514. /** Class used to render a grid */
  86515. export class DisplayGrid extends Control {
  86516. name?: string | undefined;
  86517. private _cellWidth;
  86518. private _cellHeight;
  86519. private _minorLineTickness;
  86520. private _minorLineColor;
  86521. private _majorLineTickness;
  86522. private _majorLineColor;
  86523. private _majorLineFrequency;
  86524. private _background;
  86525. private _displayMajorLines;
  86526. private _displayMinorLines;
  86527. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  86528. get displayMinorLines(): boolean;
  86529. set displayMinorLines(value: boolean);
  86530. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  86531. get displayMajorLines(): boolean;
  86532. set displayMajorLines(value: boolean);
  86533. /** Gets or sets background color (Black by default) */
  86534. get background(): string;
  86535. set background(value: string);
  86536. /** Gets or sets the width of each cell (20 by default) */
  86537. get cellWidth(): number;
  86538. set cellWidth(value: number);
  86539. /** Gets or sets the height of each cell (20 by default) */
  86540. get cellHeight(): number;
  86541. set cellHeight(value: number);
  86542. /** Gets or sets the tickness of minor lines (1 by default) */
  86543. get minorLineTickness(): number;
  86544. set minorLineTickness(value: number);
  86545. /** Gets or sets the color of minor lines (DarkGray by default) */
  86546. get minorLineColor(): string;
  86547. set minorLineColor(value: string);
  86548. /** Gets or sets the tickness of major lines (2 by default) */
  86549. get majorLineTickness(): number;
  86550. set majorLineTickness(value: number);
  86551. /** Gets or sets the color of major lines (White by default) */
  86552. get majorLineColor(): string;
  86553. set majorLineColor(value: string);
  86554. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  86555. get majorLineFrequency(): number;
  86556. set majorLineFrequency(value: number);
  86557. /**
  86558. * Creates a new GridDisplayRectangle
  86559. * @param name defines the control name
  86560. */
  86561. constructor(name?: string | undefined);
  86562. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  86563. protected _getTypeName(): string;
  86564. }
  86565. }
  86566. declare module BABYLON.GUI {
  86567. /**
  86568. * Class used to create slider controls based on images
  86569. */
  86570. export class ImageBasedSlider extends BaseSlider {
  86571. name?: string | undefined;
  86572. private _backgroundImage;
  86573. private _thumbImage;
  86574. private _valueBarImage;
  86575. private _tempMeasure;
  86576. get displayThumb(): boolean;
  86577. set displayThumb(value: boolean);
  86578. /**
  86579. * Gets or sets the image used to render the background
  86580. */
  86581. get backgroundImage(): Image;
  86582. set backgroundImage(value: Image);
  86583. /**
  86584. * Gets or sets the image used to render the value bar
  86585. */
  86586. get valueBarImage(): Image;
  86587. set valueBarImage(value: Image);
  86588. /**
  86589. * Gets or sets the image used to render the thumb
  86590. */
  86591. get thumbImage(): Image;
  86592. set thumbImage(value: Image);
  86593. /**
  86594. * Creates a new ImageBasedSlider
  86595. * @param name defines the control name
  86596. */
  86597. constructor(name?: string | undefined);
  86598. protected _getTypeName(): string;
  86599. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  86600. }
  86601. }
  86602. declare module BABYLON.GUI {
  86603. /**
  86604. * Forcing an export so that this code will execute
  86605. * @hidden
  86606. */
  86607. const name = "Statics";
  86608. }
  86609. declare module BABYLON.GUI {
  86610. /**
  86611. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  86612. */
  86613. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  86614. /**
  86615. * Define the instrumented AdvancedDynamicTexture.
  86616. */
  86617. texture: AdvancedDynamicTexture;
  86618. private _captureRenderTime;
  86619. private _renderTime;
  86620. private _captureLayoutTime;
  86621. private _layoutTime;
  86622. private _onBeginRenderObserver;
  86623. private _onEndRenderObserver;
  86624. private _onBeginLayoutObserver;
  86625. private _onEndLayoutObserver;
  86626. /**
  86627. * Gets the perf counter used to capture render time
  86628. */
  86629. get renderTimeCounter(): BABYLON.PerfCounter;
  86630. /**
  86631. * Gets the perf counter used to capture layout time
  86632. */
  86633. get layoutTimeCounter(): BABYLON.PerfCounter;
  86634. /**
  86635. * Enable or disable the render time capture
  86636. */
  86637. get captureRenderTime(): boolean;
  86638. set captureRenderTime(value: boolean);
  86639. /**
  86640. * Enable or disable the layout time capture
  86641. */
  86642. get captureLayoutTime(): boolean;
  86643. set captureLayoutTime(value: boolean);
  86644. /**
  86645. * Instantiates a new advanced dynamic texture instrumentation.
  86646. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  86647. * @param texture Defines the AdvancedDynamicTexture to instrument
  86648. */
  86649. constructor(
  86650. /**
  86651. * Define the instrumented AdvancedDynamicTexture.
  86652. */
  86653. texture: AdvancedDynamicTexture);
  86654. /**
  86655. * Dispose and release associated resources.
  86656. */
  86657. dispose(): void;
  86658. }
  86659. }
  86660. declare module BABYLON.GUI {
  86661. /**
  86662. * Class used to load GUI via XML.
  86663. */
  86664. export class XmlLoader {
  86665. private _nodes;
  86666. private _nodeTypes;
  86667. private _isLoaded;
  86668. private _objectAttributes;
  86669. private _parentClass;
  86670. /**
  86671. * Create a new xml loader
  86672. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  86673. */
  86674. constructor(parentClass?: null);
  86675. private _getChainElement;
  86676. private _getClassAttribute;
  86677. private _createGuiElement;
  86678. private _parseGrid;
  86679. private _parseElement;
  86680. private _prepareSourceElement;
  86681. private _parseElementsFromSource;
  86682. private _parseXml;
  86683. /**
  86684. * Gets if the loading has finished.
  86685. * @returns whether the loading has finished or not
  86686. */
  86687. isLoaded(): boolean;
  86688. /**
  86689. * Gets a loaded node / control by id.
  86690. * @param id the Controls id set in the xml
  86691. * @returns element of type Control
  86692. */
  86693. getNodeById(id: string): any;
  86694. /**
  86695. * Gets all loaded nodes / controls
  86696. * @returns Array of controls
  86697. */
  86698. getNodes(): any;
  86699. /**
  86700. * Initiates the xml layout loading
  86701. * @param xmlFile defines the xml layout to load
  86702. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  86703. * @param callback defines the callback called on layout load.
  86704. */
  86705. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  86706. }
  86707. }
  86708. declare module BABYLON.GUI {
  86709. /**
  86710. * Class used to create containers for controls
  86711. */
  86712. export class Container3D extends Control3D {
  86713. private _blockLayout;
  86714. /**
  86715. * Gets the list of child controls
  86716. */
  86717. protected _children: Control3D[];
  86718. /**
  86719. * Gets the list of child controls
  86720. */
  86721. get children(): Array<Control3D>;
  86722. /**
  86723. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  86724. * This is helpful to optimize layout operation when adding multiple children in a row
  86725. */
  86726. get blockLayout(): boolean;
  86727. set blockLayout(value: boolean);
  86728. /**
  86729. * Creates a new container
  86730. * @param name defines the container name
  86731. */
  86732. constructor(name?: string);
  86733. /**
  86734. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  86735. * @returns the current container
  86736. */
  86737. updateLayout(): Container3D;
  86738. /**
  86739. * Gets a boolean indicating if the given control is in the children of this control
  86740. * @param control defines the control to check
  86741. * @returns true if the control is in the child list
  86742. */
  86743. containsControl(control: Control3D): boolean;
  86744. /**
  86745. * Adds a control to the children of this control
  86746. * @param control defines the control to add
  86747. * @returns the current container
  86748. */
  86749. addControl(control: Control3D): Container3D;
  86750. /**
  86751. * This function will be called everytime a new control is added
  86752. */
  86753. protected _arrangeChildren(): void;
  86754. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  86755. /**
  86756. * Removes a control from the children of this control
  86757. * @param control defines the control to remove
  86758. * @returns the current container
  86759. */
  86760. removeControl(control: Control3D): Container3D;
  86761. protected _getTypeName(): string;
  86762. /**
  86763. * Releases all associated resources
  86764. */
  86765. dispose(): void;
  86766. /** Control rotation will remain unchanged */
  86767. static readonly UNSET_ORIENTATION: number;
  86768. /** Control will rotate to make it look at sphere central axis */
  86769. static readonly FACEORIGIN_ORIENTATION: number;
  86770. /** Control will rotate to make it look back at sphere central axis */
  86771. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  86772. /** Control will rotate to look at z axis (0, 0, 1) */
  86773. static readonly FACEFORWARD_ORIENTATION: number;
  86774. /** Control will rotate to look at negative z axis (0, 0, -1) */
  86775. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  86776. }
  86777. }
  86778. declare module BABYLON.GUI {
  86779. /**
  86780. * Class used to create a button in 3D
  86781. */
  86782. export class Button3D extends AbstractButton3D {
  86783. /** @hidden */
  86784. protected _currentMaterial: BABYLON.Material;
  86785. private _facadeTexture;
  86786. private _content;
  86787. private _contentResolution;
  86788. private _contentScaleRatio;
  86789. /**
  86790. * Gets or sets the texture resolution used to render content (512 by default)
  86791. */
  86792. get contentResolution(): BABYLON.int;
  86793. set contentResolution(value: BABYLON.int);
  86794. /**
  86795. * Gets or sets the texture scale ratio used to render content (2 by default)
  86796. */
  86797. get contentScaleRatio(): number;
  86798. set contentScaleRatio(value: number);
  86799. protected _disposeFacadeTexture(): void;
  86800. protected _resetContent(): void;
  86801. /**
  86802. * Creates a new button
  86803. * @param name defines the control name
  86804. */
  86805. constructor(name?: string);
  86806. /**
  86807. * Gets or sets the GUI 2D content used to display the button's facade
  86808. */
  86809. get content(): Control;
  86810. set content(value: Control);
  86811. /**
  86812. * Apply the facade texture (created from the content property).
  86813. * This function can be overloaded by child classes
  86814. * @param facadeTexture defines the AdvancedDynamicTexture to use
  86815. */
  86816. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  86817. protected _getTypeName(): string;
  86818. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86819. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  86820. /**
  86821. * Releases all associated resources
  86822. */
  86823. dispose(): void;
  86824. }
  86825. }
  86826. declare module BABYLON.GUI {
  86827. /**
  86828. * Class used to create a touchable button in 3D
  86829. */
  86830. export class TouchButton3D extends Button3D {
  86831. private _collisionMesh;
  86832. private _collidableFrontDirection;
  86833. private _lastTouchPoint;
  86834. private _tempButtonForwardRay;
  86835. private _lastKnownCollidableScale;
  86836. private _collidableInitialized;
  86837. private _frontOffset;
  86838. private _backOffset;
  86839. private _hoverOffset;
  86840. private _pushThroughBackOffset;
  86841. private _activeInteractions;
  86842. private _previousHeight;
  86843. /**
  86844. * Creates a new touchable button
  86845. * @param name defines the control name
  86846. * @param collisionMesh mesh to track collisions with
  86847. */
  86848. constructor(name?: string, collisionMesh?: BABYLON.Mesh);
  86849. /**
  86850. * Sets the front-facing direction of the button
  86851. * @param frontDir the forward direction of the button
  86852. */
  86853. set collidableFrontDirection(frontWorldDir: BABYLON.Vector3);
  86854. private _getWorldMatrixData;
  86855. /**
  86856. * Sets the mesh used for testing input collision
  86857. * @param collisionMesh the new collision mesh for the button
  86858. */
  86859. set collisionMesh(collisionMesh: BABYLON.Mesh);
  86860. private _getShortestDistancePointToLine;
  86861. private _isPrimedForInteraction;
  86862. private _getPointOnButton;
  86863. private _updateDistanceOffsets;
  86864. private _getHeightFromButtonCenter;
  86865. private _getDistanceOffPlane;
  86866. private _updateButtonState;
  86867. /** @hidden */
  86868. _collisionCheckForStateChange(mesh: BABYLON.AbstractMesh): void;
  86869. protected _getTypeName(): string;
  86870. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86871. /**
  86872. * Releases all associated resources
  86873. */
  86874. dispose(): void;
  86875. }
  86876. }
  86877. declare module BABYLON.GUI {
  86878. /**
  86879. * Class used to manage 3D user interface
  86880. * @see https://doc.babylonjs.com/how_to/gui3d
  86881. */
  86882. export class GUI3DManager implements BABYLON.IDisposable {
  86883. private _scene;
  86884. private _sceneDisposeObserver;
  86885. private _utilityLayer;
  86886. private _rootContainer;
  86887. private _pointerObserver;
  86888. private _pointerOutObserver;
  86889. private _touchableButtons;
  86890. /** @hidden */
  86891. _lastPickedControl: Control3D;
  86892. /** @hidden */
  86893. _lastControlOver: {
  86894. [pointerId: number]: Control3D;
  86895. };
  86896. /** @hidden */
  86897. _lastControlDown: {
  86898. [pointerId: number]: Control3D;
  86899. };
  86900. /**
  86901. * BABYLON.Observable raised when the point picked by the pointer events changed
  86902. */
  86903. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  86904. /** @hidden */
  86905. _sharedMaterials: {
  86906. [key: string]: BABYLON.Material;
  86907. };
  86908. /** @hidden */
  86909. _touchSharedMaterials: {
  86910. [key: string]: BABYLON.Material;
  86911. };
  86912. /** Gets the hosting scene */
  86913. get scene(): BABYLON.Scene;
  86914. /** Gets associated utility layer */
  86915. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  86916. /**
  86917. * Creates a new GUI3DManager
  86918. * @param scene
  86919. */
  86920. constructor(scene?: BABYLON.Scene);
  86921. private _handlePointerOut;
  86922. private _doPicking;
  86923. private _processTouchControls;
  86924. /**
  86925. * Gets the root container
  86926. */
  86927. get rootContainer(): Container3D;
  86928. /**
  86929. * Gets a boolean indicating if the given control is in the root child list
  86930. * @param control defines the control to check
  86931. * @returns true if the control is in the root child list
  86932. */
  86933. containsControl(control: Control3D): boolean;
  86934. /**
  86935. * Adds a control to the root child list
  86936. * @param control defines the control to add
  86937. * @returns the current manager
  86938. */
  86939. addControl(control: Control3D): GUI3DManager;
  86940. /**
  86941. * Removes a control from the root child list
  86942. * @param control defines the control to remove
  86943. * @returns the current container
  86944. */
  86945. removeControl(control: Control3D): GUI3DManager;
  86946. /**
  86947. * Releases all associated resources
  86948. */
  86949. dispose(): void;
  86950. }
  86951. }
  86952. declare module BABYLON.GUI {
  86953. /**
  86954. * Class used to transport BABYLON.Vector3 information for pointer events
  86955. */
  86956. export class Vector3WithInfo extends BABYLON.Vector3 {
  86957. /** defines the current mouse button index */
  86958. buttonIndex: number;
  86959. /**
  86960. * Creates a new Vector3WithInfo
  86961. * @param source defines the vector3 data to transport
  86962. * @param buttonIndex defines the current mouse button index
  86963. */
  86964. constructor(source: BABYLON.Vector3,
  86965. /** defines the current mouse button index */
  86966. buttonIndex?: number);
  86967. }
  86968. }
  86969. declare module BABYLON.GUI {
  86970. /**
  86971. * Class used as base class for controls
  86972. */
  86973. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  86974. /** Defines the control name */
  86975. name?: string | undefined;
  86976. /** @hidden */
  86977. _host: GUI3DManager;
  86978. private _node;
  86979. private _downCount;
  86980. private _enterCount;
  86981. private _downPointerIds;
  86982. private _isVisible;
  86983. /** Gets or sets the control position in world space */
  86984. get position(): BABYLON.Vector3;
  86985. set position(value: BABYLON.Vector3);
  86986. /** Gets or sets the control scaling in world space */
  86987. get scaling(): BABYLON.Vector3;
  86988. set scaling(value: BABYLON.Vector3);
  86989. /** Callback used to start pointer enter animation */
  86990. pointerEnterAnimation: () => void;
  86991. /** Callback used to start pointer out animation */
  86992. pointerOutAnimation: () => void;
  86993. /** Callback used to start pointer down animation */
  86994. pointerDownAnimation: () => void;
  86995. /** Callback used to start pointer up animation */
  86996. pointerUpAnimation: () => void;
  86997. /**
  86998. * An event triggered when the pointer move over the control
  86999. */
  87000. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  87001. /**
  87002. * An event triggered when the pointer move out of the control
  87003. */
  87004. onPointerOutObservable: BABYLON.Observable<Control3D>;
  87005. /**
  87006. * An event triggered when the pointer taps the control
  87007. */
  87008. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  87009. /**
  87010. * An event triggered when pointer is up
  87011. */
  87012. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  87013. /**
  87014. * An event triggered when a control is clicked on (with a mouse)
  87015. */
  87016. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  87017. /**
  87018. * An event triggered when pointer enters the control
  87019. */
  87020. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  87021. /**
  87022. * Gets or sets the parent container
  87023. */
  87024. parent: BABYLON.Nullable<Container3D>;
  87025. private _behaviors;
  87026. /**
  87027. * Gets the list of attached behaviors
  87028. * @see https://doc.babylonjs.com/features/behaviour
  87029. */
  87030. get behaviors(): BABYLON.Behavior<Control3D>[];
  87031. /**
  87032. * Attach a behavior to the control
  87033. * @see https://doc.babylonjs.com/features/behaviour
  87034. * @param behavior defines the behavior to attach
  87035. * @returns the current control
  87036. */
  87037. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  87038. /**
  87039. * Remove an attached behavior
  87040. * @see https://doc.babylonjs.com/features/behaviour
  87041. * @param behavior defines the behavior to attach
  87042. * @returns the current control
  87043. */
  87044. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  87045. /**
  87046. * Gets an attached behavior by name
  87047. * @param name defines the name of the behavior to look for
  87048. * @see https://doc.babylonjs.com/features/behaviour
  87049. * @returns null if behavior was not found else the requested behavior
  87050. */
  87051. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  87052. /** Gets or sets a boolean indicating if the control is visible */
  87053. get isVisible(): boolean;
  87054. set isVisible(value: boolean);
  87055. /**
  87056. * Creates a new control
  87057. * @param name defines the control name
  87058. */
  87059. constructor(
  87060. /** Defines the control name */
  87061. name?: string | undefined);
  87062. /**
  87063. * Gets a string representing the class name
  87064. */
  87065. get typeName(): string;
  87066. /**
  87067. * Get the current class name of the control.
  87068. * @returns current class name
  87069. */
  87070. getClassName(): string;
  87071. protected _getTypeName(): string;
  87072. /**
  87073. * Gets the transform node used by this control
  87074. */
  87075. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  87076. /**
  87077. * Gets the mesh used to render this control
  87078. */
  87079. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  87080. /**
  87081. * Link the control as child of the given node
  87082. * @param node defines the node to link to. Use null to unlink the control
  87083. * @returns the current control
  87084. */
  87085. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  87086. /** @hidden **/
  87087. _prepareNode(scene: BABYLON.Scene): void;
  87088. protected _injectGUI3DMetadata(node: BABYLON.TransformNode): any;
  87089. /**
  87090. * Node creation.
  87091. * Can be overriden by children
  87092. * @param scene defines the scene where the node must be attached
  87093. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  87094. */
  87095. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  87096. /**
  87097. * Affect a material to the given mesh
  87098. * @param mesh defines the mesh which will represent the control
  87099. */
  87100. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  87101. /** @hidden */
  87102. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  87103. /** @hidden */
  87104. _onPointerEnter(target: Control3D): boolean;
  87105. /** @hidden */
  87106. _onPointerOut(target: Control3D): void;
  87107. /** @hidden */
  87108. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  87109. /** @hidden */
  87110. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  87111. /** @hidden */
  87112. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  87113. /** @hidden */
  87114. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  87115. /** @hidden */
  87116. _disposeNode(): void;
  87117. /**
  87118. * Releases all associated resources
  87119. */
  87120. dispose(): void;
  87121. }
  87122. }
  87123. declare module BABYLON.GUI {
  87124. /**
  87125. * Class used as a root to all buttons
  87126. */
  87127. export class AbstractButton3D extends Control3D {
  87128. /**
  87129. * Creates a new button
  87130. * @param name defines the control name
  87131. */
  87132. constructor(name?: string);
  87133. protected _getTypeName(): string;
  87134. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  87135. }
  87136. }
  87137. declare module BABYLON.GUI {
  87138. /**
  87139. * Abstract class used to create a container panel deployed on the surface of a volume
  87140. */
  87141. export abstract class VolumeBasedPanel extends Container3D {
  87142. private _columns;
  87143. private _rows;
  87144. private _rowThenColum;
  87145. private _orientation;
  87146. protected _cellWidth: number;
  87147. protected _cellHeight: number;
  87148. /**
  87149. * Gets or sets the distance between elements
  87150. */
  87151. margin: number;
  87152. /**
  87153. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  87154. * | Value | Type | Description |
  87155. * | ----- | ----------------------------------- | ----------- |
  87156. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  87157. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  87158. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  87159. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  87160. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  87161. */
  87162. get orientation(): number;
  87163. set orientation(value: number);
  87164. /**
  87165. * Gets or sets the number of columns requested (10 by default).
  87166. * The panel will automatically compute the number of rows based on number of child controls.
  87167. */
  87168. get columns(): BABYLON.int;
  87169. set columns(value: BABYLON.int);
  87170. /**
  87171. * Gets or sets a the number of rows requested.
  87172. * The panel will automatically compute the number of columns based on number of child controls.
  87173. */
  87174. get rows(): BABYLON.int;
  87175. set rows(value: BABYLON.int);
  87176. /**
  87177. * Creates new VolumeBasedPanel
  87178. */
  87179. constructor();
  87180. protected _arrangeChildren(): void;
  87181. /** Child classes must implement this function to provide correct control positioning */
  87182. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  87183. /** Child classes can implement this function to provide additional processing */
  87184. protected _finalProcessing(): void;
  87185. }
  87186. }
  87187. declare module BABYLON.GUI {
  87188. /**
  87189. * Class used to create a container panel deployed on the surface of a cylinder
  87190. */
  87191. export class CylinderPanel extends VolumeBasedPanel {
  87192. private _radius;
  87193. /**
  87194. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  87195. */
  87196. get radius(): BABYLON.float;
  87197. set radius(value: BABYLON.float);
  87198. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  87199. private _cylindricalMapping;
  87200. }
  87201. }
  87202. declare module BABYLON.GUI {
  87203. /** @hidden */
  87204. export var fluentVertexShader: {
  87205. name: string;
  87206. shader: string;
  87207. };
  87208. }
  87209. declare module BABYLON.GUI {
  87210. /** @hidden */
  87211. export var fluentPixelShader: {
  87212. name: string;
  87213. shader: string;
  87214. };
  87215. }
  87216. declare module BABYLON.GUI {
  87217. /** @hidden */
  87218. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  87219. INNERGLOW: boolean;
  87220. BORDER: boolean;
  87221. HOVERLIGHT: boolean;
  87222. TEXTURE: boolean;
  87223. constructor();
  87224. }
  87225. /**
  87226. * Class used to render controls with fluent desgin
  87227. */
  87228. export class FluentMaterial extends BABYLON.PushMaterial {
  87229. /**
  87230. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  87231. */
  87232. innerGlowColorIntensity: number;
  87233. /**
  87234. * Gets or sets the inner glow color (white by default)
  87235. */
  87236. innerGlowColor: BABYLON.Color3;
  87237. /**
  87238. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  87239. */
  87240. albedoColor: BABYLON.Color3;
  87241. /**
  87242. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  87243. */
  87244. renderBorders: boolean;
  87245. /**
  87246. * Gets or sets border width (default is 0.5)
  87247. */
  87248. borderWidth: number;
  87249. /**
  87250. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  87251. */
  87252. edgeSmoothingValue: number;
  87253. /**
  87254. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  87255. */
  87256. borderMinValue: number;
  87257. /**
  87258. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  87259. */
  87260. renderHoverLight: boolean;
  87261. /**
  87262. * Gets or sets the radius used to render the hover light (default is 1.0)
  87263. */
  87264. hoverRadius: number;
  87265. /**
  87266. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  87267. */
  87268. hoverColor: BABYLON.Color4;
  87269. /**
  87270. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  87271. */
  87272. hoverPosition: BABYLON.Vector3;
  87273. private _albedoTexture;
  87274. /** Gets or sets the texture to use for albedo color */
  87275. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  87276. /**
  87277. * Creates a new Fluent material
  87278. * @param name defines the name of the material
  87279. * @param scene defines the hosting scene
  87280. */
  87281. constructor(name: string, scene: BABYLON.Scene);
  87282. needAlphaBlending(): boolean;
  87283. needAlphaTesting(): boolean;
  87284. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87285. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87286. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87287. getActiveTextures(): BABYLON.BaseTexture[];
  87288. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87289. dispose(forceDisposeEffect?: boolean): void;
  87290. clone(name: string): FluentMaterial;
  87291. serialize(): any;
  87292. getClassName(): string;
  87293. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  87294. }
  87295. }
  87296. declare module BABYLON.GUI {
  87297. /**
  87298. * Class used to create a holographic button in 3D
  87299. */
  87300. export class HolographicButton extends Button3D {
  87301. private _backPlate;
  87302. private _textPlate;
  87303. private _frontPlate;
  87304. private _text;
  87305. private _imageUrl;
  87306. private _shareMaterials;
  87307. private _frontMaterial;
  87308. private _backMaterial;
  87309. private _plateMaterial;
  87310. private _pickedPointObserver;
  87311. private _tooltipFade;
  87312. private _tooltipTextBlock;
  87313. private _tooltipTexture;
  87314. private _tooltipMesh;
  87315. private _tooltipHoverObserver;
  87316. private _tooltipOutObserver;
  87317. private _disposeTooltip;
  87318. /**
  87319. * Rendering ground id of all the mesh in the button
  87320. */
  87321. set renderingGroupId(id: number);
  87322. get renderingGroupId(): number;
  87323. /**
  87324. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  87325. */
  87326. set tooltipText(text: BABYLON.Nullable<string>);
  87327. get tooltipText(): BABYLON.Nullable<string>;
  87328. /**
  87329. * Gets or sets text for the button
  87330. */
  87331. get text(): string;
  87332. set text(value: string);
  87333. /**
  87334. * Gets or sets the image url for the button
  87335. */
  87336. get imageUrl(): string;
  87337. set imageUrl(value: string);
  87338. /**
  87339. * Gets the back material used by this button
  87340. */
  87341. get backMaterial(): FluentMaterial;
  87342. /**
  87343. * Gets the front material used by this button
  87344. */
  87345. get frontMaterial(): FluentMaterial;
  87346. /**
  87347. * Gets the plate material used by this button
  87348. */
  87349. get plateMaterial(): BABYLON.StandardMaterial;
  87350. /**
  87351. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  87352. */
  87353. get shareMaterials(): boolean;
  87354. /**
  87355. * Creates a new button
  87356. * @param name defines the control name
  87357. */
  87358. constructor(name?: string, shareMaterials?: boolean);
  87359. protected _getTypeName(): string;
  87360. private _rebuildContent;
  87361. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  87362. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  87363. private _createBackMaterial;
  87364. private _createFrontMaterial;
  87365. private _createPlateMaterial;
  87366. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  87367. /**
  87368. * Releases all associated resources
  87369. */
  87370. dispose(): void;
  87371. }
  87372. }
  87373. declare module BABYLON.GUI {
  87374. /**
  87375. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  87376. */
  87377. export class MeshButton3D extends Button3D {
  87378. /** @hidden */
  87379. protected _currentMesh: BABYLON.Mesh;
  87380. /**
  87381. * Creates a new 3D button based on a mesh
  87382. * @param mesh mesh to become a 3D button
  87383. * @param name defines the control name
  87384. */
  87385. constructor(mesh: BABYLON.Mesh, name?: string);
  87386. protected _getTypeName(): string;
  87387. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  87388. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  87389. }
  87390. }
  87391. declare module BABYLON.GUI {
  87392. /**
  87393. * Class used to create a container panel deployed on the surface of a plane
  87394. */
  87395. export class PlanePanel extends VolumeBasedPanel {
  87396. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  87397. }
  87398. }
  87399. declare module BABYLON.GUI {
  87400. /**
  87401. * Class used to create a container panel where items get randomized planar mapping
  87402. */
  87403. export class ScatterPanel extends VolumeBasedPanel {
  87404. private _iteration;
  87405. /**
  87406. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  87407. */
  87408. get iteration(): BABYLON.float;
  87409. set iteration(value: BABYLON.float);
  87410. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  87411. private _scatterMapping;
  87412. protected _finalProcessing(): void;
  87413. }
  87414. }
  87415. declare module BABYLON.GUI {
  87416. /**
  87417. * Class used to create a container panel deployed on the surface of a sphere
  87418. */
  87419. export class SpherePanel extends VolumeBasedPanel {
  87420. private _radius;
  87421. /**
  87422. * Gets or sets the radius of the sphere where to project controls (5 by default)
  87423. */
  87424. get radius(): BABYLON.float;
  87425. set radius(value: BABYLON.float);
  87426. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  87427. private _sphericalMapping;
  87428. }
  87429. }
  87430. declare module BABYLON.GUI {
  87431. /**
  87432. * Class used to create a stack panel in 3D on XY plane
  87433. */
  87434. export class StackPanel3D extends Container3D {
  87435. private _isVertical;
  87436. /**
  87437. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  87438. */
  87439. get isVertical(): boolean;
  87440. set isVertical(value: boolean);
  87441. /**
  87442. * Gets or sets the distance between elements
  87443. */
  87444. margin: number;
  87445. /**
  87446. * Creates new StackPanel
  87447. * @param isVertical
  87448. */
  87449. constructor(isVertical?: boolean);
  87450. protected _arrangeChildren(): void;
  87451. }
  87452. }
  87453. declare module BABYLON.GUI {
  87454. /**
  87455. * Class used to create an interactable object. It's a touchable 3D button using a mesh coming from the current scene
  87456. */
  87457. export class TouchMeshButton3D extends TouchButton3D {
  87458. /** @hidden */
  87459. protected _currentMesh: BABYLON.Mesh;
  87460. /**
  87461. * Creates a new 3D button based on a mesh
  87462. * @param mesh mesh to become a 3D button
  87463. * @param collisionMesh mesh to track collisions with
  87464. * @param name defines the control name
  87465. */
  87466. constructor(mesh: BABYLON.Mesh, options: {
  87467. collisionMesh: BABYLON.Mesh;
  87468. useDynamicMesh?: boolean;
  87469. }, name?: string);
  87470. protected _getTypeName(): string;
  87471. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  87472. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  87473. }
  87474. }
  87475. declare module BABYLON.GUI {
  87476. /**
  87477. * Class used to create a holographic button in 3D
  87478. */
  87479. export class TouchHolographicButton extends TouchButton3D {
  87480. private _backPlate;
  87481. private _textPlate;
  87482. private _frontPlate;
  87483. private _text;
  87484. private _imageUrl;
  87485. private _shareMaterials;
  87486. private _frontMaterial;
  87487. private _backMaterial;
  87488. private _plateMaterial;
  87489. private _pickedPointObserver;
  87490. private _tooltipFade;
  87491. private _tooltipTextBlock;
  87492. private _tooltipTexture;
  87493. private _tooltipMesh;
  87494. private _tooltipHoverObserver;
  87495. private _tooltipOutObserver;
  87496. private _disposeTooltip;
  87497. /**
  87498. * Rendering ground id of all the mesh in the button
  87499. */
  87500. set renderingGroupId(id: number);
  87501. get renderingGroupId(): number;
  87502. /**
  87503. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  87504. */
  87505. set tooltipText(text: BABYLON.Nullable<string>);
  87506. get tooltipText(): BABYLON.Nullable<string>;
  87507. /**
  87508. * Gets or sets text for the button
  87509. */
  87510. get text(): string;
  87511. set text(value: string);
  87512. /**
  87513. * Gets or sets the image url for the button
  87514. */
  87515. get imageUrl(): string;
  87516. set imageUrl(value: string);
  87517. /**
  87518. * Gets the back material used by this button
  87519. */
  87520. get backMaterial(): FluentMaterial;
  87521. /**
  87522. * Gets the front material used by this button
  87523. */
  87524. get frontMaterial(): FluentMaterial;
  87525. /**
  87526. * Gets the plate material used by this button
  87527. */
  87528. get plateMaterial(): BABYLON.StandardMaterial;
  87529. /**
  87530. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  87531. */
  87532. get shareMaterials(): boolean;
  87533. /**
  87534. * Creates a new button
  87535. * @param name defines the control name
  87536. */
  87537. constructor(name?: string, shareMaterials?: boolean);
  87538. protected _getTypeName(): string;
  87539. private _rebuildContent;
  87540. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  87541. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  87542. private _createBackMaterial;
  87543. private _createFrontMaterial;
  87544. private _createPlateMaterial;
  87545. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  87546. /**
  87547. * Releases all associated resources
  87548. */
  87549. dispose(): void;
  87550. }
  87551. }
  87552. declare module BABYLON {
  87553. /**
  87554. * Configuration for glTF validation
  87555. */
  87556. export interface IGLTFValidationConfiguration {
  87557. /**
  87558. * The url of the glTF validator.
  87559. */
  87560. url: string;
  87561. }
  87562. /**
  87563. * glTF validation
  87564. */
  87565. export class GLTFValidation {
  87566. /**
  87567. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  87568. */
  87569. static Configuration: IGLTFValidationConfiguration;
  87570. private static _LoadScriptPromise;
  87571. /**
  87572. * Validate a glTF asset using the glTF-Validator.
  87573. * @param data The JSON of a glTF or the array buffer of a binary glTF
  87574. * @param rootUrl The root url for the glTF
  87575. * @param fileName The file name for the glTF
  87576. * @param getExternalResource The callback to get external resources for the glTF validator
  87577. * @returns A promise that resolves with the glTF validation results once complete
  87578. */
  87579. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  87580. }
  87581. }
  87582. declare module BABYLON {
  87583. /**
  87584. * Mode that determines the coordinate system to use.
  87585. */
  87586. export enum GLTFLoaderCoordinateSystemMode {
  87587. /**
  87588. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  87589. */
  87590. AUTO = 0,
  87591. /**
  87592. * Sets the useRightHandedSystem flag on the scene.
  87593. */
  87594. FORCE_RIGHT_HANDED = 1
  87595. }
  87596. /**
  87597. * Mode that determines what animations will start.
  87598. */
  87599. export enum GLTFLoaderAnimationStartMode {
  87600. /**
  87601. * No animation will start.
  87602. */
  87603. NONE = 0,
  87604. /**
  87605. * The first animation will start.
  87606. */
  87607. FIRST = 1,
  87608. /**
  87609. * All animations will start.
  87610. */
  87611. ALL = 2
  87612. }
  87613. /**
  87614. * Interface that contains the data for the glTF asset.
  87615. */
  87616. export interface IGLTFLoaderData {
  87617. /**
  87618. * The object that represents the glTF JSON.
  87619. */
  87620. json: Object;
  87621. /**
  87622. * The BIN chunk of a binary glTF.
  87623. */
  87624. bin: Nullable<IDataBuffer>;
  87625. }
  87626. /**
  87627. * Interface for extending the loader.
  87628. */
  87629. export interface IGLTFLoaderExtension {
  87630. /**
  87631. * The name of this extension.
  87632. */
  87633. readonly name: string;
  87634. /**
  87635. * Defines whether this extension is enabled.
  87636. */
  87637. enabled: boolean;
  87638. /**
  87639. * Defines the order of this extension.
  87640. * The loader sorts the extensions using these values when loading.
  87641. */
  87642. order?: number;
  87643. }
  87644. /**
  87645. * Loader state.
  87646. */
  87647. export enum GLTFLoaderState {
  87648. /**
  87649. * The asset is loading.
  87650. */
  87651. LOADING = 0,
  87652. /**
  87653. * The asset is ready for rendering.
  87654. */
  87655. READY = 1,
  87656. /**
  87657. * The asset is completely loaded.
  87658. */
  87659. COMPLETE = 2
  87660. }
  87661. /** @hidden */
  87662. export interface IGLTFLoader extends IDisposable {
  87663. readonly state: Nullable<GLTFLoaderState>;
  87664. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<ISceneLoaderAsyncResult>;
  87665. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  87666. }
  87667. /**
  87668. * File loader for loading glTF files into a scene.
  87669. */
  87670. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  87671. /** @hidden */
  87672. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  87673. /** @hidden */
  87674. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  87675. /**
  87676. * Raised when the asset has been parsed
  87677. */
  87678. onParsedObservable: Observable<IGLTFLoaderData>;
  87679. private _onParsedObserver;
  87680. /**
  87681. * Raised when the asset has been parsed
  87682. */
  87683. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  87684. /**
  87685. * 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.
  87686. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  87687. * Defaults to true.
  87688. * @hidden
  87689. */
  87690. static IncrementalLoading: boolean;
  87691. /**
  87692. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  87693. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  87694. * @hidden
  87695. */
  87696. static HomogeneousCoordinates: boolean;
  87697. /**
  87698. * The coordinate system mode. Defaults to AUTO.
  87699. */
  87700. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  87701. /**
  87702. * The animation start mode. Defaults to FIRST.
  87703. */
  87704. animationStartMode: GLTFLoaderAnimationStartMode;
  87705. /**
  87706. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  87707. */
  87708. compileMaterials: boolean;
  87709. /**
  87710. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  87711. */
  87712. useClipPlane: boolean;
  87713. /**
  87714. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  87715. */
  87716. compileShadowGenerators: boolean;
  87717. /**
  87718. * Defines if the Alpha blended materials are only applied as coverage.
  87719. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  87720. * If true, no extra effects are applied to transparent pixels.
  87721. */
  87722. transparencyAsCoverage: boolean;
  87723. /**
  87724. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  87725. * Enabling will disable offline support and glTF validator.
  87726. * Defaults to false.
  87727. */
  87728. useRangeRequests: boolean;
  87729. /**
  87730. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  87731. */
  87732. createInstances: boolean;
  87733. /**
  87734. * 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.
  87735. */
  87736. alwaysComputeBoundingBox: boolean;
  87737. /**
  87738. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  87739. */
  87740. loadAllMaterials: boolean;
  87741. /**
  87742. * Function called before loading a url referenced by the asset.
  87743. */
  87744. preprocessUrlAsync: (url: string) => Promise<string>;
  87745. /**
  87746. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  87747. * 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, ...)
  87748. */
  87749. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  87750. private _onMeshLoadedObserver;
  87751. /**
  87752. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  87753. * 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, ...)
  87754. */
  87755. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  87756. /**
  87757. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  87758. */
  87759. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  87760. private _onTextureLoadedObserver;
  87761. /**
  87762. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  87763. */
  87764. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  87765. /**
  87766. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  87767. */
  87768. readonly onMaterialLoadedObservable: Observable<Material>;
  87769. private _onMaterialLoadedObserver;
  87770. /**
  87771. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  87772. */
  87773. set onMaterialLoaded(callback: (material: Material) => void);
  87774. /**
  87775. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  87776. */
  87777. readonly onCameraLoadedObservable: Observable<Camera>;
  87778. private _onCameraLoadedObserver;
  87779. /**
  87780. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  87781. */
  87782. set onCameraLoaded(callback: (camera: Camera) => void);
  87783. /**
  87784. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  87785. * For assets with LODs, raised when all of the LODs are complete.
  87786. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  87787. */
  87788. readonly onCompleteObservable: Observable<void>;
  87789. private _onCompleteObserver;
  87790. /**
  87791. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  87792. * For assets with LODs, raised when all of the LODs are complete.
  87793. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  87794. */
  87795. set onComplete(callback: () => void);
  87796. /**
  87797. * Observable raised when an error occurs.
  87798. */
  87799. readonly onErrorObservable: Observable<any>;
  87800. private _onErrorObserver;
  87801. /**
  87802. * Callback raised when an error occurs.
  87803. */
  87804. set onError(callback: (reason: any) => void);
  87805. /**
  87806. * Observable raised after the loader is disposed.
  87807. */
  87808. readonly onDisposeObservable: Observable<void>;
  87809. private _onDisposeObserver;
  87810. /**
  87811. * Callback raised after the loader is disposed.
  87812. */
  87813. set onDispose(callback: () => void);
  87814. /**
  87815. * Observable raised after a loader extension is created.
  87816. * Set additional options for a loader extension in this event.
  87817. */
  87818. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  87819. private _onExtensionLoadedObserver;
  87820. /**
  87821. * Callback raised after a loader extension is created.
  87822. */
  87823. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  87824. /**
  87825. * Defines if the loader logging is enabled.
  87826. */
  87827. get loggingEnabled(): boolean;
  87828. set loggingEnabled(value: boolean);
  87829. /**
  87830. * Defines if the loader should capture performance counters.
  87831. */
  87832. get capturePerformanceCounters(): boolean;
  87833. set capturePerformanceCounters(value: boolean);
  87834. /**
  87835. * Defines if the loader should validate the asset.
  87836. */
  87837. validate: boolean;
  87838. /**
  87839. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  87840. */
  87841. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  87842. private _onValidatedObserver;
  87843. /**
  87844. * Callback raised after a loader extension is created.
  87845. */
  87846. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  87847. private _loader;
  87848. private _progressCallback?;
  87849. private _requests;
  87850. private static magicBase64Encoded;
  87851. /**
  87852. * Name of the loader ("gltf")
  87853. */
  87854. name: string;
  87855. /** @hidden */
  87856. extensions: ISceneLoaderPluginExtensions;
  87857. /**
  87858. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  87859. */
  87860. dispose(): void;
  87861. /** @hidden */
  87862. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  87863. /** @hidden */
  87864. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  87865. /** @hidden */
  87866. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  87867. /** @hidden */
  87868. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  87869. /** @hidden */
  87870. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  87871. /** @hidden */
  87872. canDirectLoad(data: string): boolean;
  87873. /** @hidden */
  87874. directLoad(scene: Scene, data: string): Promise<any>;
  87875. /**
  87876. * The callback that allows custom handling of the root url based on the response url.
  87877. * @param rootUrl the original root url
  87878. * @param responseURL the response url if available
  87879. * @returns the new root url
  87880. */
  87881. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  87882. /** @hidden */
  87883. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  87884. /**
  87885. * The loader state or null if the loader is not active.
  87886. */
  87887. get loaderState(): Nullable<GLTFLoaderState>;
  87888. /**
  87889. * Returns a promise that resolves when the asset is completely loaded.
  87890. * @returns a promise that resolves when the asset is completely loaded.
  87891. */
  87892. whenCompleteAsync(): Promise<void>;
  87893. /** @hidden */
  87894. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  87895. /** @hidden */
  87896. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  87897. private _onProgress;
  87898. private _validate;
  87899. private _getLoader;
  87900. private _parseJson;
  87901. private _unpackBinaryAsync;
  87902. private _unpackBinaryV1Async;
  87903. private _unpackBinaryV2Async;
  87904. private static _parseVersion;
  87905. private static _compareVersion;
  87906. private static readonly _logSpaces;
  87907. private _logIndentLevel;
  87908. private _loggingEnabled;
  87909. /** @hidden */
  87910. _log: (message: string) => void;
  87911. /** @hidden */
  87912. _logOpen(message: string): void;
  87913. /** @hidden */
  87914. _logClose(): void;
  87915. private _logEnabled;
  87916. private _logDisabled;
  87917. private _capturePerformanceCounters;
  87918. /** @hidden */
  87919. _startPerformanceCounter: (counterName: string) => void;
  87920. /** @hidden */
  87921. _endPerformanceCounter: (counterName: string) => void;
  87922. private _startPerformanceCounterEnabled;
  87923. private _startPerformanceCounterDisabled;
  87924. private _endPerformanceCounterEnabled;
  87925. private _endPerformanceCounterDisabled;
  87926. }
  87927. }
  87928. declare module BABYLON.GLTF1 {
  87929. /**
  87930. * Enums
  87931. * @hidden
  87932. */
  87933. export enum EComponentType {
  87934. BYTE = 5120,
  87935. UNSIGNED_BYTE = 5121,
  87936. SHORT = 5122,
  87937. UNSIGNED_SHORT = 5123,
  87938. FLOAT = 5126
  87939. }
  87940. /** @hidden */
  87941. export enum EShaderType {
  87942. FRAGMENT = 35632,
  87943. VERTEX = 35633
  87944. }
  87945. /** @hidden */
  87946. export enum EParameterType {
  87947. BYTE = 5120,
  87948. UNSIGNED_BYTE = 5121,
  87949. SHORT = 5122,
  87950. UNSIGNED_SHORT = 5123,
  87951. INT = 5124,
  87952. UNSIGNED_INT = 5125,
  87953. FLOAT = 5126,
  87954. FLOAT_VEC2 = 35664,
  87955. FLOAT_VEC3 = 35665,
  87956. FLOAT_VEC4 = 35666,
  87957. INT_VEC2 = 35667,
  87958. INT_VEC3 = 35668,
  87959. INT_VEC4 = 35669,
  87960. BOOL = 35670,
  87961. BOOL_VEC2 = 35671,
  87962. BOOL_VEC3 = 35672,
  87963. BOOL_VEC4 = 35673,
  87964. FLOAT_MAT2 = 35674,
  87965. FLOAT_MAT3 = 35675,
  87966. FLOAT_MAT4 = 35676,
  87967. SAMPLER_2D = 35678
  87968. }
  87969. /** @hidden */
  87970. export enum ETextureWrapMode {
  87971. CLAMP_TO_EDGE = 33071,
  87972. MIRRORED_REPEAT = 33648,
  87973. REPEAT = 10497
  87974. }
  87975. /** @hidden */
  87976. export enum ETextureFilterType {
  87977. NEAREST = 9728,
  87978. LINEAR = 9728,
  87979. NEAREST_MIPMAP_NEAREST = 9984,
  87980. LINEAR_MIPMAP_NEAREST = 9985,
  87981. NEAREST_MIPMAP_LINEAR = 9986,
  87982. LINEAR_MIPMAP_LINEAR = 9987
  87983. }
  87984. /** @hidden */
  87985. export enum ETextureFormat {
  87986. ALPHA = 6406,
  87987. RGB = 6407,
  87988. RGBA = 6408,
  87989. LUMINANCE = 6409,
  87990. LUMINANCE_ALPHA = 6410
  87991. }
  87992. /** @hidden */
  87993. export enum ECullingType {
  87994. FRONT = 1028,
  87995. BACK = 1029,
  87996. FRONT_AND_BACK = 1032
  87997. }
  87998. /** @hidden */
  87999. export enum EBlendingFunction {
  88000. ZERO = 0,
  88001. ONE = 1,
  88002. SRC_COLOR = 768,
  88003. ONE_MINUS_SRC_COLOR = 769,
  88004. DST_COLOR = 774,
  88005. ONE_MINUS_DST_COLOR = 775,
  88006. SRC_ALPHA = 770,
  88007. ONE_MINUS_SRC_ALPHA = 771,
  88008. DST_ALPHA = 772,
  88009. ONE_MINUS_DST_ALPHA = 773,
  88010. CONSTANT_COLOR = 32769,
  88011. ONE_MINUS_CONSTANT_COLOR = 32770,
  88012. CONSTANT_ALPHA = 32771,
  88013. ONE_MINUS_CONSTANT_ALPHA = 32772,
  88014. SRC_ALPHA_SATURATE = 776
  88015. }
  88016. /** @hidden */
  88017. export interface IGLTFProperty {
  88018. extensions?: {
  88019. [key: string]: any;
  88020. };
  88021. extras?: Object;
  88022. }
  88023. /** @hidden */
  88024. export interface IGLTFChildRootProperty extends IGLTFProperty {
  88025. name?: string;
  88026. }
  88027. /** @hidden */
  88028. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  88029. bufferView: string;
  88030. byteOffset: number;
  88031. byteStride: number;
  88032. count: number;
  88033. type: string;
  88034. componentType: EComponentType;
  88035. max?: number[];
  88036. min?: number[];
  88037. name?: string;
  88038. }
  88039. /** @hidden */
  88040. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  88041. buffer: string;
  88042. byteOffset: number;
  88043. byteLength: number;
  88044. byteStride: number;
  88045. target?: number;
  88046. }
  88047. /** @hidden */
  88048. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  88049. uri: string;
  88050. byteLength?: number;
  88051. type?: string;
  88052. }
  88053. /** @hidden */
  88054. export interface IGLTFShader extends IGLTFChildRootProperty {
  88055. uri: string;
  88056. type: EShaderType;
  88057. }
  88058. /** @hidden */
  88059. export interface IGLTFProgram extends IGLTFChildRootProperty {
  88060. attributes: string[];
  88061. fragmentShader: string;
  88062. vertexShader: string;
  88063. }
  88064. /** @hidden */
  88065. export interface IGLTFTechniqueParameter {
  88066. type: number;
  88067. count?: number;
  88068. semantic?: string;
  88069. node?: string;
  88070. value?: number | boolean | string | Array<any>;
  88071. source?: string;
  88072. babylonValue?: any;
  88073. }
  88074. /** @hidden */
  88075. export interface IGLTFTechniqueCommonProfile {
  88076. lightingModel: string;
  88077. texcoordBindings: Object;
  88078. parameters?: Array<any>;
  88079. }
  88080. /** @hidden */
  88081. export interface IGLTFTechniqueStatesFunctions {
  88082. blendColor?: number[];
  88083. blendEquationSeparate?: number[];
  88084. blendFuncSeparate?: number[];
  88085. colorMask: boolean[];
  88086. cullFace: number[];
  88087. }
  88088. /** @hidden */
  88089. export interface IGLTFTechniqueStates {
  88090. enable: number[];
  88091. functions: IGLTFTechniqueStatesFunctions;
  88092. }
  88093. /** @hidden */
  88094. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  88095. parameters: {
  88096. [key: string]: IGLTFTechniqueParameter;
  88097. };
  88098. program: string;
  88099. attributes: {
  88100. [key: string]: string;
  88101. };
  88102. uniforms: {
  88103. [key: string]: string;
  88104. };
  88105. states: IGLTFTechniqueStates;
  88106. }
  88107. /** @hidden */
  88108. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  88109. technique?: string;
  88110. values: string[];
  88111. }
  88112. /** @hidden */
  88113. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  88114. attributes: {
  88115. [key: string]: string;
  88116. };
  88117. indices: string;
  88118. material: string;
  88119. mode?: number;
  88120. }
  88121. /** @hidden */
  88122. export interface IGLTFMesh extends IGLTFChildRootProperty {
  88123. primitives: IGLTFMeshPrimitive[];
  88124. }
  88125. /** @hidden */
  88126. export interface IGLTFImage extends IGLTFChildRootProperty {
  88127. uri: string;
  88128. }
  88129. /** @hidden */
  88130. export interface IGLTFSampler extends IGLTFChildRootProperty {
  88131. magFilter?: number;
  88132. minFilter?: number;
  88133. wrapS?: number;
  88134. wrapT?: number;
  88135. }
  88136. /** @hidden */
  88137. export interface IGLTFTexture extends IGLTFChildRootProperty {
  88138. sampler: string;
  88139. source: string;
  88140. format?: ETextureFormat;
  88141. internalFormat?: ETextureFormat;
  88142. target?: number;
  88143. type?: number;
  88144. babylonTexture?: Texture;
  88145. }
  88146. /** @hidden */
  88147. export interface IGLTFAmbienLight {
  88148. color?: number[];
  88149. }
  88150. /** @hidden */
  88151. export interface IGLTFDirectionalLight {
  88152. color?: number[];
  88153. }
  88154. /** @hidden */
  88155. export interface IGLTFPointLight {
  88156. color?: number[];
  88157. constantAttenuation?: number;
  88158. linearAttenuation?: number;
  88159. quadraticAttenuation?: number;
  88160. }
  88161. /** @hidden */
  88162. export interface IGLTFSpotLight {
  88163. color?: number[];
  88164. constantAttenuation?: number;
  88165. fallOfAngle?: number;
  88166. fallOffExponent?: number;
  88167. linearAttenuation?: number;
  88168. quadraticAttenuation?: number;
  88169. }
  88170. /** @hidden */
  88171. export interface IGLTFLight extends IGLTFChildRootProperty {
  88172. type: string;
  88173. }
  88174. /** @hidden */
  88175. export interface IGLTFCameraOrthographic {
  88176. xmag: number;
  88177. ymag: number;
  88178. zfar: number;
  88179. znear: number;
  88180. }
  88181. /** @hidden */
  88182. export interface IGLTFCameraPerspective {
  88183. aspectRatio: number;
  88184. yfov: number;
  88185. zfar: number;
  88186. znear: number;
  88187. }
  88188. /** @hidden */
  88189. export interface IGLTFCamera extends IGLTFChildRootProperty {
  88190. type: string;
  88191. }
  88192. /** @hidden */
  88193. export interface IGLTFAnimationChannelTarget {
  88194. id: string;
  88195. path: string;
  88196. }
  88197. /** @hidden */
  88198. export interface IGLTFAnimationChannel {
  88199. sampler: string;
  88200. target: IGLTFAnimationChannelTarget;
  88201. }
  88202. /** @hidden */
  88203. export interface IGLTFAnimationSampler {
  88204. input: string;
  88205. output: string;
  88206. interpolation?: string;
  88207. }
  88208. /** @hidden */
  88209. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  88210. channels?: IGLTFAnimationChannel[];
  88211. parameters?: {
  88212. [key: string]: string;
  88213. };
  88214. samplers?: {
  88215. [key: string]: IGLTFAnimationSampler;
  88216. };
  88217. }
  88218. /** @hidden */
  88219. export interface IGLTFNodeInstanceSkin {
  88220. skeletons: string[];
  88221. skin: string;
  88222. meshes: string[];
  88223. }
  88224. /** @hidden */
  88225. export interface IGLTFSkins extends IGLTFChildRootProperty {
  88226. bindShapeMatrix: number[];
  88227. inverseBindMatrices: string;
  88228. jointNames: string[];
  88229. babylonSkeleton?: Skeleton;
  88230. }
  88231. /** @hidden */
  88232. export interface IGLTFNode extends IGLTFChildRootProperty {
  88233. camera?: string;
  88234. children: string[];
  88235. skin?: string;
  88236. jointName?: string;
  88237. light?: string;
  88238. matrix: number[];
  88239. mesh?: string;
  88240. meshes?: string[];
  88241. rotation?: number[];
  88242. scale?: number[];
  88243. translation?: number[];
  88244. babylonNode?: Node;
  88245. }
  88246. /** @hidden */
  88247. export interface IGLTFScene extends IGLTFChildRootProperty {
  88248. nodes: string[];
  88249. }
  88250. /** @hidden */
  88251. export interface IGLTFRuntime {
  88252. extensions: {
  88253. [key: string]: any;
  88254. };
  88255. accessors: {
  88256. [key: string]: IGLTFAccessor;
  88257. };
  88258. buffers: {
  88259. [key: string]: IGLTFBuffer;
  88260. };
  88261. bufferViews: {
  88262. [key: string]: IGLTFBufferView;
  88263. };
  88264. meshes: {
  88265. [key: string]: IGLTFMesh;
  88266. };
  88267. lights: {
  88268. [key: string]: IGLTFLight;
  88269. };
  88270. cameras: {
  88271. [key: string]: IGLTFCamera;
  88272. };
  88273. nodes: {
  88274. [key: string]: IGLTFNode;
  88275. };
  88276. images: {
  88277. [key: string]: IGLTFImage;
  88278. };
  88279. textures: {
  88280. [key: string]: IGLTFTexture;
  88281. };
  88282. shaders: {
  88283. [key: string]: IGLTFShader;
  88284. };
  88285. programs: {
  88286. [key: string]: IGLTFProgram;
  88287. };
  88288. samplers: {
  88289. [key: string]: IGLTFSampler;
  88290. };
  88291. techniques: {
  88292. [key: string]: IGLTFTechnique;
  88293. };
  88294. materials: {
  88295. [key: string]: IGLTFMaterial;
  88296. };
  88297. animations: {
  88298. [key: string]: IGLTFAnimation;
  88299. };
  88300. skins: {
  88301. [key: string]: IGLTFSkins;
  88302. };
  88303. currentScene?: Object;
  88304. scenes: {
  88305. [key: string]: IGLTFScene;
  88306. };
  88307. extensionsUsed: string[];
  88308. extensionsRequired?: string[];
  88309. buffersCount: number;
  88310. shaderscount: number;
  88311. scene: Scene;
  88312. rootUrl: string;
  88313. loadedBufferCount: number;
  88314. loadedBufferViews: {
  88315. [name: string]: ArrayBufferView;
  88316. };
  88317. loadedShaderCount: number;
  88318. importOnlyMeshes: boolean;
  88319. importMeshesNames?: string[];
  88320. dummyNodes: Node[];
  88321. forAssetContainer: boolean;
  88322. }
  88323. /** @hidden */
  88324. export interface INodeToRoot {
  88325. bone: Bone;
  88326. node: IGLTFNode;
  88327. id: string;
  88328. }
  88329. /** @hidden */
  88330. export interface IJointNode {
  88331. node: IGLTFNode;
  88332. id: string;
  88333. }
  88334. }
  88335. declare module BABYLON.GLTF1 {
  88336. /**
  88337. * Utils functions for GLTF
  88338. * @hidden
  88339. */
  88340. export class GLTFUtils {
  88341. /**
  88342. * Sets the given "parameter" matrix
  88343. * @param scene: the Scene object
  88344. * @param source: the source node where to pick the matrix
  88345. * @param parameter: the GLTF technique parameter
  88346. * @param uniformName: the name of the shader's uniform
  88347. * @param shaderMaterial: the shader material
  88348. */
  88349. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  88350. /**
  88351. * Sets the given "parameter" matrix
  88352. * @param shaderMaterial: the shader material
  88353. * @param uniform: the name of the shader's uniform
  88354. * @param value: the value of the uniform
  88355. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  88356. */
  88357. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  88358. /**
  88359. * Returns the wrap mode of the texture
  88360. * @param mode: the mode value
  88361. */
  88362. static GetWrapMode(mode: number): number;
  88363. /**
  88364. * Returns the byte stride giving an accessor
  88365. * @param accessor: the GLTF accessor objet
  88366. */
  88367. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  88368. /**
  88369. * Returns the texture filter mode giving a mode value
  88370. * @param mode: the filter mode value
  88371. */
  88372. static GetTextureFilterMode(mode: number): ETextureFilterType;
  88373. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  88374. /**
  88375. * Returns a buffer from its accessor
  88376. * @param gltfRuntime: the GLTF runtime
  88377. * @param accessor: the GLTF accessor
  88378. */
  88379. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  88380. /**
  88381. * Decodes a buffer view into a string
  88382. * @param view: the buffer view
  88383. */
  88384. static DecodeBufferToText(view: ArrayBufferView): string;
  88385. /**
  88386. * Returns the default material of gltf. Related to
  88387. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  88388. * @param scene: the Babylon.js scene
  88389. */
  88390. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  88391. private static _DefaultMaterial;
  88392. }
  88393. }
  88394. declare module BABYLON.GLTF1 {
  88395. /**
  88396. * Implementation of the base glTF spec
  88397. * @hidden
  88398. */
  88399. export class GLTFLoaderBase {
  88400. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  88401. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  88402. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  88403. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  88404. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  88405. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  88406. }
  88407. /**
  88408. * glTF V1 Loader
  88409. * @hidden
  88410. */
  88411. export class GLTFLoader implements IGLTFLoader {
  88412. static Extensions: {
  88413. [name: string]: GLTFLoaderExtension;
  88414. };
  88415. static RegisterExtension(extension: GLTFLoaderExtension): void;
  88416. state: Nullable<GLTFLoaderState>;
  88417. dispose(): void;
  88418. private _importMeshAsync;
  88419. /**
  88420. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  88421. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  88422. * @param scene the scene the meshes should be added to
  88423. * @param forAssetContainer defines if the entities must be stored in the scene
  88424. * @param data gltf data containing information of the meshes in a loaded file
  88425. * @param rootUrl root url to load from
  88426. * @param onProgress event that fires when loading progress has occured
  88427. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  88428. */
  88429. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<ISceneLoaderAsyncResult>;
  88430. private _loadAsync;
  88431. /**
  88432. * Imports all objects from a loaded gltf file and adds them to the scene
  88433. * @param scene the scene the objects should be added to
  88434. * @param data gltf data containing information of the meshes in a loaded file
  88435. * @param rootUrl root url to load from
  88436. * @param onProgress event that fires when loading progress has occured
  88437. * @returns a promise which completes when objects have been loaded to the scene
  88438. */
  88439. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  88440. private _loadShadersAsync;
  88441. private _loadBuffersAsync;
  88442. private _createNodes;
  88443. }
  88444. /** @hidden */
  88445. export abstract class GLTFLoaderExtension {
  88446. private _name;
  88447. constructor(name: string);
  88448. get name(): string;
  88449. /**
  88450. * Defines an override for loading the runtime
  88451. * Return true to stop further extensions from loading the runtime
  88452. */
  88453. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  88454. /**
  88455. * Defines an onverride for creating gltf runtime
  88456. * Return true to stop further extensions from creating the runtime
  88457. */
  88458. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  88459. /**
  88460. * Defines an override for loading buffers
  88461. * Return true to stop further extensions from loading this buffer
  88462. */
  88463. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  88464. /**
  88465. * Defines an override for loading texture buffers
  88466. * Return true to stop further extensions from loading this texture data
  88467. */
  88468. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  88469. /**
  88470. * Defines an override for creating textures
  88471. * Return true to stop further extensions from loading this texture
  88472. */
  88473. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  88474. /**
  88475. * Defines an override for loading shader strings
  88476. * Return true to stop further extensions from loading this shader data
  88477. */
  88478. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  88479. /**
  88480. * Defines an override for loading materials
  88481. * Return true to stop further extensions from loading this material
  88482. */
  88483. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  88484. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  88485. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  88486. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  88487. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  88488. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  88489. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  88490. private static LoadTextureBufferAsync;
  88491. private static CreateTextureAsync;
  88492. private static ApplyExtensions;
  88493. }
  88494. }
  88495. declare module BABYLON.GLTF1 {
  88496. /** @hidden */
  88497. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  88498. private _bin;
  88499. constructor();
  88500. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  88501. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  88502. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  88503. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  88504. }
  88505. }
  88506. declare module BABYLON.GLTF1 {
  88507. /** @hidden */
  88508. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  88509. constructor();
  88510. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  88511. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  88512. private _loadTexture;
  88513. }
  88514. }
  88515. declare module BABYLON.GLTF2.Loader {
  88516. /**
  88517. * Loader interface with an index field.
  88518. */
  88519. export interface IArrayItem {
  88520. /**
  88521. * The index of this item in the array.
  88522. */
  88523. index: number;
  88524. }
  88525. /**
  88526. * Loader interface with additional members.
  88527. */
  88528. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  88529. /** @hidden */
  88530. _data?: Promise<ArrayBufferView>;
  88531. /** @hidden */
  88532. _babylonVertexBuffer?: Promise<VertexBuffer>;
  88533. }
  88534. /**
  88535. * Loader interface with additional members.
  88536. */
  88537. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  88538. }
  88539. /** @hidden */
  88540. export interface _IAnimationSamplerData {
  88541. input: Float32Array;
  88542. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  88543. output: Float32Array;
  88544. }
  88545. /**
  88546. * Loader interface with additional members.
  88547. */
  88548. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  88549. /** @hidden */
  88550. _data?: Promise<_IAnimationSamplerData>;
  88551. }
  88552. /**
  88553. * Loader interface with additional members.
  88554. */
  88555. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  88556. channels: IAnimationChannel[];
  88557. samplers: IAnimationSampler[];
  88558. /** @hidden */
  88559. _babylonAnimationGroup?: AnimationGroup;
  88560. }
  88561. /**
  88562. * Loader interface with additional members.
  88563. */
  88564. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  88565. /** @hidden */
  88566. _data?: Promise<ArrayBufferView>;
  88567. }
  88568. /**
  88569. * Loader interface with additional members.
  88570. */
  88571. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  88572. /** @hidden */
  88573. _data?: Promise<ArrayBufferView>;
  88574. /** @hidden */
  88575. _babylonBuffer?: Promise<Buffer>;
  88576. }
  88577. /**
  88578. * Loader interface with additional members.
  88579. */
  88580. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  88581. }
  88582. /**
  88583. * Loader interface with additional members.
  88584. */
  88585. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  88586. /** @hidden */
  88587. _data?: Promise<ArrayBufferView>;
  88588. }
  88589. /**
  88590. * Loader interface with additional members.
  88591. */
  88592. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  88593. }
  88594. /**
  88595. * Loader interface with additional members.
  88596. */
  88597. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  88598. }
  88599. /**
  88600. * Loader interface with additional members.
  88601. */
  88602. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  88603. baseColorTexture?: ITextureInfo;
  88604. metallicRoughnessTexture?: ITextureInfo;
  88605. }
  88606. /**
  88607. * Loader interface with additional members.
  88608. */
  88609. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  88610. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  88611. normalTexture?: IMaterialNormalTextureInfo;
  88612. occlusionTexture?: IMaterialOcclusionTextureInfo;
  88613. emissiveTexture?: ITextureInfo;
  88614. /** @hidden */
  88615. _data?: {
  88616. [babylonDrawMode: number]: {
  88617. babylonMaterial: Material;
  88618. babylonMeshes: AbstractMesh[];
  88619. promise: Promise<void>;
  88620. };
  88621. };
  88622. }
  88623. /**
  88624. * Loader interface with additional members.
  88625. */
  88626. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  88627. primitives: IMeshPrimitive[];
  88628. }
  88629. /**
  88630. * Loader interface with additional members.
  88631. */
  88632. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  88633. /** @hidden */
  88634. _instanceData?: {
  88635. babylonSourceMesh: Mesh;
  88636. promise: Promise<any>;
  88637. };
  88638. }
  88639. /**
  88640. * Loader interface with additional members.
  88641. */
  88642. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  88643. /**
  88644. * The parent glTF node.
  88645. */
  88646. parent?: INode;
  88647. /** @hidden */
  88648. _babylonTransformNode?: TransformNode;
  88649. /** @hidden */
  88650. _primitiveBabylonMeshes?: AbstractMesh[];
  88651. /** @hidden */
  88652. _babylonBones?: Bone[];
  88653. /** @hidden */
  88654. _numMorphTargets?: number;
  88655. }
  88656. /** @hidden */
  88657. export interface _ISamplerData {
  88658. noMipMaps: boolean;
  88659. samplingMode: number;
  88660. wrapU: number;
  88661. wrapV: number;
  88662. }
  88663. /**
  88664. * Loader interface with additional members.
  88665. */
  88666. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  88667. /** @hidden */
  88668. _data?: _ISamplerData;
  88669. }
  88670. /**
  88671. * Loader interface with additional members.
  88672. */
  88673. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  88674. }
  88675. /**
  88676. * Loader interface with additional members.
  88677. */
  88678. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  88679. /** @hidden */
  88680. _data?: {
  88681. babylonSkeleton: Skeleton;
  88682. promise: Promise<void>;
  88683. };
  88684. }
  88685. /**
  88686. * Loader interface with additional members.
  88687. */
  88688. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  88689. /** @hidden */
  88690. _textureInfo: ITextureInfo;
  88691. }
  88692. /**
  88693. * Loader interface with additional members.
  88694. */
  88695. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  88696. /** false or undefined if the texture holds color data (true if data are roughness, normal, ...) */
  88697. nonColorData?: boolean;
  88698. }
  88699. /**
  88700. * Loader interface with additional members.
  88701. */
  88702. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  88703. accessors?: IAccessor[];
  88704. animations?: IAnimation[];
  88705. buffers?: IBuffer[];
  88706. bufferViews?: IBufferView[];
  88707. cameras?: ICamera[];
  88708. images?: IImage[];
  88709. materials?: IMaterial[];
  88710. meshes?: IMesh[];
  88711. nodes?: INode[];
  88712. samplers?: ISampler[];
  88713. scenes?: IScene[];
  88714. skins?: ISkin[];
  88715. textures?: ITexture[];
  88716. }
  88717. }
  88718. declare module BABYLON.GLTF2 {
  88719. /**
  88720. * Interface for a glTF loader extension.
  88721. */
  88722. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  88723. /**
  88724. * Called after the loader state changes to LOADING.
  88725. */
  88726. onLoading?(): void;
  88727. /**
  88728. * Called after the loader state changes to READY.
  88729. */
  88730. onReady?(): void;
  88731. /**
  88732. * Define this method to modify the default behavior when loading scenes.
  88733. * @param context The context when loading the asset
  88734. * @param scene The glTF scene property
  88735. * @returns A promise that resolves when the load is complete or null if not handled
  88736. */
  88737. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  88738. /**
  88739. * Define this method to modify the default behavior when loading nodes.
  88740. * @param context The context when loading the asset
  88741. * @param node The glTF node property
  88742. * @param assign A function called synchronously after parsing the glTF properties
  88743. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  88744. */
  88745. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88746. /**
  88747. * Define this method to modify the default behavior when loading cameras.
  88748. * @param context The context when loading the asset
  88749. * @param camera The glTF camera property
  88750. * @param assign A function called synchronously after parsing the glTF properties
  88751. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  88752. */
  88753. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  88754. /**
  88755. * @hidden
  88756. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  88757. * @param context The context when loading the asset
  88758. * @param primitive The glTF mesh primitive property
  88759. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  88760. */
  88761. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  88762. /**
  88763. * @hidden
  88764. * Define this method to modify the default behavior when loading data for mesh primitives.
  88765. * @param context The context when loading the asset
  88766. * @param name The mesh name when loading the asset
  88767. * @param node The glTF node when loading the asset
  88768. * @param mesh The glTF mesh when loading the asset
  88769. * @param primitive The glTF mesh primitive property
  88770. * @param assign A function called synchronously after parsing the glTF properties
  88771. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  88772. */
  88773. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  88774. /**
  88775. * @hidden
  88776. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  88777. * @param context The context when loading the asset
  88778. * @param material The glTF material property
  88779. * @param assign A function called synchronously after parsing the glTF properties
  88780. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  88781. */
  88782. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  88783. /**
  88784. * Define this method to modify the default behavior when creating materials.
  88785. * @param context The context when loading the asset
  88786. * @param material The glTF material property
  88787. * @param babylonDrawMode The draw mode for the Babylon material
  88788. * @returns The Babylon material or null if not handled
  88789. */
  88790. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  88791. /**
  88792. * Define this method to modify the default behavior when loading material properties.
  88793. * @param context The context when loading the asset
  88794. * @param material The glTF material property
  88795. * @param babylonMaterial The Babylon material
  88796. * @returns A promise that resolves when the load is complete or null if not handled
  88797. */
  88798. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88799. /**
  88800. * Define this method to modify the default behavior when loading texture infos.
  88801. * @param context The context when loading the asset
  88802. * @param textureInfo The glTF texture info property
  88803. * @param assign A function called synchronously after parsing the glTF properties
  88804. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  88805. */
  88806. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88807. /**
  88808. * @hidden
  88809. * Define this method to modify the default behavior when loading textures.
  88810. * @param context The context when loading the asset
  88811. * @param texture The glTF texture property
  88812. * @param assign A function called synchronously after parsing the glTF properties
  88813. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  88814. */
  88815. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88816. /**
  88817. * Define this method to modify the default behavior when loading animations.
  88818. * @param context The context when loading the asset
  88819. * @param animation The glTF animation property
  88820. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  88821. */
  88822. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  88823. /**
  88824. * @hidden
  88825. * Define this method to modify the default behavior when loading skins.
  88826. * @param context The context when loading the asset
  88827. * @param node The glTF node property
  88828. * @param skin The glTF skin property
  88829. * @returns A promise that resolves when the load is complete or null if not handled
  88830. */
  88831. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  88832. /**
  88833. * @hidden
  88834. * Define this method to modify the default behavior when loading uris.
  88835. * @param context The context when loading the asset
  88836. * @param property The glTF property associated with the uri
  88837. * @param uri The uri to load
  88838. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  88839. */
  88840. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  88841. /**
  88842. * Define this method to modify the default behavior when loading buffer views.
  88843. * @param context The context when loading the asset
  88844. * @param bufferView The glTF buffer view property
  88845. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  88846. */
  88847. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  88848. /**
  88849. * Define this method to modify the default behavior when loading buffers.
  88850. * @param context The context when loading the asset
  88851. * @param buffer The glTF buffer property
  88852. * @param byteOffset The byte offset to load
  88853. * @param byteLength The byte length to load
  88854. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  88855. */
  88856. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  88857. }
  88858. }
  88859. declare module BABYLON.GLTF2 {
  88860. /**
  88861. * Helper class for working with arrays when loading the glTF asset
  88862. */
  88863. export class ArrayItem {
  88864. /**
  88865. * Gets an item from the given array.
  88866. * @param context The context when loading the asset
  88867. * @param array The array to get the item from
  88868. * @param index The index to the array
  88869. * @returns The array item
  88870. */
  88871. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  88872. /**
  88873. * Assign an `index` field to each item of the given array.
  88874. * @param array The array of items
  88875. */
  88876. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  88877. }
  88878. /**
  88879. * The glTF 2.0 loader
  88880. */
  88881. export class GLTFLoader implements IGLTFLoader {
  88882. /** @hidden */
  88883. _completePromises: Promise<any>[];
  88884. /** @hidden */
  88885. _forAssetContainer: boolean;
  88886. /** Storage */
  88887. _babylonLights: Light[];
  88888. /** @hidden */
  88889. _disableInstancedMesh: number;
  88890. private _disposed;
  88891. private _parent;
  88892. private _state;
  88893. private _extensions;
  88894. private _rootUrl;
  88895. private _fileName;
  88896. private _uniqueRootUrl;
  88897. private _gltf;
  88898. private _bin;
  88899. private _babylonScene;
  88900. private _rootBabylonMesh;
  88901. private _defaultBabylonMaterialData;
  88902. private static _RegisteredExtensions;
  88903. /**
  88904. * The default glTF sampler.
  88905. */
  88906. static readonly DefaultSampler: ISampler;
  88907. /**
  88908. * Registers a loader extension.
  88909. * @param name The name of the loader extension.
  88910. * @param factory The factory function that creates the loader extension.
  88911. */
  88912. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  88913. /**
  88914. * Unregisters a loader extension.
  88915. * @param name The name of the loader extension.
  88916. * @returns A boolean indicating whether the extension has been unregistered
  88917. */
  88918. static UnregisterExtension(name: string): boolean;
  88919. /**
  88920. * The loader state.
  88921. */
  88922. get state(): Nullable<GLTFLoaderState>;
  88923. /**
  88924. * The object that represents the glTF JSON.
  88925. */
  88926. get gltf(): IGLTF;
  88927. /**
  88928. * The BIN chunk of a binary glTF.
  88929. */
  88930. get bin(): Nullable<IDataBuffer>;
  88931. /**
  88932. * The parent file loader.
  88933. */
  88934. get parent(): GLTFFileLoader;
  88935. /**
  88936. * The Babylon scene when loading the asset.
  88937. */
  88938. get babylonScene(): Scene;
  88939. /**
  88940. * The root Babylon mesh when loading the asset.
  88941. */
  88942. get rootBabylonMesh(): Mesh;
  88943. /** @hidden */
  88944. constructor(parent: GLTFFileLoader);
  88945. /** @hidden */
  88946. dispose(): void;
  88947. /** @hidden */
  88948. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  88949. /** @hidden */
  88950. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  88951. private _loadAsync;
  88952. private _loadData;
  88953. private _setupData;
  88954. private _loadExtensions;
  88955. private _checkExtensions;
  88956. private _setState;
  88957. private _createRootNode;
  88958. /**
  88959. * Loads a glTF scene.
  88960. * @param context The context when loading the asset
  88961. * @param scene The glTF scene property
  88962. * @returns A promise that resolves when the load is complete
  88963. */
  88964. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  88965. private _forEachPrimitive;
  88966. private _getGeometries;
  88967. private _getMeshes;
  88968. private _getTransformNodes;
  88969. private _getSkeletons;
  88970. private _getAnimationGroups;
  88971. private _startAnimations;
  88972. /**
  88973. * Loads a glTF node.
  88974. * @param context The context when loading the asset
  88975. * @param node The glTF node property
  88976. * @param assign A function called synchronously after parsing the glTF properties
  88977. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  88978. */
  88979. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  88980. private _loadMeshAsync;
  88981. /**
  88982. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  88983. * @param context The context when loading the asset
  88984. * @param name The mesh name when loading the asset
  88985. * @param node The glTF node when loading the asset
  88986. * @param mesh The glTF mesh when loading the asset
  88987. * @param primitive The glTF mesh primitive property
  88988. * @param assign A function called synchronously after parsing the glTF properties
  88989. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  88990. */
  88991. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  88992. private _loadVertexDataAsync;
  88993. private _createMorphTargets;
  88994. private _loadMorphTargetsAsync;
  88995. private _loadMorphTargetVertexDataAsync;
  88996. private static _LoadTransform;
  88997. private _loadSkinAsync;
  88998. private _loadBones;
  88999. private _loadBone;
  89000. private _loadSkinInverseBindMatricesDataAsync;
  89001. private _updateBoneMatrices;
  89002. private _getNodeMatrix;
  89003. /**
  89004. * Loads a glTF camera.
  89005. * @param context The context when loading the asset
  89006. * @param camera The glTF camera property
  89007. * @param assign A function called synchronously after parsing the glTF properties
  89008. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  89009. */
  89010. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  89011. private _loadAnimationsAsync;
  89012. /**
  89013. * Loads a glTF animation.
  89014. * @param context The context when loading the asset
  89015. * @param animation The glTF animation property
  89016. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  89017. */
  89018. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  89019. /**
  89020. * @hidden Loads a glTF animation channel.
  89021. * @param context The context when loading the asset
  89022. * @param animationContext The context of the animation when loading the asset
  89023. * @param animation The glTF animation property
  89024. * @param channel The glTF animation channel property
  89025. * @param babylonAnimationGroup The babylon animation group property
  89026. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  89027. * @returns A void promise when the channel load is complete
  89028. */
  89029. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  89030. private _loadAnimationSamplerAsync;
  89031. /**
  89032. * Loads a glTF buffer.
  89033. * @param context The context when loading the asset
  89034. * @param buffer The glTF buffer property
  89035. * @param byteOffset The byte offset to use
  89036. * @param byteLength The byte length to use
  89037. * @returns A promise that resolves with the loaded data when the load is complete
  89038. */
  89039. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  89040. /**
  89041. * Loads a glTF buffer view.
  89042. * @param context The context when loading the asset
  89043. * @param bufferView The glTF buffer view property
  89044. * @returns A promise that resolves with the loaded data when the load is complete
  89045. */
  89046. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  89047. private _loadAccessorAsync;
  89048. /** @hidden */
  89049. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  89050. private _loadIndicesAccessorAsync;
  89051. private _loadVertexBufferViewAsync;
  89052. private _loadVertexAccessorAsync;
  89053. private _loadMaterialMetallicRoughnessPropertiesAsync;
  89054. /** @hidden */
  89055. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  89056. private _createDefaultMaterial;
  89057. /**
  89058. * Creates a Babylon material from a glTF material.
  89059. * @param context The context when loading the asset
  89060. * @param material The glTF material property
  89061. * @param babylonDrawMode The draw mode for the Babylon material
  89062. * @returns The Babylon material
  89063. */
  89064. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  89065. /**
  89066. * Loads properties from a glTF material into a Babylon material.
  89067. * @param context The context when loading the asset
  89068. * @param material The glTF material property
  89069. * @param babylonMaterial The Babylon material
  89070. * @returns A promise that resolves when the load is complete
  89071. */
  89072. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  89073. /**
  89074. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  89075. * @param context The context when loading the asset
  89076. * @param material The glTF material property
  89077. * @param babylonMaterial The Babylon material
  89078. * @returns A promise that resolves when the load is complete
  89079. */
  89080. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  89081. /**
  89082. * Loads the alpha properties from a glTF material into a Babylon material.
  89083. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  89084. * @param context The context when loading the asset
  89085. * @param material The glTF material property
  89086. * @param babylonMaterial The Babylon material
  89087. */
  89088. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  89089. /**
  89090. * Loads a glTF texture info.
  89091. * @param context The context when loading the asset
  89092. * @param textureInfo The glTF texture info property
  89093. * @param assign A function called synchronously after parsing the glTF properties
  89094. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  89095. */
  89096. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  89097. /** @hidden */
  89098. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  89099. /** @hidden */
  89100. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  89101. private _loadSampler;
  89102. /**
  89103. * Loads a glTF image.
  89104. * @param context The context when loading the asset
  89105. * @param image The glTF image property
  89106. * @returns A promise that resolves with the loaded data when the load is complete
  89107. */
  89108. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  89109. /**
  89110. * Loads a glTF uri.
  89111. * @param context The context when loading the asset
  89112. * @param property The glTF property associated with the uri
  89113. * @param uri The base64 or relative uri
  89114. * @returns A promise that resolves with the loaded data when the load is complete
  89115. */
  89116. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  89117. /**
  89118. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  89119. * @param babylonObject the Babylon object with metadata
  89120. * @param pointer the JSON pointer
  89121. */
  89122. static AddPointerMetadata(babylonObject: {
  89123. metadata: any;
  89124. }, pointer: string): void;
  89125. private static _GetTextureWrapMode;
  89126. private static _GetTextureSamplingMode;
  89127. private static _GetTypedArrayConstructor;
  89128. private static _GetTypedArray;
  89129. private static _GetNumComponents;
  89130. private static _ValidateUri;
  89131. /** @hidden */
  89132. static _GetDrawMode(context: string, mode: number | undefined): number;
  89133. private _compileMaterialsAsync;
  89134. private _compileShadowGeneratorsAsync;
  89135. private _forEachExtensions;
  89136. private _applyExtensions;
  89137. private _extensionsOnLoading;
  89138. private _extensionsOnReady;
  89139. private _extensionsLoadSceneAsync;
  89140. private _extensionsLoadNodeAsync;
  89141. private _extensionsLoadCameraAsync;
  89142. private _extensionsLoadVertexDataAsync;
  89143. private _extensionsLoadMeshPrimitiveAsync;
  89144. private _extensionsLoadMaterialAsync;
  89145. private _extensionsCreateMaterial;
  89146. private _extensionsLoadMaterialPropertiesAsync;
  89147. private _extensionsLoadTextureInfoAsync;
  89148. private _extensionsLoadTextureAsync;
  89149. private _extensionsLoadAnimationAsync;
  89150. private _extensionsLoadSkinAsync;
  89151. private _extensionsLoadUriAsync;
  89152. private _extensionsLoadBufferViewAsync;
  89153. private _extensionsLoadBufferAsync;
  89154. /**
  89155. * Helper method called by a loader extension to load an glTF extension.
  89156. * @param context The context when loading the asset
  89157. * @param property The glTF property to load the extension from
  89158. * @param extensionName The name of the extension to load
  89159. * @param actionAsync The action to run
  89160. * @returns The promise returned by actionAsync or null if the extension does not exist
  89161. */
  89162. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  89163. /**
  89164. * Helper method called by a loader extension to load a glTF extra.
  89165. * @param context The context when loading the asset
  89166. * @param property The glTF property to load the extra from
  89167. * @param extensionName The name of the extension to load
  89168. * @param actionAsync The action to run
  89169. * @returns The promise returned by actionAsync or null if the extra does not exist
  89170. */
  89171. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  89172. /**
  89173. * Checks for presence of an extension.
  89174. * @param name The name of the extension to check
  89175. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  89176. */
  89177. isExtensionUsed(name: string): boolean;
  89178. /**
  89179. * Increments the indentation level and logs a message.
  89180. * @param message The message to log
  89181. */
  89182. logOpen(message: string): void;
  89183. /**
  89184. * Decrements the indentation level.
  89185. */
  89186. logClose(): void;
  89187. /**
  89188. * Logs a message
  89189. * @param message The message to log
  89190. */
  89191. log(message: string): void;
  89192. /**
  89193. * Starts a performance counter.
  89194. * @param counterName The name of the performance counter
  89195. */
  89196. startPerformanceCounter(counterName: string): void;
  89197. /**
  89198. * Ends a performance counter.
  89199. * @param counterName The name of the performance counter
  89200. */
  89201. endPerformanceCounter(counterName: string): void;
  89202. }
  89203. }
  89204. declare module BABYLON.GLTF2.Loader.Extensions {
  89205. /** @hidden */
  89206. interface IEXTLightsImageBased_LightImageBased {
  89207. _babylonTexture?: BaseTexture;
  89208. _loaded?: Promise<void>;
  89209. }
  89210. /**
  89211. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  89212. */
  89213. export class EXT_lights_image_based 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. private _loader;
  89223. private _lights?;
  89224. /** @hidden */
  89225. constructor(loader: GLTFLoader);
  89226. /** @hidden */
  89227. dispose(): void;
  89228. /** @hidden */
  89229. onLoading(): void;
  89230. /** @hidden */
  89231. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  89232. private _loadLightAsync;
  89233. }
  89234. }
  89235. declare module BABYLON.GLTF2.Loader.Extensions {
  89236. /**
  89237. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  89238. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  89239. * !!! Experimental Extension Subject to Changes !!!
  89240. */
  89241. export class EXT_mesh_gpu_instancing 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. private _loader;
  89251. /** @hidden */
  89252. constructor(loader: GLTFLoader);
  89253. /** @hidden */
  89254. dispose(): void;
  89255. /** @hidden */
  89256. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  89257. }
  89258. }
  89259. declare module BABYLON.GLTF2.Loader.Extensions {
  89260. /**
  89261. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_meshopt_compression)
  89262. *
  89263. * This extension uses a WebAssembly decoder module from https://github.com/zeux/meshoptimizer/tree/master/js
  89264. */
  89265. export class EXT_meshopt_compression implements IGLTFLoaderExtension {
  89266. /**
  89267. * The name of this extension.
  89268. */
  89269. readonly name: string;
  89270. /**
  89271. * Defines whether this extension is enabled.
  89272. */
  89273. enabled: boolean;
  89274. /**
  89275. * Path to decoder module; defaults to https://preview.babylonjs.com/meshopt_decoder.js
  89276. */
  89277. static DecoderPath: string;
  89278. private _loader;
  89279. private _decoderPromise?;
  89280. /** @hidden */
  89281. constructor(loader: GLTFLoader);
  89282. /** @hidden */
  89283. dispose(): void;
  89284. /** @hidden */
  89285. loadBufferViewAsync(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  89286. }
  89287. }
  89288. declare module BABYLON.GLTF2.Loader.Extensions {
  89289. /**
  89290. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  89291. */
  89292. export class EXT_texture_webp implements IGLTFLoaderExtension {
  89293. /** The name of this extension. */
  89294. readonly name: string;
  89295. /** Defines whether this extension is enabled. */
  89296. enabled: boolean;
  89297. private _loader;
  89298. /** @hidden */
  89299. constructor(loader: GLTFLoader);
  89300. /** @hidden */
  89301. dispose(): void;
  89302. /** @hidden */
  89303. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  89304. }
  89305. }
  89306. declare module BABYLON.GLTF2.Loader.Extensions {
  89307. /**
  89308. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  89309. */
  89310. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  89311. /**
  89312. * The name of this extension.
  89313. */
  89314. readonly name: string;
  89315. /**
  89316. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  89317. */
  89318. dracoCompression?: DracoCompression;
  89319. /**
  89320. * Defines whether this extension is enabled.
  89321. */
  89322. enabled: boolean;
  89323. private _loader;
  89324. /** @hidden */
  89325. constructor(loader: GLTFLoader);
  89326. /** @hidden */
  89327. dispose(): void;
  89328. /** @hidden */
  89329. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  89330. }
  89331. }
  89332. declare module BABYLON.GLTF2.Loader.Extensions {
  89333. /**
  89334. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  89335. */
  89336. export class KHR_lights implements IGLTFLoaderExtension {
  89337. /**
  89338. * The name of this extension.
  89339. */
  89340. readonly name: string;
  89341. /**
  89342. * Defines whether this extension is enabled.
  89343. */
  89344. enabled: boolean;
  89345. private _loader;
  89346. private _lights?;
  89347. /** @hidden */
  89348. constructor(loader: GLTFLoader);
  89349. /** @hidden */
  89350. dispose(): void;
  89351. /** @hidden */
  89352. onLoading(): void;
  89353. /** @hidden */
  89354. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  89355. }
  89356. }
  89357. declare module BABYLON.GLTF2.Loader.Extensions {
  89358. /**
  89359. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  89360. */
  89361. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  89362. /**
  89363. * The name of this extension.
  89364. */
  89365. readonly name: string;
  89366. /**
  89367. * Defines whether this extension is enabled.
  89368. */
  89369. enabled: boolean;
  89370. /**
  89371. * Defines a number that determines the order the extensions are applied.
  89372. */
  89373. order: number;
  89374. private _loader;
  89375. /** @hidden */
  89376. constructor(loader: GLTFLoader);
  89377. /** @hidden */
  89378. dispose(): void;
  89379. /** @hidden */
  89380. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89381. private _loadSpecularGlossinessPropertiesAsync;
  89382. }
  89383. }
  89384. declare module BABYLON.GLTF2.Loader.Extensions {
  89385. /**
  89386. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  89387. */
  89388. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  89389. /**
  89390. * The name of this extension.
  89391. */
  89392. readonly name: string;
  89393. /**
  89394. * Defines whether this extension is enabled.
  89395. */
  89396. enabled: boolean;
  89397. /**
  89398. * Defines a number that determines the order the extensions are applied.
  89399. */
  89400. order: number;
  89401. private _loader;
  89402. /** @hidden */
  89403. constructor(loader: GLTFLoader);
  89404. /** @hidden */
  89405. dispose(): void;
  89406. /** @hidden */
  89407. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89408. private _loadUnlitPropertiesAsync;
  89409. }
  89410. }
  89411. declare module BABYLON.GLTF2.Loader.Extensions {
  89412. /**
  89413. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  89414. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  89415. */
  89416. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  89417. /**
  89418. * The name of this extension.
  89419. */
  89420. readonly name: string;
  89421. /**
  89422. * Defines whether this extension is enabled.
  89423. */
  89424. enabled: boolean;
  89425. /**
  89426. * Defines a number that determines the order the extensions are applied.
  89427. */
  89428. order: number;
  89429. private _loader;
  89430. /** @hidden */
  89431. constructor(loader: GLTFLoader);
  89432. /** @hidden */
  89433. dispose(): void;
  89434. /** @hidden */
  89435. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89436. private _loadClearCoatPropertiesAsync;
  89437. }
  89438. }
  89439. declare module BABYLON.GLTF2.Loader.Extensions {
  89440. /**
  89441. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_sheen/README.md)
  89442. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  89443. * !!! Experimental Extension Subject to Changes !!!
  89444. */
  89445. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  89446. /**
  89447. * The name of this extension.
  89448. */
  89449. readonly name: string;
  89450. /**
  89451. * Defines whether this extension is enabled.
  89452. */
  89453. enabled: boolean;
  89454. /**
  89455. * Defines a number that determines the order the extensions are applied.
  89456. */
  89457. order: number;
  89458. private _loader;
  89459. /** @hidden */
  89460. constructor(loader: GLTFLoader);
  89461. /** @hidden */
  89462. dispose(): void;
  89463. /** @hidden */
  89464. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89465. private _loadSheenPropertiesAsync;
  89466. }
  89467. }
  89468. declare module BABYLON.GLTF2.Loader.Extensions {
  89469. /**
  89470. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  89471. * !!! Experimental Extension Subject to Changes !!!
  89472. */
  89473. export class KHR_materials_specular implements IGLTFLoaderExtension {
  89474. /**
  89475. * The name of this extension.
  89476. */
  89477. readonly name: string;
  89478. /**
  89479. * Defines whether this extension is enabled.
  89480. */
  89481. enabled: boolean;
  89482. /**
  89483. * Defines a number that determines the order the extensions are applied.
  89484. */
  89485. order: number;
  89486. private _loader;
  89487. /** @hidden */
  89488. constructor(loader: GLTFLoader);
  89489. /** @hidden */
  89490. dispose(): void;
  89491. /** @hidden */
  89492. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89493. private _loadSpecularPropertiesAsync;
  89494. }
  89495. }
  89496. declare module BABYLON.GLTF2.Loader.Extensions {
  89497. /**
  89498. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  89499. * !!! Experimental Extension Subject to Changes !!!
  89500. */
  89501. export class KHR_materials_ior implements IGLTFLoaderExtension {
  89502. /**
  89503. * Default ior Value from the spec.
  89504. */
  89505. private static readonly _DEFAULT_IOR;
  89506. /**
  89507. * The name of this extension.
  89508. */
  89509. readonly name: string;
  89510. /**
  89511. * Defines whether this extension is enabled.
  89512. */
  89513. enabled: boolean;
  89514. /**
  89515. * Defines a number that determines the order the extensions are applied.
  89516. */
  89517. order: number;
  89518. private _loader;
  89519. /** @hidden */
  89520. constructor(loader: GLTFLoader);
  89521. /** @hidden */
  89522. dispose(): void;
  89523. /** @hidden */
  89524. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89525. private _loadIorPropertiesAsync;
  89526. }
  89527. }
  89528. declare module BABYLON.GLTF2.Loader.Extensions {
  89529. /**
  89530. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_variants/README.md)
  89531. */
  89532. export class KHR_materials_variants implements IGLTFLoaderExtension {
  89533. /**
  89534. * The name of this extension.
  89535. */
  89536. readonly name: string;
  89537. /**
  89538. * Defines whether this extension is enabled.
  89539. */
  89540. enabled: boolean;
  89541. private _loader;
  89542. private _variants?;
  89543. /** @hidden */
  89544. constructor(loader: GLTFLoader);
  89545. /** @hidden */
  89546. dispose(): void;
  89547. /**
  89548. * Gets the list of available variant names for this asset.
  89549. * @param rootMesh The glTF root mesh
  89550. * @returns the list of all the variant names for this model
  89551. */
  89552. static GetAvailableVariants(rootMesh: Mesh): string[];
  89553. /**
  89554. * Gets the list of available variant names for this asset.
  89555. * @param rootMesh The glTF root mesh
  89556. * @returns the list of all the variant names for this model
  89557. */
  89558. getAvailableVariants(rootMesh: Mesh): string[];
  89559. /**
  89560. * Select a variant given a variant name or a list of variant names.
  89561. * @param rootMesh The glTF root mesh
  89562. * @param variantName The variant name(s) to select.
  89563. */
  89564. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  89565. /**
  89566. * Select a variant given a variant name or a list of variant names.
  89567. * @param rootMesh The glTF root mesh
  89568. * @param variantName The variant name(s) to select.
  89569. */
  89570. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  89571. /**
  89572. * Reset back to the original before selecting a variant.
  89573. * @param rootMesh The glTF root mesh
  89574. */
  89575. static Reset(rootMesh: Mesh): void;
  89576. /**
  89577. * Reset back to the original before selecting a variant.
  89578. * @param rootMesh The glTF root mesh
  89579. */
  89580. reset(rootMesh: Mesh): void;
  89581. /**
  89582. * Gets the last selected variant name(s) or null if original.
  89583. * @param rootMesh The glTF root mesh
  89584. * @returns The selected variant name(s).
  89585. */
  89586. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  89587. /**
  89588. * Gets the last selected variant name(s) or null if original.
  89589. * @param rootMesh The glTF root mesh
  89590. * @returns The selected variant name(s).
  89591. */
  89592. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  89593. private static _GetExtensionMetadata;
  89594. /** @hidden */
  89595. onLoading(): void;
  89596. /** @hidden */
  89597. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  89598. }
  89599. }
  89600. declare module BABYLON.GLTF2.Loader.Extensions {
  89601. /**
  89602. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_transmission/README.md)
  89603. */
  89604. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  89605. /**
  89606. * The name of this extension.
  89607. */
  89608. readonly name: string;
  89609. /**
  89610. * Defines whether this extension is enabled.
  89611. */
  89612. enabled: boolean;
  89613. /**
  89614. * Defines a number that determines the order the extensions are applied.
  89615. */
  89616. order: number;
  89617. private _loader;
  89618. /** @hidden */
  89619. constructor(loader: GLTFLoader);
  89620. /** @hidden */
  89621. dispose(): void;
  89622. /** @hidden */
  89623. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89624. private _loadTransparentPropertiesAsync;
  89625. }
  89626. }
  89627. declare module BABYLON.GLTF2.Loader.Extensions {
  89628. /**
  89629. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)
  89630. * !!! Experimental Extension Subject to Changes !!!
  89631. */
  89632. export class KHR_materials_translucency implements IGLTFLoaderExtension {
  89633. /**
  89634. * The name of this extension.
  89635. */
  89636. readonly name: string;
  89637. /**
  89638. * Defines whether this extension is enabled.
  89639. */
  89640. enabled: boolean;
  89641. /**
  89642. * Defines a number that determines the order the extensions are applied.
  89643. */
  89644. order: number;
  89645. private _loader;
  89646. /** @hidden */
  89647. constructor(loader: GLTFLoader);
  89648. /** @hidden */
  89649. dispose(): void;
  89650. /** @hidden */
  89651. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89652. private _loadTranslucentPropertiesAsync;
  89653. }
  89654. }
  89655. declare module BABYLON.GLTF2.Loader.Extensions {
  89656. /**
  89657. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  89658. */
  89659. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  89660. /**
  89661. * The name of this extension.
  89662. */
  89663. readonly name: string;
  89664. /**
  89665. * Defines whether this extension is enabled.
  89666. */
  89667. enabled: boolean;
  89668. /** @hidden */
  89669. constructor(loader: GLTFLoader);
  89670. /** @hidden */
  89671. dispose(): void;
  89672. }
  89673. }
  89674. declare module BABYLON.GLTF2.Loader.Extensions {
  89675. /**
  89676. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  89677. * !!! Experimental Extension Subject to Changes !!!
  89678. */
  89679. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  89680. /** The name of this extension. */
  89681. readonly name: string;
  89682. /** Defines whether this extension is enabled. */
  89683. enabled: boolean;
  89684. private _loader;
  89685. /** @hidden */
  89686. constructor(loader: GLTFLoader);
  89687. /** @hidden */
  89688. dispose(): void;
  89689. /** @hidden */
  89690. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  89691. }
  89692. }
  89693. declare module BABYLON.GLTF2.Loader.Extensions {
  89694. /**
  89695. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  89696. */
  89697. export class KHR_texture_transform 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. /** @hidden */
  89708. constructor(loader: GLTFLoader);
  89709. /** @hidden */
  89710. dispose(): void;
  89711. /** @hidden */
  89712. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  89713. }
  89714. }
  89715. declare module BABYLON.GLTF2.Loader.Extensions {
  89716. /**
  89717. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1893)
  89718. * !!! Experimental Extension Subject to Changes !!!
  89719. */
  89720. export class KHR_xmp_json_ld implements IGLTFLoaderExtension {
  89721. /**
  89722. * The name of this extension.
  89723. */
  89724. readonly name: string;
  89725. /**
  89726. * Defines whether this extension is enabled.
  89727. */
  89728. enabled: boolean;
  89729. /**
  89730. * Defines a number that determines the order the extensions are applied.
  89731. */
  89732. order: number;
  89733. private _loader;
  89734. /** @hidden */
  89735. constructor(loader: GLTFLoader);
  89736. /** @hidden */
  89737. dispose(): void;
  89738. /**
  89739. * Called after the loader state changes to LOADING.
  89740. */
  89741. onLoading(): void;
  89742. }
  89743. }
  89744. declare module BABYLON.GLTF2.Loader.Extensions {
  89745. /**
  89746. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  89747. */
  89748. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  89749. /**
  89750. * The name of this extension.
  89751. */
  89752. readonly name: string;
  89753. /**
  89754. * Defines whether this extension is enabled.
  89755. */
  89756. enabled: boolean;
  89757. private _loader;
  89758. private _clips;
  89759. private _emitters;
  89760. /** @hidden */
  89761. constructor(loader: GLTFLoader);
  89762. /** @hidden */
  89763. dispose(): void;
  89764. /** @hidden */
  89765. onLoading(): void;
  89766. /** @hidden */
  89767. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  89768. /** @hidden */
  89769. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  89770. /** @hidden */
  89771. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  89772. private _loadClipAsync;
  89773. private _loadEmitterAsync;
  89774. private _getEventAction;
  89775. private _loadAnimationEventAsync;
  89776. }
  89777. }
  89778. declare module BABYLON.GLTF2.Loader.Extensions {
  89779. /**
  89780. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  89781. */
  89782. export class MSFT_lod implements IGLTFLoaderExtension {
  89783. /**
  89784. * The name of this extension.
  89785. */
  89786. readonly name: string;
  89787. /**
  89788. * Defines whether this extension is enabled.
  89789. */
  89790. enabled: boolean;
  89791. /**
  89792. * Defines a number that determines the order the extensions are applied.
  89793. */
  89794. order: number;
  89795. /**
  89796. * Maximum number of LODs to load, starting from the lowest LOD.
  89797. */
  89798. maxLODsToLoad: number;
  89799. /**
  89800. * Observable raised when all node LODs of one level are loaded.
  89801. * The event data is the index of the loaded LOD starting from zero.
  89802. * Dispose the loader to cancel the loading of the next level of LODs.
  89803. */
  89804. onNodeLODsLoadedObservable: Observable<number>;
  89805. /**
  89806. * Observable raised when all material LODs of one level are loaded.
  89807. * The event data is the index of the loaded LOD starting from zero.
  89808. * Dispose the loader to cancel the loading of the next level of LODs.
  89809. */
  89810. onMaterialLODsLoadedObservable: Observable<number>;
  89811. private _loader;
  89812. private _bufferLODs;
  89813. private _nodeIndexLOD;
  89814. private _nodeSignalLODs;
  89815. private _nodePromiseLODs;
  89816. private _nodeBufferLODs;
  89817. private _materialIndexLOD;
  89818. private _materialSignalLODs;
  89819. private _materialPromiseLODs;
  89820. private _materialBufferLODs;
  89821. /** @hidden */
  89822. constructor(loader: GLTFLoader);
  89823. /** @hidden */
  89824. dispose(): void;
  89825. /** @hidden */
  89826. onReady(): void;
  89827. /** @hidden */
  89828. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  89829. /** @hidden */
  89830. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  89831. /** @hidden */
  89832. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  89833. /** @hidden */
  89834. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  89835. /** @hidden */
  89836. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  89837. private _loadBufferLOD;
  89838. /**
  89839. * Gets an array of LOD properties from lowest to highest.
  89840. */
  89841. private _getLODs;
  89842. private _disposeTransformNode;
  89843. private _disposeMaterials;
  89844. }
  89845. }
  89846. declare module BABYLON.GLTF2.Loader.Extensions {
  89847. /** @hidden */
  89848. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  89849. readonly name: string;
  89850. enabled: boolean;
  89851. private _loader;
  89852. constructor(loader: GLTFLoader);
  89853. dispose(): void;
  89854. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89855. }
  89856. }
  89857. declare module BABYLON.GLTF2.Loader.Extensions {
  89858. /** @hidden */
  89859. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  89860. readonly name: string;
  89861. enabled: boolean;
  89862. private _loader;
  89863. constructor(loader: GLTFLoader);
  89864. dispose(): void;
  89865. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89866. }
  89867. }
  89868. declare module BABYLON.GLTF2.Loader.Extensions {
  89869. /**
  89870. * Store glTF extras (if present) in BJS objects' metadata
  89871. */
  89872. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  89873. /**
  89874. * The name of this extension.
  89875. */
  89876. readonly name: string;
  89877. /**
  89878. * Defines whether this extension is enabled.
  89879. */
  89880. enabled: boolean;
  89881. private _loader;
  89882. private _assignExtras;
  89883. /** @hidden */
  89884. constructor(loader: GLTFLoader);
  89885. /** @hidden */
  89886. dispose(): void;
  89887. /** @hidden */
  89888. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  89889. /** @hidden */
  89890. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  89891. /** @hidden */
  89892. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  89893. }
  89894. }
  89895. declare module BABYLON {
  89896. /**
  89897. * Class reading and parsing the MTL file bundled with the obj file.
  89898. */
  89899. export class MTLFileLoader {
  89900. /**
  89901. * Invert Y-Axis of referenced textures on load
  89902. */
  89903. static INVERT_TEXTURE_Y: boolean;
  89904. /**
  89905. * All material loaded from the mtl will be set here
  89906. */
  89907. materials: StandardMaterial[];
  89908. /**
  89909. * This function will read the mtl file and create each material described inside
  89910. * This function could be improve by adding :
  89911. * -some component missing (Ni, Tf...)
  89912. * -including the specific options available
  89913. *
  89914. * @param scene defines the scene the material will be created in
  89915. * @param data defines the mtl data to parse
  89916. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  89917. * @param forAssetContainer defines if the material should be registered in the scene
  89918. */
  89919. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  89920. /**
  89921. * Gets the texture for the material.
  89922. *
  89923. * If the material is imported from input file,
  89924. * We sanitize the url to ensure it takes the textre from aside the material.
  89925. *
  89926. * @param rootUrl The root url to load from
  89927. * @param value The value stored in the mtl
  89928. * @return The Texture
  89929. */
  89930. private static _getTexture;
  89931. }
  89932. }
  89933. declare module BABYLON {
  89934. /**
  89935. * Options for loading OBJ/MTL files
  89936. */
  89937. type MeshLoadOptions = {
  89938. /**
  89939. * Defines if UVs are optimized by default during load.
  89940. */
  89941. OptimizeWithUV: boolean;
  89942. /**
  89943. * Defines custom scaling of UV coordinates of loaded meshes.
  89944. */
  89945. UVScaling: Vector2;
  89946. /**
  89947. * Invert model on y-axis (does a model scaling inversion)
  89948. */
  89949. InvertY: boolean;
  89950. /**
  89951. * Invert Y-Axis of referenced textures on load
  89952. */
  89953. InvertTextureY: boolean;
  89954. /**
  89955. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  89956. */
  89957. ImportVertexColors: boolean;
  89958. /**
  89959. * Compute the normals for the model, even if normals are present in the file.
  89960. */
  89961. ComputeNormals: boolean;
  89962. /**
  89963. * 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.
  89964. * Using OptimizehNormals = true will help smoothing the lighting by averaging the normals of those vertices.
  89965. */
  89966. OptimizeNormals: boolean;
  89967. /**
  89968. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  89969. */
  89970. SkipMaterials: boolean;
  89971. /**
  89972. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  89973. */
  89974. MaterialLoadingFailsSilently: boolean;
  89975. };
  89976. /**
  89977. * OBJ file type loader.
  89978. * This is a babylon scene loader plugin.
  89979. */
  89980. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  89981. /**
  89982. * Defines if UVs are optimized by default during load.
  89983. */
  89984. static OPTIMIZE_WITH_UV: boolean;
  89985. /**
  89986. * Invert model on y-axis (does a model scaling inversion)
  89987. */
  89988. static INVERT_Y: boolean;
  89989. /**
  89990. * Invert Y-Axis of referenced textures on load
  89991. */
  89992. static get INVERT_TEXTURE_Y(): boolean;
  89993. static set INVERT_TEXTURE_Y(value: boolean);
  89994. /**
  89995. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  89996. */
  89997. static IMPORT_VERTEX_COLORS: boolean;
  89998. /**
  89999. * Compute the normals for the model, even if normals are present in the file.
  90000. */
  90001. static COMPUTE_NORMALS: boolean;
  90002. /**
  90003. * 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.
  90004. * Using OptimizehNormals = true will help smoothing the lighting by averaging the normals of those vertices.
  90005. */
  90006. static OPTIMIZE_NORMALS: boolean;
  90007. /**
  90008. * Defines custom scaling of UV coordinates of loaded meshes.
  90009. */
  90010. static UV_SCALING: Vector2;
  90011. /**
  90012. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  90013. */
  90014. static SKIP_MATERIALS: boolean;
  90015. /**
  90016. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  90017. *
  90018. * Defaults to true for backwards compatibility.
  90019. */
  90020. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  90021. /**
  90022. * Defines the name of the plugin.
  90023. */
  90024. name: string;
  90025. /**
  90026. * Defines the extension the plugin is able to load.
  90027. */
  90028. extensions: string;
  90029. /** @hidden */
  90030. obj: RegExp;
  90031. /** @hidden */
  90032. group: RegExp;
  90033. /** @hidden */
  90034. mtllib: RegExp;
  90035. /** @hidden */
  90036. usemtl: RegExp;
  90037. /** @hidden */
  90038. smooth: RegExp;
  90039. /** @hidden */
  90040. vertexPattern: RegExp;
  90041. /** @hidden */
  90042. normalPattern: RegExp;
  90043. /** @hidden */
  90044. uvPattern: RegExp;
  90045. /** @hidden */
  90046. facePattern1: RegExp;
  90047. /** @hidden */
  90048. facePattern2: RegExp;
  90049. /** @hidden */
  90050. facePattern3: RegExp;
  90051. /** @hidden */
  90052. facePattern4: RegExp;
  90053. /** @hidden */
  90054. facePattern5: RegExp;
  90055. private _forAssetContainer;
  90056. private _meshLoadOptions;
  90057. /**
  90058. * Creates loader for .OBJ files
  90059. *
  90060. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  90061. */
  90062. constructor(meshLoadOptions?: MeshLoadOptions);
  90063. private static get currentMeshLoadOptions();
  90064. /**
  90065. * Calls synchronously the MTL file attached to this obj.
  90066. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  90067. * Without this function materials are not displayed in the first frame (but displayed after).
  90068. * In consequence it is impossible to get material information in your HTML file
  90069. *
  90070. * @param url The URL of the MTL file
  90071. * @param rootUrl
  90072. * @param onSuccess Callback function to be called when the MTL file is loaded
  90073. * @private
  90074. */
  90075. private _loadMTL;
  90076. /**
  90077. * Instantiates a OBJ file loader plugin.
  90078. * @returns the created plugin
  90079. */
  90080. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  90081. /**
  90082. * If the data string can be loaded directly.
  90083. *
  90084. * @param data string containing the file data
  90085. * @returns if the data can be loaded directly
  90086. */
  90087. canDirectLoad(data: string): boolean;
  90088. /**
  90089. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  90090. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  90091. * @param scene the scene the meshes should be added to
  90092. * @param data the OBJ data to load
  90093. * @param rootUrl root url to load from
  90094. * @param onProgress event that fires when loading progress has occured
  90095. * @param fileName Defines the name of the file to load
  90096. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  90097. */
  90098. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  90099. /**
  90100. * Imports all objects from the loaded OBJ data and adds them to the scene
  90101. * @param scene the scene the objects should be added to
  90102. * @param data the OBJ data to load
  90103. * @param rootUrl root url to load from
  90104. * @param onProgress event that fires when loading progress has occured
  90105. * @param fileName Defines the name of the file to load
  90106. * @returns a promise which completes when objects have been loaded to the scene
  90107. */
  90108. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  90109. /**
  90110. * Load into an asset container.
  90111. * @param scene The scene to load into
  90112. * @param data The data to import
  90113. * @param rootUrl The root url for scene and resources
  90114. * @param onProgress The callback when the load progresses
  90115. * @param fileName Defines the name of the file to load
  90116. * @returns The loaded asset container
  90117. */
  90118. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  90119. private _optimizeNormals;
  90120. /**
  90121. * Read the OBJ file and create an Array of meshes.
  90122. * Each mesh contains all information given by the OBJ and the MTL file.
  90123. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  90124. *
  90125. * @param meshesNames
  90126. * @param scene Scene The scene where are displayed the data
  90127. * @param data String The content of the obj file
  90128. * @param rootUrl String The path to the folder
  90129. * @returns Array<AbstractMesh>
  90130. * @private
  90131. */
  90132. private _parseSolid;
  90133. }
  90134. }
  90135. declare module BABYLON {
  90136. /**
  90137. * STL file type loader.
  90138. * This is a babylon scene loader plugin.
  90139. */
  90140. export class STLFileLoader implements ISceneLoaderPlugin {
  90141. /** @hidden */
  90142. solidPattern: RegExp;
  90143. /** @hidden */
  90144. facetsPattern: RegExp;
  90145. /** @hidden */
  90146. normalPattern: RegExp;
  90147. /** @hidden */
  90148. vertexPattern: RegExp;
  90149. /**
  90150. * Defines the name of the plugin.
  90151. */
  90152. name: string;
  90153. /**
  90154. * Defines the extensions the stl loader is able to load.
  90155. * force data to come in as an ArrayBuffer
  90156. * we'll convert to string if it looks like it's an ASCII .stl
  90157. */
  90158. extensions: ISceneLoaderPluginExtensions;
  90159. /**
  90160. * Import meshes into a scene.
  90161. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  90162. * @param scene The scene to import into
  90163. * @param data The data to import
  90164. * @param rootUrl The root url for scene and resources
  90165. * @param meshes The meshes array to import into
  90166. * @param particleSystems The particle systems array to import into
  90167. * @param skeletons The skeletons array to import into
  90168. * @param onError The callback when import fails
  90169. * @returns True if successful or false otherwise
  90170. */
  90171. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  90172. /**
  90173. * Load into a scene.
  90174. * @param scene The scene to load into
  90175. * @param data The data to import
  90176. * @param rootUrl The root url for scene and resources
  90177. * @param onError The callback when import fails
  90178. * @returns true if successful or false otherwise
  90179. */
  90180. load(scene: Scene, data: any, rootUrl: string): boolean;
  90181. /**
  90182. * Load into an asset container.
  90183. * @param scene The scene to load into
  90184. * @param data The data to import
  90185. * @param rootUrl The root url for scene and resources
  90186. * @param onError The callback when import fails
  90187. * @returns The loaded asset container
  90188. */
  90189. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  90190. private _isBinary;
  90191. private _parseBinary;
  90192. private _parseASCII;
  90193. }
  90194. }
  90195. declare module BABYLON {
  90196. /**
  90197. * Class for generating OBJ data from a Babylon scene.
  90198. */
  90199. export class OBJExport {
  90200. /**
  90201. * Exports the geometry of a Mesh array in .OBJ file format (text)
  90202. * @param mesh defines the list of meshes to serialize
  90203. * @param materials defines if materials should be exported
  90204. * @param matlibname defines the name of the associated mtl file
  90205. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  90206. * @returns the OBJ content
  90207. */
  90208. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  90209. /**
  90210. * Exports the material(s) of a mesh in .MTL file format (text)
  90211. * @param mesh defines the mesh to extract the material from
  90212. * @returns the mtl content
  90213. */
  90214. static MTL(mesh: Mesh): string;
  90215. }
  90216. }
  90217. declare module BABYLON {
  90218. /** @hidden */
  90219. export var __IGLTFExporterExtension: number;
  90220. /**
  90221. * Interface for extending the exporter
  90222. * @hidden
  90223. */
  90224. export interface IGLTFExporterExtension {
  90225. /**
  90226. * The name of this extension
  90227. */
  90228. readonly name: string;
  90229. /**
  90230. * Defines whether this extension is enabled
  90231. */
  90232. enabled: boolean;
  90233. /**
  90234. * Defines whether this extension is required
  90235. */
  90236. required: boolean;
  90237. }
  90238. }
  90239. declare module BABYLON.GLTF2.Exporter {
  90240. /** @hidden */
  90241. export var __IGLTFExporterExtensionV2: number;
  90242. /**
  90243. * Interface for a glTF exporter extension
  90244. * @hidden
  90245. */
  90246. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  90247. /**
  90248. * Define this method to modify the default behavior before exporting a texture
  90249. * @param context The context when loading the asset
  90250. * @param babylonTexture The Babylon.js texture
  90251. * @param mimeType The mime-type of the generated image
  90252. * @returns A promise that resolves with the exported texture
  90253. */
  90254. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  90255. /**
  90256. * Define this method to get notified when a texture info is created
  90257. * @param context The context when loading the asset
  90258. * @param textureInfo The glTF texture info
  90259. * @param babylonTexture The Babylon.js texture
  90260. */
  90261. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  90262. /**
  90263. * Define this method to modify the default behavior when exporting texture info
  90264. * @param context The context when loading the asset
  90265. * @param meshPrimitive glTF mesh primitive
  90266. * @param babylonSubMesh Babylon submesh
  90267. * @param binaryWriter glTF serializer binary writer instance
  90268. * @returns nullable IMeshPrimitive promise
  90269. */
  90270. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  90271. /**
  90272. * Define this method to modify the default behavior when exporting a node
  90273. * @param context The context when exporting the node
  90274. * @param node glTF node
  90275. * @param babylonNode BabylonJS node
  90276. * @returns nullable INode promise
  90277. */
  90278. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  90279. [key: number]: number;
  90280. }): Promise<Nullable<INode>>;
  90281. /**
  90282. * Define this method to modify the default behavior when exporting a material
  90283. * @param material glTF material
  90284. * @param babylonMaterial BabylonJS material
  90285. * @returns nullable IMaterial promise
  90286. */
  90287. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  90288. /**
  90289. * Define this method to return additional textures to export from a material
  90290. * @param material glTF material
  90291. * @param babylonMaterial BabylonJS material
  90292. * @returns List of textures
  90293. */
  90294. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  90295. /** Gets a boolean indicating that this extension was used */
  90296. wasUsed: boolean;
  90297. /** Gets a boolean indicating that this extension is required for the file to work */
  90298. required: boolean;
  90299. /**
  90300. * Called after the exporter state changes to EXPORTING
  90301. */
  90302. onExporting?(): void;
  90303. }
  90304. }
  90305. declare module BABYLON.GLTF2.Exporter {
  90306. /**
  90307. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  90308. * @hidden
  90309. */
  90310. export class _GLTFMaterialExporter {
  90311. /**
  90312. * Represents the dielectric specular values for R, G and B
  90313. */
  90314. private static readonly _DielectricSpecular;
  90315. /**
  90316. * Allows the maximum specular power to be defined for material calculations
  90317. */
  90318. private static readonly _MaxSpecularPower;
  90319. /**
  90320. * Mapping to store textures
  90321. */
  90322. private _textureMap;
  90323. /**
  90324. * Numeric tolerance value
  90325. */
  90326. private static readonly _Epsilon;
  90327. /**
  90328. * Reference to the glTF Exporter
  90329. */
  90330. private _exporter;
  90331. constructor(exporter: _Exporter);
  90332. /**
  90333. * Specifies if two colors are approximately equal in value
  90334. * @param color1 first color to compare to
  90335. * @param color2 second color to compare to
  90336. * @param epsilon threshold value
  90337. */
  90338. private static FuzzyEquals;
  90339. /**
  90340. * Gets the materials from a Babylon scene and converts them to glTF materials
  90341. * @param scene babylonjs scene
  90342. * @param mimeType texture mime type
  90343. * @param images array of images
  90344. * @param textures array of textures
  90345. * @param materials array of materials
  90346. * @param imageData mapping of texture names to base64 textures
  90347. * @param hasTextureCoords specifies if texture coordinates are present on the material
  90348. */
  90349. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  90350. /**
  90351. * Makes a copy of the glTF material without the texture parameters
  90352. * @param originalMaterial original glTF material
  90353. * @returns glTF material without texture parameters
  90354. */
  90355. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  90356. /**
  90357. * Specifies if the material has any texture parameters present
  90358. * @param material glTF Material
  90359. * @returns boolean specifying if texture parameters are present
  90360. */
  90361. _hasTexturesPresent(material: IMaterial): boolean;
  90362. /**
  90363. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  90364. * @param babylonStandardMaterial
  90365. * @returns glTF Metallic Roughness Material representation
  90366. */
  90367. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  90368. /**
  90369. * Computes the metallic factor
  90370. * @param diffuse diffused value
  90371. * @param specular specular value
  90372. * @param oneMinusSpecularStrength one minus the specular strength
  90373. * @returns metallic value
  90374. */
  90375. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  90376. /**
  90377. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  90378. * @param glTFMaterial glTF material
  90379. * @param babylonMaterial Babylon material
  90380. */
  90381. private static _SetAlphaMode;
  90382. /**
  90383. * Converts a Babylon Standard Material to a glTF Material
  90384. * @param babylonStandardMaterial BJS Standard Material
  90385. * @param mimeType mime type to use for the textures
  90386. * @param images array of glTF image interfaces
  90387. * @param textures array of glTF texture interfaces
  90388. * @param materials array of glTF material interfaces
  90389. * @param imageData map of image file name to data
  90390. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  90391. */
  90392. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  90393. private _finishMaterial;
  90394. /**
  90395. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  90396. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  90397. * @param mimeType mime type to use for the textures
  90398. * @param images array of glTF image interfaces
  90399. * @param textures array of glTF texture interfaces
  90400. * @param materials array of glTF material interfaces
  90401. * @param imageData map of image file name to data
  90402. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  90403. */
  90404. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  90405. /**
  90406. * Converts an image typed array buffer to a base64 image
  90407. * @param buffer typed array buffer
  90408. * @param width width of the image
  90409. * @param height height of the image
  90410. * @param mimeType mimetype of the image
  90411. * @returns base64 image string
  90412. */
  90413. private _createBase64FromCanvasAsync;
  90414. /**
  90415. * Generates a white texture based on the specified width and height
  90416. * @param width width of the texture in pixels
  90417. * @param height height of the texture in pixels
  90418. * @param scene babylonjs scene
  90419. * @returns white texture
  90420. */
  90421. private _createWhiteTexture;
  90422. /**
  90423. * 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
  90424. * @param texture1 first texture to resize
  90425. * @param texture2 second texture to resize
  90426. * @param scene babylonjs scene
  90427. * @returns resized textures or null
  90428. */
  90429. private _resizeTexturesToSameDimensions;
  90430. /**
  90431. * Converts an array of pixels to a Float32Array
  90432. * Throws an error if the pixel format is not supported
  90433. * @param pixels - array buffer containing pixel values
  90434. * @returns Float32 of pixels
  90435. */
  90436. private _convertPixelArrayToFloat32;
  90437. /**
  90438. * Convert Specular Glossiness Textures to Metallic Roughness
  90439. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  90440. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  90441. * @param diffuseTexture texture used to store diffuse information
  90442. * @param specularGlossinessTexture texture used to store specular and glossiness information
  90443. * @param factors specular glossiness material factors
  90444. * @param mimeType the mime type to use for the texture
  90445. * @returns pbr metallic roughness interface or null
  90446. */
  90447. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  90448. /**
  90449. * Converts specular glossiness material properties to metallic roughness
  90450. * @param specularGlossiness interface with specular glossiness material properties
  90451. * @returns interface with metallic roughness material properties
  90452. */
  90453. private _convertSpecularGlossinessToMetallicRoughness;
  90454. /**
  90455. * Calculates the surface reflectance, independent of lighting conditions
  90456. * @param color Color source to calculate brightness from
  90457. * @returns number representing the perceived brightness, or zero if color is undefined
  90458. */
  90459. private _getPerceivedBrightness;
  90460. /**
  90461. * Returns the maximum color component value
  90462. * @param color
  90463. * @returns maximum color component value, or zero if color is null or undefined
  90464. */
  90465. private _getMaxComponent;
  90466. /**
  90467. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  90468. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  90469. * @param mimeType mime type to use for the textures
  90470. * @param images array of glTF image interfaces
  90471. * @param textures array of glTF texture interfaces
  90472. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  90473. * @param imageData map of image file name to data
  90474. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  90475. * @returns glTF PBR Metallic Roughness factors
  90476. */
  90477. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  90478. private _getGLTFTextureSampler;
  90479. private _getGLTFTextureWrapMode;
  90480. private _getGLTFTextureWrapModesSampler;
  90481. /**
  90482. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  90483. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  90484. * @param mimeType mime type to use for the textures
  90485. * @param images array of glTF image interfaces
  90486. * @param textures array of glTF texture interfaces
  90487. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  90488. * @param imageData map of image file name to data
  90489. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  90490. * @returns glTF PBR Metallic Roughness factors
  90491. */
  90492. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  90493. /**
  90494. * Converts a Babylon PBR Base Material to a glTF Material
  90495. * @param babylonPBRMaterial BJS PBR Base Material
  90496. * @param mimeType mime type to use for the textures
  90497. * @param images array of glTF image interfaces
  90498. * @param textures array of glTF texture interfaces
  90499. * @param materials array of glTF material interfaces
  90500. * @param imageData map of image file name to data
  90501. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  90502. */
  90503. _convertPBRMaterialAsync(babylonPBRMaterial: PBRBaseMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  90504. private setMetallicRoughnessPbrMaterial;
  90505. private getPixelsFromTexture;
  90506. /**
  90507. * Extracts a texture from a Babylon texture into file data and glTF data
  90508. * @param babylonTexture Babylon texture to extract
  90509. * @param mimeType Mime Type of the babylonTexture
  90510. * @return glTF texture info, or null if the texture format is not supported
  90511. */
  90512. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  90513. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  90514. /**
  90515. * Builds a texture from base64 string
  90516. * @param base64Texture base64 texture string
  90517. * @param baseTextureName Name to use for the texture
  90518. * @param mimeType image mime type for the texture
  90519. * @param images array of images
  90520. * @param textures array of textures
  90521. * @param imageData map of image data
  90522. * @returns glTF texture info, or null if the texture format is not supported
  90523. */
  90524. private _getTextureInfoFromBase64;
  90525. }
  90526. }
  90527. declare module BABYLON {
  90528. /**
  90529. * Class for holding and downloading glTF file data
  90530. */
  90531. export class GLTFData {
  90532. /**
  90533. * Object which contains the file name as the key and its data as the value
  90534. */
  90535. glTFFiles: {
  90536. [fileName: string]: string | Blob;
  90537. };
  90538. /**
  90539. * Initializes the glTF file object
  90540. */
  90541. constructor();
  90542. /**
  90543. * Downloads the glTF data as files based on their names and data
  90544. */
  90545. downloadFiles(): void;
  90546. }
  90547. }
  90548. declare module BABYLON {
  90549. /**
  90550. * Holds a collection of exporter options and parameters
  90551. */
  90552. export interface IExportOptions {
  90553. /**
  90554. * Function which indicates whether a babylon node should be exported or not
  90555. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  90556. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  90557. */
  90558. shouldExportNode?(node: Node): boolean;
  90559. /**
  90560. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  90561. * @param metadata source metadata to read from
  90562. * @returns the data to store to glTF node extras
  90563. */
  90564. metadataSelector?(metadata: any): any;
  90565. /**
  90566. * The sample rate to bake animation curves
  90567. */
  90568. animationSampleRate?: number;
  90569. /**
  90570. * Begin serialization without waiting for the scene to be ready
  90571. */
  90572. exportWithoutWaitingForScene?: boolean;
  90573. /**
  90574. * Indicates if coordinate system swapping root nodes should be included in export
  90575. */
  90576. includeCoordinateSystemConversionNodes?: boolean;
  90577. }
  90578. /**
  90579. * Class for generating glTF data from a Babylon scene.
  90580. */
  90581. export class GLTF2Export {
  90582. /**
  90583. * Exports the geometry of the scene to .gltf file format asynchronously
  90584. * @param scene Babylon scene with scene hierarchy information
  90585. * @param filePrefix File prefix to use when generating the glTF file
  90586. * @param options Exporter options
  90587. * @returns Returns an object with a .gltf file and associates texture names
  90588. * as keys and their data and paths as values
  90589. */
  90590. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  90591. private static _PreExportAsync;
  90592. private static _PostExportAsync;
  90593. /**
  90594. * Exports the geometry of the scene to .glb file format asychronously
  90595. * @param scene Babylon scene with scene hierarchy information
  90596. * @param filePrefix File prefix to use when generating glb file
  90597. * @param options Exporter options
  90598. * @returns Returns an object with a .glb filename as key and data as value
  90599. */
  90600. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  90601. }
  90602. }
  90603. declare module BABYLON.GLTF2.Exporter {
  90604. /**
  90605. * @hidden
  90606. */
  90607. export class _GLTFUtilities {
  90608. /**
  90609. * Creates a buffer view based on the supplied arguments
  90610. * @param bufferIndex index value of the specified buffer
  90611. * @param byteOffset byte offset value
  90612. * @param byteLength byte length of the bufferView
  90613. * @param byteStride byte distance between conequential elements
  90614. * @param name name of the buffer view
  90615. * @returns bufferView for glTF
  90616. */
  90617. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  90618. /**
  90619. * Creates an accessor based on the supplied arguments
  90620. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  90621. * @param name The name of the accessor
  90622. * @param type The type of the accessor
  90623. * @param componentType The datatype of components in the attribute
  90624. * @param count The number of attributes referenced by this accessor
  90625. * @param byteOffset The offset relative to the start of the bufferView in bytes
  90626. * @param min Minimum value of each component in this attribute
  90627. * @param max Maximum value of each component in this attribute
  90628. * @returns accessor for glTF
  90629. */
  90630. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  90631. /**
  90632. * Calculates the minimum and maximum values of an array of position floats
  90633. * @param positions Positions array of a mesh
  90634. * @param vertexStart Starting vertex offset to calculate min and max values
  90635. * @param vertexCount Number of vertices to check for min and max values
  90636. * @returns min number array and max number array
  90637. */
  90638. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  90639. min: number[];
  90640. max: number[];
  90641. };
  90642. /**
  90643. * Converts a new right-handed Vector3
  90644. * @param vector vector3 array
  90645. * @returns right-handed Vector3
  90646. */
  90647. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  90648. /**
  90649. * Converts a Vector3 to right-handed
  90650. * @param vector Vector3 to convert to right-handed
  90651. */
  90652. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  90653. /**
  90654. * Converts a three element number array to right-handed
  90655. * @param vector number array to convert to right-handed
  90656. */
  90657. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  90658. /**
  90659. * Converts a new right-handed Vector3
  90660. * @param vector vector3 array
  90661. * @returns right-handed Vector3
  90662. */
  90663. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  90664. /**
  90665. * Converts a Vector3 to right-handed
  90666. * @param vector Vector3 to convert to right-handed
  90667. */
  90668. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  90669. /**
  90670. * Converts a three element number array to right-handed
  90671. * @param vector number array to convert to right-handed
  90672. */
  90673. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  90674. /**
  90675. * Converts a Vector4 to right-handed
  90676. * @param vector Vector4 to convert to right-handed
  90677. */
  90678. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  90679. /**
  90680. * Converts a Vector4 to right-handed
  90681. * @param vector Vector4 to convert to right-handed
  90682. */
  90683. static _GetRightHandedArray4FromRef(vector: number[]): void;
  90684. /**
  90685. * Converts a Quaternion to right-handed
  90686. * @param quaternion Source quaternion to convert to right-handed
  90687. */
  90688. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  90689. /**
  90690. * Converts a Quaternion to right-handed
  90691. * @param quaternion Source quaternion to convert to right-handed
  90692. */
  90693. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  90694. static _NormalizeTangentFromRef(tangent: Vector4): void;
  90695. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  90696. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  90697. }
  90698. }
  90699. declare module BABYLON.GLTF2.Exporter {
  90700. /**
  90701. * Converts Babylon Scene into glTF 2.0.
  90702. * @hidden
  90703. */
  90704. export class _Exporter {
  90705. /**
  90706. * Stores the glTF to export
  90707. */
  90708. _glTF: IGLTF;
  90709. /**
  90710. * Stores all generated buffer views, which represents views into the main glTF buffer data
  90711. */
  90712. _bufferViews: IBufferView[];
  90713. /**
  90714. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  90715. */
  90716. _accessors: IAccessor[];
  90717. /**
  90718. * Stores all the generated nodes, which contains transform and/or mesh information per node
  90719. */
  90720. _nodes: INode[];
  90721. /**
  90722. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  90723. */
  90724. private _scenes;
  90725. /**
  90726. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  90727. */
  90728. private _meshes;
  90729. /**
  90730. * Stores all the generated material information, which represents the appearance of each primitive
  90731. */
  90732. _materials: IMaterial[];
  90733. _materialMap: {
  90734. [materialID: number]: number;
  90735. };
  90736. /**
  90737. * Stores all the generated texture information, which is referenced by glTF materials
  90738. */
  90739. _textures: ITexture[];
  90740. /**
  90741. * Stores all the generated image information, which is referenced by glTF textures
  90742. */
  90743. _images: IImage[];
  90744. /**
  90745. * Stores all the texture samplers
  90746. */
  90747. _samplers: ISampler[];
  90748. /**
  90749. * Stores all the generated glTF skins
  90750. */
  90751. _skins: ISkin[];
  90752. /**
  90753. * Stores all the generated animation samplers, which is referenced by glTF animations
  90754. */
  90755. /**
  90756. * Stores the animations for glTF models
  90757. */
  90758. private _animations;
  90759. /**
  90760. * Stores the total amount of bytes stored in the glTF buffer
  90761. */
  90762. private _totalByteLength;
  90763. /**
  90764. * Stores a reference to the Babylon scene containing the source geometry and material information
  90765. */
  90766. _babylonScene: Scene;
  90767. /**
  90768. * Stores a map of the image data, where the key is the file name and the value
  90769. * is the image data
  90770. */
  90771. _imageData: {
  90772. [fileName: string]: {
  90773. data: Uint8Array;
  90774. mimeType: ImageMimeType;
  90775. };
  90776. };
  90777. protected _orderedImageData: Array<{
  90778. data: Uint8Array;
  90779. mimeType: ImageMimeType;
  90780. }>;
  90781. /**
  90782. * Stores a map of the unique id of a node to its index in the node array
  90783. */
  90784. _nodeMap: {
  90785. [key: number]: number;
  90786. };
  90787. /**
  90788. * Specifies if the source Babylon scene was left handed, and needed conversion.
  90789. */
  90790. _convertToRightHandedSystem: boolean;
  90791. /**
  90792. * Specifies if a Babylon node should be converted to right-handed on export
  90793. */
  90794. _convertToRightHandedSystemMap: {
  90795. [nodeId: number]: boolean;
  90796. };
  90797. _includeCoordinateSystemConversionNodes: boolean;
  90798. /**
  90799. * Baked animation sample rate
  90800. */
  90801. private _animationSampleRate;
  90802. private _options;
  90803. private _localEngine;
  90804. _glTFMaterialExporter: _GLTFMaterialExporter;
  90805. private _extensions;
  90806. private static _ExtensionNames;
  90807. private static _ExtensionFactories;
  90808. private _applyExtension;
  90809. private _applyExtensions;
  90810. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  90811. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  90812. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  90813. [key: number]: number;
  90814. }): Promise<Nullable<INode>>;
  90815. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  90816. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  90817. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  90818. private _forEachExtensions;
  90819. private _extensionsOnExporting;
  90820. /**
  90821. * Load glTF serializer extensions
  90822. */
  90823. private _loadExtensions;
  90824. /**
  90825. * Creates a glTF Exporter instance, which can accept optional exporter options
  90826. * @param babylonScene Babylon scene object
  90827. * @param options Options to modify the behavior of the exporter
  90828. */
  90829. constructor(babylonScene: Scene, options?: IExportOptions);
  90830. dispose(): void;
  90831. /**
  90832. * Registers a glTF exporter extension
  90833. * @param name Name of the extension to export
  90834. * @param factory The factory function that creates the exporter extension
  90835. */
  90836. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  90837. /**
  90838. * Un-registers an exporter extension
  90839. * @param name The name fo the exporter extension
  90840. * @returns A boolean indicating whether the extension has been un-registered
  90841. */
  90842. static UnregisterExtension(name: string): boolean;
  90843. private reorderIndicesBasedOnPrimitiveMode;
  90844. /**
  90845. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  90846. * clock-wise during export to glTF
  90847. * @param submesh BabylonJS submesh
  90848. * @param primitiveMode Primitive mode of the mesh
  90849. * @param sideOrientation the winding order of the submesh
  90850. * @param vertexBufferKind The type of vertex attribute
  90851. * @param meshAttributeArray The vertex attribute data
  90852. * @param byteOffset The offset to the binary data
  90853. * @param binaryWriter The binary data for the glTF file
  90854. * @param convertToRightHandedSystem Converts the values to right-handed
  90855. */
  90856. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  90857. /**
  90858. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  90859. * clock-wise during export to glTF
  90860. * @param submesh BabylonJS submesh
  90861. * @param primitiveMode Primitive mode of the mesh
  90862. * @param sideOrientation the winding order of the submesh
  90863. * @param vertexBufferKind The type of vertex attribute
  90864. * @param meshAttributeArray The vertex attribute data
  90865. * @param byteOffset The offset to the binary data
  90866. * @param binaryWriter The binary data for the glTF file
  90867. * @param convertToRightHandedSystem Converts the values to right-handed
  90868. */
  90869. private reorderTriangleFillMode;
  90870. /**
  90871. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  90872. * clock-wise during export to glTF
  90873. * @param submesh BabylonJS submesh
  90874. * @param primitiveMode Primitive mode of the mesh
  90875. * @param sideOrientation the winding order of the submesh
  90876. * @param vertexBufferKind The type of vertex attribute
  90877. * @param meshAttributeArray The vertex attribute data
  90878. * @param byteOffset The offset to the binary data
  90879. * @param binaryWriter The binary data for the glTF file
  90880. * @param convertToRightHandedSystem Converts the values to right-handed
  90881. */
  90882. private reorderTriangleStripDrawMode;
  90883. /**
  90884. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  90885. * clock-wise during export to glTF
  90886. * @param submesh BabylonJS submesh
  90887. * @param primitiveMode Primitive mode of the mesh
  90888. * @param sideOrientation the winding order of the submesh
  90889. * @param vertexBufferKind The type of vertex attribute
  90890. * @param meshAttributeArray The vertex attribute data
  90891. * @param byteOffset The offset to the binary data
  90892. * @param binaryWriter The binary data for the glTF file
  90893. * @param convertToRightHandedSystem Converts the values to right-handed
  90894. */
  90895. private reorderTriangleFanMode;
  90896. /**
  90897. * Writes the vertex attribute data to binary
  90898. * @param vertices The vertices to write to the binary writer
  90899. * @param byteOffset The offset into the binary writer to overwrite binary data
  90900. * @param vertexAttributeKind The vertex attribute type
  90901. * @param meshAttributeArray The vertex attribute data
  90902. * @param binaryWriter The writer containing the binary data
  90903. * @param convertToRightHandedSystem Converts the values to right-handed
  90904. */
  90905. private writeVertexAttributeData;
  90906. /**
  90907. * Writes mesh attribute data to a data buffer
  90908. * Returns the bytelength of the data
  90909. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  90910. * @param meshAttributeArray Array containing the attribute data
  90911. * @param byteStride Specifies the space between data
  90912. * @param binaryWriter The buffer to write the binary data to
  90913. * @param convertToRightHandedSystem Converts the values to right-handed
  90914. */
  90915. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  90916. /**
  90917. * Writes mesh attribute data to a data buffer
  90918. * Returns the bytelength of the data
  90919. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  90920. * @param meshAttributeArray Array containing the attribute data
  90921. * @param byteStride Specifies the space between data
  90922. * @param binaryWriter The buffer to write the binary data to
  90923. * @param convertToRightHandedSystem Converts the values to right-handed
  90924. */
  90925. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  90926. /**
  90927. * Generates glTF json data
  90928. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  90929. * @param glTFPrefix Text to use when prefixing a glTF file
  90930. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  90931. * @returns json data as string
  90932. */
  90933. private generateJSON;
  90934. /**
  90935. * Generates data for .gltf and .bin files based on the glTF prefix string
  90936. * @param glTFPrefix Text to use when prefixing a glTF file
  90937. * @param dispose Dispose the exporter
  90938. * @returns GLTFData with glTF file data
  90939. */
  90940. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  90941. /**
  90942. * Creates a binary buffer for glTF
  90943. * @returns array buffer for binary data
  90944. */
  90945. private _generateBinaryAsync;
  90946. /**
  90947. * Pads the number to a multiple of 4
  90948. * @param num number to pad
  90949. * @returns padded number
  90950. */
  90951. private _getPadding;
  90952. /**
  90953. * @hidden
  90954. */
  90955. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  90956. /**
  90957. * Sets the TRS for each node
  90958. * @param node glTF Node for storing the transformation data
  90959. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  90960. * @param convertToRightHandedSystem Converts the values to right-handed
  90961. */
  90962. private setNodeTransformation;
  90963. private getVertexBufferFromMesh;
  90964. /**
  90965. * Creates a bufferview based on the vertices type for the Babylon mesh
  90966. * @param kind Indicates the type of vertices data
  90967. * @param componentType Indicates the numerical type used to store the data
  90968. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  90969. * @param binaryWriter The buffer to write the bufferview data to
  90970. * @param convertToRightHandedSystem Converts the values to right-handed
  90971. */
  90972. private createBufferViewKind;
  90973. /**
  90974. * Creates a bufferview based on the vertices type for the Babylon mesh
  90975. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  90976. * @param babylonMorphTarget the morph target to be exported
  90977. * @param binaryWriter The buffer to write the bufferview data to
  90978. * @param convertToRightHandedSystem Converts the values to right-handed
  90979. */
  90980. private setMorphTargetAttributes;
  90981. /**
  90982. * The primitive mode of the Babylon mesh
  90983. * @param babylonMesh The BabylonJS mesh
  90984. */
  90985. private getMeshPrimitiveMode;
  90986. /**
  90987. * Sets the primitive mode of the glTF mesh primitive
  90988. * @param meshPrimitive glTF mesh primitive
  90989. * @param primitiveMode The primitive mode
  90990. */
  90991. private setPrimitiveMode;
  90992. /**
  90993. * Sets the vertex attribute accessor based of the glTF mesh primitive
  90994. * @param meshPrimitive glTF mesh primitive
  90995. * @param attributeKind vertex attribute
  90996. * @returns boolean specifying if uv coordinates are present
  90997. */
  90998. private setAttributeKind;
  90999. /**
  91000. * Sets data for the primitive attributes of each submesh
  91001. * @param mesh glTF Mesh object to store the primitive attribute information
  91002. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  91003. * @param binaryWriter Buffer to write the attribute data to
  91004. * @param convertToRightHandedSystem Converts the values to right-handed
  91005. */
  91006. private setPrimitiveAttributesAsync;
  91007. /**
  91008. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  91009. * @param node The node to check
  91010. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  91011. */
  91012. private isBabylonCoordinateSystemConvertingNode;
  91013. /**
  91014. * Creates a glTF scene based on the array of meshes
  91015. * Returns the the total byte offset
  91016. * @param babylonScene Babylon scene to get the mesh data from
  91017. * @param binaryWriter Buffer to write binary data to
  91018. */
  91019. private createSceneAsync;
  91020. /**
  91021. * Creates a mapping of Node unique id to node index and handles animations
  91022. * @param babylonScene Babylon Scene
  91023. * @param nodes Babylon transform nodes
  91024. * @param binaryWriter Buffer to write binary data to
  91025. * @returns Node mapping of unique id to index
  91026. */
  91027. private createNodeMapAndAnimationsAsync;
  91028. /**
  91029. * Creates a glTF node from a Babylon mesh
  91030. * @param babylonMesh Source Babylon mesh
  91031. * @param binaryWriter Buffer for storing geometry data
  91032. * @param convertToRightHandedSystem Converts the values to right-handed
  91033. * @param nodeMap Node mapping of unique id to glTF node index
  91034. * @returns glTF node
  91035. */
  91036. private createNodeAsync;
  91037. /**
  91038. * Creates a glTF skin from a Babylon skeleton
  91039. * @param babylonScene Babylon Scene
  91040. * @param nodes Babylon transform nodes
  91041. * @param binaryWriter Buffer to write binary data to
  91042. * @returns Node mapping of unique id to index
  91043. */
  91044. private createSkinsAsync;
  91045. }
  91046. /**
  91047. * @hidden
  91048. *
  91049. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  91050. */
  91051. export class _BinaryWriter {
  91052. /**
  91053. * Array buffer which stores all binary data
  91054. */
  91055. private _arrayBuffer;
  91056. /**
  91057. * View of the array buffer
  91058. */
  91059. private _dataView;
  91060. /**
  91061. * byte offset of data in array buffer
  91062. */
  91063. private _byteOffset;
  91064. /**
  91065. * Initialize binary writer with an initial byte length
  91066. * @param byteLength Initial byte length of the array buffer
  91067. */
  91068. constructor(byteLength: number);
  91069. /**
  91070. * Resize the array buffer to the specified byte length
  91071. * @param byteLength
  91072. */
  91073. private resizeBuffer;
  91074. /**
  91075. * Get an array buffer with the length of the byte offset
  91076. * @returns ArrayBuffer resized to the byte offset
  91077. */
  91078. getArrayBuffer(): ArrayBuffer;
  91079. /**
  91080. * Get the byte offset of the array buffer
  91081. * @returns byte offset
  91082. */
  91083. getByteOffset(): number;
  91084. /**
  91085. * Stores an UInt8 in the array buffer
  91086. * @param entry
  91087. * @param byteOffset If defined, specifies where to set the value as an offset.
  91088. */
  91089. setUInt8(entry: number, byteOffset?: number): void;
  91090. /**
  91091. * Stores an UInt16 in the array buffer
  91092. * @param entry
  91093. * @param byteOffset If defined, specifies where to set the value as an offset.
  91094. */
  91095. setUInt16(entry: number, byteOffset?: number): void;
  91096. /**
  91097. * Gets an UInt32 in the array buffer
  91098. * @param entry
  91099. * @param byteOffset If defined, specifies where to set the value as an offset.
  91100. */
  91101. getUInt32(byteOffset: number): number;
  91102. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  91103. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  91104. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  91105. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  91106. /**
  91107. * Stores a Float32 in the array buffer
  91108. * @param entry
  91109. */
  91110. setFloat32(entry: number, byteOffset?: number): void;
  91111. /**
  91112. * Stores an UInt32 in the array buffer
  91113. * @param entry
  91114. * @param byteOffset If defined, specifies where to set the value as an offset.
  91115. */
  91116. setUInt32(entry: number, byteOffset?: number): void;
  91117. }
  91118. }
  91119. declare module BABYLON.GLTF2.Exporter {
  91120. /**
  91121. * @hidden
  91122. * Interface to store animation data.
  91123. */
  91124. export interface _IAnimationData {
  91125. /**
  91126. * Keyframe data.
  91127. */
  91128. inputs: number[];
  91129. /**
  91130. * Value data.
  91131. */
  91132. outputs: number[][];
  91133. /**
  91134. * Animation interpolation data.
  91135. */
  91136. samplerInterpolation: AnimationSamplerInterpolation;
  91137. /**
  91138. * Minimum keyframe value.
  91139. */
  91140. inputsMin: number;
  91141. /**
  91142. * Maximum keyframe value.
  91143. */
  91144. inputsMax: number;
  91145. }
  91146. /**
  91147. * @hidden
  91148. */
  91149. export interface _IAnimationInfo {
  91150. /**
  91151. * The target channel for the animation
  91152. */
  91153. animationChannelTargetPath: AnimationChannelTargetPath;
  91154. /**
  91155. * The glTF accessor type for the data.
  91156. */
  91157. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  91158. /**
  91159. * Specifies if quaternions should be used.
  91160. */
  91161. useQuaternion: boolean;
  91162. }
  91163. /**
  91164. * @hidden
  91165. * Utility class for generating glTF animation data from BabylonJS.
  91166. */
  91167. export class _GLTFAnimation {
  91168. /**
  91169. * @ignore
  91170. *
  91171. * Creates glTF channel animation from BabylonJS animation.
  91172. * @param babylonTransformNode - BabylonJS mesh.
  91173. * @param animation - animation.
  91174. * @param animationChannelTargetPath - The target animation channel.
  91175. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  91176. * @param useQuaternion - Specifies if quaternions are used.
  91177. * @returns nullable IAnimationData
  91178. */
  91179. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  91180. private static _DeduceAnimationInfo;
  91181. /**
  91182. * @ignore
  91183. * Create node animations from the transform node animations
  91184. * @param babylonNode
  91185. * @param runtimeGLTFAnimation
  91186. * @param idleGLTFAnimations
  91187. * @param nodeMap
  91188. * @param nodes
  91189. * @param binaryWriter
  91190. * @param bufferViews
  91191. * @param accessors
  91192. * @param convertToRightHandedSystem
  91193. * @param animationSampleRate
  91194. */
  91195. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  91196. [key: number]: number;
  91197. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  91198. /**
  91199. * @ignore
  91200. * Create individual morph animations from the mesh's morph target animation tracks
  91201. * @param babylonNode
  91202. * @param runtimeGLTFAnimation
  91203. * @param idleGLTFAnimations
  91204. * @param nodeMap
  91205. * @param nodes
  91206. * @param binaryWriter
  91207. * @param bufferViews
  91208. * @param accessors
  91209. * @param convertToRightHandedSystem
  91210. * @param animationSampleRate
  91211. */
  91212. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  91213. [key: number]: number;
  91214. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  91215. /**
  91216. * @ignore
  91217. * Create node and morph animations from the animation groups
  91218. * @param babylonScene
  91219. * @param glTFAnimations
  91220. * @param nodeMap
  91221. * @param nodes
  91222. * @param binaryWriter
  91223. * @param bufferViews
  91224. * @param accessors
  91225. * @param convertToRightHandedSystemMap
  91226. * @param animationSampleRate
  91227. */
  91228. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  91229. [key: number]: number;
  91230. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  91231. [nodeId: number]: boolean;
  91232. }, animationSampleRate: number): void;
  91233. private static AddAnimation;
  91234. /**
  91235. * Create a baked animation
  91236. * @param babylonTransformNode BabylonJS mesh
  91237. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  91238. * @param animationChannelTargetPath animation target channel
  91239. * @param minFrame minimum animation frame
  91240. * @param maxFrame maximum animation frame
  91241. * @param fps frames per second of the animation
  91242. * @param inputs input key frames of the animation
  91243. * @param outputs output key frame data of the animation
  91244. * @param convertToRightHandedSystem converts the values to right-handed
  91245. * @param useQuaternion specifies if quaternions should be used
  91246. */
  91247. private static _CreateBakedAnimation;
  91248. private static _ConvertFactorToVector3OrQuaternion;
  91249. private static _SetInterpolatedValue;
  91250. /**
  91251. * Creates linear animation from the animation key frames
  91252. * @param babylonTransformNode BabylonJS mesh
  91253. * @param animation BabylonJS animation
  91254. * @param animationChannelTargetPath The target animation channel
  91255. * @param frameDelta The difference between the last and first frame of the animation
  91256. * @param inputs Array to store the key frame times
  91257. * @param outputs Array to store the key frame data
  91258. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  91259. * @param useQuaternion Specifies if quaternions are used in the animation
  91260. */
  91261. private static _CreateLinearOrStepAnimation;
  91262. /**
  91263. * Creates cubic spline animation from the animation key frames
  91264. * @param babylonTransformNode BabylonJS mesh
  91265. * @param animation BabylonJS animation
  91266. * @param animationChannelTargetPath The target animation channel
  91267. * @param frameDelta The difference between the last and first frame of the animation
  91268. * @param inputs Array to store the key frame times
  91269. * @param outputs Array to store the key frame data
  91270. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  91271. * @param useQuaternion Specifies if quaternions are used in the animation
  91272. */
  91273. private static _CreateCubicSplineAnimation;
  91274. private static _GetBasePositionRotationOrScale;
  91275. /**
  91276. * Adds a key frame value
  91277. * @param keyFrame
  91278. * @param animation
  91279. * @param outputs
  91280. * @param animationChannelTargetPath
  91281. * @param basePositionRotationOrScale
  91282. * @param convertToRightHandedSystem
  91283. * @param useQuaternion
  91284. */
  91285. private static _AddKeyframeValue;
  91286. /**
  91287. * Determine the interpolation based on the key frames
  91288. * @param keyFrames
  91289. * @param animationChannelTargetPath
  91290. * @param useQuaternion
  91291. */
  91292. private static _DeduceInterpolation;
  91293. /**
  91294. * Adds an input tangent or output tangent to the output data
  91295. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  91296. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  91297. * @param outputs The animation data by keyframe
  91298. * @param animationChannelTargetPath The target animation channel
  91299. * @param interpolation The interpolation type
  91300. * @param keyFrame The key frame with the animation data
  91301. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  91302. * @param useQuaternion Specifies if quaternions are used
  91303. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  91304. */
  91305. private static AddSplineTangent;
  91306. /**
  91307. * Get the minimum and maximum key frames' frame values
  91308. * @param keyFrames animation key frames
  91309. * @returns the minimum and maximum key frame value
  91310. */
  91311. private static calculateMinMaxKeyFrames;
  91312. }
  91313. }
  91314. declare module BABYLON.GLTF2.Exporter {
  91315. /** @hidden */
  91316. export var textureTransformPixelShader: {
  91317. name: string;
  91318. shader: string;
  91319. };
  91320. }
  91321. declare module BABYLON.GLTF2.Exporter.Extensions {
  91322. /**
  91323. * @hidden
  91324. */
  91325. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  91326. private _recordedTextures;
  91327. /** Name of this extension */
  91328. readonly name: string;
  91329. /** Defines whether this extension is enabled */
  91330. enabled: boolean;
  91331. /** Defines whether this extension is required */
  91332. required: boolean;
  91333. /** Reference to the glTF exporter */
  91334. private _wasUsed;
  91335. constructor(exporter: _Exporter);
  91336. dispose(): void;
  91337. /** @hidden */
  91338. get wasUsed(): boolean;
  91339. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  91340. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  91341. /**
  91342. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  91343. * @param babylonTexture
  91344. * @param offset
  91345. * @param rotation
  91346. * @param scale
  91347. * @param scene
  91348. */
  91349. private _textureTransformTextureAsync;
  91350. }
  91351. }
  91352. declare module BABYLON.GLTF2.Exporter.Extensions {
  91353. /**
  91354. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  91355. */
  91356. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  91357. /** The name of this extension. */
  91358. readonly name: string;
  91359. /** Defines whether this extension is enabled. */
  91360. enabled: boolean;
  91361. /** Defines whether this extension is required */
  91362. required: boolean;
  91363. /** Reference to the glTF exporter */
  91364. private _exporter;
  91365. private _lights;
  91366. /** @hidden */
  91367. constructor(exporter: _Exporter);
  91368. /** @hidden */
  91369. dispose(): void;
  91370. /** @hidden */
  91371. get wasUsed(): boolean;
  91372. /** @hidden */
  91373. onExporting(): void;
  91374. /**
  91375. * Define this method to modify the default behavior when exporting a node
  91376. * @param context The context when exporting the node
  91377. * @param node glTF node
  91378. * @param babylonNode BabylonJS node
  91379. * @param nodeMap Node mapping of unique id to glTF node index
  91380. * @returns nullable INode promise
  91381. */
  91382. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  91383. [key: number]: number;
  91384. }): Promise<Nullable<INode>>;
  91385. }
  91386. }
  91387. declare module BABYLON.GLTF2.Exporter.Extensions {
  91388. /**
  91389. * @hidden
  91390. */
  91391. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  91392. /** Name of this extension */
  91393. readonly name: string;
  91394. /** Defines whether this extension is enabled */
  91395. enabled: boolean;
  91396. /** Defines whether this extension is required */
  91397. required: boolean;
  91398. /** Reference to the glTF exporter */
  91399. private _textureInfos;
  91400. private _exportedTextures;
  91401. private _wasUsed;
  91402. constructor(exporter: _Exporter);
  91403. dispose(): void;
  91404. /** @hidden */
  91405. get wasUsed(): boolean;
  91406. private _getTextureIndex;
  91407. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  91408. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  91409. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  91410. }
  91411. }
  91412. declare module BABYLON.GLTF2.Exporter.Extensions {
  91413. /**
  91414. * @hidden
  91415. */
  91416. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  91417. /** Name of this extension */
  91418. readonly name: string;
  91419. /** Defines whether this extension is enabled */
  91420. enabled: boolean;
  91421. /** Defines whether this extension is required */
  91422. required: boolean;
  91423. private _wasUsed;
  91424. constructor(exporter: _Exporter);
  91425. /** @hidden */
  91426. get wasUsed(): boolean;
  91427. dispose(): void;
  91428. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  91429. }
  91430. }
  91431. declare module BABYLON {
  91432. /**
  91433. * Class for generating STL data from a Babylon scene.
  91434. */
  91435. export class STLExport {
  91436. /**
  91437. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  91438. * @param meshes list defines the mesh to serialize
  91439. * @param download triggers the automatic download of the file.
  91440. * @param fileName changes the downloads fileName.
  91441. * @param binary changes the STL to a binary type.
  91442. * @param isLittleEndian toggle for binary type exporter.
  91443. * @param doNotBakeTransform toggle if meshes transforms should be baked or not.
  91444. * @returns the STL as UTF8 string
  91445. */
  91446. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean, doNotBakeTransform?: boolean): any;
  91447. }
  91448. }
  91449. declare module "babylonjs-gltf2interface" {
  91450. export = BABYLON.GLTF2;
  91451. }
  91452. /**
  91453. * Module for glTF 2.0 Interface
  91454. */
  91455. declare module BABYLON.GLTF2 {
  91456. /**
  91457. * The datatype of the components in the attribute
  91458. */
  91459. const enum AccessorComponentType {
  91460. /**
  91461. * Byte
  91462. */
  91463. BYTE = 5120,
  91464. /**
  91465. * Unsigned Byte
  91466. */
  91467. UNSIGNED_BYTE = 5121,
  91468. /**
  91469. * Short
  91470. */
  91471. SHORT = 5122,
  91472. /**
  91473. * Unsigned Short
  91474. */
  91475. UNSIGNED_SHORT = 5123,
  91476. /**
  91477. * Unsigned Int
  91478. */
  91479. UNSIGNED_INT = 5125,
  91480. /**
  91481. * Float
  91482. */
  91483. FLOAT = 5126,
  91484. }
  91485. /**
  91486. * Specifies if the attirbute is a scalar, vector, or matrix
  91487. */
  91488. const enum AccessorType {
  91489. /**
  91490. * Scalar
  91491. */
  91492. SCALAR = "SCALAR",
  91493. /**
  91494. * Vector2
  91495. */
  91496. VEC2 = "VEC2",
  91497. /**
  91498. * Vector3
  91499. */
  91500. VEC3 = "VEC3",
  91501. /**
  91502. * Vector4
  91503. */
  91504. VEC4 = "VEC4",
  91505. /**
  91506. * Matrix2x2
  91507. */
  91508. MAT2 = "MAT2",
  91509. /**
  91510. * Matrix3x3
  91511. */
  91512. MAT3 = "MAT3",
  91513. /**
  91514. * Matrix4x4
  91515. */
  91516. MAT4 = "MAT4",
  91517. }
  91518. /**
  91519. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  91520. */
  91521. const enum AnimationChannelTargetPath {
  91522. /**
  91523. * Translation
  91524. */
  91525. TRANSLATION = "translation",
  91526. /**
  91527. * Rotation
  91528. */
  91529. ROTATION = "rotation",
  91530. /**
  91531. * Scale
  91532. */
  91533. SCALE = "scale",
  91534. /**
  91535. * Weights
  91536. */
  91537. WEIGHTS = "weights",
  91538. }
  91539. /**
  91540. * Interpolation algorithm
  91541. */
  91542. const enum AnimationSamplerInterpolation {
  91543. /**
  91544. * The animated values are linearly interpolated between keyframes
  91545. */
  91546. LINEAR = "LINEAR",
  91547. /**
  91548. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  91549. */
  91550. STEP = "STEP",
  91551. /**
  91552. * The animation's interpolation is computed using a cubic spline with specified tangents
  91553. */
  91554. CUBICSPLINE = "CUBICSPLINE",
  91555. }
  91556. /**
  91557. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  91558. */
  91559. const enum CameraType {
  91560. /**
  91561. * A perspective camera containing properties to create a perspective projection matrix
  91562. */
  91563. PERSPECTIVE = "perspective",
  91564. /**
  91565. * An orthographic camera containing properties to create an orthographic projection matrix
  91566. */
  91567. ORTHOGRAPHIC = "orthographic",
  91568. }
  91569. /**
  91570. * The mime-type of the image
  91571. */
  91572. const enum ImageMimeType {
  91573. /**
  91574. * JPEG Mime-type
  91575. */
  91576. JPEG = "image/jpeg",
  91577. /**
  91578. * PNG Mime-type
  91579. */
  91580. PNG = "image/png",
  91581. }
  91582. /**
  91583. * The alpha rendering mode of the material
  91584. */
  91585. const enum MaterialAlphaMode {
  91586. /**
  91587. * The alpha value is ignored and the rendered output is fully opaque
  91588. */
  91589. OPAQUE = "OPAQUE",
  91590. /**
  91591. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  91592. */
  91593. MASK = "MASK",
  91594. /**
  91595. * 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)
  91596. */
  91597. BLEND = "BLEND",
  91598. }
  91599. /**
  91600. * The type of the primitives to render
  91601. */
  91602. const enum MeshPrimitiveMode {
  91603. /**
  91604. * Points
  91605. */
  91606. POINTS = 0,
  91607. /**
  91608. * Lines
  91609. */
  91610. LINES = 1,
  91611. /**
  91612. * Line Loop
  91613. */
  91614. LINE_LOOP = 2,
  91615. /**
  91616. * Line Strip
  91617. */
  91618. LINE_STRIP = 3,
  91619. /**
  91620. * Triangles
  91621. */
  91622. TRIANGLES = 4,
  91623. /**
  91624. * Triangle Strip
  91625. */
  91626. TRIANGLE_STRIP = 5,
  91627. /**
  91628. * Triangle Fan
  91629. */
  91630. TRIANGLE_FAN = 6,
  91631. }
  91632. /**
  91633. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  91634. */
  91635. const enum TextureMagFilter {
  91636. /**
  91637. * Nearest
  91638. */
  91639. NEAREST = 9728,
  91640. /**
  91641. * Linear
  91642. */
  91643. LINEAR = 9729,
  91644. }
  91645. /**
  91646. * Minification filter. All valid values correspond to WebGL enums
  91647. */
  91648. const enum TextureMinFilter {
  91649. /**
  91650. * Nearest
  91651. */
  91652. NEAREST = 9728,
  91653. /**
  91654. * Linear
  91655. */
  91656. LINEAR = 9729,
  91657. /**
  91658. * Nearest Mip-Map Nearest
  91659. */
  91660. NEAREST_MIPMAP_NEAREST = 9984,
  91661. /**
  91662. * Linear Mipmap Nearest
  91663. */
  91664. LINEAR_MIPMAP_NEAREST = 9985,
  91665. /**
  91666. * Nearest Mipmap Linear
  91667. */
  91668. NEAREST_MIPMAP_LINEAR = 9986,
  91669. /**
  91670. * Linear Mipmap Linear
  91671. */
  91672. LINEAR_MIPMAP_LINEAR = 9987,
  91673. }
  91674. /**
  91675. * S (U) wrapping mode. All valid values correspond to WebGL enums
  91676. */
  91677. const enum TextureWrapMode {
  91678. /**
  91679. * Clamp to Edge
  91680. */
  91681. CLAMP_TO_EDGE = 33071,
  91682. /**
  91683. * Mirrored Repeat
  91684. */
  91685. MIRRORED_REPEAT = 33648,
  91686. /**
  91687. * Repeat
  91688. */
  91689. REPEAT = 10497,
  91690. }
  91691. /**
  91692. * glTF Property
  91693. */
  91694. interface IProperty {
  91695. /**
  91696. * Dictionary object with extension-specific objects
  91697. */
  91698. extensions?: {
  91699. [key: string]: any;
  91700. };
  91701. /**
  91702. * Application-Specific data
  91703. */
  91704. extras?: any;
  91705. }
  91706. /**
  91707. * glTF Child of Root Property
  91708. */
  91709. interface IChildRootProperty extends IProperty {
  91710. /**
  91711. * The user-defined name of this object
  91712. */
  91713. name?: string;
  91714. }
  91715. /**
  91716. * Indices of those attributes that deviate from their initialization value
  91717. */
  91718. interface IAccessorSparseIndices extends IProperty {
  91719. /**
  91720. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  91721. */
  91722. bufferView: number;
  91723. /**
  91724. * The offset relative to the start of the bufferView in bytes. Must be aligned
  91725. */
  91726. byteOffset?: number;
  91727. /**
  91728. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  91729. */
  91730. componentType: AccessorComponentType;
  91731. }
  91732. /**
  91733. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  91734. */
  91735. interface IAccessorSparseValues extends IProperty {
  91736. /**
  91737. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  91738. */
  91739. bufferView: number;
  91740. /**
  91741. * The offset relative to the start of the bufferView in bytes. Must be aligned
  91742. */
  91743. byteOffset?: number;
  91744. }
  91745. /**
  91746. * Sparse storage of attributes that deviate from their initialization value
  91747. */
  91748. interface IAccessorSparse extends IProperty {
  91749. /**
  91750. * The number of attributes encoded in this sparse accessor
  91751. */
  91752. count: number;
  91753. /**
  91754. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  91755. */
  91756. indices: IAccessorSparseIndices;
  91757. /**
  91758. * 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
  91759. */
  91760. values: IAccessorSparseValues;
  91761. }
  91762. /**
  91763. * 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
  91764. */
  91765. interface IAccessor extends IChildRootProperty {
  91766. /**
  91767. * The index of the bufferview
  91768. */
  91769. bufferView?: number;
  91770. /**
  91771. * The offset relative to the start of the bufferView in bytes
  91772. */
  91773. byteOffset?: number;
  91774. /**
  91775. * The datatype of components in the attribute
  91776. */
  91777. componentType: AccessorComponentType;
  91778. /**
  91779. * Specifies whether integer data values should be normalized
  91780. */
  91781. normalized?: boolean;
  91782. /**
  91783. * The number of attributes referenced by this accessor
  91784. */
  91785. count: number;
  91786. /**
  91787. * Specifies if the attribute is a scalar, vector, or matrix
  91788. */
  91789. type: AccessorType;
  91790. /**
  91791. * Maximum value of each component in this attribute
  91792. */
  91793. max?: number[];
  91794. /**
  91795. * Minimum value of each component in this attribute
  91796. */
  91797. min?: number[];
  91798. /**
  91799. * Sparse storage of attributes that deviate from their initialization value
  91800. */
  91801. sparse?: IAccessorSparse;
  91802. }
  91803. /**
  91804. * Targets an animation's sampler at a node's property
  91805. */
  91806. interface IAnimationChannel extends IProperty {
  91807. /**
  91808. * The index of a sampler in this animation used to compute the value for the target
  91809. */
  91810. sampler: number;
  91811. /**
  91812. * The index of the node and TRS property to target
  91813. */
  91814. target: IAnimationChannelTarget;
  91815. }
  91816. /**
  91817. * The index of the node and TRS property that an animation channel targets
  91818. */
  91819. interface IAnimationChannelTarget extends IProperty {
  91820. /**
  91821. * The index of the node to target
  91822. */
  91823. node: number;
  91824. /**
  91825. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  91826. */
  91827. path: AnimationChannelTargetPath;
  91828. }
  91829. /**
  91830. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  91831. */
  91832. interface IAnimationSampler extends IProperty {
  91833. /**
  91834. * The index of an accessor containing keyframe input values, e.g., time
  91835. */
  91836. input: number;
  91837. /**
  91838. * Interpolation algorithm
  91839. */
  91840. interpolation?: AnimationSamplerInterpolation;
  91841. /**
  91842. * The index of an accessor, containing keyframe output values
  91843. */
  91844. output: number;
  91845. }
  91846. /**
  91847. * A keyframe animation
  91848. */
  91849. interface IAnimation extends IChildRootProperty {
  91850. /**
  91851. * An array of channels, each of which targets an animation's sampler at a node's property
  91852. */
  91853. channels: IAnimationChannel[];
  91854. /**
  91855. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  91856. */
  91857. samplers: IAnimationSampler[];
  91858. }
  91859. /**
  91860. * Metadata about the glTF asset
  91861. */
  91862. interface IAsset extends IChildRootProperty {
  91863. /**
  91864. * A copyright message suitable for display to credit the content creator
  91865. */
  91866. copyright?: string;
  91867. /**
  91868. * Tool that generated this glTF model. Useful for debugging
  91869. */
  91870. generator?: string;
  91871. /**
  91872. * The glTF version that this asset targets
  91873. */
  91874. version: string;
  91875. /**
  91876. * The minimum glTF version that this asset targets
  91877. */
  91878. minVersion?: string;
  91879. }
  91880. /**
  91881. * A buffer points to binary geometry, animation, or skins
  91882. */
  91883. interface IBuffer extends IChildRootProperty {
  91884. /**
  91885. * 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
  91886. */
  91887. uri?: string;
  91888. /**
  91889. * The length of the buffer in bytes
  91890. */
  91891. byteLength: number;
  91892. }
  91893. /**
  91894. * A view into a buffer generally representing a subset of the buffer
  91895. */
  91896. interface IBufferView extends IChildRootProperty {
  91897. /**
  91898. * The index of the buffer
  91899. */
  91900. buffer: number;
  91901. /**
  91902. * The offset into the buffer in bytes
  91903. */
  91904. byteOffset?: number;
  91905. /**
  91906. * The lenth of the bufferView in bytes
  91907. */
  91908. byteLength: number;
  91909. /**
  91910. * The stride, in bytes
  91911. */
  91912. byteStride?: number;
  91913. }
  91914. /**
  91915. * An orthographic camera containing properties to create an orthographic projection matrix
  91916. */
  91917. interface ICameraOrthographic extends IProperty {
  91918. /**
  91919. * The floating-point horizontal magnification of the view. Must not be zero
  91920. */
  91921. xmag: number;
  91922. /**
  91923. * The floating-point vertical magnification of the view. Must not be zero
  91924. */
  91925. ymag: number;
  91926. /**
  91927. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  91928. */
  91929. zfar: number;
  91930. /**
  91931. * The floating-point distance to the near clipping plane
  91932. */
  91933. znear: number;
  91934. }
  91935. /**
  91936. * A perspective camera containing properties to create a perspective projection matrix
  91937. */
  91938. interface ICameraPerspective extends IProperty {
  91939. /**
  91940. * The floating-point aspect ratio of the field of view
  91941. */
  91942. aspectRatio?: number;
  91943. /**
  91944. * The floating-point vertical field of view in radians
  91945. */
  91946. yfov: number;
  91947. /**
  91948. * The floating-point distance to the far clipping plane
  91949. */
  91950. zfar?: number;
  91951. /**
  91952. * The floating-point distance to the near clipping plane
  91953. */
  91954. znear: number;
  91955. }
  91956. /**
  91957. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  91958. */
  91959. interface ICamera extends IChildRootProperty {
  91960. /**
  91961. * An orthographic camera containing properties to create an orthographic projection matrix
  91962. */
  91963. orthographic?: ICameraOrthographic;
  91964. /**
  91965. * A perspective camera containing properties to create a perspective projection matrix
  91966. */
  91967. perspective?: ICameraPerspective;
  91968. /**
  91969. * Specifies if the camera uses a perspective or orthographic projection
  91970. */
  91971. type: CameraType;
  91972. }
  91973. /**
  91974. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  91975. */
  91976. interface IImage extends IChildRootProperty {
  91977. /**
  91978. * 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
  91979. */
  91980. uri?: string;
  91981. /**
  91982. * The image's MIME type
  91983. */
  91984. mimeType?: ImageMimeType;
  91985. /**
  91986. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  91987. */
  91988. bufferView?: number;
  91989. }
  91990. /**
  91991. * Material Normal Texture Info
  91992. */
  91993. interface IMaterialNormalTextureInfo extends ITextureInfo {
  91994. /**
  91995. * The scalar multiplier applied to each normal vector of the normal texture
  91996. */
  91997. scale?: number;
  91998. }
  91999. /**
  92000. * Material Occlusion Texture Info
  92001. */
  92002. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  92003. /**
  92004. * A scalar multiplier controlling the amount of occlusion applied
  92005. */
  92006. strength?: number;
  92007. }
  92008. /**
  92009. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  92010. */
  92011. interface IMaterialPbrMetallicRoughness {
  92012. /**
  92013. * The material's base color factor
  92014. */
  92015. baseColorFactor?: number[];
  92016. /**
  92017. * The base color texture
  92018. */
  92019. baseColorTexture?: ITextureInfo;
  92020. /**
  92021. * The metalness of the material
  92022. */
  92023. metallicFactor?: number;
  92024. /**
  92025. * The roughness of the material
  92026. */
  92027. roughnessFactor?: number;
  92028. /**
  92029. * The metallic-roughness texture
  92030. */
  92031. metallicRoughnessTexture?: ITextureInfo;
  92032. }
  92033. /**
  92034. * The material appearance of a primitive
  92035. */
  92036. interface IMaterial extends IChildRootProperty {
  92037. /**
  92038. * 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
  92039. */
  92040. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  92041. /**
  92042. * The normal map texture
  92043. */
  92044. normalTexture?: IMaterialNormalTextureInfo;
  92045. /**
  92046. * The occlusion map texture
  92047. */
  92048. occlusionTexture?: IMaterialOcclusionTextureInfo;
  92049. /**
  92050. * The emissive map texture
  92051. */
  92052. emissiveTexture?: ITextureInfo;
  92053. /**
  92054. * 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
  92055. */
  92056. emissiveFactor?: number[];
  92057. /**
  92058. * The alpha rendering mode of the material
  92059. */
  92060. alphaMode?: MaterialAlphaMode;
  92061. /**
  92062. * The alpha cutoff value of the material
  92063. */
  92064. alphaCutoff?: number;
  92065. /**
  92066. * Specifies whether the material is double sided
  92067. */
  92068. doubleSided?: boolean;
  92069. }
  92070. /**
  92071. * Geometry to be rendered with the given material
  92072. */
  92073. interface IMeshPrimitive extends IProperty {
  92074. /**
  92075. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  92076. */
  92077. attributes: {
  92078. [name: string]: number;
  92079. };
  92080. /**
  92081. * The index of the accessor that contains the indices
  92082. */
  92083. indices?: number;
  92084. /**
  92085. * The index of the material to apply to this primitive when rendering
  92086. */
  92087. material?: number;
  92088. /**
  92089. * The type of primitives to render. All valid values correspond to WebGL enums
  92090. */
  92091. mode?: MeshPrimitiveMode;
  92092. /**
  92093. * 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
  92094. */
  92095. targets?: {
  92096. [name: string]: number;
  92097. }[];
  92098. }
  92099. /**
  92100. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  92101. */
  92102. interface IMesh extends IChildRootProperty {
  92103. /**
  92104. * An array of primitives, each defining geometry to be rendered with a material
  92105. */
  92106. primitives: IMeshPrimitive[];
  92107. /**
  92108. * Array of weights to be applied to the Morph Targets
  92109. */
  92110. weights?: number[];
  92111. }
  92112. /**
  92113. * A node in the node hierarchy
  92114. */
  92115. interface INode extends IChildRootProperty {
  92116. /**
  92117. * The index of the camera referenced by this node
  92118. */
  92119. camera?: number;
  92120. /**
  92121. * The indices of this node's children
  92122. */
  92123. children?: number[];
  92124. /**
  92125. * The index of the skin referenced by this node
  92126. */
  92127. skin?: number;
  92128. /**
  92129. * A floating-point 4x4 transformation matrix stored in column-major order
  92130. */
  92131. matrix?: number[];
  92132. /**
  92133. * The index of the mesh in this node
  92134. */
  92135. mesh?: number;
  92136. /**
  92137. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  92138. */
  92139. rotation?: number[];
  92140. /**
  92141. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  92142. */
  92143. scale?: number[];
  92144. /**
  92145. * The node's translation along the x, y, and z axes
  92146. */
  92147. translation?: number[];
  92148. /**
  92149. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  92150. */
  92151. weights?: number[];
  92152. }
  92153. /**
  92154. * Texture sampler properties for filtering and wrapping modes
  92155. */
  92156. interface ISampler extends IChildRootProperty {
  92157. /**
  92158. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  92159. */
  92160. magFilter?: TextureMagFilter;
  92161. /**
  92162. * Minification filter. All valid values correspond to WebGL enums
  92163. */
  92164. minFilter?: TextureMinFilter;
  92165. /**
  92166. * S (U) wrapping mode. All valid values correspond to WebGL enums
  92167. */
  92168. wrapS?: TextureWrapMode;
  92169. /**
  92170. * T (V) wrapping mode. All valid values correspond to WebGL enums
  92171. */
  92172. wrapT?: TextureWrapMode;
  92173. }
  92174. /**
  92175. * The root nodes of a scene
  92176. */
  92177. interface IScene extends IChildRootProperty {
  92178. /**
  92179. * The indices of each root node
  92180. */
  92181. nodes: number[];
  92182. }
  92183. /**
  92184. * Joints and matrices defining a skin
  92185. */
  92186. interface ISkin extends IChildRootProperty {
  92187. /**
  92188. * 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
  92189. */
  92190. inverseBindMatrices?: number;
  92191. /**
  92192. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  92193. */
  92194. skeleton?: number;
  92195. /**
  92196. * 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)
  92197. */
  92198. joints: number[];
  92199. }
  92200. /**
  92201. * A texture and its sampler
  92202. */
  92203. interface ITexture extends IChildRootProperty {
  92204. /**
  92205. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  92206. */
  92207. sampler?: number;
  92208. /**
  92209. * The index of the image used by this texture
  92210. */
  92211. source: number;
  92212. }
  92213. /**
  92214. * Reference to a texture
  92215. */
  92216. interface ITextureInfo extends IProperty {
  92217. /**
  92218. * The index of the texture
  92219. */
  92220. index: number;
  92221. /**
  92222. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  92223. */
  92224. texCoord?: number;
  92225. }
  92226. /**
  92227. * The root object for a glTF asset
  92228. */
  92229. interface IGLTF extends IProperty {
  92230. /**
  92231. * An array of accessors. An accessor is a typed view into a bufferView
  92232. */
  92233. accessors?: IAccessor[];
  92234. /**
  92235. * An array of keyframe animations
  92236. */
  92237. animations?: IAnimation[];
  92238. /**
  92239. * Metadata about the glTF asset
  92240. */
  92241. asset: IAsset;
  92242. /**
  92243. * An array of buffers. A buffer points to binary geometry, animation, or skins
  92244. */
  92245. buffers?: IBuffer[];
  92246. /**
  92247. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  92248. */
  92249. bufferViews?: IBufferView[];
  92250. /**
  92251. * An array of cameras
  92252. */
  92253. cameras?: ICamera[];
  92254. /**
  92255. * Names of glTF extensions used somewhere in this asset
  92256. */
  92257. extensionsUsed?: string[];
  92258. /**
  92259. * Names of glTF extensions required to properly load this asset
  92260. */
  92261. extensionsRequired?: string[];
  92262. /**
  92263. * An array of images. An image defines data used to create a texture
  92264. */
  92265. images?: IImage[];
  92266. /**
  92267. * An array of materials. A material defines the appearance of a primitive
  92268. */
  92269. materials?: IMaterial[];
  92270. /**
  92271. * An array of meshes. A mesh is a set of primitives to be rendered
  92272. */
  92273. meshes?: IMesh[];
  92274. /**
  92275. * An array of nodes
  92276. */
  92277. nodes?: INode[];
  92278. /**
  92279. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  92280. */
  92281. samplers?: ISampler[];
  92282. /**
  92283. * The index of the default scene
  92284. */
  92285. scene?: number;
  92286. /**
  92287. * An array of scenes
  92288. */
  92289. scenes?: IScene[];
  92290. /**
  92291. * An array of skins. A skin is defined by joints and matrices
  92292. */
  92293. skins?: ISkin[];
  92294. /**
  92295. * An array of textures
  92296. */
  92297. textures?: ITexture[];
  92298. }
  92299. /**
  92300. * The glTF validation results
  92301. * @ignore
  92302. */
  92303. interface IGLTFValidationResults {
  92304. info: {
  92305. generator: string;
  92306. hasAnimations: boolean;
  92307. hasDefaultScene: boolean;
  92308. hasMaterials: boolean;
  92309. hasMorphTargets: boolean;
  92310. hasSkins: boolean;
  92311. hasTextures: boolean;
  92312. maxAttributesUsed: number;
  92313. primitivesCount: number
  92314. };
  92315. issues: {
  92316. messages: Array<string>;
  92317. numErrors: number;
  92318. numHints: number;
  92319. numInfos: number;
  92320. numWarnings: number;
  92321. truncated: boolean
  92322. };
  92323. mimeType: string;
  92324. uri: string;
  92325. validatedAt: string;
  92326. validatorVersion: string;
  92327. }
  92328. /**
  92329. * The glTF validation options
  92330. */
  92331. interface IGLTFValidationOptions {
  92332. /** Uri to use */
  92333. uri?: string;
  92334. /** Function used to load external resources */
  92335. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  92336. /** Boolean indicating that we need to validate accessor data */
  92337. validateAccessorData?: boolean;
  92338. /** max number of issues allowed */
  92339. maxIssues?: number;
  92340. /** Ignored issues */
  92341. ignoredIssues?: Array<string>;
  92342. /** Value to override severy settings */
  92343. severityOverrides?: Object;
  92344. }
  92345. /**
  92346. * The glTF validator object
  92347. * @ignore
  92348. */
  92349. interface IGLTFValidator {
  92350. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  92351. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  92352. }
  92353. /**
  92354. * Interfaces from the EXT_lights_image_based extension
  92355. */
  92356. /** @hidden */
  92357. interface IEXTLightsImageBased_LightReferenceImageBased {
  92358. light: number;
  92359. }
  92360. /** @hidden */
  92361. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  92362. intensity: number;
  92363. rotation: number[];
  92364. specularImageSize: number;
  92365. specularImages: number[][];
  92366. irradianceCoefficients: number[][];
  92367. }
  92368. /** @hidden */
  92369. interface IEXTLightsImageBased {
  92370. lights: IEXTLightsImageBased_LightImageBased[];
  92371. }
  92372. /**
  92373. * Interfaces from the EXT_mesh_gpu_instancing extension
  92374. * !!! Experimental Extension Subject to Changes !!!
  92375. */
  92376. /** @hidden */
  92377. interface IEXTMeshGpuInstancing {
  92378. mesh?: number;
  92379. attributes: { [name: string]: number };
  92380. }
  92381. /**
  92382. * Interfaces from the KHR_draco_mesh_compression extension
  92383. */
  92384. /** @hidden */
  92385. interface IKHRDracoMeshCompression {
  92386. bufferView: number;
  92387. attributes: { [name: string]: number };
  92388. }
  92389. /**
  92390. * Interfaces from the KHR_lights_punctual extension
  92391. */
  92392. /** @hidden */
  92393. const enum IKHRLightsPunctual_LightType {
  92394. DIRECTIONAL = "directional",
  92395. POINT = "point",
  92396. SPOT = "spot"
  92397. }
  92398. /** @hidden */
  92399. interface IKHRLightsPunctual_LightReference {
  92400. light: number;
  92401. }
  92402. /** @hidden */
  92403. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  92404. type: IKHRLightsPunctual_LightType;
  92405. color?: number[];
  92406. intensity?: number;
  92407. range?: number;
  92408. spot?: {
  92409. innerConeAngle?: number;
  92410. outerConeAngle?: number;
  92411. };
  92412. }
  92413. /** @hidden */
  92414. interface IKHRLightsPunctual {
  92415. lights: IKHRLightsPunctual_Light[];
  92416. }
  92417. /**
  92418. * Interfaces from the KHR_materials_clearcoat extension
  92419. * !!! Experimental Extension Subject to Changes !!!
  92420. */
  92421. /** @hidden */
  92422. interface IKHRMaterialsClearcoat {
  92423. clearcoatFactor: number;
  92424. clearcoatTexture: ITextureInfo;
  92425. clearcoatRoughnessFactor: number;
  92426. clearcoatRoughnessTexture: ITextureInfo;
  92427. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  92428. }
  92429. /**
  92430. * Interfaces from the KHR_materials_ior extension
  92431. * !!! Experimental Extension Subject to Changes !!!
  92432. */
  92433. /** @hidden */
  92434. interface IKHRMaterialsIor {
  92435. ior: number;
  92436. }
  92437. /**
  92438. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  92439. */
  92440. /** @hidden */
  92441. interface IKHRMaterialsPbrSpecularGlossiness {
  92442. diffuseFactor: number[];
  92443. diffuseTexture: ITextureInfo;
  92444. specularFactor: number[];
  92445. glossinessFactor: number;
  92446. specularGlossinessTexture: ITextureInfo;
  92447. }
  92448. /**
  92449. * Interfaces from the KHR_materials_sheen extension
  92450. * !!! Experimental Extension Subject to Changes !!!
  92451. */
  92452. /** @hidden */
  92453. interface IKHRMaterialsSheen {
  92454. sheenColorFactor?: number[];
  92455. sheenColorTexture?: ITextureInfo;
  92456. sheenRoughnessFactor?: number;
  92457. sheenRoughnessTexture?: ITextureInfo;
  92458. }
  92459. /**
  92460. * Interfaces from the KHR_materials_specular extension
  92461. * !!! Experimental Extension Subject to Changes !!!
  92462. */
  92463. /** @hidden */
  92464. interface IKHRMaterialsSpecular {
  92465. specularFactor: number;
  92466. specularColorFactor: number[];
  92467. specularTexture: ITextureInfo;
  92468. }
  92469. /**
  92470. * Interfaces from the KHR_materials_transmission extension
  92471. * !!! Experimental Extension Subject to Changes !!!
  92472. */
  92473. /** @hidden */
  92474. interface IKHRMaterialsTransmission {
  92475. transmissionFactor?: number;
  92476. transmissionTexture?: ITextureInfo;
  92477. }
  92478. /**
  92479. * Interfaces from the KHR_materials_translucency extension
  92480. * !!! Experimental Extension Subject to Changes !!!
  92481. */
  92482. /** @hidden */
  92483. interface IKHRMaterialsTranslucency {
  92484. translucencyFactor?: number;
  92485. translucencyTexture?: ITextureInfo;
  92486. }
  92487. /**
  92488. * Interfaces from the KHR_materials_variants extension
  92489. * !!! Experimental Extension Subject to Changes !!!
  92490. */
  92491. /** @hidden */
  92492. interface IKHRMaterialVariants_Mapping extends IProperty {
  92493. mappings: Array<{
  92494. variants: number[];
  92495. material: number;
  92496. }>;
  92497. }
  92498. /** @hidden */
  92499. interface IKHRMaterialVariants_Variant extends IProperty {
  92500. name: string;
  92501. }
  92502. /** @hidden */
  92503. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  92504. variants: Array<IKHRMaterialVariants_Variant>;
  92505. }
  92506. /**
  92507. * Interfaces from the KHR_texture_basisu extension
  92508. * !!! Experimental Extension Subject to Changes !!!
  92509. */
  92510. /** @hidden */
  92511. interface IKHRTextureBasisU {
  92512. source: number;
  92513. }
  92514. /**
  92515. * Interfaces from the EXT_texture_webp extension
  92516. */
  92517. /** @hidden */
  92518. interface IEXTTextureWebP {
  92519. source: number;
  92520. }
  92521. /**
  92522. * Interfaces from the KHR_texture_transform extension
  92523. */
  92524. /** @hidden */
  92525. interface IKHRTextureTransform {
  92526. offset?: number[];
  92527. rotation?: number;
  92528. scale?: number[];
  92529. texCoord?: number;
  92530. }
  92531. /**
  92532. * Interfaces from the KHR_xmp_json_ld extension
  92533. * !!! Experimental Extension Subject to Changes !!!
  92534. */
  92535. /** @hidden */
  92536. interface IKHRXmpJsonLd_Gltf {
  92537. packets: Array<{
  92538. [key: string]: unknown;
  92539. }>;
  92540. }
  92541. /** @hidden */
  92542. interface IKHRXmpJsonLd_Node {
  92543. packet: number;
  92544. }
  92545. /**
  92546. * Interfaces from the MSFT_audio_emitter extension
  92547. */
  92548. /** @hidden */
  92549. interface IMSFTAudioEmitter_ClipReference {
  92550. clip: number;
  92551. weight?: number;
  92552. }
  92553. /** @hidden */
  92554. interface IMSFTAudioEmitter_EmittersReference {
  92555. emitters: number[];
  92556. }
  92557. /** @hidden */
  92558. const enum IMSFTAudioEmitter_DistanceModel {
  92559. linear = "linear",
  92560. inverse = "inverse",
  92561. exponential = "exponential",
  92562. }
  92563. /** @hidden */
  92564. interface IMSFTAudioEmitter_Emitter {
  92565. name?: string;
  92566. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  92567. refDistance?: number;
  92568. maxDistance?: number;
  92569. rolloffFactor?: number;
  92570. innerAngle?: number;
  92571. outerAngle?: number;
  92572. loop?: boolean;
  92573. volume?: number;
  92574. clips: IMSFTAudioEmitter_ClipReference[];
  92575. }
  92576. /** @hidden */
  92577. const enum IMSFTAudioEmitter_AudioMimeType {
  92578. WAV = "audio/wav",
  92579. }
  92580. /** @hidden */
  92581. interface IMSFTAudioEmitter_Clip extends IProperty {
  92582. uri?: string;
  92583. bufferView?: number;
  92584. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  92585. }
  92586. /** @hidden */
  92587. const enum IMSFTAudioEmitter_AnimationEventAction {
  92588. play = "play",
  92589. pause = "pause",
  92590. stop = "stop",
  92591. }
  92592. /** @hidden */
  92593. interface IMSFTAudioEmitter_AnimationEvent {
  92594. action: IMSFTAudioEmitter_AnimationEventAction;
  92595. emitter: number;
  92596. time: number;
  92597. startOffset?: number;
  92598. }
  92599. /**
  92600. * Interfaces from the MSFT_lod extension
  92601. */
  92602. /** @hidden */
  92603. interface IMSFTLOD {
  92604. ids: number[];
  92605. }
  92606. /**
  92607. * Interfaces from the EXT_meshopt_compression extension
  92608. */
  92609. /** @hidden */
  92610. interface IEXTMeshoptCompression {
  92611. buffer: number;
  92612. byteOffset?: number;
  92613. byteLength: number;
  92614. byteStride: number;
  92615. count: number;
  92616. mode: "ATTRIBUTES" | "TRIANGLES" | "INDICES";
  92617. filter?: "NONE" | "OCTAHEDRAL" | "QUATERNION" | "EXPONENTIAL";
  92618. }
  92619. }
  92620. declare module BABYLON {
  92621. /** @hidden */
  92622. export var cellPixelShader: {
  92623. name: string;
  92624. shader: string;
  92625. };
  92626. }
  92627. declare module BABYLON {
  92628. /** @hidden */
  92629. export var cellVertexShader: {
  92630. name: string;
  92631. shader: string;
  92632. };
  92633. }
  92634. declare module BABYLON {
  92635. export class CellMaterial extends BABYLON.PushMaterial {
  92636. private _diffuseTexture;
  92637. diffuseTexture: BABYLON.BaseTexture;
  92638. diffuseColor: BABYLON.Color3;
  92639. _computeHighLevel: boolean;
  92640. computeHighLevel: boolean;
  92641. private _disableLighting;
  92642. disableLighting: boolean;
  92643. private _maxSimultaneousLights;
  92644. maxSimultaneousLights: number;
  92645. constructor(name: string, scene: BABYLON.Scene);
  92646. needAlphaBlending(): boolean;
  92647. needAlphaTesting(): boolean;
  92648. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92649. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92650. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92651. getAnimatables(): BABYLON.IAnimatable[];
  92652. getActiveTextures(): BABYLON.BaseTexture[];
  92653. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92654. dispose(forceDisposeEffect?: boolean): void;
  92655. getClassName(): string;
  92656. clone(name: string): CellMaterial;
  92657. serialize(): any;
  92658. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  92659. }
  92660. }
  92661. declare module BABYLON {
  92662. export class CustomShaderStructure {
  92663. FragmentStore: string;
  92664. VertexStore: string;
  92665. constructor();
  92666. }
  92667. export class ShaderSpecialParts {
  92668. constructor();
  92669. Fragment_Begin: string;
  92670. Fragment_Definitions: string;
  92671. Fragment_MainBegin: string;
  92672. Fragment_Custom_Diffuse: string;
  92673. Fragment_Before_Lights: string;
  92674. Fragment_Before_Fog: string;
  92675. Fragment_Custom_Alpha: string;
  92676. Fragment_Before_FragColor: string;
  92677. Vertex_Begin: string;
  92678. Vertex_Definitions: string;
  92679. Vertex_MainBegin: string;
  92680. Vertex_Before_PositionUpdated: string;
  92681. Vertex_Before_NormalUpdated: string;
  92682. Vertex_After_WorldPosComputed: string;
  92683. Vertex_MainEnd: string;
  92684. }
  92685. export class CustomMaterial extends BABYLON.StandardMaterial {
  92686. static ShaderIndexer: number;
  92687. CustomParts: ShaderSpecialParts;
  92688. _isCreatedShader: boolean;
  92689. _createdShaderName: string;
  92690. _customUniform: string[];
  92691. _newUniforms: string[];
  92692. _newUniformInstances: {
  92693. [name: string]: any;
  92694. };
  92695. _newSamplerInstances: {
  92696. [name: string]: BABYLON.Texture;
  92697. };
  92698. _customAttributes: string[];
  92699. FragmentShader: string;
  92700. VertexShader: string;
  92701. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  92702. ReviewUniform(name: string, arr: string[]): string[];
  92703. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  92704. constructor(name: string, scene: BABYLON.Scene);
  92705. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  92706. AddAttribute(name: string): CustomMaterial;
  92707. Fragment_Begin(shaderPart: string): CustomMaterial;
  92708. Fragment_Definitions(shaderPart: string): CustomMaterial;
  92709. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  92710. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  92711. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  92712. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  92713. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  92714. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  92715. Vertex_Begin(shaderPart: string): CustomMaterial;
  92716. Vertex_Definitions(shaderPart: string): CustomMaterial;
  92717. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  92718. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  92719. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  92720. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  92721. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  92722. }
  92723. }
  92724. declare module BABYLON {
  92725. export class ShaderAlebdoParts {
  92726. constructor();
  92727. Fragment_Begin: string;
  92728. Fragment_Definitions: string;
  92729. Fragment_MainBegin: string;
  92730. Fragment_Custom_Albedo: string;
  92731. Fragment_Before_Lights: string;
  92732. Fragment_Custom_MetallicRoughness: string;
  92733. Fragment_Custom_MicroSurface: string;
  92734. Fragment_Before_Fog: string;
  92735. Fragment_Custom_Alpha: string;
  92736. Fragment_Before_FragColor: string;
  92737. Vertex_Begin: string;
  92738. Vertex_Definitions: string;
  92739. Vertex_MainBegin: string;
  92740. Vertex_Before_PositionUpdated: string;
  92741. Vertex_Before_NormalUpdated: string;
  92742. Vertex_After_WorldPosComputed: string;
  92743. Vertex_MainEnd: string;
  92744. }
  92745. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  92746. static ShaderIndexer: number;
  92747. CustomParts: ShaderAlebdoParts;
  92748. _isCreatedShader: boolean;
  92749. _createdShaderName: string;
  92750. _customUniform: string[];
  92751. _newUniforms: string[];
  92752. _newUniformInstances: {
  92753. [name: string]: any;
  92754. };
  92755. _newSamplerInstances: {
  92756. [name: string]: BABYLON.Texture;
  92757. };
  92758. _customAttributes: string[];
  92759. FragmentShader: string;
  92760. VertexShader: string;
  92761. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  92762. ReviewUniform(name: string, arr: string[]): string[];
  92763. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[], options?: BABYLON.ICustomShaderNameResolveOptions): string;
  92764. constructor(name: string, scene: BABYLON.Scene);
  92765. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  92766. AddAttribute(name: string): PBRCustomMaterial;
  92767. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  92768. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  92769. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  92770. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  92771. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  92772. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  92773. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  92774. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  92775. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  92776. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  92777. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  92778. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  92779. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  92780. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  92781. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  92782. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  92783. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  92784. }
  92785. }
  92786. declare module BABYLON {
  92787. /** @hidden */
  92788. export var firePixelShader: {
  92789. name: string;
  92790. shader: string;
  92791. };
  92792. }
  92793. declare module BABYLON {
  92794. /** @hidden */
  92795. export var fireVertexShader: {
  92796. name: string;
  92797. shader: string;
  92798. };
  92799. }
  92800. declare module BABYLON {
  92801. export class FireMaterial extends BABYLON.PushMaterial {
  92802. private _diffuseTexture;
  92803. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  92804. private _distortionTexture;
  92805. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  92806. private _opacityTexture;
  92807. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  92808. diffuseColor: BABYLON.Color3;
  92809. speed: number;
  92810. private _scaledDiffuse;
  92811. private _lastTime;
  92812. constructor(name: string, scene: BABYLON.Scene);
  92813. needAlphaBlending(): boolean;
  92814. needAlphaTesting(): boolean;
  92815. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92816. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92817. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92818. getAnimatables(): BABYLON.IAnimatable[];
  92819. getActiveTextures(): BABYLON.BaseTexture[];
  92820. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92821. getClassName(): string;
  92822. dispose(forceDisposeEffect?: boolean): void;
  92823. clone(name: string): FireMaterial;
  92824. serialize(): any;
  92825. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  92826. }
  92827. }
  92828. declare module BABYLON {
  92829. /** @hidden */
  92830. export var furPixelShader: {
  92831. name: string;
  92832. shader: string;
  92833. };
  92834. }
  92835. declare module BABYLON {
  92836. /** @hidden */
  92837. export var furVertexShader: {
  92838. name: string;
  92839. shader: string;
  92840. };
  92841. }
  92842. declare module BABYLON {
  92843. export class FurMaterial extends BABYLON.PushMaterial {
  92844. private _diffuseTexture;
  92845. diffuseTexture: BABYLON.BaseTexture;
  92846. private _heightTexture;
  92847. heightTexture: BABYLON.BaseTexture;
  92848. diffuseColor: BABYLON.Color3;
  92849. furLength: number;
  92850. furAngle: number;
  92851. furColor: BABYLON.Color3;
  92852. furOffset: number;
  92853. furSpacing: number;
  92854. furGravity: BABYLON.Vector3;
  92855. furSpeed: number;
  92856. furDensity: number;
  92857. furOcclusion: number;
  92858. furTexture: BABYLON.DynamicTexture;
  92859. private _disableLighting;
  92860. disableLighting: boolean;
  92861. private _maxSimultaneousLights;
  92862. maxSimultaneousLights: number;
  92863. highLevelFur: boolean;
  92864. _meshes: BABYLON.AbstractMesh[];
  92865. private _furTime;
  92866. constructor(name: string, scene: BABYLON.Scene);
  92867. get furTime(): number;
  92868. set furTime(furTime: number);
  92869. needAlphaBlending(): boolean;
  92870. needAlphaTesting(): boolean;
  92871. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92872. updateFur(): void;
  92873. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92874. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92875. getAnimatables(): BABYLON.IAnimatable[];
  92876. getActiveTextures(): BABYLON.BaseTexture[];
  92877. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92878. dispose(forceDisposeEffect?: boolean): void;
  92879. clone(name: string): FurMaterial;
  92880. serialize(): any;
  92881. getClassName(): string;
  92882. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  92883. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  92884. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  92885. }
  92886. }
  92887. declare module BABYLON {
  92888. /** @hidden */
  92889. export var gradientPixelShader: {
  92890. name: string;
  92891. shader: string;
  92892. };
  92893. }
  92894. declare module BABYLON {
  92895. /** @hidden */
  92896. export var gradientVertexShader: {
  92897. name: string;
  92898. shader: string;
  92899. };
  92900. }
  92901. declare module BABYLON {
  92902. export class GradientMaterial extends BABYLON.PushMaterial {
  92903. private _maxSimultaneousLights;
  92904. maxSimultaneousLights: number;
  92905. topColor: BABYLON.Color3;
  92906. topColorAlpha: number;
  92907. bottomColor: BABYLON.Color3;
  92908. bottomColorAlpha: number;
  92909. offset: number;
  92910. scale: number;
  92911. smoothness: number;
  92912. private _disableLighting;
  92913. disableLighting: boolean;
  92914. constructor(name: string, scene: BABYLON.Scene);
  92915. needAlphaBlending(): boolean;
  92916. needAlphaTesting(): boolean;
  92917. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92918. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92919. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92920. getAnimatables(): BABYLON.IAnimatable[];
  92921. dispose(forceDisposeEffect?: boolean): void;
  92922. clone(name: string): GradientMaterial;
  92923. serialize(): any;
  92924. getClassName(): string;
  92925. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  92926. }
  92927. }
  92928. declare module BABYLON {
  92929. /** @hidden */
  92930. export var gridPixelShader: {
  92931. name: string;
  92932. shader: string;
  92933. };
  92934. }
  92935. declare module BABYLON {
  92936. /** @hidden */
  92937. export var gridVertexShader: {
  92938. name: string;
  92939. shader: string;
  92940. };
  92941. }
  92942. declare module BABYLON {
  92943. /**
  92944. * The grid materials allows you to wrap any shape with a grid.
  92945. * Colors are customizable.
  92946. */
  92947. export class GridMaterial extends BABYLON.PushMaterial {
  92948. /**
  92949. * Main color of the grid (e.g. between lines)
  92950. */
  92951. mainColor: BABYLON.Color3;
  92952. /**
  92953. * Color of the grid lines.
  92954. */
  92955. lineColor: BABYLON.Color3;
  92956. /**
  92957. * The scale of the grid compared to unit.
  92958. */
  92959. gridRatio: number;
  92960. /**
  92961. * Allows setting an offset for the grid lines.
  92962. */
  92963. gridOffset: BABYLON.Vector3;
  92964. /**
  92965. * The frequency of thicker lines.
  92966. */
  92967. majorUnitFrequency: number;
  92968. /**
  92969. * The visibility of minor units in the grid.
  92970. */
  92971. minorUnitVisibility: number;
  92972. /**
  92973. * The grid opacity outside of the lines.
  92974. */
  92975. opacity: number;
  92976. /**
  92977. * Determine RBG output is premultiplied by alpha value.
  92978. */
  92979. preMultiplyAlpha: boolean;
  92980. private _opacityTexture;
  92981. opacityTexture: BABYLON.BaseTexture;
  92982. private _gridControl;
  92983. /**
  92984. * constructor
  92985. * @param name The name given to the material in order to identify it afterwards.
  92986. * @param scene The scene the material is used in.
  92987. */
  92988. constructor(name: string, scene: BABYLON.Scene);
  92989. /**
  92990. * Returns wehter or not the grid requires alpha blending.
  92991. */
  92992. needAlphaBlending(): boolean;
  92993. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  92994. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92995. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92996. /**
  92997. * Dispose the material and its associated resources.
  92998. * @param forceDisposeEffect will also dispose the used effect when true
  92999. */
  93000. dispose(forceDisposeEffect?: boolean): void;
  93001. clone(name: string): GridMaterial;
  93002. serialize(): any;
  93003. getClassName(): string;
  93004. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  93005. }
  93006. }
  93007. declare module BABYLON {
  93008. /** @hidden */
  93009. export var lavaPixelShader: {
  93010. name: string;
  93011. shader: string;
  93012. };
  93013. }
  93014. declare module BABYLON {
  93015. /** @hidden */
  93016. export var lavaVertexShader: {
  93017. name: string;
  93018. shader: string;
  93019. };
  93020. }
  93021. declare module BABYLON {
  93022. export class LavaMaterial extends BABYLON.PushMaterial {
  93023. private _diffuseTexture;
  93024. diffuseTexture: BABYLON.BaseTexture;
  93025. noiseTexture: BABYLON.BaseTexture;
  93026. fogColor: BABYLON.Color3;
  93027. speed: number;
  93028. movingSpeed: number;
  93029. lowFrequencySpeed: number;
  93030. fogDensity: number;
  93031. private _lastTime;
  93032. diffuseColor: BABYLON.Color3;
  93033. private _disableLighting;
  93034. disableLighting: boolean;
  93035. private _unlit;
  93036. unlit: boolean;
  93037. private _maxSimultaneousLights;
  93038. maxSimultaneousLights: number;
  93039. private _scaledDiffuse;
  93040. constructor(name: string, scene: BABYLON.Scene);
  93041. needAlphaBlending(): boolean;
  93042. needAlphaTesting(): boolean;
  93043. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  93044. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  93045. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  93046. getAnimatables(): BABYLON.IAnimatable[];
  93047. getActiveTextures(): BABYLON.BaseTexture[];
  93048. hasTexture(texture: BABYLON.BaseTexture): boolean;
  93049. dispose(forceDisposeEffect?: boolean): void;
  93050. clone(name: string): LavaMaterial;
  93051. serialize(): any;
  93052. getClassName(): string;
  93053. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  93054. }
  93055. }
  93056. declare module BABYLON {
  93057. /** @hidden */
  93058. export var mixPixelShader: {
  93059. name: string;
  93060. shader: string;
  93061. };
  93062. }
  93063. declare module BABYLON {
  93064. /** @hidden */
  93065. export var mixVertexShader: {
  93066. name: string;
  93067. shader: string;
  93068. };
  93069. }
  93070. declare module BABYLON {
  93071. export class MixMaterial extends BABYLON.PushMaterial {
  93072. /**
  93073. * Mix textures
  93074. */
  93075. private _mixTexture1;
  93076. mixTexture1: BABYLON.BaseTexture;
  93077. private _mixTexture2;
  93078. mixTexture2: BABYLON.BaseTexture;
  93079. /**
  93080. * Diffuse textures
  93081. */
  93082. private _diffuseTexture1;
  93083. diffuseTexture1: BABYLON.Texture;
  93084. private _diffuseTexture2;
  93085. diffuseTexture2: BABYLON.Texture;
  93086. private _diffuseTexture3;
  93087. diffuseTexture3: BABYLON.Texture;
  93088. private _diffuseTexture4;
  93089. diffuseTexture4: BABYLON.Texture;
  93090. private _diffuseTexture5;
  93091. diffuseTexture5: BABYLON.Texture;
  93092. private _diffuseTexture6;
  93093. diffuseTexture6: BABYLON.Texture;
  93094. private _diffuseTexture7;
  93095. diffuseTexture7: BABYLON.Texture;
  93096. private _diffuseTexture8;
  93097. diffuseTexture8: BABYLON.Texture;
  93098. /**
  93099. * Uniforms
  93100. */
  93101. diffuseColor: BABYLON.Color3;
  93102. specularColor: BABYLON.Color3;
  93103. specularPower: number;
  93104. private _disableLighting;
  93105. disableLighting: boolean;
  93106. private _maxSimultaneousLights;
  93107. maxSimultaneousLights: number;
  93108. constructor(name: string, scene: BABYLON.Scene);
  93109. needAlphaBlending(): boolean;
  93110. needAlphaTesting(): boolean;
  93111. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  93112. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  93113. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  93114. getAnimatables(): BABYLON.IAnimatable[];
  93115. getActiveTextures(): BABYLON.BaseTexture[];
  93116. hasTexture(texture: BABYLON.BaseTexture): boolean;
  93117. dispose(forceDisposeEffect?: boolean): void;
  93118. clone(name: string): MixMaterial;
  93119. serialize(): any;
  93120. getClassName(): string;
  93121. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  93122. }
  93123. }
  93124. declare module BABYLON {
  93125. /** @hidden */
  93126. export var normalPixelShader: {
  93127. name: string;
  93128. shader: string;
  93129. };
  93130. }
  93131. declare module BABYLON {
  93132. /** @hidden */
  93133. export var normalVertexShader: {
  93134. name: string;
  93135. shader: string;
  93136. };
  93137. }
  93138. declare module BABYLON {
  93139. export class NormalMaterial extends BABYLON.PushMaterial {
  93140. private _diffuseTexture;
  93141. diffuseTexture: BABYLON.BaseTexture;
  93142. diffuseColor: BABYLON.Color3;
  93143. private _disableLighting;
  93144. disableLighting: boolean;
  93145. private _maxSimultaneousLights;
  93146. maxSimultaneousLights: number;
  93147. constructor(name: string, scene: BABYLON.Scene);
  93148. needAlphaBlending(): boolean;
  93149. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  93150. needAlphaTesting(): boolean;
  93151. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  93152. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  93153. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  93154. getAnimatables(): BABYLON.IAnimatable[];
  93155. getActiveTextures(): BABYLON.BaseTexture[];
  93156. hasTexture(texture: BABYLON.BaseTexture): boolean;
  93157. dispose(forceDisposeEffect?: boolean): void;
  93158. clone(name: string): NormalMaterial;
  93159. serialize(): any;
  93160. getClassName(): string;
  93161. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  93162. }
  93163. }
  93164. declare module BABYLON {
  93165. /** @hidden */
  93166. export var shadowOnlyPixelShader: {
  93167. name: string;
  93168. shader: string;
  93169. };
  93170. }
  93171. declare module BABYLON {
  93172. /** @hidden */
  93173. export var shadowOnlyVertexShader: {
  93174. name: string;
  93175. shader: string;
  93176. };
  93177. }
  93178. declare module BABYLON {
  93179. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  93180. private _activeLight;
  93181. private _needAlphaBlending;
  93182. constructor(name: string, scene: BABYLON.Scene);
  93183. shadowColor: BABYLON.Color3;
  93184. needAlphaBlending(): boolean;
  93185. needAlphaTesting(): boolean;
  93186. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  93187. get activeLight(): BABYLON.IShadowLight;
  93188. set activeLight(light: BABYLON.IShadowLight);
  93189. private _getFirstShadowLightForMesh;
  93190. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  93191. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  93192. clone(name: string): ShadowOnlyMaterial;
  93193. serialize(): any;
  93194. getClassName(): string;
  93195. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  93196. }
  93197. }
  93198. declare module BABYLON {
  93199. /** @hidden */
  93200. export var simplePixelShader: {
  93201. name: string;
  93202. shader: string;
  93203. };
  93204. }
  93205. declare module BABYLON {
  93206. /** @hidden */
  93207. export var simpleVertexShader: {
  93208. name: string;
  93209. shader: string;
  93210. };
  93211. }
  93212. declare module BABYLON {
  93213. export class SimpleMaterial extends BABYLON.PushMaterial {
  93214. private _diffuseTexture;
  93215. diffuseTexture: BABYLON.BaseTexture;
  93216. diffuseColor: BABYLON.Color3;
  93217. private _disableLighting;
  93218. disableLighting: boolean;
  93219. private _maxSimultaneousLights;
  93220. maxSimultaneousLights: number;
  93221. constructor(name: string, scene: BABYLON.Scene);
  93222. needAlphaBlending(): boolean;
  93223. needAlphaTesting(): boolean;
  93224. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  93225. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  93226. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  93227. getAnimatables(): BABYLON.IAnimatable[];
  93228. getActiveTextures(): BABYLON.BaseTexture[];
  93229. hasTexture(texture: BABYLON.BaseTexture): boolean;
  93230. dispose(forceDisposeEffect?: boolean): void;
  93231. clone(name: string): SimpleMaterial;
  93232. serialize(): any;
  93233. getClassName(): string;
  93234. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  93235. }
  93236. }
  93237. declare module BABYLON {
  93238. /** @hidden */
  93239. export var skyPixelShader: {
  93240. name: string;
  93241. shader: string;
  93242. };
  93243. }
  93244. declare module BABYLON {
  93245. /** @hidden */
  93246. export var skyVertexShader: {
  93247. name: string;
  93248. shader: string;
  93249. };
  93250. }
  93251. declare module BABYLON {
  93252. /**
  93253. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  93254. * @see https://doc.babylonjs.com/extensions/sky
  93255. */
  93256. export class SkyMaterial extends BABYLON.PushMaterial {
  93257. /**
  93258. * Defines the overall luminance of sky in interval ]0, 1[.
  93259. */
  93260. luminance: number;
  93261. /**
  93262. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  93263. */
  93264. turbidity: number;
  93265. /**
  93266. * Defines the sky appearance (light intensity).
  93267. */
  93268. rayleigh: number;
  93269. /**
  93270. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  93271. */
  93272. mieCoefficient: number;
  93273. /**
  93274. * Defines the amount of haze particles following the Mie scattering theory.
  93275. */
  93276. mieDirectionalG: number;
  93277. /**
  93278. * Defines the distance of the sun according to the active scene camera.
  93279. */
  93280. distance: number;
  93281. /**
  93282. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  93283. * "inclined".
  93284. */
  93285. inclination: number;
  93286. /**
  93287. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  93288. * an object direction and a reference direction.
  93289. */
  93290. azimuth: number;
  93291. /**
  93292. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  93293. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  93294. */
  93295. sunPosition: BABYLON.Vector3;
  93296. /**
  93297. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  93298. * .sunPosition property.
  93299. */
  93300. useSunPosition: boolean;
  93301. /**
  93302. * Defines an offset vector used to get a horizon offset.
  93303. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  93304. */
  93305. cameraOffset: BABYLON.Vector3;
  93306. /**
  93307. * Defines the vector the skyMaterial should consider as up. (default is BABYLON.Vector3(0, 1, 0) as returned by BABYLON.Vector3.Up())
  93308. */
  93309. up: BABYLON.Vector3;
  93310. private _cameraPosition;
  93311. private _skyOrientation;
  93312. /**
  93313. * Instantiates a new sky material.
  93314. * This material allows to create dynamic and texture free
  93315. * effects for skyboxes by taking care of the atmosphere state.
  93316. * @see https://doc.babylonjs.com/extensions/sky
  93317. * @param name Define the name of the material in the scene
  93318. * @param scene Define the scene the material belong to
  93319. */
  93320. constructor(name: string, scene: BABYLON.Scene);
  93321. /**
  93322. * Specifies if the material will require alpha blending
  93323. * @returns a boolean specifying if alpha blending is needed
  93324. */
  93325. needAlphaBlending(): boolean;
  93326. /**
  93327. * Specifies if this material should be rendered in alpha test mode
  93328. * @returns false as the sky material doesn't need alpha testing.
  93329. */
  93330. needAlphaTesting(): boolean;
  93331. /**
  93332. * Get the texture used for alpha test purpose.
  93333. * @returns null as the sky material has no texture.
  93334. */
  93335. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  93336. /**
  93337. * Get if the submesh is ready to be used and all its information available.
  93338. * Child classes can use it to update shaders
  93339. * @param mesh defines the mesh to check
  93340. * @param subMesh defines which submesh to check
  93341. * @param useInstances specifies that instances should be used
  93342. * @returns a boolean indicating that the submesh is ready or not
  93343. */
  93344. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  93345. /**
  93346. * Binds the submesh to this material by preparing the effect and shader to draw
  93347. * @param world defines the world transformation matrix
  93348. * @param mesh defines the mesh containing the submesh
  93349. * @param subMesh defines the submesh to bind the material to
  93350. */
  93351. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  93352. /**
  93353. * Get the list of animatables in the material.
  93354. * @returns the list of animatables object used in the material
  93355. */
  93356. getAnimatables(): BABYLON.IAnimatable[];
  93357. /**
  93358. * Disposes the material
  93359. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  93360. */
  93361. dispose(forceDisposeEffect?: boolean): void;
  93362. /**
  93363. * Makes a duplicate of the material, and gives it a new name
  93364. * @param name defines the new name for the duplicated material
  93365. * @returns the cloned material
  93366. */
  93367. clone(name: string): SkyMaterial;
  93368. /**
  93369. * Serializes this material in a JSON representation
  93370. * @returns the serialized material object
  93371. */
  93372. serialize(): any;
  93373. /**
  93374. * Gets the current class name of the material e.g. "SkyMaterial"
  93375. * Mainly use in serialization.
  93376. * @returns the class name
  93377. */
  93378. getClassName(): string;
  93379. /**
  93380. * Creates a sky material from parsed material data
  93381. * @param source defines the JSON representation of the material
  93382. * @param scene defines the hosting scene
  93383. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  93384. * @returns a new sky material
  93385. */
  93386. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  93387. }
  93388. }
  93389. declare module BABYLON {
  93390. /** @hidden */
  93391. export var terrainPixelShader: {
  93392. name: string;
  93393. shader: string;
  93394. };
  93395. }
  93396. declare module BABYLON {
  93397. /** @hidden */
  93398. export var terrainVertexShader: {
  93399. name: string;
  93400. shader: string;
  93401. };
  93402. }
  93403. declare module BABYLON {
  93404. export class TerrainMaterial extends BABYLON.PushMaterial {
  93405. private _mixTexture;
  93406. mixTexture: BABYLON.BaseTexture;
  93407. private _diffuseTexture1;
  93408. diffuseTexture1: BABYLON.Texture;
  93409. private _diffuseTexture2;
  93410. diffuseTexture2: BABYLON.Texture;
  93411. private _diffuseTexture3;
  93412. diffuseTexture3: BABYLON.Texture;
  93413. private _bumpTexture1;
  93414. bumpTexture1: BABYLON.Texture;
  93415. private _bumpTexture2;
  93416. bumpTexture2: BABYLON.Texture;
  93417. private _bumpTexture3;
  93418. bumpTexture3: BABYLON.Texture;
  93419. diffuseColor: BABYLON.Color3;
  93420. specularColor: BABYLON.Color3;
  93421. specularPower: number;
  93422. private _disableLighting;
  93423. disableLighting: boolean;
  93424. private _maxSimultaneousLights;
  93425. maxSimultaneousLights: number;
  93426. constructor(name: string, scene: BABYLON.Scene);
  93427. needAlphaBlending(): boolean;
  93428. needAlphaTesting(): boolean;
  93429. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  93430. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  93431. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  93432. getAnimatables(): BABYLON.IAnimatable[];
  93433. getActiveTextures(): BABYLON.BaseTexture[];
  93434. hasTexture(texture: BABYLON.BaseTexture): boolean;
  93435. dispose(forceDisposeEffect?: boolean): void;
  93436. clone(name: string): TerrainMaterial;
  93437. serialize(): any;
  93438. getClassName(): string;
  93439. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  93440. }
  93441. }
  93442. declare module BABYLON {
  93443. /** @hidden */
  93444. export var triplanarPixelShader: {
  93445. name: string;
  93446. shader: string;
  93447. };
  93448. }
  93449. declare module BABYLON {
  93450. /** @hidden */
  93451. export var triplanarVertexShader: {
  93452. name: string;
  93453. shader: string;
  93454. };
  93455. }
  93456. declare module BABYLON {
  93457. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  93458. mixTexture: BABYLON.BaseTexture;
  93459. private _diffuseTextureX;
  93460. diffuseTextureX: BABYLON.BaseTexture;
  93461. private _diffuseTextureY;
  93462. diffuseTextureY: BABYLON.BaseTexture;
  93463. private _diffuseTextureZ;
  93464. diffuseTextureZ: BABYLON.BaseTexture;
  93465. private _normalTextureX;
  93466. normalTextureX: BABYLON.BaseTexture;
  93467. private _normalTextureY;
  93468. normalTextureY: BABYLON.BaseTexture;
  93469. private _normalTextureZ;
  93470. normalTextureZ: BABYLON.BaseTexture;
  93471. tileSize: number;
  93472. diffuseColor: BABYLON.Color3;
  93473. specularColor: BABYLON.Color3;
  93474. specularPower: number;
  93475. private _disableLighting;
  93476. disableLighting: boolean;
  93477. private _maxSimultaneousLights;
  93478. maxSimultaneousLights: number;
  93479. constructor(name: string, scene: BABYLON.Scene);
  93480. needAlphaBlending(): boolean;
  93481. needAlphaTesting(): boolean;
  93482. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  93483. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  93484. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  93485. getAnimatables(): BABYLON.IAnimatable[];
  93486. getActiveTextures(): BABYLON.BaseTexture[];
  93487. hasTexture(texture: BABYLON.BaseTexture): boolean;
  93488. dispose(forceDisposeEffect?: boolean): void;
  93489. clone(name: string): TriPlanarMaterial;
  93490. serialize(): any;
  93491. getClassName(): string;
  93492. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  93493. }
  93494. }
  93495. declare module BABYLON {
  93496. /** @hidden */
  93497. export var waterPixelShader: {
  93498. name: string;
  93499. shader: string;
  93500. };
  93501. }
  93502. declare module BABYLON {
  93503. /** @hidden */
  93504. export var waterVertexShader: {
  93505. name: string;
  93506. shader: string;
  93507. };
  93508. }
  93509. declare module BABYLON {
  93510. export class WaterMaterial extends BABYLON.PushMaterial {
  93511. renderTargetSize: BABYLON.Vector2;
  93512. private _bumpTexture;
  93513. bumpTexture: BABYLON.BaseTexture;
  93514. diffuseColor: BABYLON.Color3;
  93515. specularColor: BABYLON.Color3;
  93516. specularPower: number;
  93517. private _disableLighting;
  93518. disableLighting: boolean;
  93519. private _maxSimultaneousLights;
  93520. maxSimultaneousLights: number;
  93521. /**
  93522. * Defines the wind force.
  93523. */
  93524. windForce: number;
  93525. /**
  93526. * Defines the direction of the wind in the plane (X, Z).
  93527. */
  93528. windDirection: BABYLON.Vector2;
  93529. /**
  93530. * Defines the height of the waves.
  93531. */
  93532. waveHeight: number;
  93533. /**
  93534. * Defines the bump height related to the bump map.
  93535. */
  93536. bumpHeight: number;
  93537. /**
  93538. * Defines wether or not: to add a smaller moving bump to less steady waves.
  93539. */
  93540. private _bumpSuperimpose;
  93541. bumpSuperimpose: boolean;
  93542. /**
  93543. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  93544. */
  93545. private _fresnelSeparate;
  93546. fresnelSeparate: boolean;
  93547. /**
  93548. * Defines wether or not bump Wwves modify the reflection.
  93549. */
  93550. private _bumpAffectsReflection;
  93551. bumpAffectsReflection: boolean;
  93552. /**
  93553. * Defines the water color blended with the refraction (near).
  93554. */
  93555. waterColor: BABYLON.Color3;
  93556. /**
  93557. * Defines the blend factor related to the water color.
  93558. */
  93559. colorBlendFactor: number;
  93560. /**
  93561. * Defines the water color blended with the reflection (far).
  93562. */
  93563. waterColor2: BABYLON.Color3;
  93564. /**
  93565. * Defines the blend factor related to the water color (reflection, far).
  93566. */
  93567. colorBlendFactor2: number;
  93568. /**
  93569. * Defines the maximum length of a wave.
  93570. */
  93571. waveLength: number;
  93572. /**
  93573. * Defines the waves speed.
  93574. */
  93575. waveSpeed: number;
  93576. /**
  93577. * 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.
  93578. */
  93579. waveCount: number;
  93580. /**
  93581. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  93582. * will avoid calculating useless pixels in the pixel shader of the water material.
  93583. */
  93584. disableClipPlane: boolean;
  93585. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  93586. private _mesh;
  93587. private _refractionRTT;
  93588. private _reflectionRTT;
  93589. private _reflectionTransform;
  93590. private _lastTime;
  93591. private _lastDeltaTime;
  93592. private _useLogarithmicDepth;
  93593. private _waitingRenderList;
  93594. private _imageProcessingConfiguration;
  93595. private _imageProcessingObserver;
  93596. /**
  93597. * Gets a boolean indicating that current material needs to register RTT
  93598. */
  93599. get hasRenderTargetTextures(): boolean;
  93600. /**
  93601. * Constructor
  93602. */
  93603. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  93604. get useLogarithmicDepth(): boolean;
  93605. set useLogarithmicDepth(value: boolean);
  93606. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  93607. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  93608. addToRenderList(node: any): void;
  93609. enableRenderTargets(enable: boolean): void;
  93610. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  93611. get renderTargetsEnabled(): boolean;
  93612. needAlphaBlending(): boolean;
  93613. needAlphaTesting(): boolean;
  93614. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  93615. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  93616. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  93617. private _createRenderTargets;
  93618. getAnimatables(): BABYLON.IAnimatable[];
  93619. getActiveTextures(): BABYLON.BaseTexture[];
  93620. hasTexture(texture: BABYLON.BaseTexture): boolean;
  93621. dispose(forceDisposeEffect?: boolean): void;
  93622. clone(name: string): WaterMaterial;
  93623. serialize(): any;
  93624. getClassName(): string;
  93625. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  93626. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  93627. }
  93628. }
  93629. declare module BABYLON {
  93630. /** @hidden */
  93631. export var asciiartPixelShader: {
  93632. name: string;
  93633. shader: string;
  93634. };
  93635. }
  93636. declare module BABYLON {
  93637. /**
  93638. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  93639. *
  93640. * It basically takes care rendering the font front the given font size to a texture.
  93641. * This is used later on in the postprocess.
  93642. */
  93643. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  93644. private _font;
  93645. private _text;
  93646. private _charSize;
  93647. /**
  93648. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  93649. */
  93650. get charSize(): number;
  93651. /**
  93652. * Create a new instance of the Ascii Art FontTexture class
  93653. * @param name the name of the texture
  93654. * @param font the font to use, use the W3C CSS notation
  93655. * @param text the caracter set to use in the rendering.
  93656. * @param scene the scene that owns the texture
  93657. */
  93658. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  93659. /**
  93660. * Gets the max char width of a font.
  93661. * @param font the font to use, use the W3C CSS notation
  93662. * @return the max char width
  93663. */
  93664. private getFontWidth;
  93665. /**
  93666. * Gets the max char height of a font.
  93667. * @param font the font to use, use the W3C CSS notation
  93668. * @return the max char height
  93669. */
  93670. private getFontHeight;
  93671. /**
  93672. * Clones the current AsciiArtTexture.
  93673. * @return the clone of the texture.
  93674. */
  93675. clone(): AsciiArtFontTexture;
  93676. /**
  93677. * Parses a json object representing the texture and returns an instance of it.
  93678. * @param source the source JSON representation
  93679. * @param scene the scene to create the texture for
  93680. * @return the parsed texture
  93681. */
  93682. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  93683. }
  93684. /**
  93685. * Option available in the Ascii Art Post Process.
  93686. */
  93687. export interface IAsciiArtPostProcessOptions {
  93688. /**
  93689. * The font to use following the w3c font definition.
  93690. */
  93691. font?: string;
  93692. /**
  93693. * The character set to use in the postprocess.
  93694. */
  93695. characterSet?: string;
  93696. /**
  93697. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  93698. * This number is defined between 0 and 1;
  93699. */
  93700. mixToTile?: number;
  93701. /**
  93702. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  93703. * This number is defined between 0 and 1;
  93704. */
  93705. mixToNormal?: number;
  93706. }
  93707. /**
  93708. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  93709. *
  93710. * Simmply add it to your scene and let the nerd that lives in you have fun.
  93711. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  93712. */
  93713. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  93714. /**
  93715. * The font texture used to render the char in the post process.
  93716. */
  93717. private _asciiArtFontTexture;
  93718. /**
  93719. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  93720. * This number is defined between 0 and 1;
  93721. */
  93722. mixToTile: number;
  93723. /**
  93724. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  93725. * This number is defined between 0 and 1;
  93726. */
  93727. mixToNormal: number;
  93728. /**
  93729. * Instantiates a new Ascii Art Post Process.
  93730. * @param name the name to give to the postprocess
  93731. * @camera the camera to apply the post process to.
  93732. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  93733. */
  93734. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  93735. }
  93736. }
  93737. declare module BABYLON {
  93738. /** @hidden */
  93739. export var digitalrainPixelShader: {
  93740. name: string;
  93741. shader: string;
  93742. };
  93743. }
  93744. declare module BABYLON {
  93745. /**
  93746. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  93747. *
  93748. * It basically takes care rendering the font front the given font size to a texture.
  93749. * This is used later on in the postprocess.
  93750. */
  93751. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  93752. private _font;
  93753. private _text;
  93754. private _charSize;
  93755. /**
  93756. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  93757. */
  93758. get charSize(): number;
  93759. /**
  93760. * Create a new instance of the Digital Rain FontTexture class
  93761. * @param name the name of the texture
  93762. * @param font the font to use, use the W3C CSS notation
  93763. * @param text the caracter set to use in the rendering.
  93764. * @param scene the scene that owns the texture
  93765. */
  93766. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  93767. /**
  93768. * Gets the max char width of a font.
  93769. * @param font the font to use, use the W3C CSS notation
  93770. * @return the max char width
  93771. */
  93772. private getFontWidth;
  93773. /**
  93774. * Gets the max char height of a font.
  93775. * @param font the font to use, use the W3C CSS notation
  93776. * @return the max char height
  93777. */
  93778. private getFontHeight;
  93779. /**
  93780. * Clones the current DigitalRainFontTexture.
  93781. * @return the clone of the texture.
  93782. */
  93783. clone(): DigitalRainFontTexture;
  93784. /**
  93785. * Parses a json object representing the texture and returns an instance of it.
  93786. * @param source the source JSON representation
  93787. * @param scene the scene to create the texture for
  93788. * @return the parsed texture
  93789. */
  93790. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  93791. }
  93792. /**
  93793. * Option available in the Digital Rain Post Process.
  93794. */
  93795. export interface IDigitalRainPostProcessOptions {
  93796. /**
  93797. * The font to use following the w3c font definition.
  93798. */
  93799. font?: string;
  93800. /**
  93801. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  93802. * This number is defined between 0 and 1;
  93803. */
  93804. mixToTile?: number;
  93805. /**
  93806. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  93807. * This number is defined between 0 and 1;
  93808. */
  93809. mixToNormal?: number;
  93810. }
  93811. /**
  93812. * DigitalRainPostProcess helps rendering everithing in digital rain.
  93813. *
  93814. * Simmply add it to your scene and let the nerd that lives in you have fun.
  93815. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  93816. */
  93817. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  93818. /**
  93819. * The font texture used to render the char in the post process.
  93820. */
  93821. private _digitalRainFontTexture;
  93822. /**
  93823. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  93824. * This number is defined between 0 and 1;
  93825. */
  93826. mixToTile: number;
  93827. /**
  93828. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  93829. * This number is defined between 0 and 1;
  93830. */
  93831. mixToNormal: number;
  93832. /**
  93833. * Instantiates a new Digital Rain Post Process.
  93834. * @param name the name to give to the postprocess
  93835. * @camera the camera to apply the post process to.
  93836. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  93837. */
  93838. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  93839. }
  93840. }
  93841. declare module BABYLON {
  93842. /** @hidden */
  93843. export var brickProceduralTexturePixelShader: {
  93844. name: string;
  93845. shader: string;
  93846. };
  93847. }
  93848. declare module BABYLON {
  93849. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  93850. private _numberOfBricksHeight;
  93851. private _numberOfBricksWidth;
  93852. private _jointColor;
  93853. private _brickColor;
  93854. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93855. updateShaderUniforms(): void;
  93856. get numberOfBricksHeight(): number;
  93857. set numberOfBricksHeight(value: number);
  93858. get numberOfBricksWidth(): number;
  93859. set numberOfBricksWidth(value: number);
  93860. get jointColor(): BABYLON.Color3;
  93861. set jointColor(value: BABYLON.Color3);
  93862. get brickColor(): BABYLON.Color3;
  93863. set brickColor(value: BABYLON.Color3);
  93864. /**
  93865. * Serializes this brick procedural texture
  93866. * @returns a serialized brick procedural texture object
  93867. */
  93868. serialize(): any;
  93869. /**
  93870. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  93871. * @param parsedTexture defines parsed texture data
  93872. * @param scene defines the current scene
  93873. * @param rootUrl defines the root URL containing brick procedural texture information
  93874. * @returns a parsed Brick Procedural BABYLON.Texture
  93875. */
  93876. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  93877. }
  93878. }
  93879. declare module BABYLON {
  93880. /** @hidden */
  93881. export var cloudProceduralTexturePixelShader: {
  93882. name: string;
  93883. shader: string;
  93884. };
  93885. }
  93886. declare module BABYLON {
  93887. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  93888. private _skyColor;
  93889. private _cloudColor;
  93890. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93891. updateShaderUniforms(): void;
  93892. get skyColor(): BABYLON.Color4;
  93893. set skyColor(value: BABYLON.Color4);
  93894. get cloudColor(): BABYLON.Color4;
  93895. set cloudColor(value: BABYLON.Color4);
  93896. /**
  93897. * Serializes this cloud procedural texture
  93898. * @returns a serialized cloud procedural texture object
  93899. */
  93900. serialize(): any;
  93901. /**
  93902. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  93903. * @param parsedTexture defines parsed texture data
  93904. * @param scene defines the current scene
  93905. * @param rootUrl defines the root URL containing cloud procedural texture information
  93906. * @returns a parsed Cloud Procedural BABYLON.Texture
  93907. */
  93908. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  93909. }
  93910. }
  93911. declare module BABYLON {
  93912. /** @hidden */
  93913. export var fireProceduralTexturePixelShader: {
  93914. name: string;
  93915. shader: string;
  93916. };
  93917. }
  93918. declare module BABYLON {
  93919. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  93920. private _time;
  93921. private _speed;
  93922. private _autoGenerateTime;
  93923. private _fireColors;
  93924. private _alphaThreshold;
  93925. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93926. updateShaderUniforms(): void;
  93927. render(useCameraPostProcess?: boolean): void;
  93928. static get PurpleFireColors(): BABYLON.Color3[];
  93929. static get GreenFireColors(): BABYLON.Color3[];
  93930. static get RedFireColors(): BABYLON.Color3[];
  93931. static get BlueFireColors(): BABYLON.Color3[];
  93932. get autoGenerateTime(): boolean;
  93933. set autoGenerateTime(value: boolean);
  93934. get fireColors(): BABYLON.Color3[];
  93935. set fireColors(value: BABYLON.Color3[]);
  93936. get time(): number;
  93937. set time(value: number);
  93938. get speed(): BABYLON.Vector2;
  93939. set speed(value: BABYLON.Vector2);
  93940. get alphaThreshold(): number;
  93941. set alphaThreshold(value: number);
  93942. /**
  93943. * Serializes this fire procedural texture
  93944. * @returns a serialized fire procedural texture object
  93945. */
  93946. serialize(): any;
  93947. /**
  93948. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  93949. * @param parsedTexture defines parsed texture data
  93950. * @param scene defines the current scene
  93951. * @param rootUrl defines the root URL containing fire procedural texture information
  93952. * @returns a parsed Fire Procedural BABYLON.Texture
  93953. */
  93954. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  93955. }
  93956. }
  93957. declare module BABYLON {
  93958. /** @hidden */
  93959. export var grassProceduralTexturePixelShader: {
  93960. name: string;
  93961. shader: string;
  93962. };
  93963. }
  93964. declare module BABYLON {
  93965. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  93966. private _grassColors;
  93967. private _groundColor;
  93968. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93969. updateShaderUniforms(): void;
  93970. get grassColors(): BABYLON.Color3[];
  93971. set grassColors(value: BABYLON.Color3[]);
  93972. get groundColor(): BABYLON.Color3;
  93973. set groundColor(value: BABYLON.Color3);
  93974. /**
  93975. * Serializes this grass procedural texture
  93976. * @returns a serialized grass procedural texture object
  93977. */
  93978. serialize(): any;
  93979. /**
  93980. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  93981. * @param parsedTexture defines parsed texture data
  93982. * @param scene defines the current scene
  93983. * @param rootUrl defines the root URL containing grass procedural texture information
  93984. * @returns a parsed Grass Procedural BABYLON.Texture
  93985. */
  93986. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  93987. }
  93988. }
  93989. declare module BABYLON {
  93990. /** @hidden */
  93991. export var marbleProceduralTexturePixelShader: {
  93992. name: string;
  93993. shader: string;
  93994. };
  93995. }
  93996. declare module BABYLON {
  93997. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  93998. private _numberOfTilesHeight;
  93999. private _numberOfTilesWidth;
  94000. private _amplitude;
  94001. private _jointColor;
  94002. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  94003. updateShaderUniforms(): void;
  94004. get numberOfTilesHeight(): number;
  94005. set numberOfTilesHeight(value: number);
  94006. get amplitude(): number;
  94007. set amplitude(value: number);
  94008. get numberOfTilesWidth(): number;
  94009. set numberOfTilesWidth(value: number);
  94010. get jointColor(): BABYLON.Color3;
  94011. set jointColor(value: BABYLON.Color3);
  94012. /**
  94013. * Serializes this marble procedural texture
  94014. * @returns a serialized marble procedural texture object
  94015. */
  94016. serialize(): any;
  94017. /**
  94018. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  94019. * @param parsedTexture defines parsed texture data
  94020. * @param scene defines the current scene
  94021. * @param rootUrl defines the root URL containing marble procedural texture information
  94022. * @returns a parsed Marble Procedural BABYLON.Texture
  94023. */
  94024. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  94025. }
  94026. }
  94027. declare module BABYLON {
  94028. /** @hidden */
  94029. export var normalMapProceduralTexturePixelShader: {
  94030. name: string;
  94031. shader: string;
  94032. };
  94033. }
  94034. declare module BABYLON {
  94035. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  94036. private _baseTexture;
  94037. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  94038. updateShaderUniforms(): void;
  94039. render(useCameraPostProcess?: boolean): void;
  94040. resize(size: any, generateMipMaps: any): void;
  94041. isReady(): boolean;
  94042. get baseTexture(): BABYLON.Texture;
  94043. set baseTexture(texture: BABYLON.Texture);
  94044. /**
  94045. * Serializes this normal map procedural texture
  94046. * @returns a serialized normal map procedural texture object
  94047. */
  94048. serialize(): any;
  94049. /**
  94050. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  94051. * @param parsedTexture defines parsed texture data
  94052. * @param scene defines the current scene
  94053. * @param rootUrl defines the root URL containing normal map procedural texture information
  94054. * @returns a parsed Normal Map Procedural BABYLON.Texture
  94055. */
  94056. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  94057. }
  94058. }
  94059. declare module BABYLON {
  94060. /** @hidden */
  94061. export var perlinNoiseProceduralTexturePixelShader: {
  94062. name: string;
  94063. shader: string;
  94064. };
  94065. }
  94066. declare module BABYLON {
  94067. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  94068. time: number;
  94069. timeScale: number;
  94070. translationSpeed: number;
  94071. private _currentTranslation;
  94072. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  94073. updateShaderUniforms(): void;
  94074. render(useCameraPostProcess?: boolean): void;
  94075. resize(size: any, generateMipMaps: any): void;
  94076. /**
  94077. * Serializes this perlin noise procedural texture
  94078. * @returns a serialized perlin noise procedural texture object
  94079. */
  94080. serialize(): any;
  94081. /**
  94082. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  94083. * @param parsedTexture defines parsed texture data
  94084. * @param scene defines the current scene
  94085. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  94086. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  94087. */
  94088. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  94089. }
  94090. }
  94091. declare module BABYLON {
  94092. /** @hidden */
  94093. export var roadProceduralTexturePixelShader: {
  94094. name: string;
  94095. shader: string;
  94096. };
  94097. }
  94098. declare module BABYLON {
  94099. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  94100. private _roadColor;
  94101. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  94102. updateShaderUniforms(): void;
  94103. get roadColor(): BABYLON.Color3;
  94104. set roadColor(value: BABYLON.Color3);
  94105. /**
  94106. * Serializes this road procedural texture
  94107. * @returns a serialized road procedural texture object
  94108. */
  94109. serialize(): any;
  94110. /**
  94111. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  94112. * @param parsedTexture defines parsed texture data
  94113. * @param scene defines the current scene
  94114. * @param rootUrl defines the root URL containing road procedural texture information
  94115. * @returns a parsed Road Procedural BABYLON.Texture
  94116. */
  94117. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  94118. }
  94119. }
  94120. declare module BABYLON {
  94121. /** @hidden */
  94122. export var starfieldProceduralTexturePixelShader: {
  94123. name: string;
  94124. shader: string;
  94125. };
  94126. }
  94127. declare module BABYLON {
  94128. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  94129. private _time;
  94130. private _alpha;
  94131. private _beta;
  94132. private _zoom;
  94133. private _formuparam;
  94134. private _stepsize;
  94135. private _tile;
  94136. private _brightness;
  94137. private _darkmatter;
  94138. private _distfading;
  94139. private _saturation;
  94140. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  94141. updateShaderUniforms(): void;
  94142. get time(): number;
  94143. set time(value: number);
  94144. get alpha(): number;
  94145. set alpha(value: number);
  94146. get beta(): number;
  94147. set beta(value: number);
  94148. get formuparam(): number;
  94149. set formuparam(value: number);
  94150. get stepsize(): number;
  94151. set stepsize(value: number);
  94152. get zoom(): number;
  94153. set zoom(value: number);
  94154. get tile(): number;
  94155. set tile(value: number);
  94156. get brightness(): number;
  94157. set brightness(value: number);
  94158. get darkmatter(): number;
  94159. set darkmatter(value: number);
  94160. get distfading(): number;
  94161. set distfading(value: number);
  94162. get saturation(): number;
  94163. set saturation(value: number);
  94164. /**
  94165. * Serializes this starfield procedural texture
  94166. * @returns a serialized starfield procedural texture object
  94167. */
  94168. serialize(): any;
  94169. /**
  94170. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  94171. * @param parsedTexture defines parsed texture data
  94172. * @param scene defines the current scene
  94173. * @param rootUrl defines the root URL containing startfield procedural texture information
  94174. * @returns a parsed Starfield Procedural BABYLON.Texture
  94175. */
  94176. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  94177. }
  94178. }
  94179. declare module BABYLON {
  94180. /** @hidden */
  94181. export var woodProceduralTexturePixelShader: {
  94182. name: string;
  94183. shader: string;
  94184. };
  94185. }
  94186. declare module BABYLON {
  94187. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  94188. private _ampScale;
  94189. private _woodColor;
  94190. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  94191. updateShaderUniforms(): void;
  94192. get ampScale(): number;
  94193. set ampScale(value: number);
  94194. get woodColor(): BABYLON.Color3;
  94195. set woodColor(value: BABYLON.Color3);
  94196. /**
  94197. * Serializes this wood procedural texture
  94198. * @returns a serialized wood procedural texture object
  94199. */
  94200. serialize(): any;
  94201. /**
  94202. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  94203. * @param parsedTexture defines parsed texture data
  94204. * @param scene defines the current scene
  94205. * @param rootUrl defines the root URL containing wood procedural texture information
  94206. * @returns a parsed Wood Procedural BABYLON.Texture
  94207. */
  94208. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  94209. }
  94210. }