documentation.d.ts 3.9 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732807338073480735807368073780738807398074080741807428074380744807458074680747807488074980750807518075280753807548075580756807578075880759807608076180762807638076480765807668076780768807698077080771807728077380774807758077680777807788077980780807818078280783807848078580786807878078880789807908079180792807938079480795807968079780798807998080080801808028080380804808058080680807808088080980810808118081280813808148081580816808178081880819808208082180822808238082480825808268082780828808298083080831808328083380834808358083680837808388083980840808418084280843808448084580846808478084880849808508085180852808538085480855808568085780858808598086080861808628086380864808658086680867808688086980870808718087280873808748087580876808778087880879808808088180882808838088480885808868088780888808898089080891808928089380894808958089680897808988089980900809018090280903809048090580906809078090880909809108091180912809138091480915809168091780918809198092080921809228092380924809258092680927809288092980930809318093280933809348093580936809378093880939809408094180942809438094480945809468094780948809498095080951809528095380954809558095680957809588095980960809618096280963809648096580966809678096880969809708097180972809738097480975809768097780978809798098080981809828098380984809858098680987809888098980990809918099280993809948099580996809978099880999810008100181002810038100481005810068100781008810098101081011810128101381014810158101681017810188101981020810218102281023810248102581026810278102881029810308103181032810338103481035810368103781038810398104081041810428104381044810458104681047810488104981050810518105281053810548105581056810578105881059810608106181062810638106481065810668106781068810698107081071810728107381074810758107681077810788107981080810818108281083810848108581086810878108881089810908109181092810938109481095810968109781098810998110081101811028110381104811058110681107811088110981110811118111281113811148111581116811178111881119811208112181122811238112481125811268112781128811298113081131811328113381134811358113681137811388113981140811418114281143811448114581146811478114881149811508115181152811538115481155811568115781158811598116081161811628116381164811658116681167811688116981170811718117281173811748117581176811778117881179811808118181182811838118481185811868118781188811898119081191811928119381194811958119681197811988119981200812018120281203812048120581206812078120881209812108121181212812138121481215812168121781218812198122081221812228122381224812258122681227812288122981230812318123281233812348123581236812378123881239812408124181242812438124481245812468124781248812498125081251812528125381254812558125681257812588125981260812618126281263812648126581266812678126881269812708127181272812738127481275812768127781278812798128081281812828128381284812858128681287812888128981290812918129281293812948129581296812978129881299813008130181302813038130481305813068130781308813098131081311813128131381314813158131681317813188131981320813218132281323813248132581326813278132881329813308133181332813338133481335813368133781338813398134081341813428134381344813458134681347813488134981350813518135281353813548135581356813578135881359813608136181362813638136481365813668136781368813698137081371813728137381374813758137681377813788137981380813818138281383813848138581386813878138881389813908139181392813938139481395813968139781398813998140081401814028140381404814058140681407814088140981410814118141281413814148141581416814178141881419814208142181422814238142481425814268142781428814298143081431814328143381434814358143681437814388143981440814418144281443814448144581446814478144881449814508145181452814538145481455814568145781458814598146081461814628146381464814658146681467814688146981470814718147281473814748147581476814778147881479814808148181482814838148481485814868148781488814898149081491814928149381494814958149681497814988149981500815018150281503815048150581506815078150881509815108151181512815138151481515815168151781518815198152081521815228152381524815258152681527815288152981530815318153281533815348153581536815378153881539815408154181542815438154481545815468154781548815498155081551815528155381554815558155681557815588155981560815618156281563815648156581566815678156881569815708157181572815738157481575815768157781578815798158081581815828158381584815858158681587815888158981590815918159281593815948159581596815978159881599816008160181602816038160481605816068160781608816098161081611816128161381614816158161681617816188161981620816218162281623816248162581626816278162881629816308163181632816338163481635816368163781638816398164081641816428164381644816458164681647816488164981650816518165281653816548165581656816578165881659816608166181662816638166481665816668166781668816698167081671816728167381674816758167681677816788167981680816818168281683816848168581686816878168881689816908169181692816938169481695816968169781698816998170081701817028170381704817058170681707817088170981710817118171281713817148171581716817178171881719817208172181722817238172481725817268172781728817298173081731817328173381734817358173681737817388173981740817418174281743817448174581746817478174881749817508175181752817538175481755817568175781758817598176081761817628176381764817658176681767817688176981770817718177281773817748177581776817778177881779817808178181782817838178481785817868178781788817898179081791817928179381794817958179681797817988179981800818018180281803818048180581806818078180881809818108181181812818138181481815818168181781818818198182081821818228182381824818258182681827818288182981830818318183281833818348183581836818378183881839818408184181842818438184481845818468184781848818498185081851818528185381854818558185681857818588185981860818618186281863818648186581866818678186881869818708187181872818738187481875818768187781878818798188081881818828188381884818858188681887818888188981890818918189281893818948189581896818978189881899819008190181902819038190481905819068190781908819098191081911819128191381914819158191681917819188191981920819218192281923819248192581926819278192881929819308193181932819338193481935819368193781938819398194081941819428194381944819458194681947819488194981950819518195281953819548195581956819578195881959819608196181962819638196481965819668196781968819698197081971819728197381974819758197681977819788197981980819818198281983819848198581986819878198881989819908199181992819938199481995819968199781998819998200082001820028200382004820058200682007820088200982010820118201282013820148201582016820178201882019820208202182022820238202482025820268202782028820298203082031820328203382034820358203682037820388203982040820418204282043820448204582046820478204882049820508205182052820538205482055820568205782058820598206082061820628206382064820658206682067820688206982070820718207282073820748207582076820778207882079820808208182082820838208482085820868208782088820898209082091820928209382094820958209682097820988209982100821018210282103821048210582106821078210882109821108211182112821138211482115821168211782118821198212082121821228212382124821258212682127821288212982130821318213282133821348213582136821378213882139821408214182142821438214482145821468214782148821498215082151821528215382154821558215682157821588215982160821618216282163821648216582166821678216882169821708217182172821738217482175821768217782178821798218082181821828218382184821858218682187821888218982190821918219282193821948219582196821978219882199822008220182202822038220482205822068220782208822098221082211822128221382214822158221682217822188221982220822218222282223822248222582226822278222882229822308223182232822338223482235822368223782238822398224082241822428224382244822458224682247822488224982250822518225282253822548225582256822578225882259822608226182262822638226482265822668226782268822698227082271822728227382274822758227682277822788227982280822818228282283822848228582286822878228882289822908229182292822938229482295822968229782298822998230082301823028230382304823058230682307823088230982310823118231282313823148231582316823178231882319823208232182322823238232482325823268232782328823298233082331823328233382334823358233682337823388233982340823418234282343823448234582346823478234882349823508235182352823538235482355823568235782358823598236082361823628236382364823658236682367823688236982370823718237282373823748237582376823778237882379823808238182382823838238482385823868238782388823898239082391823928239382394823958239682397823988239982400824018240282403824048240582406824078240882409824108241182412824138241482415824168241782418824198242082421824228242382424824258242682427824288242982430824318243282433824348243582436824378243882439824408244182442824438244482445824468244782448824498245082451824528245382454824558245682457824588245982460824618246282463824648246582466824678246882469824708247182472824738247482475824768247782478824798248082481824828248382484824858248682487824888248982490824918249282493824948249582496824978249882499825008250182502825038250482505825068250782508825098251082511825128251382514825158251682517825188251982520825218252282523825248252582526825278252882529825308253182532825338253482535825368253782538825398254082541825428254382544825458254682547825488254982550825518255282553825548255582556825578255882559825608256182562825638256482565825668256782568825698257082571825728257382574825758257682577825788257982580825818258282583825848258582586825878258882589825908259182592825938259482595825968259782598825998260082601826028260382604826058260682607826088260982610826118261282613826148261582616826178261882619826208262182622826238262482625826268262782628826298263082631826328263382634826358263682637826388263982640826418264282643826448264582646826478264882649826508265182652826538265482655826568265782658826598266082661826628266382664826658266682667826688266982670826718267282673826748267582676826778267882679826808268182682826838268482685826868268782688826898269082691826928269382694826958269682697826988269982700827018270282703827048270582706827078270882709827108271182712827138271482715827168271782718827198272082721827228272382724827258272682727827288272982730827318273282733827348273582736827378273882739827408274182742827438274482745827468274782748827498275082751827528275382754827558275682757827588275982760827618276282763827648276582766827678276882769827708277182772827738277482775827768277782778827798278082781827828278382784827858278682787827888278982790827918279282793827948279582796827978279882799828008280182802828038280482805828068280782808828098281082811828128281382814828158281682817828188281982820828218282282823828248282582826828278282882829828308283182832828338283482835828368283782838828398284082841828428284382844828458284682847828488284982850828518285282853828548285582856828578285882859828608286182862828638286482865828668286782868828698287082871828728287382874828758287682877828788287982880828818288282883828848288582886828878288882889828908289182892828938289482895828968289782898828998290082901829028290382904829058290682907829088290982910829118291282913829148291582916829178291882919829208292182922829238292482925829268292782928829298293082931829328293382934829358293682937829388293982940829418294282943829448294582946829478294882949829508295182952829538295482955829568295782958829598296082961829628296382964829658296682967829688296982970829718297282973829748297582976829778297882979829808298182982829838298482985829868298782988829898299082991829928299382994829958299682997829988299983000830018300283003830048300583006830078300883009830108301183012830138301483015830168301783018830198302083021830228302383024830258302683027830288302983030830318303283033830348303583036830378303883039830408304183042830438304483045830468304783048830498305083051830528305383054830558305683057830588305983060830618306283063830648306583066830678306883069830708307183072830738307483075830768307783078830798308083081830828308383084830858308683087830888308983090830918309283093830948309583096830978309883099831008310183102831038310483105831068310783108831098311083111831128311383114831158311683117831188311983120831218312283123831248312583126831278312883129831308313183132831338313483135831368313783138831398314083141831428314383144831458314683147831488314983150831518315283153831548315583156831578315883159831608316183162831638316483165831668316783168831698317083171831728317383174831758317683177831788317983180831818318283183831848318583186831878318883189831908319183192831938319483195831968319783198831998320083201832028320383204832058320683207832088320983210832118321283213832148321583216832178321883219832208322183222832238322483225832268322783228832298323083231832328323383234832358323683237832388323983240832418324283243832448324583246832478324883249832508325183252832538325483255832568325783258832598326083261832628326383264832658326683267832688326983270832718327283273832748327583276832778327883279832808328183282832838328483285832868328783288832898329083291832928329383294832958329683297832988329983300833018330283303833048330583306833078330883309833108331183312833138331483315833168331783318833198332083321833228332383324833258332683327833288332983330833318333283333833348333583336833378333883339833408334183342833438334483345833468334783348833498335083351833528335383354833558335683357833588335983360833618336283363833648336583366833678336883369833708337183372833738337483375833768337783378833798338083381833828338383384833858338683387833888338983390833918339283393833948339583396833978339883399834008340183402834038340483405834068340783408834098341083411834128341383414834158341683417834188341983420834218342283423834248342583426834278342883429834308343183432834338343483435834368343783438834398344083441834428344383444834458344683447834488344983450834518345283453834548345583456834578345883459834608346183462834638346483465834668346783468834698347083471834728347383474834758347683477834788347983480834818348283483834848348583486834878348883489834908349183492834938349483495834968349783498834998350083501835028350383504835058350683507835088350983510835118351283513835148351583516835178351883519835208352183522835238352483525835268352783528835298353083531835328353383534835358353683537835388353983540835418354283543835448354583546835478354883549835508355183552835538355483555835568355783558835598356083561835628356383564835658356683567835688356983570835718357283573835748357583576835778357883579835808358183582835838358483585835868358783588835898359083591835928359383594835958359683597835988359983600836018360283603836048360583606836078360883609836108361183612836138361483615836168361783618836198362083621836228362383624836258362683627836288362983630836318363283633836348363583636836378363883639836408364183642836438364483645836468364783648836498365083651836528365383654836558365683657836588365983660836618366283663836648366583666836678366883669836708367183672836738367483675836768367783678836798368083681836828368383684836858368683687836888368983690836918369283693836948369583696836978369883699837008370183702837038370483705837068370783708837098371083711837128371383714837158371683717837188371983720837218372283723837248372583726837278372883729837308373183732837338373483735837368373783738837398374083741837428374383744837458374683747837488374983750837518375283753837548375583756837578375883759837608376183762837638376483765837668376783768837698377083771837728377383774837758377683777837788377983780837818378283783837848378583786837878378883789837908379183792837938379483795837968379783798837998380083801838028380383804838058380683807838088380983810838118381283813838148381583816838178381883819838208382183822838238382483825838268382783828838298383083831838328383383834838358383683837838388383983840838418384283843838448384583846838478384883849838508385183852838538385483855838568385783858838598386083861838628386383864838658386683867838688386983870838718387283873838748387583876838778387883879838808388183882838838388483885838868388783888838898389083891838928389383894838958389683897838988389983900839018390283903839048390583906839078390883909839108391183912839138391483915839168391783918839198392083921839228392383924839258392683927839288392983930839318393283933839348393583936839378393883939839408394183942839438394483945839468394783948839498395083951839528395383954839558395683957839588395983960839618396283963839648396583966839678396883969839708397183972839738397483975839768397783978839798398083981839828398383984839858398683987839888398983990839918399283993839948399583996839978399883999840008400184002840038400484005840068400784008840098401084011840128401384014840158401684017840188401984020840218402284023840248402584026840278402884029840308403184032840338403484035840368403784038840398404084041840428404384044840458404684047840488404984050840518405284053840548405584056840578405884059840608406184062840638406484065840668406784068840698407084071840728407384074840758407684077840788407984080840818408284083840848408584086840878408884089840908409184092840938409484095840968409784098840998410084101841028410384104841058410684107841088410984110841118411284113841148411584116841178411884119841208412184122841238412484125841268412784128841298413084131841328413384134841358413684137841388413984140841418414284143841448414584146841478414884149841508415184152841538415484155841568415784158841598416084161841628416384164841658416684167841688416984170841718417284173841748417584176841778417884179841808418184182841838418484185841868418784188841898419084191841928419384194841958419684197841988419984200842018420284203842048420584206842078420884209842108421184212842138421484215842168421784218842198422084221842228422384224842258422684227842288422984230842318423284233842348423584236842378423884239842408424184242842438424484245842468424784248842498425084251842528425384254842558425684257842588425984260842618426284263842648426584266842678426884269842708427184272842738427484275842768427784278842798428084281842828428384284842858428684287842888428984290842918429284293842948429584296842978429884299843008430184302843038430484305843068430784308843098431084311843128431384314843158431684317843188431984320843218432284323843248432584326843278432884329843308433184332843338433484335843368433784338843398434084341843428434384344843458434684347843488434984350843518435284353843548435584356843578435884359843608436184362843638436484365843668436784368843698437084371843728437384374843758437684377843788437984380843818438284383843848438584386843878438884389843908439184392843938439484395843968439784398843998440084401844028440384404844058440684407844088440984410844118441284413844148441584416844178441884419844208442184422844238442484425844268442784428844298443084431844328443384434844358443684437844388443984440844418444284443844448444584446844478444884449844508445184452844538445484455844568445784458844598446084461844628446384464844658446684467844688446984470844718447284473844748447584476844778447884479844808448184482844838448484485844868448784488844898449084491844928449384494844958449684497844988449984500845018450284503845048450584506845078450884509845108451184512845138451484515845168451784518845198452084521845228452384524845258452684527845288452984530845318453284533845348453584536845378453884539845408454184542845438454484545845468454784548845498455084551845528455384554845558455684557845588455984560845618456284563845648456584566845678456884569845708457184572845738457484575845768457784578845798458084581845828458384584845858458684587845888458984590845918459284593845948459584596845978459884599846008460184602846038460484605846068460784608846098461084611846128461384614846158461684617846188461984620846218462284623846248462584626846278462884629846308463184632846338463484635846368463784638846398464084641846428464384644846458464684647846488464984650846518465284653846548465584656846578465884659846608466184662846638466484665846668466784668846698467084671846728467384674846758467684677846788467984680846818468284683846848468584686846878468884689846908469184692846938469484695846968469784698846998470084701847028470384704847058470684707847088470984710847118471284713847148471584716847178471884719847208472184722847238472484725847268472784728847298473084731847328473384734847358473684737847388473984740847418474284743847448474584746847478474884749847508475184752847538475484755847568475784758847598476084761847628476384764847658476684767847688476984770847718477284773847748477584776847778477884779847808478184782847838478484785847868478784788847898479084791847928479384794847958479684797847988479984800848018480284803848048480584806848078480884809848108481184812848138481484815848168481784818848198482084821848228482384824848258482684827848288482984830848318483284833848348483584836848378483884839848408484184842848438484484845848468484784848848498485084851848528485384854848558485684857848588485984860848618486284863848648486584866848678486884869848708487184872848738487484875848768487784878848798488084881848828488384884848858488684887848888488984890848918489284893848948489584896848978489884899849008490184902849038490484905849068490784908849098491084911849128491384914849158491684917849188491984920849218492284923849248492584926849278492884929849308493184932849338493484935849368493784938849398494084941849428494384944849458494684947849488494984950849518495284953849548495584956849578495884959849608496184962849638496484965849668496784968849698497084971849728497384974849758497684977849788497984980849818498284983849848498584986849878498884989849908499184992849938499484995849968499784998849998500085001850028500385004850058500685007850088500985010850118501285013850148501585016850178501885019850208502185022850238502485025850268502785028850298503085031850328503385034850358503685037850388503985040850418504285043850448504585046850478504885049850508505185052850538505485055850568505785058850598506085061850628506385064850658506685067850688506985070850718507285073850748507585076850778507885079850808508185082850838508485085850868508785088850898509085091850928509385094850958509685097850988509985100851018510285103851048510585106851078510885109851108511185112851138511485115851168511785118851198512085121851228512385124851258512685127851288512985130851318513285133851348513585136851378513885139851408514185142851438514485145851468514785148851498515085151851528515385154851558515685157851588515985160851618516285163851648516585166851678516885169851708517185172851738517485175851768517785178851798518085181851828518385184851858518685187851888518985190851918519285193851948519585196851978519885199852008520185202852038520485205852068520785208852098521085211852128521385214852158521685217852188521985220852218522285223852248522585226852278522885229852308523185232852338523485235852368523785238852398524085241852428524385244852458524685247852488524985250852518525285253852548525585256852578525885259852608526185262852638526485265852668526785268852698527085271852728527385274852758527685277852788527985280852818528285283852848528585286852878528885289852908529185292852938529485295852968529785298852998530085301853028530385304853058530685307853088530985310853118531285313853148531585316853178531885319853208532185322853238532485325853268532785328853298533085331853328533385334853358533685337853388533985340853418534285343853448534585346853478534885349853508535185352853538535485355853568535785358853598536085361853628536385364853658536685367853688536985370853718537285373853748537585376853778537885379853808538185382853838538485385853868538785388853898539085391853928539385394853958539685397853988539985400854018540285403854048540585406854078540885409854108541185412854138541485415854168541785418854198542085421854228542385424854258542685427854288542985430854318543285433854348543585436854378543885439854408544185442854438544485445854468544785448854498545085451854528545385454854558545685457854588545985460854618546285463854648546585466854678546885469854708547185472854738547485475854768547785478854798548085481854828548385484854858548685487854888548985490854918549285493854948549585496854978549885499855008550185502855038550485505855068550785508855098551085511855128551385514855158551685517855188551985520855218552285523855248552585526855278552885529855308553185532855338553485535855368553785538855398554085541855428554385544855458554685547855488554985550855518555285553855548555585556855578555885559855608556185562855638556485565855668556785568855698557085571855728557385574855758557685577855788557985580855818558285583855848558585586855878558885589855908559185592855938559485595855968559785598855998560085601856028560385604856058560685607856088560985610856118561285613856148561585616856178561885619856208562185622856238562485625856268562785628856298563085631856328563385634856358563685637856388563985640856418564285643856448564585646856478564885649856508565185652856538565485655856568565785658856598566085661856628566385664856658566685667856688566985670856718567285673856748567585676856778567885679856808568185682856838568485685856868568785688856898569085691856928569385694856958569685697856988569985700857018570285703857048570585706857078570885709857108571185712857138571485715857168571785718857198572085721857228572385724857258572685727857288572985730857318573285733857348573585736857378573885739857408574185742857438574485745857468574785748857498575085751857528575385754857558575685757857588575985760857618576285763857648576585766857678576885769857708577185772857738577485775857768577785778857798578085781857828578385784857858578685787857888578985790857918579285793857948579585796857978579885799858008580185802858038580485805858068580785808858098581085811858128581385814858158581685817858188581985820858218582285823858248582585826858278582885829858308583185832858338583485835858368583785838858398584085841858428584385844858458584685847858488584985850858518585285853858548585585856858578585885859858608586185862858638586485865858668586785868858698587085871858728587385874858758587685877858788587985880858818588285883858848588585886858878588885889858908589185892858938589485895858968589785898858998590085901859028590385904859058590685907859088590985910859118591285913859148591585916859178591885919859208592185922859238592485925859268592785928859298593085931859328593385934859358593685937859388593985940859418594285943859448594585946859478594885949859508595185952859538595485955859568595785958859598596085961859628596385964859658596685967859688596985970859718597285973859748597585976859778597885979859808598185982859838598485985859868598785988859898599085991859928599385994859958599685997859988599986000860018600286003860048600586006860078600886009860108601186012860138601486015860168601786018860198602086021860228602386024860258602686027860288602986030860318603286033860348603586036860378603886039860408604186042860438604486045860468604786048860498605086051860528605386054860558605686057860588605986060860618606286063860648606586066860678606886069860708607186072860738607486075860768607786078860798608086081860828608386084860858608686087860888608986090860918609286093860948609586096860978609886099861008610186102861038610486105861068610786108861098611086111861128611386114861158611686117861188611986120861218612286123861248612586126861278612886129861308613186132861338613486135861368613786138861398614086141861428614386144861458614686147861488614986150861518615286153861548615586156861578615886159861608616186162861638616486165861668616786168861698617086171861728617386174861758617686177861788617986180861818618286183861848618586186861878618886189861908619186192861938619486195861968619786198861998620086201862028620386204862058620686207862088620986210862118621286213862148621586216862178621886219862208622186222862238622486225862268622786228862298623086231862328623386234862358623686237862388623986240862418624286243862448624586246862478624886249862508625186252862538625486255862568625786258862598626086261862628626386264862658626686267862688626986270862718627286273862748627586276862778627886279862808628186282862838628486285862868628786288862898629086291862928629386294862958629686297862988629986300863018630286303863048630586306863078630886309863108631186312863138631486315863168631786318863198632086321863228632386324863258632686327863288632986330863318633286333863348633586336863378633886339863408634186342863438634486345863468634786348863498635086351863528635386354863558635686357863588635986360863618636286363863648636586366863678636886369863708637186372863738637486375863768637786378863798638086381863828638386384863858638686387863888638986390863918639286393863948639586396863978639886399864008640186402864038640486405864068640786408864098641086411864128641386414864158641686417864188641986420864218642286423864248642586426864278642886429864308643186432864338643486435864368643786438864398644086441864428644386444864458644686447864488644986450864518645286453864548645586456864578645886459864608646186462864638646486465864668646786468864698647086471864728647386474864758647686477864788647986480864818648286483864848648586486864878648886489864908649186492864938649486495864968649786498864998650086501865028650386504865058650686507865088650986510865118651286513865148651586516865178651886519865208652186522865238652486525865268652786528865298653086531865328653386534865358653686537865388653986540865418654286543865448654586546865478654886549865508655186552865538655486555865568655786558865598656086561865628656386564865658656686567865688656986570865718657286573865748657586576865778657886579865808658186582865838658486585865868658786588865898659086591865928659386594865958659686597865988659986600866018660286603866048660586606866078660886609866108661186612866138661486615866168661786618866198662086621866228662386624866258662686627866288662986630866318663286633866348663586636866378663886639866408664186642866438664486645866468664786648866498665086651866528665386654866558665686657866588665986660866618666286663866648666586666866678666886669866708667186672866738667486675866768667786678866798668086681866828668386684866858668686687866888668986690866918669286693866948669586696866978669886699867008670186702867038670486705867068670786708867098671086711867128671386714867158671686717867188671986720867218672286723867248672586726867278672886729867308673186732867338673486735867368673786738867398674086741867428674386744867458674686747867488674986750867518675286753867548675586756867578675886759867608676186762867638676486765867668676786768867698677086771867728677386774867758677686777867788677986780867818678286783867848678586786867878678886789867908679186792867938679486795867968679786798867998680086801868028680386804868058680686807868088680986810868118681286813868148681586816868178681886819868208682186822868238682486825868268682786828868298683086831868328683386834868358683686837868388683986840868418684286843868448684586846868478684886849868508685186852868538685486855868568685786858868598686086861868628686386864868658686686867868688686986870868718687286873868748687586876868778687886879868808688186882868838688486885868868688786888868898689086891868928689386894868958689686897868988689986900869018690286903869048690586906869078690886909869108691186912869138691486915869168691786918869198692086921869228692386924869258692686927869288692986930869318693286933869348693586936869378693886939869408694186942869438694486945869468694786948869498695086951869528695386954869558695686957869588695986960869618696286963869648696586966869678696886969869708697186972869738697486975869768697786978869798698086981869828698386984869858698686987869888698986990869918699286993869948699586996869978699886999870008700187002870038700487005870068700787008870098701087011870128701387014870158701687017870188701987020870218702287023870248702587026870278702887029870308703187032870338703487035870368703787038870398704087041870428704387044870458704687047870488704987050870518705287053870548705587056870578705887059870608706187062870638706487065870668706787068870698707087071870728707387074870758707687077870788707987080870818708287083870848708587086870878708887089870908709187092870938709487095870968709787098870998710087101871028710387104871058710687107871088710987110871118711287113871148711587116871178711887119871208712187122871238712487125871268712787128871298713087131871328713387134871358713687137871388713987140871418714287143871448714587146871478714887149871508715187152871538715487155871568715787158871598716087161871628716387164871658716687167871688716987170871718717287173871748717587176871778717887179871808718187182871838718487185871868718787188871898719087191871928719387194871958719687197871988719987200872018720287203872048720587206872078720887209872108721187212872138721487215872168721787218872198722087221872228722387224872258722687227872288722987230872318723287233872348723587236872378723887239872408724187242872438724487245872468724787248872498725087251872528725387254872558725687257872588725987260872618726287263872648726587266872678726887269872708727187272872738727487275872768727787278872798728087281872828728387284872858728687287872888728987290872918729287293872948729587296872978729887299873008730187302873038730487305873068730787308873098731087311873128731387314873158731687317873188731987320873218732287323873248732587326873278732887329873308733187332873338733487335873368733787338873398734087341873428734387344873458734687347873488734987350873518735287353873548735587356873578735887359873608736187362873638736487365873668736787368873698737087371873728737387374873758737687377873788737987380873818738287383873848738587386873878738887389873908739187392873938739487395873968739787398873998740087401874028740387404874058740687407874088740987410874118741287413874148741587416874178741887419874208742187422874238742487425874268742787428874298743087431874328743387434874358743687437874388743987440874418744287443874448744587446874478744887449874508745187452874538745487455874568745787458874598746087461874628746387464874658746687467874688746987470874718747287473874748747587476874778747887479874808748187482874838748487485874868748787488874898749087491874928749387494874958749687497874988749987500875018750287503875048750587506875078750887509875108751187512875138751487515875168751787518875198752087521875228752387524875258752687527875288752987530875318753287533875348753587536875378753887539875408754187542875438754487545875468754787548875498755087551875528755387554875558755687557875588755987560875618756287563875648756587566875678756887569875708757187572875738757487575875768757787578875798758087581875828758387584875858758687587875888758987590875918759287593875948759587596875978759887599876008760187602876038760487605876068760787608876098761087611876128761387614876158761687617876188761987620876218762287623876248762587626876278762887629876308763187632876338763487635876368763787638876398764087641876428764387644876458764687647876488764987650876518765287653876548765587656876578765887659876608766187662876638766487665876668766787668876698767087671876728767387674876758767687677876788767987680876818768287683876848768587686876878768887689876908769187692876938769487695876968769787698876998770087701877028770387704877058770687707877088770987710877118771287713877148771587716877178771887719877208772187722877238772487725877268772787728877298773087731877328773387734877358773687737877388773987740877418774287743877448774587746877478774887749877508775187752877538775487755877568775787758877598776087761877628776387764877658776687767877688776987770877718777287773877748777587776877778777887779877808778187782877838778487785877868778787788877898779087791877928779387794877958779687797877988779987800878018780287803878048780587806878078780887809878108781187812878138781487815878168781787818878198782087821878228782387824878258782687827878288782987830878318783287833878348783587836878378783887839878408784187842878438784487845878468784787848878498785087851878528785387854878558785687857878588785987860878618786287863878648786587866878678786887869878708787187872878738787487875878768787787878878798788087881878828788387884878858788687887878888788987890878918789287893878948789587896878978789887899879008790187902879038790487905879068790787908879098791087911879128791387914879158791687917879188791987920879218792287923879248792587926879278792887929879308793187932879338793487935879368793787938879398794087941879428794387944879458794687947879488794987950879518795287953879548795587956879578795887959879608796187962879638796487965879668796787968879698797087971879728797387974879758797687977879788797987980879818798287983879848798587986879878798887989879908799187992879938799487995879968799787998879998800088001880028800388004880058800688007880088800988010880118801288013880148801588016880178801888019880208802188022880238802488025880268802788028880298803088031880328803388034880358803688037880388803988040880418804288043880448804588046880478804888049880508805188052880538805488055880568805788058880598806088061880628806388064880658806688067880688806988070880718807288073880748807588076880778807888079880808808188082880838808488085880868808788088880898809088091880928809388094880958809688097880988809988100881018810288103881048810588106881078810888109881108811188112881138811488115881168811788118881198812088121881228812388124881258812688127881288812988130881318813288133881348813588136881378813888139881408814188142881438814488145881468814788148881498815088151881528815388154881558815688157881588815988160881618816288163881648816588166881678816888169881708817188172881738817488175881768817788178881798818088181881828818388184881858818688187881888818988190881918819288193881948819588196881978819888199882008820188202882038820488205882068820788208882098821088211882128821388214882158821688217882188821988220882218822288223882248822588226882278822888229882308823188232882338823488235882368823788238882398824088241882428824388244882458824688247882488824988250882518825288253882548825588256882578825888259882608826188262882638826488265882668826788268882698827088271882728827388274882758827688277882788827988280882818828288283882848828588286882878828888289882908829188292882938829488295882968829788298882998830088301883028830388304883058830688307883088830988310883118831288313883148831588316883178831888319883208832188322883238832488325883268832788328883298833088331883328833388334883358833688337883388833988340883418834288343883448834588346883478834888349883508835188352883538835488355883568835788358883598836088361883628836388364883658836688367883688836988370883718837288373883748837588376883778837888379883808838188382883838838488385883868838788388883898839088391883928839388394883958839688397883988839988400884018840288403884048840588406884078840888409884108841188412884138841488415884168841788418884198842088421884228842388424884258842688427884288842988430884318843288433884348843588436884378843888439884408844188442884438844488445884468844788448884498845088451884528845388454884558845688457884588845988460884618846288463884648846588466884678846888469884708847188472884738847488475884768847788478884798848088481884828848388484884858848688487884888848988490884918849288493884948849588496884978849888499885008850188502885038850488505885068850788508885098851088511885128851388514885158851688517885188851988520885218852288523885248852588526885278852888529885308853188532885338853488535885368853788538885398854088541885428854388544885458854688547885488854988550885518855288553885548855588556885578855888559885608856188562885638856488565885668856788568885698857088571885728857388574885758857688577885788857988580885818858288583885848858588586885878858888589885908859188592885938859488595885968859788598885998860088601886028860388604886058860688607886088860988610886118861288613886148861588616886178861888619886208862188622886238862488625886268862788628886298863088631886328863388634886358863688637886388863988640886418864288643886448864588646886478864888649886508865188652886538865488655886568865788658886598866088661886628866388664886658866688667886688866988670886718867288673886748867588676886778867888679886808868188682886838868488685886868868788688886898869088691886928869388694886958869688697886988869988700887018870288703887048870588706887078870888709887108871188712887138871488715887168871788718887198872088721887228872388724887258872688727887288872988730887318873288733887348873588736887378873888739887408874188742887438874488745887468874788748887498875088751887528875388754887558875688757887588875988760887618876288763887648876588766887678876888769887708877188772887738877488775887768877788778887798878088781887828878388784887858878688787887888878988790887918879288793887948879588796887978879888799888008880188802888038880488805888068880788808888098881088811888128881388814888158881688817888188881988820888218882288823888248882588826888278882888829888308883188832888338883488835888368883788838888398884088841888428884388844888458884688847888488884988850888518885288853888548885588856888578885888859888608886188862888638886488865888668886788868888698887088871888728887388874888758887688877888788887988880888818888288883888848888588886888878888888889888908889188892888938889488895888968889788898888998890088901889028890388904889058890688907889088890988910889118891288913889148891588916889178891888919889208892188922889238892488925889268892788928889298893088931889328893388934889358893688937889388893988940889418894288943889448894588946889478894888949889508895188952889538895488955889568895788958889598896088961889628896388964889658896688967889688896988970889718897288973889748897588976889778897888979889808898188982889838898488985889868898788988889898899088991889928899388994889958899688997889988899989000890018900289003890048900589006890078900889009890108901189012890138901489015890168901789018890198902089021890228902389024890258902689027890288902989030890318903289033890348903589036890378903889039890408904189042890438904489045890468904789048890498905089051890528905389054890558905689057890588905989060890618906289063890648906589066890678906889069890708907189072890738907489075890768907789078890798908089081890828908389084890858908689087890888908989090890918909289093890948909589096890978909889099891008910189102891038910489105891068910789108891098911089111891128911389114891158911689117891188911989120891218912289123891248912589126891278912889129891308913189132891338913489135891368913789138891398914089141891428914389144891458914689147891488914989150891518915289153891548915589156891578915889159891608916189162891638916489165891668916789168891698917089171891728917389174891758917689177891788917989180891818918289183891848918589186891878918889189891908919189192891938919489195891968919789198891998920089201892028920389204892058920689207892088920989210892118921289213892148921589216892178921889219892208922189222892238922489225892268922789228892298923089231892328923389234892358923689237892388923989240892418924289243892448924589246892478924889249892508925189252892538925489255892568925789258892598926089261892628926389264892658926689267892688926989270892718927289273892748927589276892778927889279892808928189282892838928489285892868928789288892898929089291892928929389294892958929689297892988929989300893018930289303893048930589306893078930889309893108931189312893138931489315893168931789318893198932089321893228932389324893258932689327893288932989330893318933289333893348933589336893378933889339893408934189342893438934489345893468934789348893498935089351893528935389354893558935689357893588935989360893618936289363893648936589366893678936889369893708937189372893738937489375893768937789378893798938089381893828938389384893858938689387893888938989390893918939289393893948939589396893978939889399894008940189402894038940489405894068940789408894098941089411894128941389414894158941689417894188941989420894218942289423894248942589426894278942889429894308943189432894338943489435894368943789438894398944089441894428944389444894458944689447894488944989450894518945289453894548945589456894578945889459894608946189462894638946489465894668946789468894698947089471894728947389474894758947689477894788947989480894818948289483894848948589486894878948889489894908949189492894938949489495894968949789498894998950089501895028950389504895058950689507895088950989510895118951289513895148951589516895178951889519895208952189522895238952489525895268952789528895298953089531895328953389534895358953689537895388953989540895418954289543895448954589546895478954889549895508955189552895538955489555895568955789558895598956089561895628956389564895658956689567895688956989570895718957289573895748957589576895778957889579895808958189582895838958489585895868958789588895898959089591895928959389594895958959689597895988959989600896018960289603896048960589606896078960889609896108961189612896138961489615896168961789618896198962089621896228962389624896258962689627896288962989630896318963289633896348963589636896378963889639896408964189642896438964489645896468964789648896498965089651896528965389654896558965689657896588965989660896618966289663896648966589666896678966889669896708967189672896738967489675896768967789678896798968089681896828968389684896858968689687896888968989690896918969289693896948969589696896978969889699897008970189702897038970489705897068970789708897098971089711897128971389714897158971689717897188971989720897218972289723897248972589726897278972889729897308973189732897338973489735897368973789738897398974089741897428974389744897458974689747897488974989750897518975289753897548975589756897578975889759897608976189762897638976489765897668976789768897698977089771897728977389774897758977689777897788977989780897818978289783897848978589786897878978889789897908979189792897938979489795897968979789798897998980089801898028980389804898058980689807898088980989810898118981289813898148981589816898178981889819898208982189822898238982489825898268982789828898298983089831898328983389834898358983689837898388983989840898418984289843898448984589846898478984889849898508985189852898538985489855898568985789858898598986089861898628986389864898658986689867898688986989870898718987289873898748987589876898778987889879898808988189882898838988489885898868988789888898898989089891898928989389894898958989689897898988989989900899018990289903899048990589906899078990889909899108991189912899138991489915899168991789918899198992089921899228992389924899258992689927899288992989930899318993289933899348993589936899378993889939899408994189942899438994489945899468994789948899498995089951899528995389954899558995689957899588995989960899618996289963899648996589966899678996889969899708997189972899738997489975899768997789978899798998089981899828998389984899858998689987899888998989990899918999289993899948999589996899978999889999900009000190002900039000490005900069000790008900099001090011900129001390014900159001690017900189001990020900219002290023900249002590026900279002890029900309003190032900339003490035900369003790038900399004090041900429004390044900459004690047900489004990050900519005290053900549005590056900579005890059900609006190062900639006490065900669006790068900699007090071900729007390074900759007690077900789007990080900819008290083900849008590086900879008890089900909009190092900939009490095900969009790098900999010090101901029010390104901059010690107901089010990110901119011290113901149011590116901179011890119901209012190122901239012490125901269012790128901299013090131901329013390134901359013690137901389013990140901419014290143901449014590146901479014890149901509015190152901539015490155901569015790158901599016090161901629016390164901659016690167901689016990170901719017290173901749017590176901779017890179901809018190182901839018490185901869018790188901899019090191901929019390194901959019690197901989019990200902019020290203902049020590206902079020890209902109021190212902139021490215902169021790218902199022090221902229022390224902259022690227902289022990230902319023290233902349023590236902379023890239902409024190242902439024490245902469024790248902499025090251902529025390254902559025690257902589025990260902619026290263902649026590266902679026890269902709027190272902739027490275902769027790278902799028090281902829028390284902859028690287902889028990290902919029290293902949029590296902979029890299903009030190302903039030490305903069030790308903099031090311903129031390314903159031690317903189031990320903219032290323903249032590326903279032890329903309033190332903339033490335903369033790338903399034090341903429034390344903459034690347903489034990350903519035290353903549035590356903579035890359903609036190362903639036490365903669036790368903699037090371903729037390374903759037690377903789037990380903819038290383903849038590386903879038890389903909039190392903939039490395903969039790398903999040090401904029040390404904059040690407904089040990410904119041290413904149041590416904179041890419904209042190422904239042490425904269042790428904299043090431904329043390434904359043690437904389043990440904419044290443904449044590446904479044890449904509045190452904539045490455904569045790458904599046090461904629046390464904659046690467904689046990470904719047290473904749047590476904779047890479904809048190482904839048490485904869048790488904899049090491904929049390494904959049690497904989049990500905019050290503905049050590506905079050890509905109051190512905139051490515905169051790518905199052090521905229052390524905259052690527905289052990530905319053290533905349053590536905379053890539905409054190542905439054490545905469054790548905499055090551905529055390554905559055690557905589055990560905619056290563905649056590566905679056890569905709057190572905739057490575905769057790578905799058090581905829058390584905859058690587905889058990590905919059290593905949059590596905979059890599906009060190602906039060490605906069060790608906099061090611906129061390614906159061690617906189061990620906219062290623906249062590626906279062890629906309063190632906339063490635906369063790638906399064090641906429064390644906459064690647906489064990650906519065290653906549065590656906579065890659906609066190662906639066490665906669066790668906699067090671906729067390674906759067690677906789067990680906819068290683906849068590686906879068890689906909069190692906939069490695906969069790698906999070090701907029070390704907059070690707907089070990710907119071290713907149071590716907179071890719907209072190722907239072490725907269072790728907299073090731907329073390734907359073690737907389073990740907419074290743907449074590746907479074890749907509075190752907539075490755907569075790758907599076090761907629076390764907659076690767907689076990770907719077290773907749077590776907779077890779907809078190782907839078490785907869078790788907899079090791907929079390794907959079690797907989079990800908019080290803908049080590806908079080890809908109081190812908139081490815908169081790818908199082090821908229082390824908259082690827908289082990830908319083290833908349083590836908379083890839908409084190842908439084490845908469084790848908499085090851908529085390854908559085690857908589085990860908619086290863908649086590866908679086890869908709087190872908739087490875908769087790878908799088090881908829088390884908859088690887908889088990890908919089290893908949089590896908979089890899909009090190902909039090490905909069090790908909099091090911909129091390914909159091690917909189091990920909219092290923909249092590926909279092890929909309093190932909339093490935909369093790938909399094090941909429094390944909459094690947909489094990950909519095290953909549095590956909579095890959909609096190962909639096490965909669096790968909699097090971909729097390974909759097690977909789097990980909819098290983909849098590986909879098890989909909099190992909939099490995909969099790998909999100091001910029100391004910059100691007910089100991010910119101291013910149101591016910179101891019910209102191022910239102491025910269102791028910299103091031910329103391034910359103691037910389103991040910419104291043910449104591046910479104891049910509105191052910539105491055910569105791058910599106091061910629106391064910659106691067910689106991070910719107291073910749107591076910779107891079910809108191082910839108491085910869108791088910899109091091910929109391094910959109691097910989109991100911019110291103911049110591106911079110891109911109111191112911139111491115911169111791118911199112091121911229112391124911259112691127911289112991130911319113291133911349113591136911379113891139911409114191142911439114491145911469114791148911499115091151911529115391154911559115691157911589115991160911619116291163911649116591166911679116891169911709117191172911739117491175911769117791178911799118091181911829118391184911859118691187911889118991190911919119291193911949119591196911979119891199912009120191202912039120491205912069120791208912099121091211912129121391214912159121691217912189121991220912219122291223912249122591226912279122891229912309123191232912339123491235912369123791238912399124091241912429124391244912459124691247912489124991250912519125291253912549125591256912579125891259912609126191262912639126491265912669126791268912699127091271912729127391274912759127691277912789127991280912819128291283912849128591286912879128891289912909129191292912939129491295912969129791298912999130091301913029130391304913059130691307913089130991310913119131291313913149131591316913179131891319913209132191322913239132491325913269132791328913299133091331913329133391334913359133691337913389133991340913419134291343913449134591346913479134891349913509135191352913539135491355913569135791358913599136091361913629136391364913659136691367913689136991370913719137291373913749137591376913779137891379913809138191382913839138491385913869138791388913899139091391913929139391394913959139691397913989139991400914019140291403914049140591406914079140891409914109141191412914139141491415914169141791418914199142091421914229142391424914259142691427914289142991430914319143291433914349143591436914379143891439914409144191442914439144491445914469144791448914499145091451914529145391454914559145691457914589145991460914619146291463914649146591466914679146891469914709147191472914739147491475914769147791478914799148091481914829148391484914859148691487914889148991490914919149291493914949149591496914979149891499915009150191502915039150491505915069150791508915099151091511915129151391514915159151691517915189151991520915219152291523915249152591526915279152891529915309153191532915339153491535915369153791538915399154091541915429154391544915459154691547915489154991550915519155291553915549155591556915579155891559915609156191562915639156491565915669156791568915699157091571915729157391574915759157691577915789157991580915819158291583915849158591586915879158891589915909159191592915939159491595915969159791598915999160091601916029160391604916059160691607916089160991610916119161291613916149161591616916179161891619916209162191622916239162491625916269162791628916299163091631916329163391634916359163691637916389163991640916419164291643916449164591646916479164891649916509165191652916539165491655916569165791658916599166091661916629166391664916659166691667916689166991670916719167291673916749167591676916779167891679916809168191682916839168491685916869168791688916899169091691916929169391694916959169691697916989169991700917019170291703917049170591706917079170891709917109171191712917139171491715917169171791718917199172091721917229172391724917259172691727917289172991730917319173291733917349173591736917379173891739917409174191742917439174491745917469174791748917499175091751917529175391754917559175691757917589175991760917619176291763917649176591766917679176891769917709177191772917739177491775917769177791778917799178091781917829178391784917859178691787917889178991790917919179291793917949179591796917979179891799918009180191802918039180491805918069180791808918099181091811918129181391814918159181691817918189181991820918219182291823918249182591826918279182891829918309183191832918339183491835918369183791838918399184091841918429184391844918459184691847918489184991850918519185291853918549185591856918579185891859918609186191862918639186491865918669186791868918699187091871918729187391874918759187691877918789187991880918819188291883918849188591886918879188891889918909189191892918939189491895918969189791898918999190091901919029190391904919059190691907919089190991910919119191291913919149191591916919179191891919919209192191922919239192491925919269192791928919299193091931919329193391934919359193691937919389193991940919419194291943919449194591946919479194891949919509195191952919539195491955919569195791958919599196091961919629196391964919659196691967919689196991970919719197291973919749197591976919779197891979919809198191982919839198491985919869198791988919899199091991919929199391994919959199691997919989199992000920019200292003920049200592006920079200892009920109201192012920139201492015920169201792018920199202092021920229202392024920259202692027920289202992030920319203292033920349203592036920379203892039920409204192042920439204492045920469204792048920499205092051920529205392054920559205692057920589205992060920619206292063920649206592066920679206892069920709207192072920739207492075920769207792078920799208092081920829208392084920859208692087920889208992090920919209292093920949209592096920979209892099921009210192102921039210492105921069210792108921099211092111921129211392114921159211692117921189211992120921219212292123921249212592126921279212892129921309213192132921339213492135921369213792138921399214092141921429214392144921459214692147921489214992150921519215292153921549215592156921579215892159921609216192162921639216492165921669216792168921699217092171921729217392174921759217692177921789217992180921819218292183921849218592186921879218892189921909219192192921939219492195921969219792198921999220092201922029220392204922059220692207922089220992210922119221292213922149221592216922179221892219922209222192222922239222492225922269222792228922299223092231922329223392234922359223692237922389223992240922419224292243922449224592246922479224892249922509225192252922539225492255922569225792258922599226092261922629226392264922659226692267922689226992270922719227292273922749227592276922779227892279922809228192282922839228492285922869228792288922899229092291922929229392294922959229692297922989229992300923019230292303923049230592306923079230892309923109231192312923139231492315923169231792318923199232092321923229232392324923259232692327923289232992330923319233292333923349233592336923379233892339923409234192342923439234492345923469234792348923499235092351923529235392354923559235692357923589235992360923619236292363923649236592366923679236892369923709237192372923739237492375923769237792378923799238092381923829238392384923859238692387923889238992390923919239292393923949239592396923979239892399924009240192402924039240492405924069240792408924099241092411924129241392414924159241692417924189241992420924219242292423924249242592426924279242892429924309243192432924339243492435924369243792438924399244092441924429244392444924459244692447924489244992450924519245292453924549245592456924579245892459924609246192462924639246492465924669246792468924699247092471924729247392474924759247692477924789247992480924819248292483924849248592486924879248892489924909249192492924939249492495924969249792498924999250092501925029250392504925059250692507925089250992510925119251292513925149251592516925179251892519925209252192522925239252492525925269252792528925299253092531925329253392534925359253692537925389253992540925419254292543925449254592546925479254892549925509255192552925539255492555925569255792558925599256092561925629256392564925659256692567925689256992570925719257292573925749257592576925779257892579925809258192582925839258492585925869258792588925899259092591925929259392594925959259692597925989259992600926019260292603926049260592606926079260892609926109261192612926139261492615926169261792618926199262092621926229262392624926259262692627926289262992630926319263292633926349263592636926379263892639926409264192642926439264492645926469264792648926499265092651926529265392654926559265692657926589265992660926619266292663926649266592666926679266892669926709267192672926739267492675926769267792678926799268092681926829268392684926859268692687926889268992690926919269292693926949269592696926979269892699927009270192702927039270492705927069270792708927099271092711927129271392714927159271692717927189271992720927219272292723927249272592726927279272892729927309273192732927339273492735927369273792738927399274092741927429274392744927459274692747927489274992750927519275292753927549275592756927579275892759927609276192762927639276492765927669276792768927699277092771927729277392774927759277692777927789277992780927819278292783927849278592786927879278892789927909279192792927939279492795927969279792798927999280092801928029280392804928059280692807928089280992810928119281292813928149281592816928179281892819928209282192822928239282492825928269282792828928299283092831928329283392834928359283692837928389283992840928419284292843928449284592846928479284892849928509285192852928539285492855928569285792858928599286092861928629286392864928659286692867928689286992870928719287292873928749287592876928779287892879928809288192882928839288492885928869288792888928899289092891928929289392894928959289692897928989289992900929019290292903929049290592906929079290892909929109291192912929139291492915929169291792918929199292092921929229292392924929259292692927929289292992930929319293292933929349293592936929379293892939929409294192942929439294492945929469294792948929499295092951929529295392954929559295692957929589295992960929619296292963929649296592966929679296892969929709297192972929739297492975929769297792978929799298092981929829298392984929859298692987929889298992990929919299292993929949299592996929979299892999930009300193002930039300493005930069300793008930099301093011930129301393014930159301693017930189301993020930219302293023930249302593026930279302893029930309303193032930339303493035930369303793038930399304093041930429304393044930459304693047930489304993050930519305293053930549305593056930579305893059930609306193062930639306493065930669306793068930699307093071930729307393074930759307693077930789307993080930819308293083930849308593086930879308893089930909309193092930939309493095930969309793098930999310093101931029310393104931059310693107931089310993110931119311293113931149311593116931179311893119931209312193122931239312493125931269312793128931299313093131931329313393134931359313693137931389313993140931419314293143931449314593146931479314893149931509315193152931539315493155931569315793158931599316093161931629316393164931659316693167931689316993170931719317293173931749317593176931779317893179931809318193182931839318493185931869318793188931899319093191931929319393194931959319693197931989319993200932019320293203932049320593206932079320893209932109321193212932139321493215932169321793218932199322093221932229322393224932259322693227932289322993230932319323293233932349323593236932379323893239932409324193242932439324493245932469324793248932499325093251932529325393254932559325693257932589325993260932619326293263932649326593266932679326893269932709327193272932739327493275932769327793278932799328093281932829328393284932859328693287932889328993290932919329293293932949329593296932979329893299933009330193302933039330493305933069330793308933099331093311933129331393314933159331693317933189331993320933219332293323933249332593326933279332893329933309333193332933339333493335933369333793338933399334093341933429334393344933459334693347933489334993350933519335293353933549335593356933579335893359933609336193362933639336493365933669336793368933699337093371933729337393374933759337693377933789337993380933819338293383933849338593386933879338893389933909339193392933939339493395933969339793398933999340093401934029340393404934059340693407934089340993410934119341293413934149341593416934179341893419934209342193422934239342493425934269342793428934299343093431934329343393434934359343693437934389343993440934419344293443934449344593446934479344893449934509345193452934539345493455934569345793458934599346093461934629346393464934659346693467934689346993470934719347293473934749347593476934779347893479934809348193482934839348493485934869348793488934899349093491934929349393494934959349693497934989349993500935019350293503935049350593506935079350893509935109351193512935139351493515935169351793518935199352093521935229352393524935259352693527935289352993530935319353293533935349353593536935379353893539935409354193542935439354493545935469354793548935499355093551935529355393554935559355693557935589355993560935619356293563935649356593566935679356893569935709357193572935739357493575935769357793578935799358093581935829358393584935859358693587935889358993590935919359293593935949359593596935979359893599936009360193602936039360493605936069360793608936099361093611936129361393614936159361693617936189361993620936219362293623936249362593626936279362893629936309363193632936339363493635936369363793638936399364093641936429364393644936459364693647936489364993650936519365293653936549365593656936579365893659936609366193662936639366493665936669366793668936699367093671936729367393674936759367693677936789367993680936819368293683936849368593686936879368893689936909369193692936939369493695936969369793698936999370093701937029370393704937059370693707937089370993710937119371293713937149371593716937179371893719937209372193722937239372493725937269372793728937299373093731937329373393734937359373693737937389373993740937419374293743937449374593746937479374893749937509375193752937539375493755937569375793758937599376093761937629376393764937659376693767937689376993770937719377293773937749377593776937779377893779937809378193782937839378493785937869378793788937899379093791937929379393794937959379693797937989379993800938019380293803938049380593806938079380893809938109381193812938139381493815938169381793818938199382093821938229382393824938259382693827938289382993830938319383293833938349383593836938379383893839938409384193842938439384493845938469384793848938499385093851938529385393854938559385693857938589385993860938619386293863938649386593866938679386893869938709387193872938739387493875938769387793878938799388093881938829388393884938859388693887938889388993890938919389293893938949389593896938979389893899939009390193902939039390493905939069390793908939099391093911939129391393914939159391693917939189391993920939219392293923939249392593926939279392893929939309393193932939339393493935939369393793938939399394093941939429394393944939459394693947939489394993950939519395293953939549395593956939579395893959939609396193962939639396493965939669396793968939699397093971939729397393974939759397693977939789397993980939819398293983939849398593986939879398893989939909399193992939939399493995939969399793998939999400094001940029400394004940059400694007940089400994010940119401294013940149401594016940179401894019940209402194022940239402494025940269402794028940299403094031940329403394034940359403694037940389403994040940419404294043940449404594046940479404894049940509405194052940539405494055940569405794058940599406094061940629406394064940659406694067940689406994070940719407294073940749407594076940779407894079940809408194082940839408494085940869408794088940899409094091940929409394094940959409694097940989409994100941019410294103941049410594106941079410894109941109411194112941139411494115941169411794118941199412094121941229412394124941259412694127941289412994130941319413294133941349413594136941379413894139941409414194142941439414494145941469414794148941499415094151941529415394154941559415694157941589415994160941619416294163941649416594166941679416894169941709417194172941739417494175941769417794178941799418094181941829418394184941859418694187941889418994190941919419294193941949419594196941979419894199942009420194202942039420494205942069420794208942099421094211942129421394214942159421694217942189421994220942219422294223942249422594226942279422894229942309423194232942339423494235942369423794238942399424094241942429424394244942459424694247942489424994250942519425294253942549425594256942579425894259942609426194262942639426494265942669426794268942699427094271942729427394274942759427694277942789427994280942819428294283942849428594286942879428894289942909429194292942939429494295942969429794298942999430094301943029430394304943059430694307943089430994310943119431294313943149431594316943179431894319943209432194322943239432494325943269432794328943299433094331943329433394334943359433694337943389433994340943419434294343943449434594346943479434894349943509435194352943539435494355943569435794358943599436094361943629436394364943659436694367943689436994370943719437294373943749437594376943779437894379943809438194382943839438494385943869438794388943899439094391943929439394394943959439694397943989439994400944019440294403944049440594406944079440894409944109441194412944139441494415944169441794418944199442094421944229442394424944259442694427944289442994430944319443294433944349443594436944379443894439944409444194442944439444494445944469444794448944499445094451944529445394454944559445694457944589445994460944619446294463944649446594466944679446894469944709447194472944739447494475944769447794478944799448094481944829448394484944859448694487944889448994490944919449294493944949449594496944979449894499945009450194502945039450494505945069450794508945099451094511945129451394514945159451694517945189451994520945219452294523945249452594526945279452894529945309453194532945339453494535945369453794538945399454094541945429454394544945459454694547945489454994550945519455294553945549455594556945579455894559945609456194562945639456494565945669456794568945699457094571945729457394574945759457694577945789457994580945819458294583945849458594586945879458894589945909459194592945939459494595945969459794598945999460094601946029460394604946059460694607946089460994610946119461294613946149461594616946179461894619946209462194622946239462494625
  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 _morphTargetTextureIndices;
  32183. private _supportsNormals;
  32184. private _supportsTangents;
  32185. private _supportsUVs;
  32186. private _vertexCount;
  32187. private _textureVertexStride;
  32188. private _textureWidth;
  32189. private _textureHeight;
  32190. private _uniqueId;
  32191. private _tempInfluences;
  32192. private _canUseTextureForTargets;
  32193. /** @hidden */
  32194. _targetStoreTexture: Nullable<RawTexture2DArray>;
  32195. /**
  32196. * Gets or sets a boolean indicating if normals must be morphed
  32197. */
  32198. enableNormalMorphing: boolean;
  32199. /**
  32200. * Gets or sets a boolean indicating if tangents must be morphed
  32201. */
  32202. enableTangentMorphing: boolean;
  32203. /**
  32204. * Gets or sets a boolean indicating if UV must be morphed
  32205. */
  32206. enableUVMorphing: boolean;
  32207. /**
  32208. * Creates a new MorphTargetManager
  32209. * @param scene defines the current scene
  32210. */
  32211. constructor(scene?: Nullable<Scene>);
  32212. /**
  32213. * Gets the unique ID of this manager
  32214. */
  32215. get uniqueId(): number;
  32216. /**
  32217. * Gets the number of vertices handled by this manager
  32218. */
  32219. get vertexCount(): number;
  32220. /**
  32221. * Gets a boolean indicating if this manager supports morphing of normals
  32222. */
  32223. get supportsNormals(): boolean;
  32224. /**
  32225. * Gets a boolean indicating if this manager supports morphing of tangents
  32226. */
  32227. get supportsTangents(): boolean;
  32228. /**
  32229. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  32230. */
  32231. get supportsUVs(): boolean;
  32232. /**
  32233. * Gets the number of targets stored in this manager
  32234. */
  32235. get numTargets(): number;
  32236. /**
  32237. * Gets the number of influencers (ie. the number of targets with influences > 0)
  32238. */
  32239. get numInfluencers(): number;
  32240. /**
  32241. * Gets the list of influences (one per target)
  32242. */
  32243. get influences(): Float32Array;
  32244. private _useTextureToStoreTargets;
  32245. /**
  32246. * Gets or sets a boolean indicating that targets should be stored as a texture instead of using vertex attributes (default is true).
  32247. * Please note that this option is not available if the hardware does not support it
  32248. */
  32249. get useTextureToStoreTargets(): boolean;
  32250. set useTextureToStoreTargets(value: boolean);
  32251. /**
  32252. * Gets a boolean indicating that the targets are stored into a texture (instead of as attributes)
  32253. */
  32254. get isUsingTextureForTargets(): boolean;
  32255. /**
  32256. * Gets the active target at specified index. An active target is a target with an influence > 0
  32257. * @param index defines the index to check
  32258. * @returns the requested target
  32259. */
  32260. getActiveTarget(index: number): MorphTarget;
  32261. /**
  32262. * Gets the target at specified index
  32263. * @param index defines the index to check
  32264. * @returns the requested target
  32265. */
  32266. getTarget(index: number): MorphTarget;
  32267. /**
  32268. * Add a new target to this manager
  32269. * @param target defines the target to add
  32270. */
  32271. addTarget(target: MorphTarget): void;
  32272. /**
  32273. * Removes a target from the manager
  32274. * @param target defines the target to remove
  32275. */
  32276. removeTarget(target: MorphTarget): void;
  32277. /** @hidden */
  32278. _bind(effect: Effect): void;
  32279. /**
  32280. * Clone the current manager
  32281. * @returns a new MorphTargetManager
  32282. */
  32283. clone(): MorphTargetManager;
  32284. /**
  32285. * Serializes the current manager into a Serialization object
  32286. * @returns the serialized object
  32287. */
  32288. serialize(): any;
  32289. private _syncActiveTargets;
  32290. /**
  32291. * Synchronize the targets with all the meshes using this morph target manager
  32292. */
  32293. synchronize(): void;
  32294. /**
  32295. * Release all resources
  32296. */
  32297. dispose(): void;
  32298. /**
  32299. * Creates a new MorphTargetManager from serialized data
  32300. * @param serializationObject defines the serialized data
  32301. * @param scene defines the hosting scene
  32302. * @returns the new MorphTargetManager
  32303. */
  32304. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  32305. }
  32306. }
  32307. declare module BABYLON {
  32308. /**
  32309. * Class used to represent a specific level of detail of a mesh
  32310. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32311. */
  32312. export class MeshLODLevel {
  32313. /** Defines the distance where this level should start being displayed */
  32314. distance: number;
  32315. /** Defines the mesh to use to render this level */
  32316. mesh: Nullable<Mesh>;
  32317. /**
  32318. * Creates a new LOD level
  32319. * @param distance defines the distance where this level should star being displayed
  32320. * @param mesh defines the mesh to use to render this level
  32321. */
  32322. constructor(
  32323. /** Defines the distance where this level should start being displayed */
  32324. distance: number,
  32325. /** Defines the mesh to use to render this level */
  32326. mesh: Nullable<Mesh>);
  32327. }
  32328. }
  32329. declare module BABYLON {
  32330. /**
  32331. * Helper class used to generate a canvas to manipulate images
  32332. */
  32333. export class CanvasGenerator {
  32334. /**
  32335. * Create a new canvas (or offscreen canvas depending on the context)
  32336. * @param width defines the expected width
  32337. * @param height defines the expected height
  32338. * @return a new canvas or offscreen canvas
  32339. */
  32340. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  32341. }
  32342. }
  32343. declare module BABYLON {
  32344. /**
  32345. * Mesh representing the ground
  32346. */
  32347. export class GroundMesh extends Mesh {
  32348. /** If octree should be generated */
  32349. generateOctree: boolean;
  32350. private _heightQuads;
  32351. /** @hidden */
  32352. _subdivisionsX: number;
  32353. /** @hidden */
  32354. _subdivisionsY: number;
  32355. /** @hidden */
  32356. _width: number;
  32357. /** @hidden */
  32358. _height: number;
  32359. /** @hidden */
  32360. _minX: number;
  32361. /** @hidden */
  32362. _maxX: number;
  32363. /** @hidden */
  32364. _minZ: number;
  32365. /** @hidden */
  32366. _maxZ: number;
  32367. constructor(name: string, scene: Scene);
  32368. /**
  32369. * "GroundMesh"
  32370. * @returns "GroundMesh"
  32371. */
  32372. getClassName(): string;
  32373. /**
  32374. * The minimum of x and y subdivisions
  32375. */
  32376. get subdivisions(): number;
  32377. /**
  32378. * X subdivisions
  32379. */
  32380. get subdivisionsX(): number;
  32381. /**
  32382. * Y subdivisions
  32383. */
  32384. get subdivisionsY(): number;
  32385. /**
  32386. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  32387. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  32388. * @param chunksCount the number of subdivisions for x and y
  32389. * @param octreeBlocksSize (Default: 32)
  32390. */
  32391. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  32392. /**
  32393. * Returns a height (y) value in the World system :
  32394. * the ground altitude at the coordinates (x, z) expressed in the World system.
  32395. * @param x x coordinate
  32396. * @param z z coordinate
  32397. * @returns the ground y position if (x, z) are outside the ground surface.
  32398. */
  32399. getHeightAtCoordinates(x: number, z: number): number;
  32400. /**
  32401. * Returns a normalized vector (Vector3) orthogonal to the ground
  32402. * at the ground coordinates (x, z) expressed in the World system.
  32403. * @param x x coordinate
  32404. * @param z z coordinate
  32405. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  32406. */
  32407. getNormalAtCoordinates(x: number, z: number): Vector3;
  32408. /**
  32409. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  32410. * at the ground coordinates (x, z) expressed in the World system.
  32411. * Doesn't update the reference Vector3 if (x, z) are outside the ground surface.
  32412. * @param x x coordinate
  32413. * @param z z coordinate
  32414. * @param ref vector to store the result
  32415. * @returns the GroundMesh.
  32416. */
  32417. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  32418. /**
  32419. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  32420. * if the ground has been updated.
  32421. * This can be used in the render loop.
  32422. * @returns the GroundMesh.
  32423. */
  32424. updateCoordinateHeights(): GroundMesh;
  32425. private _getFacetAt;
  32426. private _initHeightQuads;
  32427. private _computeHeightQuads;
  32428. /**
  32429. * Serializes this ground mesh
  32430. * @param serializationObject object to write serialization to
  32431. */
  32432. serialize(serializationObject: any): void;
  32433. /**
  32434. * Parses a serialized ground mesh
  32435. * @param parsedMesh the serialized mesh
  32436. * @param scene the scene to create the ground mesh in
  32437. * @returns the created ground mesh
  32438. */
  32439. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  32440. }
  32441. }
  32442. declare module BABYLON {
  32443. /**
  32444. * Interface for Physics-Joint data
  32445. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32446. */
  32447. export interface PhysicsJointData {
  32448. /**
  32449. * The main pivot of the joint
  32450. */
  32451. mainPivot?: Vector3;
  32452. /**
  32453. * The connected pivot of the joint
  32454. */
  32455. connectedPivot?: Vector3;
  32456. /**
  32457. * The main axis of the joint
  32458. */
  32459. mainAxis?: Vector3;
  32460. /**
  32461. * The connected axis of the joint
  32462. */
  32463. connectedAxis?: Vector3;
  32464. /**
  32465. * The collision of the joint
  32466. */
  32467. collision?: boolean;
  32468. /**
  32469. * Native Oimo/Cannon/Energy data
  32470. */
  32471. nativeParams?: any;
  32472. }
  32473. /**
  32474. * This is a holder class for the physics joint created by the physics plugin
  32475. * It holds a set of functions to control the underlying joint
  32476. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32477. */
  32478. export class PhysicsJoint {
  32479. /**
  32480. * The type of the physics joint
  32481. */
  32482. type: number;
  32483. /**
  32484. * The data for the physics joint
  32485. */
  32486. jointData: PhysicsJointData;
  32487. private _physicsJoint;
  32488. protected _physicsPlugin: IPhysicsEnginePlugin;
  32489. /**
  32490. * Initializes the physics joint
  32491. * @param type The type of the physics joint
  32492. * @param jointData The data for the physics joint
  32493. */
  32494. constructor(
  32495. /**
  32496. * The type of the physics joint
  32497. */
  32498. type: number,
  32499. /**
  32500. * The data for the physics joint
  32501. */
  32502. jointData: PhysicsJointData);
  32503. /**
  32504. * Gets the physics joint
  32505. */
  32506. get physicsJoint(): any;
  32507. /**
  32508. * Sets the physics joint
  32509. */
  32510. set physicsJoint(newJoint: any);
  32511. /**
  32512. * Sets the physics plugin
  32513. */
  32514. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  32515. /**
  32516. * Execute a function that is physics-plugin specific.
  32517. * @param {Function} func the function that will be executed.
  32518. * It accepts two parameters: the physics world and the physics joint
  32519. */
  32520. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  32521. /**
  32522. * Distance-Joint type
  32523. */
  32524. static DistanceJoint: number;
  32525. /**
  32526. * Hinge-Joint type
  32527. */
  32528. static HingeJoint: number;
  32529. /**
  32530. * Ball-and-Socket joint type
  32531. */
  32532. static BallAndSocketJoint: number;
  32533. /**
  32534. * Wheel-Joint type
  32535. */
  32536. static WheelJoint: number;
  32537. /**
  32538. * Slider-Joint type
  32539. */
  32540. static SliderJoint: number;
  32541. /**
  32542. * Prismatic-Joint type
  32543. */
  32544. static PrismaticJoint: number;
  32545. /**
  32546. * Universal-Joint type
  32547. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  32548. */
  32549. static UniversalJoint: number;
  32550. /**
  32551. * Hinge-Joint 2 type
  32552. */
  32553. static Hinge2Joint: number;
  32554. /**
  32555. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  32556. */
  32557. static PointToPointJoint: number;
  32558. /**
  32559. * Spring-Joint type
  32560. */
  32561. static SpringJoint: number;
  32562. /**
  32563. * Lock-Joint type
  32564. */
  32565. static LockJoint: number;
  32566. }
  32567. /**
  32568. * A class representing a physics distance joint
  32569. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32570. */
  32571. export class DistanceJoint extends PhysicsJoint {
  32572. /**
  32573. *
  32574. * @param jointData The data for the Distance-Joint
  32575. */
  32576. constructor(jointData: DistanceJointData);
  32577. /**
  32578. * Update the predefined distance.
  32579. * @param maxDistance The maximum preferred distance
  32580. * @param minDistance The minimum preferred distance
  32581. */
  32582. updateDistance(maxDistance: number, minDistance?: number): void;
  32583. }
  32584. /**
  32585. * Represents a Motor-Enabled Joint
  32586. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32587. */
  32588. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  32589. /**
  32590. * Initializes the Motor-Enabled Joint
  32591. * @param type The type of the joint
  32592. * @param jointData The physical joint data for the joint
  32593. */
  32594. constructor(type: number, jointData: PhysicsJointData);
  32595. /**
  32596. * Set the motor values.
  32597. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32598. * @param force the force to apply
  32599. * @param maxForce max force for this motor.
  32600. */
  32601. setMotor(force?: number, maxForce?: number): void;
  32602. /**
  32603. * Set the motor's limits.
  32604. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32605. * @param upperLimit The upper limit of the motor
  32606. * @param lowerLimit The lower limit of the motor
  32607. */
  32608. setLimit(upperLimit: number, lowerLimit?: number): void;
  32609. }
  32610. /**
  32611. * This class represents a single physics Hinge-Joint
  32612. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32613. */
  32614. export class HingeJoint extends MotorEnabledJoint {
  32615. /**
  32616. * Initializes the Hinge-Joint
  32617. * @param jointData The joint data for the Hinge-Joint
  32618. */
  32619. constructor(jointData: PhysicsJointData);
  32620. /**
  32621. * Set the motor values.
  32622. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32623. * @param {number} force the force to apply
  32624. * @param {number} maxForce max force for this motor.
  32625. */
  32626. setMotor(force?: number, maxForce?: number): void;
  32627. /**
  32628. * Set the motor's limits.
  32629. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32630. * @param upperLimit The upper limit of the motor
  32631. * @param lowerLimit The lower limit of the motor
  32632. */
  32633. setLimit(upperLimit: number, lowerLimit?: number): void;
  32634. }
  32635. /**
  32636. * This class represents a dual hinge physics joint (same as wheel joint)
  32637. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32638. */
  32639. export class Hinge2Joint extends MotorEnabledJoint {
  32640. /**
  32641. * Initializes the Hinge2-Joint
  32642. * @param jointData The joint data for the Hinge2-Joint
  32643. */
  32644. constructor(jointData: PhysicsJointData);
  32645. /**
  32646. * Set the motor values.
  32647. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32648. * @param {number} targetSpeed the speed the motor is to reach
  32649. * @param {number} maxForce max force for this motor.
  32650. * @param {motorIndex} the motor's index, 0 or 1.
  32651. */
  32652. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  32653. /**
  32654. * Set the motor limits.
  32655. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32656. * @param {number} upperLimit the upper limit
  32657. * @param {number} lowerLimit lower limit
  32658. * @param {motorIndex} the motor's index, 0 or 1.
  32659. */
  32660. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32661. }
  32662. /**
  32663. * Interface for a motor enabled joint
  32664. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32665. */
  32666. export interface IMotorEnabledJoint {
  32667. /**
  32668. * Physics joint
  32669. */
  32670. physicsJoint: any;
  32671. /**
  32672. * Sets the motor of the motor-enabled joint
  32673. * @param force The force of the motor
  32674. * @param maxForce The maximum force of the motor
  32675. * @param motorIndex The index of the motor
  32676. */
  32677. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32678. /**
  32679. * Sets the limit of the motor
  32680. * @param upperLimit The upper limit of the motor
  32681. * @param lowerLimit The lower limit of the motor
  32682. * @param motorIndex The index of the motor
  32683. */
  32684. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32685. }
  32686. /**
  32687. * Joint data for a Distance-Joint
  32688. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32689. */
  32690. export interface DistanceJointData extends PhysicsJointData {
  32691. /**
  32692. * Max distance the 2 joint objects can be apart
  32693. */
  32694. maxDistance: number;
  32695. }
  32696. /**
  32697. * Joint data from a spring joint
  32698. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32699. */
  32700. export interface SpringJointData extends PhysicsJointData {
  32701. /**
  32702. * Length of the spring
  32703. */
  32704. length: number;
  32705. /**
  32706. * Stiffness of the spring
  32707. */
  32708. stiffness: number;
  32709. /**
  32710. * Damping of the spring
  32711. */
  32712. damping: number;
  32713. /** this callback will be called when applying the force to the impostors. */
  32714. forceApplicationCallback: () => void;
  32715. }
  32716. }
  32717. declare module BABYLON {
  32718. /**
  32719. * Holds the data for the raycast result
  32720. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32721. */
  32722. export class PhysicsRaycastResult {
  32723. private _hasHit;
  32724. private _hitDistance;
  32725. private _hitNormalWorld;
  32726. private _hitPointWorld;
  32727. private _rayFromWorld;
  32728. private _rayToWorld;
  32729. /**
  32730. * Gets if there was a hit
  32731. */
  32732. get hasHit(): boolean;
  32733. /**
  32734. * Gets the distance from the hit
  32735. */
  32736. get hitDistance(): number;
  32737. /**
  32738. * Gets the hit normal/direction in the world
  32739. */
  32740. get hitNormalWorld(): Vector3;
  32741. /**
  32742. * Gets the hit point in the world
  32743. */
  32744. get hitPointWorld(): Vector3;
  32745. /**
  32746. * Gets the ray "start point" of the ray in the world
  32747. */
  32748. get rayFromWorld(): Vector3;
  32749. /**
  32750. * Gets the ray "end point" of the ray in the world
  32751. */
  32752. get rayToWorld(): Vector3;
  32753. /**
  32754. * Sets the hit data (normal & point in world space)
  32755. * @param hitNormalWorld defines the normal in world space
  32756. * @param hitPointWorld defines the point in world space
  32757. */
  32758. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  32759. /**
  32760. * Sets the distance from the start point to the hit point
  32761. * @param distance
  32762. */
  32763. setHitDistance(distance: number): void;
  32764. /**
  32765. * Calculates the distance manually
  32766. */
  32767. calculateHitDistance(): void;
  32768. /**
  32769. * Resets all the values to default
  32770. * @param from The from point on world space
  32771. * @param to The to point on world space
  32772. */
  32773. reset(from?: Vector3, to?: Vector3): void;
  32774. }
  32775. /**
  32776. * Interface for the size containing width and height
  32777. */
  32778. interface IXYZ {
  32779. /**
  32780. * X
  32781. */
  32782. x: number;
  32783. /**
  32784. * Y
  32785. */
  32786. y: number;
  32787. /**
  32788. * Z
  32789. */
  32790. z: number;
  32791. }
  32792. }
  32793. declare module BABYLON {
  32794. /**
  32795. * Interface used to describe a physics joint
  32796. */
  32797. export interface PhysicsImpostorJoint {
  32798. /** Defines the main impostor to which the joint is linked */
  32799. mainImpostor: PhysicsImpostor;
  32800. /** Defines the impostor that is connected to the main impostor using this joint */
  32801. connectedImpostor: PhysicsImpostor;
  32802. /** Defines the joint itself */
  32803. joint: PhysicsJoint;
  32804. }
  32805. /** @hidden */
  32806. export interface IPhysicsEnginePlugin {
  32807. world: any;
  32808. name: string;
  32809. setGravity(gravity: Vector3): void;
  32810. setTimeStep(timeStep: number): void;
  32811. getTimeStep(): number;
  32812. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32813. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32814. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32815. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32816. removePhysicsBody(impostor: PhysicsImpostor): void;
  32817. generateJoint(joint: PhysicsImpostorJoint): void;
  32818. removeJoint(joint: PhysicsImpostorJoint): void;
  32819. isSupported(): boolean;
  32820. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32821. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32822. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32823. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32824. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32825. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32826. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32827. getBodyMass(impostor: PhysicsImpostor): number;
  32828. getBodyFriction(impostor: PhysicsImpostor): number;
  32829. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32830. getBodyRestitution(impostor: PhysicsImpostor): number;
  32831. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32832. getBodyPressure?(impostor: PhysicsImpostor): number;
  32833. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  32834. getBodyStiffness?(impostor: PhysicsImpostor): number;
  32835. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  32836. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  32837. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  32838. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  32839. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  32840. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32841. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32842. sleepBody(impostor: PhysicsImpostor): void;
  32843. wakeUpBody(impostor: PhysicsImpostor): void;
  32844. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32845. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32846. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32847. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32848. getRadius(impostor: PhysicsImpostor): number;
  32849. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32850. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32851. dispose(): void;
  32852. }
  32853. /**
  32854. * Interface used to define a physics engine
  32855. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32856. */
  32857. export interface IPhysicsEngine {
  32858. /**
  32859. * Gets the gravity vector used by the simulation
  32860. */
  32861. gravity: Vector3;
  32862. /**
  32863. * Sets the gravity vector used by the simulation
  32864. * @param gravity defines the gravity vector to use
  32865. */
  32866. setGravity(gravity: Vector3): void;
  32867. /**
  32868. * Set the time step of the physics engine.
  32869. * Default is 1/60.
  32870. * To slow it down, enter 1/600 for example.
  32871. * To speed it up, 1/30
  32872. * @param newTimeStep the new timestep to apply to this world.
  32873. */
  32874. setTimeStep(newTimeStep: number): void;
  32875. /**
  32876. * Get the time step of the physics engine.
  32877. * @returns the current time step
  32878. */
  32879. getTimeStep(): number;
  32880. /**
  32881. * Set the sub time step of the physics engine.
  32882. * Default is 0 meaning there is no sub steps
  32883. * To increase physics resolution precision, set a small value (like 1 ms)
  32884. * @param subTimeStep defines the new sub timestep used for physics resolution.
  32885. */
  32886. setSubTimeStep(subTimeStep: number): void;
  32887. /**
  32888. * Get the sub time step of the physics engine.
  32889. * @returns the current sub time step
  32890. */
  32891. getSubTimeStep(): number;
  32892. /**
  32893. * Release all resources
  32894. */
  32895. dispose(): void;
  32896. /**
  32897. * Gets the name of the current physics plugin
  32898. * @returns the name of the plugin
  32899. */
  32900. getPhysicsPluginName(): string;
  32901. /**
  32902. * Adding a new impostor for the impostor tracking.
  32903. * This will be done by the impostor itself.
  32904. * @param impostor the impostor to add
  32905. */
  32906. addImpostor(impostor: PhysicsImpostor): void;
  32907. /**
  32908. * Remove an impostor from the engine.
  32909. * This impostor and its mesh will not longer be updated by the physics engine.
  32910. * @param impostor the impostor to remove
  32911. */
  32912. removeImpostor(impostor: PhysicsImpostor): void;
  32913. /**
  32914. * Add a joint to the physics engine
  32915. * @param mainImpostor defines the main impostor to which the joint is added.
  32916. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32917. * @param joint defines the joint that will connect both impostors.
  32918. */
  32919. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32920. /**
  32921. * Removes a joint from the simulation
  32922. * @param mainImpostor defines the impostor used with the joint
  32923. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32924. * @param joint defines the joint to remove
  32925. */
  32926. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32927. /**
  32928. * Gets the current plugin used to run the simulation
  32929. * @returns current plugin
  32930. */
  32931. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32932. /**
  32933. * Gets the list of physic impostors
  32934. * @returns an array of PhysicsImpostor
  32935. */
  32936. getImpostors(): Array<PhysicsImpostor>;
  32937. /**
  32938. * Gets the impostor for a physics enabled object
  32939. * @param object defines the object impersonated by the impostor
  32940. * @returns the PhysicsImpostor or null if not found
  32941. */
  32942. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32943. /**
  32944. * Gets the impostor for a physics body object
  32945. * @param body defines physics body used by the impostor
  32946. * @returns the PhysicsImpostor or null if not found
  32947. */
  32948. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32949. /**
  32950. * Does a raycast in the physics world
  32951. * @param from when should the ray start?
  32952. * @param to when should the ray end?
  32953. * @returns PhysicsRaycastResult
  32954. */
  32955. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32956. /**
  32957. * Called by the scene. No need to call it.
  32958. * @param delta defines the timespan between frames
  32959. */
  32960. _step(delta: number): void;
  32961. }
  32962. }
  32963. declare module BABYLON {
  32964. /**
  32965. * The interface for the physics imposter parameters
  32966. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32967. */
  32968. export interface PhysicsImpostorParameters {
  32969. /**
  32970. * The mass of the physics imposter
  32971. */
  32972. mass: number;
  32973. /**
  32974. * The friction of the physics imposter
  32975. */
  32976. friction?: number;
  32977. /**
  32978. * The coefficient of restitution of the physics imposter
  32979. */
  32980. restitution?: number;
  32981. /**
  32982. * The native options of the physics imposter
  32983. */
  32984. nativeOptions?: any;
  32985. /**
  32986. * Specifies if the parent should be ignored
  32987. */
  32988. ignoreParent?: boolean;
  32989. /**
  32990. * Specifies if bi-directional transformations should be disabled
  32991. */
  32992. disableBidirectionalTransformation?: boolean;
  32993. /**
  32994. * The pressure inside the physics imposter, soft object only
  32995. */
  32996. pressure?: number;
  32997. /**
  32998. * The stiffness the physics imposter, soft object only
  32999. */
  33000. stiffness?: number;
  33001. /**
  33002. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  33003. */
  33004. velocityIterations?: number;
  33005. /**
  33006. * The number of iterations used in maintaining consistent vertex positions, soft object only
  33007. */
  33008. positionIterations?: number;
  33009. /**
  33010. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  33011. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  33012. * Add to fix multiple points
  33013. */
  33014. fixedPoints?: number;
  33015. /**
  33016. * The collision margin around a soft object
  33017. */
  33018. margin?: number;
  33019. /**
  33020. * The collision margin around a soft object
  33021. */
  33022. damping?: number;
  33023. /**
  33024. * The path for a rope based on an extrusion
  33025. */
  33026. path?: any;
  33027. /**
  33028. * The shape of an extrusion used for a rope based on an extrusion
  33029. */
  33030. shape?: any;
  33031. }
  33032. /**
  33033. * Interface for a physics-enabled object
  33034. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33035. */
  33036. export interface IPhysicsEnabledObject {
  33037. /**
  33038. * The position of the physics-enabled object
  33039. */
  33040. position: Vector3;
  33041. /**
  33042. * The rotation of the physics-enabled object
  33043. */
  33044. rotationQuaternion: Nullable<Quaternion>;
  33045. /**
  33046. * The scale of the physics-enabled object
  33047. */
  33048. scaling: Vector3;
  33049. /**
  33050. * The rotation of the physics-enabled object
  33051. */
  33052. rotation?: Vector3;
  33053. /**
  33054. * The parent of the physics-enabled object
  33055. */
  33056. parent?: any;
  33057. /**
  33058. * The bounding info of the physics-enabled object
  33059. * @returns The bounding info of the physics-enabled object
  33060. */
  33061. getBoundingInfo(): BoundingInfo;
  33062. /**
  33063. * Computes the world matrix
  33064. * @param force Specifies if the world matrix should be computed by force
  33065. * @returns A world matrix
  33066. */
  33067. computeWorldMatrix(force: boolean): Matrix;
  33068. /**
  33069. * Gets the world matrix
  33070. * @returns A world matrix
  33071. */
  33072. getWorldMatrix?(): Matrix;
  33073. /**
  33074. * Gets the child meshes
  33075. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  33076. * @returns An array of abstract meshes
  33077. */
  33078. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  33079. /**
  33080. * Gets the vertex data
  33081. * @param kind The type of vertex data
  33082. * @returns A nullable array of numbers, or a float32 array
  33083. */
  33084. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  33085. /**
  33086. * Gets the indices from the mesh
  33087. * @returns A nullable array of index arrays
  33088. */
  33089. getIndices?(): Nullable<IndicesArray>;
  33090. /**
  33091. * Gets the scene from the mesh
  33092. * @returns the indices array or null
  33093. */
  33094. getScene?(): Scene;
  33095. /**
  33096. * Gets the absolute position from the mesh
  33097. * @returns the absolute position
  33098. */
  33099. getAbsolutePosition(): Vector3;
  33100. /**
  33101. * Gets the absolute pivot point from the mesh
  33102. * @returns the absolute pivot point
  33103. */
  33104. getAbsolutePivotPoint(): Vector3;
  33105. /**
  33106. * Rotates the mesh
  33107. * @param axis The axis of rotation
  33108. * @param amount The amount of rotation
  33109. * @param space The space of the rotation
  33110. * @returns The rotation transform node
  33111. */
  33112. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  33113. /**
  33114. * Translates the mesh
  33115. * @param axis The axis of translation
  33116. * @param distance The distance of translation
  33117. * @param space The space of the translation
  33118. * @returns The transform node
  33119. */
  33120. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  33121. /**
  33122. * Sets the absolute position of the mesh
  33123. * @param absolutePosition The absolute position of the mesh
  33124. * @returns The transform node
  33125. */
  33126. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33127. /**
  33128. * Gets the class name of the mesh
  33129. * @returns The class name
  33130. */
  33131. getClassName(): string;
  33132. }
  33133. /**
  33134. * Represents a physics imposter
  33135. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33136. */
  33137. export class PhysicsImpostor {
  33138. /**
  33139. * The physics-enabled object used as the physics imposter
  33140. */
  33141. object: IPhysicsEnabledObject;
  33142. /**
  33143. * The type of the physics imposter
  33144. */
  33145. type: number;
  33146. private _options;
  33147. private _scene?;
  33148. /**
  33149. * The default object size of the imposter
  33150. */
  33151. static DEFAULT_OBJECT_SIZE: Vector3;
  33152. /**
  33153. * The identity quaternion of the imposter
  33154. */
  33155. static IDENTITY_QUATERNION: Quaternion;
  33156. /** @hidden */
  33157. _pluginData: any;
  33158. private _physicsEngine;
  33159. private _physicsBody;
  33160. private _bodyUpdateRequired;
  33161. private _onBeforePhysicsStepCallbacks;
  33162. private _onAfterPhysicsStepCallbacks;
  33163. /** @hidden */
  33164. _onPhysicsCollideCallbacks: Array<{
  33165. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  33166. otherImpostors: Array<PhysicsImpostor>;
  33167. }>;
  33168. private _deltaPosition;
  33169. private _deltaRotation;
  33170. private _deltaRotationConjugated;
  33171. /** @hidden */
  33172. _isFromLine: boolean;
  33173. private _parent;
  33174. private _isDisposed;
  33175. private static _tmpVecs;
  33176. private static _tmpQuat;
  33177. /**
  33178. * Specifies if the physics imposter is disposed
  33179. */
  33180. get isDisposed(): boolean;
  33181. /**
  33182. * Gets the mass of the physics imposter
  33183. */
  33184. get mass(): number;
  33185. set mass(value: number);
  33186. /**
  33187. * Gets the coefficient of friction
  33188. */
  33189. get friction(): number;
  33190. /**
  33191. * Sets the coefficient of friction
  33192. */
  33193. set friction(value: number);
  33194. /**
  33195. * Gets the coefficient of restitution
  33196. */
  33197. get restitution(): number;
  33198. /**
  33199. * Sets the coefficient of restitution
  33200. */
  33201. set restitution(value: number);
  33202. /**
  33203. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  33204. */
  33205. get pressure(): number;
  33206. /**
  33207. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  33208. */
  33209. set pressure(value: number);
  33210. /**
  33211. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33212. */
  33213. get stiffness(): number;
  33214. /**
  33215. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33216. */
  33217. set stiffness(value: number);
  33218. /**
  33219. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33220. */
  33221. get velocityIterations(): number;
  33222. /**
  33223. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33224. */
  33225. set velocityIterations(value: number);
  33226. /**
  33227. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33228. */
  33229. get positionIterations(): number;
  33230. /**
  33231. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33232. */
  33233. set positionIterations(value: number);
  33234. /**
  33235. * The unique id of the physics imposter
  33236. * set by the physics engine when adding this impostor to the array
  33237. */
  33238. uniqueId: number;
  33239. /**
  33240. * @hidden
  33241. */
  33242. soft: boolean;
  33243. /**
  33244. * @hidden
  33245. */
  33246. segments: number;
  33247. private _joints;
  33248. /**
  33249. * Initializes the physics imposter
  33250. * @param object The physics-enabled object used as the physics imposter
  33251. * @param type The type of the physics imposter
  33252. * @param _options The options for the physics imposter
  33253. * @param _scene The Babylon scene
  33254. */
  33255. constructor(
  33256. /**
  33257. * The physics-enabled object used as the physics imposter
  33258. */
  33259. object: IPhysicsEnabledObject,
  33260. /**
  33261. * The type of the physics imposter
  33262. */
  33263. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33264. /**
  33265. * This function will completely initialize this impostor.
  33266. * It will create a new body - but only if this mesh has no parent.
  33267. * If it has, this impostor will not be used other than to define the impostor
  33268. * of the child mesh.
  33269. * @hidden
  33270. */
  33271. _init(): void;
  33272. private _getPhysicsParent;
  33273. /**
  33274. * Should a new body be generated.
  33275. * @returns boolean specifying if body initialization is required
  33276. */
  33277. isBodyInitRequired(): boolean;
  33278. /**
  33279. * Sets the updated scaling
  33280. * @param updated Specifies if the scaling is updated
  33281. */
  33282. setScalingUpdated(): void;
  33283. /**
  33284. * Force a regeneration of this or the parent's impostor's body.
  33285. * Use under cautious - This will remove all joints already implemented.
  33286. */
  33287. forceUpdate(): void;
  33288. /**
  33289. * Gets the body that holds this impostor. Either its own, or its parent.
  33290. */
  33291. get physicsBody(): any;
  33292. /**
  33293. * Get the parent of the physics imposter
  33294. * @returns Physics imposter or null
  33295. */
  33296. get parent(): Nullable<PhysicsImpostor>;
  33297. /**
  33298. * Sets the parent of the physics imposter
  33299. */
  33300. set parent(value: Nullable<PhysicsImpostor>);
  33301. /**
  33302. * Set the physics body. Used mainly by the physics engine/plugin
  33303. */
  33304. set physicsBody(physicsBody: any);
  33305. /**
  33306. * Resets the update flags
  33307. */
  33308. resetUpdateFlags(): void;
  33309. /**
  33310. * Gets the object extend size
  33311. * @returns the object extend size
  33312. */
  33313. getObjectExtendSize(): Vector3;
  33314. /**
  33315. * Gets the object center
  33316. * @returns The object center
  33317. */
  33318. getObjectCenter(): Vector3;
  33319. /**
  33320. * Get a specific parameter from the options parameters
  33321. * @param paramName The object parameter name
  33322. * @returns The object parameter
  33323. */
  33324. getParam(paramName: string): any;
  33325. /**
  33326. * Sets a specific parameter in the options given to the physics plugin
  33327. * @param paramName The parameter name
  33328. * @param value The value of the parameter
  33329. */
  33330. setParam(paramName: string, value: number): void;
  33331. /**
  33332. * Specifically change the body's mass option. Won't recreate the physics body object
  33333. * @param mass The mass of the physics imposter
  33334. */
  33335. setMass(mass: number): void;
  33336. /**
  33337. * Gets the linear velocity
  33338. * @returns linear velocity or null
  33339. */
  33340. getLinearVelocity(): Nullable<Vector3>;
  33341. /**
  33342. * Sets the linear velocity
  33343. * @param velocity linear velocity or null
  33344. */
  33345. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33346. /**
  33347. * Gets the angular velocity
  33348. * @returns angular velocity or null
  33349. */
  33350. getAngularVelocity(): Nullable<Vector3>;
  33351. /**
  33352. * Sets the angular velocity
  33353. * @param velocity The velocity or null
  33354. */
  33355. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33356. /**
  33357. * Execute a function with the physics plugin native code
  33358. * Provide a function the will have two variables - the world object and the physics body object
  33359. * @param func The function to execute with the physics plugin native code
  33360. */
  33361. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33362. /**
  33363. * Register a function that will be executed before the physics world is stepping forward
  33364. * @param func The function to execute before the physics world is stepped forward
  33365. */
  33366. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33367. /**
  33368. * Unregister a function that will be executed before the physics world is stepping forward
  33369. * @param func The function to execute before the physics world is stepped forward
  33370. */
  33371. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33372. /**
  33373. * Register a function that will be executed after the physics step
  33374. * @param func The function to execute after physics step
  33375. */
  33376. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33377. /**
  33378. * Unregisters a function that will be executed after the physics step
  33379. * @param func The function to execute after physics step
  33380. */
  33381. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33382. /**
  33383. * register a function that will be executed when this impostor collides against a different body
  33384. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33385. * @param func Callback that is executed on collision
  33386. */
  33387. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33388. /**
  33389. * Unregisters the physics imposter on contact
  33390. * @param collideAgainst The physics object to collide against
  33391. * @param func Callback to execute on collision
  33392. */
  33393. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33394. private _tmpQuat;
  33395. private _tmpQuat2;
  33396. /**
  33397. * Get the parent rotation
  33398. * @returns The parent rotation
  33399. */
  33400. getParentsRotation(): Quaternion;
  33401. /**
  33402. * this function is executed by the physics engine.
  33403. */
  33404. beforeStep: () => void;
  33405. /**
  33406. * this function is executed by the physics engine
  33407. */
  33408. afterStep: () => void;
  33409. /**
  33410. * Legacy collision detection event support
  33411. */
  33412. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33413. /**
  33414. * event and body object due to cannon's event-based architecture.
  33415. */
  33416. onCollide: (e: {
  33417. body: any;
  33418. point: Nullable<Vector3>;
  33419. }) => void;
  33420. /**
  33421. * Apply a force
  33422. * @param force The force to apply
  33423. * @param contactPoint The contact point for the force
  33424. * @returns The physics imposter
  33425. */
  33426. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33427. /**
  33428. * Apply an impulse
  33429. * @param force The impulse force
  33430. * @param contactPoint The contact point for the impulse force
  33431. * @returns The physics imposter
  33432. */
  33433. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33434. /**
  33435. * A help function to create a joint
  33436. * @param otherImpostor A physics imposter used to create a joint
  33437. * @param jointType The type of joint
  33438. * @param jointData The data for the joint
  33439. * @returns The physics imposter
  33440. */
  33441. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33442. /**
  33443. * Add a joint to this impostor with a different impostor
  33444. * @param otherImpostor A physics imposter used to add a joint
  33445. * @param joint The joint to add
  33446. * @returns The physics imposter
  33447. */
  33448. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33449. /**
  33450. * Add an anchor to a cloth impostor
  33451. * @param otherImpostor rigid impostor to anchor to
  33452. * @param width ratio across width from 0 to 1
  33453. * @param height ratio up height from 0 to 1
  33454. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little stretch
  33455. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  33456. * @returns impostor the soft imposter
  33457. */
  33458. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33459. /**
  33460. * Add a hook to a rope impostor
  33461. * @param otherImpostor rigid impostor to anchor to
  33462. * @param length ratio across rope from 0 to 1
  33463. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little stretch
  33464. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  33465. * @returns impostor the rope imposter
  33466. */
  33467. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33468. /**
  33469. * Will keep this body still, in a sleep mode.
  33470. * @returns the physics imposter
  33471. */
  33472. sleep(): PhysicsImpostor;
  33473. /**
  33474. * Wake the body up.
  33475. * @returns The physics imposter
  33476. */
  33477. wakeUp(): PhysicsImpostor;
  33478. /**
  33479. * Clones the physics imposter
  33480. * @param newObject The physics imposter clones to this physics-enabled object
  33481. * @returns A nullable physics imposter
  33482. */
  33483. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33484. /**
  33485. * Disposes the physics imposter
  33486. */
  33487. dispose(): void;
  33488. /**
  33489. * Sets the delta position
  33490. * @param position The delta position amount
  33491. */
  33492. setDeltaPosition(position: Vector3): void;
  33493. /**
  33494. * Sets the delta rotation
  33495. * @param rotation The delta rotation amount
  33496. */
  33497. setDeltaRotation(rotation: Quaternion): void;
  33498. /**
  33499. * Gets the box size of the physics imposter and stores the result in the input parameter
  33500. * @param result Stores the box size
  33501. * @returns The physics imposter
  33502. */
  33503. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33504. /**
  33505. * Gets the radius of the physics imposter
  33506. * @returns Radius of the physics imposter
  33507. */
  33508. getRadius(): number;
  33509. /**
  33510. * Sync a bone with this impostor
  33511. * @param bone The bone to sync to the impostor.
  33512. * @param boneMesh The mesh that the bone is influencing.
  33513. * @param jointPivot The pivot of the joint / bone in local space.
  33514. * @param distToJoint Optional distance from the impostor to the joint.
  33515. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33516. */
  33517. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33518. /**
  33519. * Sync impostor to a bone
  33520. * @param bone The bone that the impostor will be synced to.
  33521. * @param boneMesh The mesh that the bone is influencing.
  33522. * @param jointPivot The pivot of the joint / bone in local space.
  33523. * @param distToJoint Optional distance from the impostor to the joint.
  33524. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33525. * @param boneAxis Optional vector3 axis the bone is aligned with
  33526. */
  33527. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33528. /**
  33529. * No-Imposter type
  33530. */
  33531. static NoImpostor: number;
  33532. /**
  33533. * Sphere-Imposter type
  33534. */
  33535. static SphereImpostor: number;
  33536. /**
  33537. * Box-Imposter type
  33538. */
  33539. static BoxImpostor: number;
  33540. /**
  33541. * Plane-Imposter type
  33542. */
  33543. static PlaneImpostor: number;
  33544. /**
  33545. * Mesh-imposter type
  33546. */
  33547. static MeshImpostor: number;
  33548. /**
  33549. * Capsule-Impostor type (Ammo.js plugin only)
  33550. */
  33551. static CapsuleImpostor: number;
  33552. /**
  33553. * Cylinder-Imposter type
  33554. */
  33555. static CylinderImpostor: number;
  33556. /**
  33557. * Particle-Imposter type
  33558. */
  33559. static ParticleImpostor: number;
  33560. /**
  33561. * Heightmap-Imposter type
  33562. */
  33563. static HeightmapImpostor: number;
  33564. /**
  33565. * ConvexHull-Impostor type (Ammo.js plugin only)
  33566. */
  33567. static ConvexHullImpostor: number;
  33568. /**
  33569. * Custom-Imposter type (Ammo.js plugin only)
  33570. */
  33571. static CustomImpostor: number;
  33572. /**
  33573. * Rope-Imposter type
  33574. */
  33575. static RopeImpostor: number;
  33576. /**
  33577. * Cloth-Imposter type
  33578. */
  33579. static ClothImpostor: number;
  33580. /**
  33581. * Softbody-Imposter type
  33582. */
  33583. static SoftbodyImpostor: number;
  33584. }
  33585. }
  33586. declare module BABYLON {
  33587. /**
  33588. * @hidden
  33589. **/
  33590. export class _CreationDataStorage {
  33591. closePath?: boolean;
  33592. closeArray?: boolean;
  33593. idx: number[];
  33594. dashSize: number;
  33595. gapSize: number;
  33596. path3D: Path3D;
  33597. pathArray: Vector3[][];
  33598. arc: number;
  33599. radius: number;
  33600. cap: number;
  33601. tessellation: number;
  33602. }
  33603. /**
  33604. * @hidden
  33605. **/
  33606. class _InstanceDataStorage {
  33607. visibleInstances: any;
  33608. batchCache: _InstancesBatch;
  33609. instancesBufferSize: number;
  33610. instancesBuffer: Nullable<Buffer>;
  33611. instancesData: Float32Array;
  33612. overridenInstanceCount: number;
  33613. isFrozen: boolean;
  33614. previousBatch: Nullable<_InstancesBatch>;
  33615. hardwareInstancedRendering: boolean;
  33616. sideOrientation: number;
  33617. manualUpdate: boolean;
  33618. previousRenderId: number;
  33619. }
  33620. /**
  33621. * @hidden
  33622. **/
  33623. export class _InstancesBatch {
  33624. mustReturn: boolean;
  33625. visibleInstances: Nullable<InstancedMesh[]>[];
  33626. renderSelf: boolean[];
  33627. hardwareInstancedRendering: boolean[];
  33628. }
  33629. /**
  33630. * @hidden
  33631. **/
  33632. class _ThinInstanceDataStorage {
  33633. instancesCount: number;
  33634. matrixBuffer: Nullable<Buffer>;
  33635. matrixBufferSize: number;
  33636. matrixData: Nullable<Float32Array>;
  33637. boundingVectors: Array<Vector3>;
  33638. worldMatrices: Nullable<Matrix[]>;
  33639. }
  33640. /**
  33641. * Class used to represent renderable models
  33642. */
  33643. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  33644. /**
  33645. * Mesh side orientation : usually the external or front surface
  33646. */
  33647. static readonly FRONTSIDE: number;
  33648. /**
  33649. * Mesh side orientation : usually the internal or back surface
  33650. */
  33651. static readonly BACKSIDE: number;
  33652. /**
  33653. * Mesh side orientation : both internal and external or front and back surfaces
  33654. */
  33655. static readonly DOUBLESIDE: number;
  33656. /**
  33657. * Mesh side orientation : by default, `FRONTSIDE`
  33658. */
  33659. static readonly DEFAULTSIDE: number;
  33660. /**
  33661. * Mesh cap setting : no cap
  33662. */
  33663. static readonly NO_CAP: number;
  33664. /**
  33665. * Mesh cap setting : one cap at the beginning of the mesh
  33666. */
  33667. static readonly CAP_START: number;
  33668. /**
  33669. * Mesh cap setting : one cap at the end of the mesh
  33670. */
  33671. static readonly CAP_END: number;
  33672. /**
  33673. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  33674. */
  33675. static readonly CAP_ALL: number;
  33676. /**
  33677. * Mesh pattern setting : no flip or rotate
  33678. */
  33679. static readonly NO_FLIP: number;
  33680. /**
  33681. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  33682. */
  33683. static readonly FLIP_TILE: number;
  33684. /**
  33685. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  33686. */
  33687. static readonly ROTATE_TILE: number;
  33688. /**
  33689. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  33690. */
  33691. static readonly FLIP_ROW: number;
  33692. /**
  33693. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  33694. */
  33695. static readonly ROTATE_ROW: number;
  33696. /**
  33697. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  33698. */
  33699. static readonly FLIP_N_ROTATE_TILE: number;
  33700. /**
  33701. * Mesh pattern setting : rotate pattern and rotate
  33702. */
  33703. static readonly FLIP_N_ROTATE_ROW: number;
  33704. /**
  33705. * Mesh tile positioning : part tiles same on left/right or top/bottom
  33706. */
  33707. static readonly CENTER: number;
  33708. /**
  33709. * Mesh tile positioning : part tiles on left
  33710. */
  33711. static readonly LEFT: number;
  33712. /**
  33713. * Mesh tile positioning : part tiles on right
  33714. */
  33715. static readonly RIGHT: number;
  33716. /**
  33717. * Mesh tile positioning : part tiles on top
  33718. */
  33719. static readonly TOP: number;
  33720. /**
  33721. * Mesh tile positioning : part tiles on bottom
  33722. */
  33723. static readonly BOTTOM: number;
  33724. /**
  33725. * Gets the default side orientation.
  33726. * @param orientation the orientation to value to attempt to get
  33727. * @returns the default orientation
  33728. * @hidden
  33729. */
  33730. static _GetDefaultSideOrientation(orientation?: number): number;
  33731. private _internalMeshDataInfo;
  33732. get computeBonesUsingShaders(): boolean;
  33733. set computeBonesUsingShaders(value: boolean);
  33734. /**
  33735. * An event triggered before rendering the mesh
  33736. */
  33737. get onBeforeRenderObservable(): Observable<Mesh>;
  33738. /**
  33739. * An event triggered before binding the mesh
  33740. */
  33741. get onBeforeBindObservable(): Observable<Mesh>;
  33742. /**
  33743. * An event triggered after rendering the mesh
  33744. */
  33745. get onAfterRenderObservable(): Observable<Mesh>;
  33746. /**
  33747. * An event triggeredbetween rendering pass wneh using separateCullingPass = true
  33748. */
  33749. get onBetweenPassObservable(): Observable<Mesh>;
  33750. /**
  33751. * An event triggered before drawing the mesh
  33752. */
  33753. get onBeforeDrawObservable(): Observable<Mesh>;
  33754. private _onBeforeDrawObserver;
  33755. /**
  33756. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  33757. */
  33758. set onBeforeDraw(callback: () => void);
  33759. get hasInstances(): boolean;
  33760. get hasThinInstances(): boolean;
  33761. /**
  33762. * Gets the delay loading state of the mesh (when delay loading is turned on)
  33763. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  33764. */
  33765. delayLoadState: number;
  33766. /**
  33767. * Gets the list of instances created from this mesh
  33768. * it is not supposed to be modified manually.
  33769. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  33770. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33771. */
  33772. instances: InstancedMesh[];
  33773. /**
  33774. * Gets the file containing delay loading data for this mesh
  33775. */
  33776. delayLoadingFile: string;
  33777. /** @hidden */
  33778. _binaryInfo: any;
  33779. /**
  33780. * User defined function used to change how LOD level selection is done
  33781. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33782. */
  33783. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  33784. /**
  33785. * Gets or sets the morph target manager
  33786. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  33787. */
  33788. get morphTargetManager(): Nullable<MorphTargetManager>;
  33789. set morphTargetManager(value: Nullable<MorphTargetManager>);
  33790. /** @hidden */
  33791. _creationDataStorage: Nullable<_CreationDataStorage>;
  33792. /** @hidden */
  33793. _geometry: Nullable<Geometry>;
  33794. /** @hidden */
  33795. _delayInfo: Array<string>;
  33796. /** @hidden */
  33797. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  33798. /** @hidden */
  33799. _instanceDataStorage: _InstanceDataStorage;
  33800. /** @hidden */
  33801. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  33802. private _effectiveMaterial;
  33803. /** @hidden */
  33804. _shouldGenerateFlatShading: boolean;
  33805. /** @hidden */
  33806. _originalBuilderSideOrientation: number;
  33807. /**
  33808. * Use this property to change the original side orientation defined at construction time
  33809. */
  33810. overrideMaterialSideOrientation: Nullable<number>;
  33811. /**
  33812. * Gets or sets a boolean indicating whether to render ignoring the active camera's max z setting. (false by default)
  33813. * Note this will reduce performance when set to true.
  33814. */
  33815. ignoreCameraMaxZ: boolean;
  33816. /**
  33817. * Gets the source mesh (the one used to clone this one from)
  33818. */
  33819. get source(): Nullable<Mesh>;
  33820. /**
  33821. * Gets the list of clones of this mesh
  33822. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  33823. * Note that useClonedMeshMap=true is the default setting
  33824. */
  33825. get cloneMeshMap(): Nullable<{
  33826. [id: string]: Mesh | undefined;
  33827. }>;
  33828. /**
  33829. * Gets or sets a boolean indicating that this mesh does not use index buffer
  33830. */
  33831. get isUnIndexed(): boolean;
  33832. set isUnIndexed(value: boolean);
  33833. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  33834. get worldMatrixInstancedBuffer(): Float32Array;
  33835. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  33836. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  33837. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  33838. /**
  33839. * @constructor
  33840. * @param name The value used by scene.getMeshByName() to do a lookup.
  33841. * @param scene The scene to add this mesh to.
  33842. * @param parent The parent of this mesh, if it has one
  33843. * @param source An optional Mesh from which geometry is shared, cloned.
  33844. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  33845. * When false, achieved by calling a clone(), also passing False.
  33846. * This will make creation of children, recursive.
  33847. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  33848. */
  33849. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  33850. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  33851. doNotInstantiate: boolean;
  33852. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  33853. /**
  33854. * Gets the class name
  33855. * @returns the string "Mesh".
  33856. */
  33857. getClassName(): string;
  33858. /** @hidden */
  33859. get _isMesh(): boolean;
  33860. /**
  33861. * Returns a description of this mesh
  33862. * @param fullDetails define if full details about this mesh must be used
  33863. * @returns a descriptive string representing this mesh
  33864. */
  33865. toString(fullDetails?: boolean): string;
  33866. /** @hidden */
  33867. _unBindEffect(): void;
  33868. /**
  33869. * Gets a boolean indicating if this mesh has LOD
  33870. */
  33871. get hasLODLevels(): boolean;
  33872. /**
  33873. * Gets the list of MeshLODLevel associated with the current mesh
  33874. * @returns an array of MeshLODLevel
  33875. */
  33876. getLODLevels(): MeshLODLevel[];
  33877. private _sortLODLevels;
  33878. /**
  33879. * Add a mesh as LOD level triggered at the given distance.
  33880. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33881. * @param distance The distance from the center of the object to show this level
  33882. * @param mesh The mesh to be added as LOD level (can be null)
  33883. * @return This mesh (for chaining)
  33884. */
  33885. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  33886. /**
  33887. * Returns the LOD level mesh at the passed distance or null if not found.
  33888. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33889. * @param distance The distance from the center of the object to show this level
  33890. * @returns a Mesh or `null`
  33891. */
  33892. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  33893. /**
  33894. * Remove a mesh from the LOD array
  33895. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33896. * @param mesh defines the mesh to be removed
  33897. * @return This mesh (for chaining)
  33898. */
  33899. removeLODLevel(mesh: Mesh): Mesh;
  33900. /**
  33901. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  33902. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33903. * @param camera defines the camera to use to compute distance
  33904. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  33905. * @return This mesh (for chaining)
  33906. */
  33907. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  33908. /**
  33909. * Gets the mesh internal Geometry object
  33910. */
  33911. get geometry(): Nullable<Geometry>;
  33912. /**
  33913. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  33914. * @returns the total number of vertices
  33915. */
  33916. getTotalVertices(): number;
  33917. /**
  33918. * Returns the content of an associated vertex buffer
  33919. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33920. * - VertexBuffer.PositionKind
  33921. * - VertexBuffer.UVKind
  33922. * - VertexBuffer.UV2Kind
  33923. * - VertexBuffer.UV3Kind
  33924. * - VertexBuffer.UV4Kind
  33925. * - VertexBuffer.UV5Kind
  33926. * - VertexBuffer.UV6Kind
  33927. * - VertexBuffer.ColorKind
  33928. * - VertexBuffer.MatricesIndicesKind
  33929. * - VertexBuffer.MatricesIndicesExtraKind
  33930. * - VertexBuffer.MatricesWeightsKind
  33931. * - VertexBuffer.MatricesWeightsExtraKind
  33932. * @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
  33933. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  33934. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  33935. */
  33936. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33937. /**
  33938. * Returns the mesh VertexBuffer object from the requested `kind`
  33939. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33940. * - VertexBuffer.PositionKind
  33941. * - VertexBuffer.NormalKind
  33942. * - VertexBuffer.UVKind
  33943. * - VertexBuffer.UV2Kind
  33944. * - VertexBuffer.UV3Kind
  33945. * - VertexBuffer.UV4Kind
  33946. * - VertexBuffer.UV5Kind
  33947. * - VertexBuffer.UV6Kind
  33948. * - VertexBuffer.ColorKind
  33949. * - VertexBuffer.MatricesIndicesKind
  33950. * - VertexBuffer.MatricesIndicesExtraKind
  33951. * - VertexBuffer.MatricesWeightsKind
  33952. * - VertexBuffer.MatricesWeightsExtraKind
  33953. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  33954. */
  33955. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  33956. /**
  33957. * Tests if a specific vertex buffer is associated with this mesh
  33958. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33959. * - VertexBuffer.PositionKind
  33960. * - VertexBuffer.NormalKind
  33961. * - VertexBuffer.UVKind
  33962. * - VertexBuffer.UV2Kind
  33963. * - VertexBuffer.UV3Kind
  33964. * - VertexBuffer.UV4Kind
  33965. * - VertexBuffer.UV5Kind
  33966. * - VertexBuffer.UV6Kind
  33967. * - VertexBuffer.ColorKind
  33968. * - VertexBuffer.MatricesIndicesKind
  33969. * - VertexBuffer.MatricesIndicesExtraKind
  33970. * - VertexBuffer.MatricesWeightsKind
  33971. * - VertexBuffer.MatricesWeightsExtraKind
  33972. * @returns a boolean
  33973. */
  33974. isVerticesDataPresent(kind: string): boolean;
  33975. /**
  33976. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  33977. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33978. * - VertexBuffer.PositionKind
  33979. * - VertexBuffer.UVKind
  33980. * - VertexBuffer.UV2Kind
  33981. * - VertexBuffer.UV3Kind
  33982. * - VertexBuffer.UV4Kind
  33983. * - VertexBuffer.UV5Kind
  33984. * - VertexBuffer.UV6Kind
  33985. * - VertexBuffer.ColorKind
  33986. * - VertexBuffer.MatricesIndicesKind
  33987. * - VertexBuffer.MatricesIndicesExtraKind
  33988. * - VertexBuffer.MatricesWeightsKind
  33989. * - VertexBuffer.MatricesWeightsExtraKind
  33990. * @returns a boolean
  33991. */
  33992. isVertexBufferUpdatable(kind: string): boolean;
  33993. /**
  33994. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  33995. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33996. * - VertexBuffer.PositionKind
  33997. * - VertexBuffer.NormalKind
  33998. * - VertexBuffer.UVKind
  33999. * - VertexBuffer.UV2Kind
  34000. * - VertexBuffer.UV3Kind
  34001. * - VertexBuffer.UV4Kind
  34002. * - VertexBuffer.UV5Kind
  34003. * - VertexBuffer.UV6Kind
  34004. * - VertexBuffer.ColorKind
  34005. * - VertexBuffer.MatricesIndicesKind
  34006. * - VertexBuffer.MatricesIndicesExtraKind
  34007. * - VertexBuffer.MatricesWeightsKind
  34008. * - VertexBuffer.MatricesWeightsExtraKind
  34009. * @returns an array of strings
  34010. */
  34011. getVerticesDataKinds(): string[];
  34012. /**
  34013. * Returns a positive integer : the total number of indices in this mesh geometry.
  34014. * @returns the numner of indices or zero if the mesh has no geometry.
  34015. */
  34016. getTotalIndices(): number;
  34017. /**
  34018. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34019. * @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.
  34020. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34021. * @returns the indices array or an empty array if the mesh has no geometry
  34022. */
  34023. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34024. get isBlocked(): boolean;
  34025. /**
  34026. * Determine if the current mesh is ready to be rendered
  34027. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34028. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  34029. * @returns true if all associated assets are ready (material, textures, shaders)
  34030. */
  34031. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  34032. /**
  34033. * 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.
  34034. */
  34035. get areNormalsFrozen(): boolean;
  34036. /**
  34037. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It prevents the mesh normals from being recomputed on next `positions` array update.
  34038. * @returns the current mesh
  34039. */
  34040. freezeNormals(): Mesh;
  34041. /**
  34042. * 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
  34043. * @returns the current mesh
  34044. */
  34045. unfreezeNormals(): Mesh;
  34046. /**
  34047. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  34048. */
  34049. set overridenInstanceCount(count: number);
  34050. /** @hidden */
  34051. _preActivate(): Mesh;
  34052. /** @hidden */
  34053. _preActivateForIntermediateRendering(renderId: number): Mesh;
  34054. /** @hidden */
  34055. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  34056. protected _afterComputeWorldMatrix(): void;
  34057. /** @hidden */
  34058. _postActivate(): void;
  34059. /**
  34060. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  34061. * This means the mesh underlying bounding box and sphere are recomputed.
  34062. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  34063. * @returns the current mesh
  34064. */
  34065. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  34066. /** @hidden */
  34067. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  34068. /**
  34069. * This function will subdivide the mesh into multiple submeshes
  34070. * @param count defines the expected number of submeshes
  34071. */
  34072. subdivide(count: number): void;
  34073. /**
  34074. * Copy a FloatArray into a specific associated vertex buffer
  34075. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34076. * - VertexBuffer.PositionKind
  34077. * - VertexBuffer.UVKind
  34078. * - VertexBuffer.UV2Kind
  34079. * - VertexBuffer.UV3Kind
  34080. * - VertexBuffer.UV4Kind
  34081. * - VertexBuffer.UV5Kind
  34082. * - VertexBuffer.UV6Kind
  34083. * - VertexBuffer.ColorKind
  34084. * - VertexBuffer.MatricesIndicesKind
  34085. * - VertexBuffer.MatricesIndicesExtraKind
  34086. * - VertexBuffer.MatricesWeightsKind
  34087. * - VertexBuffer.MatricesWeightsExtraKind
  34088. * @param data defines the data source
  34089. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34090. * @param stride defines the data stride size (can be null)
  34091. * @returns the current mesh
  34092. */
  34093. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  34094. /**
  34095. * Delete a vertex buffer associated with this mesh
  34096. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  34097. * - VertexBuffer.PositionKind
  34098. * - VertexBuffer.UVKind
  34099. * - VertexBuffer.UV2Kind
  34100. * - VertexBuffer.UV3Kind
  34101. * - VertexBuffer.UV4Kind
  34102. * - VertexBuffer.UV5Kind
  34103. * - VertexBuffer.UV6Kind
  34104. * - VertexBuffer.ColorKind
  34105. * - VertexBuffer.MatricesIndicesKind
  34106. * - VertexBuffer.MatricesIndicesExtraKind
  34107. * - VertexBuffer.MatricesWeightsKind
  34108. * - VertexBuffer.MatricesWeightsExtraKind
  34109. */
  34110. removeVerticesData(kind: string): void;
  34111. /**
  34112. * Flags an associated vertex buffer as updatable
  34113. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  34114. * - VertexBuffer.PositionKind
  34115. * - VertexBuffer.UVKind
  34116. * - VertexBuffer.UV2Kind
  34117. * - VertexBuffer.UV3Kind
  34118. * - VertexBuffer.UV4Kind
  34119. * - VertexBuffer.UV5Kind
  34120. * - VertexBuffer.UV6Kind
  34121. * - VertexBuffer.ColorKind
  34122. * - VertexBuffer.MatricesIndicesKind
  34123. * - VertexBuffer.MatricesIndicesExtraKind
  34124. * - VertexBuffer.MatricesWeightsKind
  34125. * - VertexBuffer.MatricesWeightsExtraKind
  34126. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34127. */
  34128. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  34129. /**
  34130. * Sets the mesh global Vertex Buffer
  34131. * @param buffer defines the buffer to use
  34132. * @returns the current mesh
  34133. */
  34134. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  34135. /**
  34136. * Update a specific associated vertex buffer
  34137. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34138. * - VertexBuffer.PositionKind
  34139. * - VertexBuffer.UVKind
  34140. * - VertexBuffer.UV2Kind
  34141. * - VertexBuffer.UV3Kind
  34142. * - VertexBuffer.UV4Kind
  34143. * - VertexBuffer.UV5Kind
  34144. * - VertexBuffer.UV6Kind
  34145. * - VertexBuffer.ColorKind
  34146. * - VertexBuffer.MatricesIndicesKind
  34147. * - VertexBuffer.MatricesIndicesExtraKind
  34148. * - VertexBuffer.MatricesWeightsKind
  34149. * - VertexBuffer.MatricesWeightsExtraKind
  34150. * @param data defines the data source
  34151. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34152. * @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)
  34153. * @returns the current mesh
  34154. */
  34155. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  34156. /**
  34157. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  34158. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  34159. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  34160. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  34161. * @returns the current mesh
  34162. */
  34163. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  34164. /**
  34165. * Creates a un-shared specific occurence of the geometry for the mesh.
  34166. * @returns the current mesh
  34167. */
  34168. makeGeometryUnique(): Mesh;
  34169. /**
  34170. * Set the index buffer of this mesh
  34171. * @param indices defines the source data
  34172. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  34173. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  34174. * @returns the current mesh
  34175. */
  34176. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  34177. /**
  34178. * Update the current index buffer
  34179. * @param indices defines the source data
  34180. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  34181. * @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)
  34182. * @returns the current mesh
  34183. */
  34184. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  34185. /**
  34186. * Invert the geometry to move from a right handed system to a left handed one.
  34187. * @returns the current mesh
  34188. */
  34189. toLeftHanded(): Mesh;
  34190. /** @hidden */
  34191. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  34192. /** @hidden */
  34193. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  34194. /**
  34195. * Registers for this mesh a javascript function called just before the rendering process
  34196. * @param func defines the function to call before rendering this mesh
  34197. * @returns the current mesh
  34198. */
  34199. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34200. /**
  34201. * Disposes a previously registered javascript function called before the rendering
  34202. * @param func defines the function to remove
  34203. * @returns the current mesh
  34204. */
  34205. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34206. /**
  34207. * Registers for this mesh a javascript function called just after the rendering is complete
  34208. * @param func defines the function to call after rendering this mesh
  34209. * @returns the current mesh
  34210. */
  34211. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34212. /**
  34213. * Disposes a previously registered javascript function called after the rendering.
  34214. * @param func defines the function to remove
  34215. * @returns the current mesh
  34216. */
  34217. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34218. /** @hidden */
  34219. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  34220. /** @hidden */
  34221. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  34222. /** @hidden */
  34223. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  34224. /** @hidden */
  34225. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  34226. /** @hidden */
  34227. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  34228. /** @hidden */
  34229. _rebuild(): void;
  34230. /** @hidden */
  34231. _freeze(): void;
  34232. /** @hidden */
  34233. _unFreeze(): void;
  34234. /**
  34235. * 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
  34236. * @param subMesh defines the subMesh to render
  34237. * @param enableAlphaMode defines if alpha mode can be changed
  34238. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  34239. * @returns the current mesh
  34240. */
  34241. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  34242. private _onBeforeDraw;
  34243. /**
  34244. * Renormalize the mesh and patch it up if there are no weights
  34245. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  34246. * However in the case of zero weights then we set just a single influence to 1.
  34247. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  34248. */
  34249. cleanMatrixWeights(): void;
  34250. private normalizeSkinFourWeights;
  34251. private normalizeSkinWeightsAndExtra;
  34252. /**
  34253. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  34254. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  34255. * the user know there was an issue with importing the mesh
  34256. * @returns a validation object with skinned, valid and report string
  34257. */
  34258. validateSkinning(): {
  34259. skinned: boolean;
  34260. valid: boolean;
  34261. report: string;
  34262. };
  34263. /** @hidden */
  34264. _checkDelayState(): Mesh;
  34265. private _queueLoad;
  34266. /**
  34267. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  34268. * A mesh is in the frustum if its bounding box intersects the frustum
  34269. * @param frustumPlanes defines the frustum to test
  34270. * @returns true if the mesh is in the frustum planes
  34271. */
  34272. isInFrustum(frustumPlanes: Plane[]): boolean;
  34273. /**
  34274. * Sets the mesh material by the material or multiMaterial `id` property
  34275. * @param id is a string identifying the material or the multiMaterial
  34276. * @returns the current mesh
  34277. */
  34278. setMaterialByID(id: string): Mesh;
  34279. /**
  34280. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  34281. * @returns an array of IAnimatable
  34282. */
  34283. getAnimatables(): IAnimatable[];
  34284. /**
  34285. * Modifies the mesh geometry according to the passed transformation matrix.
  34286. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  34287. * The mesh normals are modified using the same transformation.
  34288. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34289. * @param transform defines the transform matrix to use
  34290. * @see https://doc.babylonjs.com/resources/baking_transformations
  34291. * @returns the current mesh
  34292. */
  34293. bakeTransformIntoVertices(transform: Matrix): Mesh;
  34294. /**
  34295. * Modifies the mesh geometry according to its own current World Matrix.
  34296. * The mesh World Matrix is then reset.
  34297. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  34298. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34299. * @see https://doc.babylonjs.com/resources/baking_transformations
  34300. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  34301. * @returns the current mesh
  34302. */
  34303. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  34304. /** @hidden */
  34305. get _positions(): Nullable<Vector3[]>;
  34306. /** @hidden */
  34307. _resetPointsArrayCache(): Mesh;
  34308. /** @hidden */
  34309. _generatePointsArray(): boolean;
  34310. /**
  34311. * Returns a new Mesh object generated from the current mesh properties.
  34312. * This method must not get confused with createInstance()
  34313. * @param name is a string, the name given to the new mesh
  34314. * @param newParent can be any Node object (default `null`)
  34315. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  34316. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  34317. * @returns a new mesh
  34318. */
  34319. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  34320. /**
  34321. * Releases resources associated with this mesh.
  34322. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34323. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34324. */
  34325. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34326. /** @hidden */
  34327. _disposeInstanceSpecificData(): void;
  34328. /** @hidden */
  34329. _disposeThinInstanceSpecificData(): void;
  34330. /**
  34331. * Modifies the mesh geometry according to a displacement map.
  34332. * 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.
  34333. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34334. * @param url is a string, the URL from the image file is to be downloaded.
  34335. * @param minHeight is the lower limit of the displacement.
  34336. * @param maxHeight is the upper limit of the displacement.
  34337. * @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.
  34338. * @param uvOffset is an optional vector2 used to offset UV.
  34339. * @param uvScale is an optional vector2 used to scale UV.
  34340. * @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.
  34341. * @returns the Mesh.
  34342. */
  34343. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34344. /**
  34345. * Modifies the mesh geometry according to a displacementMap buffer.
  34346. * 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.
  34347. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34348. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  34349. * @param heightMapWidth is the width of the buffer image.
  34350. * @param heightMapHeight is the height of the buffer image.
  34351. * @param minHeight is the lower limit of the displacement.
  34352. * @param maxHeight is the upper limit of the displacement.
  34353. * @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.
  34354. * @param uvOffset is an optional vector2 used to offset UV.
  34355. * @param uvScale is an optional vector2 used to scale UV.
  34356. * @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.
  34357. * @returns the Mesh.
  34358. */
  34359. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34360. /**
  34361. * Modify the mesh to get a flat shading rendering.
  34362. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  34363. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  34364. * @returns current mesh
  34365. */
  34366. convertToFlatShadedMesh(): Mesh;
  34367. /**
  34368. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  34369. * In other words, more vertices, no more indices and a single bigger VBO.
  34370. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  34371. * @returns current mesh
  34372. */
  34373. convertToUnIndexedMesh(): Mesh;
  34374. /**
  34375. * Inverses facet orientations.
  34376. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34377. * @param flipNormals will also inverts the normals
  34378. * @returns current mesh
  34379. */
  34380. flipFaces(flipNormals?: boolean): Mesh;
  34381. /**
  34382. * Increase the number of facets and hence vertices in a mesh
  34383. * Vertex normals are interpolated from existing vertex normals
  34384. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34385. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  34386. */
  34387. increaseVertices(numberPerEdge: number): void;
  34388. /**
  34389. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  34390. * This will undo any application of covertToFlatShadedMesh
  34391. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34392. */
  34393. forceSharedVertices(): void;
  34394. /** @hidden */
  34395. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  34396. /** @hidden */
  34397. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  34398. /**
  34399. * Creates a new InstancedMesh object from the mesh model.
  34400. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  34401. * @param name defines the name of the new instance
  34402. * @returns a new InstancedMesh
  34403. */
  34404. createInstance(name: string): InstancedMesh;
  34405. /**
  34406. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  34407. * After this call, all the mesh instances have the same submeshes than the current mesh.
  34408. * @returns the current mesh
  34409. */
  34410. synchronizeInstances(): Mesh;
  34411. /**
  34412. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  34413. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  34414. * This should be used together with the simplification to avoid disappearing triangles.
  34415. * @param successCallback an optional success callback to be called after the optimization finished.
  34416. * @returns the current mesh
  34417. */
  34418. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  34419. /**
  34420. * Serialize current mesh
  34421. * @param serializationObject defines the object which will receive the serialization data
  34422. */
  34423. serialize(serializationObject: any): void;
  34424. /** @hidden */
  34425. _syncGeometryWithMorphTargetManager(): void;
  34426. /** @hidden */
  34427. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  34428. /**
  34429. * Returns a new Mesh object parsed from the source provided.
  34430. * @param parsedMesh is the source
  34431. * @param scene defines the hosting scene
  34432. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  34433. * @returns a new Mesh
  34434. */
  34435. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  34436. /**
  34437. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  34438. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34439. * @param name defines the name of the mesh to create
  34440. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  34441. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  34442. * @param closePath creates a seam between the first and the last points of each path of the path array
  34443. * @param offset is taken in account only if the `pathArray` is containing a single path
  34444. * @param scene defines the hosting scene
  34445. * @param updatable defines if the mesh must be flagged as updatable
  34446. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34447. * @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)
  34448. * @returns a new Mesh
  34449. */
  34450. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34451. /**
  34452. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  34453. * @param name defines the name of the mesh to create
  34454. * @param radius sets the radius size (float) of the polygon (default 0.5)
  34455. * @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
  34456. * @param scene defines the hosting scene
  34457. * @param updatable defines if the mesh must be flagged as updatable
  34458. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34459. * @returns a new Mesh
  34460. */
  34461. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34462. /**
  34463. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  34464. * @param name defines the name of the mesh to create
  34465. * @param size sets the size (float) of each box side (default 1)
  34466. * @param scene defines the hosting scene
  34467. * @param updatable defines if the mesh must be flagged as updatable
  34468. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34469. * @returns a new Mesh
  34470. */
  34471. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34472. /**
  34473. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  34474. * @param name defines the name of the mesh to create
  34475. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34476. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34477. * @param scene defines the hosting scene
  34478. * @param updatable defines if the mesh must be flagged as updatable
  34479. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34480. * @returns a new Mesh
  34481. */
  34482. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34483. /**
  34484. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  34485. * @param name defines the name of the mesh to create
  34486. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34487. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34488. * @param scene defines the hosting scene
  34489. * @returns a new Mesh
  34490. */
  34491. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  34492. /**
  34493. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  34494. * @param name defines the name of the mesh to create
  34495. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  34496. * @param diameterTop set the top cap diameter (floats, default 1)
  34497. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  34498. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  34499. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  34500. * @param scene defines the hosting scene
  34501. * @param updatable defines if the mesh must be flagged as updatable
  34502. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34503. * @returns a new Mesh
  34504. */
  34505. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  34506. /**
  34507. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  34508. * @param name defines the name of the mesh to create
  34509. * @param diameter sets the diameter size (float) of the torus (default 1)
  34510. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  34511. * @param tessellation sets the number of torus sides (positive integer, default 16)
  34512. * @param scene defines the hosting scene
  34513. * @param updatable defines if the mesh must be flagged as updatable
  34514. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34515. * @returns a new Mesh
  34516. */
  34517. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34518. /**
  34519. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  34520. * @param name defines the name of the mesh to create
  34521. * @param radius sets the global radius size (float) of the torus knot (default 2)
  34522. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  34523. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  34524. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  34525. * @param p the number of windings on X axis (positive integers, default 2)
  34526. * @param q the number of windings on Y axis (positive integers, default 3)
  34527. * @param scene defines the hosting scene
  34528. * @param updatable defines if the mesh must be flagged as updatable
  34529. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34530. * @returns a new Mesh
  34531. */
  34532. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34533. /**
  34534. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  34535. * @param name defines the name of the mesh to create
  34536. * @param points is an array successive Vector3
  34537. * @param scene defines the hosting scene
  34538. * @param updatable defines if the mesh must be flagged as updatable
  34539. * @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).
  34540. * @returns a new Mesh
  34541. */
  34542. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  34543. /**
  34544. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  34545. * @param name defines the name of the mesh to create
  34546. * @param points is an array successive Vector3
  34547. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  34548. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  34549. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  34550. * @param scene defines the hosting scene
  34551. * @param updatable defines if the mesh must be flagged as updatable
  34552. * @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)
  34553. * @returns a new Mesh
  34554. */
  34555. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  34556. /**
  34557. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  34558. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  34559. * 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.
  34560. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34561. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  34562. * Remember you can only change the shape positions, not their number when updating a polygon.
  34563. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  34564. * @param name defines the name of the mesh to create
  34565. * @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
  34566. * @param scene defines the hosting scene
  34567. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34568. * @param updatable defines if the mesh must be flagged as updatable
  34569. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34570. * @param earcutInjection can be used to inject your own earcut reference
  34571. * @returns a new Mesh
  34572. */
  34573. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34574. /**
  34575. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  34576. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  34577. * @param name defines the name of the mesh to create
  34578. * @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
  34579. * @param depth defines the height of extrusion
  34580. * @param scene defines the hosting scene
  34581. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34582. * @param updatable defines if the mesh must be flagged as updatable
  34583. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34584. * @param earcutInjection can be used to inject your own earcut reference
  34585. * @returns a new Mesh
  34586. */
  34587. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34588. /**
  34589. * Creates an extruded shape mesh.
  34590. * 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
  34591. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34592. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34593. * @param name defines the name of the mesh to create
  34594. * @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
  34595. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34596. * @param scale is the value to scale the shape
  34597. * @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
  34598. * @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
  34599. * @param scene defines the hosting scene
  34600. * @param updatable defines if the mesh must be flagged as updatable
  34601. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34602. * @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)
  34603. * @returns a new Mesh
  34604. */
  34605. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34606. /**
  34607. * Creates an custom extruded shape mesh.
  34608. * The custom extrusion is a parametric shape.
  34609. * It has no predefined shape. Its final shape will depend on the input parameters.
  34610. * Please consider using the same method from the MeshBuilder class instead
  34611. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34612. * @param name defines the name of the mesh to create
  34613. * @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
  34614. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34615. * @param scaleFunction is a custom Javascript function called on each path point
  34616. * @param rotationFunction is a custom Javascript function called on each path point
  34617. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  34618. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  34619. * @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
  34620. * @param scene defines the hosting scene
  34621. * @param updatable defines if the mesh must be flagged as updatable
  34622. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34623. * @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)
  34624. * @returns a new Mesh
  34625. */
  34626. 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;
  34627. /**
  34628. * Creates lathe mesh.
  34629. * The lathe is a shape with a symmetry axis : a 2D model shape is rotated around this axis to design the lathe.
  34630. * Please consider using the same method from the MeshBuilder class instead
  34631. * @param name defines the name of the mesh to create
  34632. * @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
  34633. * @param radius is the radius value of the lathe
  34634. * @param tessellation is the side number of the lathe.
  34635. * @param scene defines the hosting scene
  34636. * @param updatable defines if the mesh must be flagged as updatable
  34637. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34638. * @returns a new Mesh
  34639. */
  34640. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34641. /**
  34642. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  34643. * @param name defines the name of the mesh to create
  34644. * @param size sets the size (float) of both sides of the plane at once (default 1)
  34645. * @param scene defines the hosting scene
  34646. * @param updatable defines if the mesh must be flagged as updatable
  34647. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34648. * @returns a new Mesh
  34649. */
  34650. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34651. /**
  34652. * Creates a ground mesh.
  34653. * Please consider using the same method from the MeshBuilder class instead
  34654. * @param name defines the name of the mesh to create
  34655. * @param width set the width of the ground
  34656. * @param height set the height of the ground
  34657. * @param subdivisions sets the number of subdivisions per side
  34658. * @param scene defines the hosting scene
  34659. * @param updatable defines if the mesh must be flagged as updatable
  34660. * @returns a new Mesh
  34661. */
  34662. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  34663. /**
  34664. * Creates a tiled ground mesh.
  34665. * Please consider using the same method from the MeshBuilder class instead
  34666. * @param name defines the name of the mesh to create
  34667. * @param xmin set the ground minimum X coordinate
  34668. * @param zmin set the ground minimum Y coordinate
  34669. * @param xmax set the ground maximum X coordinate
  34670. * @param zmax set the ground maximum Z coordinate
  34671. * @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
  34672. * @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
  34673. * @param scene defines the hosting scene
  34674. * @param updatable defines if the mesh must be flagged as updatable
  34675. * @returns a new Mesh
  34676. */
  34677. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  34678. w: number;
  34679. h: number;
  34680. }, precision: {
  34681. w: number;
  34682. h: number;
  34683. }, scene: Scene, updatable?: boolean): Mesh;
  34684. /**
  34685. * Creates a ground mesh from a height map.
  34686. * Please consider using the same method from the MeshBuilder class instead
  34687. * @see https://doc.babylonjs.com/babylon101/height_map
  34688. * @param name defines the name of the mesh to create
  34689. * @param url sets the URL of the height map image resource
  34690. * @param width set the ground width size
  34691. * @param height set the ground height size
  34692. * @param subdivisions sets the number of subdivision per side
  34693. * @param minHeight is the minimum altitude on the ground
  34694. * @param maxHeight is the maximum altitude on the ground
  34695. * @param scene defines the hosting scene
  34696. * @param updatable defines if the mesh must be flagged as updatable
  34697. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  34698. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  34699. * @returns a new Mesh
  34700. */
  34701. 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;
  34702. /**
  34703. * Creates a tube mesh.
  34704. * The tube is a parametric shape.
  34705. * It has no predefined shape. Its final shape will depend on the input parameters.
  34706. * Please consider using the same method from the MeshBuilder class instead
  34707. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34708. * @param name defines the name of the mesh to create
  34709. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  34710. * @param radius sets the tube radius size
  34711. * @param tessellation is the number of sides on the tubular surface
  34712. * @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
  34713. * @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
  34714. * @param scene defines the hosting scene
  34715. * @param updatable defines if the mesh must be flagged as updatable
  34716. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34717. * @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)
  34718. * @returns a new Mesh
  34719. */
  34720. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  34721. (i: number, distance: number): number;
  34722. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34723. /**
  34724. * Creates a polyhedron mesh.
  34725. * Please consider using the same method from the MeshBuilder class instead.
  34726. * * 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
  34727. * * The parameter `size` (positive float, default 1) sets the polygon size
  34728. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  34729. * * 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`
  34730. * * 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
  34731. * * 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)`)
  34732. * * 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
  34733. * * 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
  34734. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34735. * * 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
  34736. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34737. * @param name defines the name of the mesh to create
  34738. * @param options defines the options used to create the mesh
  34739. * @param scene defines the hosting scene
  34740. * @returns a new Mesh
  34741. */
  34742. static CreatePolyhedron(name: string, options: {
  34743. type?: number;
  34744. size?: number;
  34745. sizeX?: number;
  34746. sizeY?: number;
  34747. sizeZ?: number;
  34748. custom?: any;
  34749. faceUV?: Vector4[];
  34750. faceColors?: Color4[];
  34751. updatable?: boolean;
  34752. sideOrientation?: number;
  34753. }, scene: Scene): Mesh;
  34754. /**
  34755. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  34756. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  34757. * * 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`)
  34758. * * The parameter `subdivisions` sets the number of subdivisions (positive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  34759. * * 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
  34760. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34761. * * 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
  34762. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34763. * @param name defines the name of the mesh
  34764. * @param options defines the options used to create the mesh
  34765. * @param scene defines the hosting scene
  34766. * @returns a new Mesh
  34767. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  34768. */
  34769. static CreateIcoSphere(name: string, options: {
  34770. radius?: number;
  34771. flat?: boolean;
  34772. subdivisions?: number;
  34773. sideOrientation?: number;
  34774. updatable?: boolean;
  34775. }, scene: Scene): Mesh;
  34776. /**
  34777. * Creates a decal mesh.
  34778. * Please consider using the same method from the MeshBuilder class instead.
  34779. * A decal is a mesh usually applied as a model onto the surface of another mesh
  34780. * @param name defines the name of the mesh
  34781. * @param sourceMesh defines the mesh receiving the decal
  34782. * @param position sets the position of the decal in world coordinates
  34783. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  34784. * @param size sets the decal scaling
  34785. * @param angle sets the angle to rotate the decal
  34786. * @returns a new Mesh
  34787. */
  34788. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  34789. /** Creates a Capsule Mesh
  34790. * @param name defines the name of the mesh.
  34791. * @param options the constructors options used to shape the mesh.
  34792. * @param scene defines the scene the mesh is scoped to.
  34793. * @returns the capsule mesh
  34794. * @see https://doc.babylonjs.com/how_to/capsule_shape
  34795. */
  34796. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  34797. /**
  34798. * Prepare internal position array for software CPU skinning
  34799. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  34800. */
  34801. setPositionsForCPUSkinning(): Float32Array;
  34802. /**
  34803. * Prepare internal normal array for software CPU skinning
  34804. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  34805. */
  34806. setNormalsForCPUSkinning(): Float32Array;
  34807. /**
  34808. * Updates the vertex buffer by applying transformation from the bones
  34809. * @param skeleton defines the skeleton to apply to current mesh
  34810. * @returns the current mesh
  34811. */
  34812. applySkeleton(skeleton: Skeleton): Mesh;
  34813. /**
  34814. * 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
  34815. * @param meshes defines the list of meshes to scan
  34816. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  34817. */
  34818. static MinMax(meshes: AbstractMesh[]): {
  34819. min: Vector3;
  34820. max: Vector3;
  34821. };
  34822. /**
  34823. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  34824. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  34825. * @returns a vector3
  34826. */
  34827. static Center(meshesOrMinMaxVector: {
  34828. min: Vector3;
  34829. max: Vector3;
  34830. } | AbstractMesh[]): Vector3;
  34831. /**
  34832. * Merge the array of meshes into a single mesh for performance reasons.
  34833. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  34834. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  34835. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  34836. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  34837. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  34838. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  34839. * @returns a new mesh
  34840. */
  34841. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  34842. /** @hidden */
  34843. addInstance(instance: InstancedMesh): void;
  34844. /** @hidden */
  34845. removeInstance(instance: InstancedMesh): void;
  34846. }
  34847. }
  34848. declare module BABYLON {
  34849. /**
  34850. * The options Interface for creating a Capsule Mesh
  34851. */
  34852. export interface ICreateCapsuleOptions {
  34853. /** The Orientation of the capsule. Default : Vector3.Up() */
  34854. orientation?: Vector3;
  34855. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  34856. subdivisions: number;
  34857. /** Number of cylindrical segments on the capsule. */
  34858. tessellation: number;
  34859. /** Height or Length of the capsule. */
  34860. height: number;
  34861. /** Radius of the capsule. */
  34862. radius: number;
  34863. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  34864. capSubdivisions: number;
  34865. /** Overwrite for the top radius. */
  34866. radiusTop?: number;
  34867. /** Overwrite for the bottom radius. */
  34868. radiusBottom?: number;
  34869. /** Overwrite for the top capSubdivisions. */
  34870. topCapSubdivisions?: number;
  34871. /** Overwrite for the bottom capSubdivisions. */
  34872. bottomCapSubdivisions?: number;
  34873. /** Internal geometry is supposed to change once created. */
  34874. updatable?: boolean;
  34875. }
  34876. /**
  34877. * Class containing static functions to help procedurally build meshes
  34878. */
  34879. export class CapsuleBuilder {
  34880. /**
  34881. * Creates a capsule or a pill mesh
  34882. * @param name defines the name of the mesh
  34883. * @param options The constructors options.
  34884. * @param scene The scene the mesh is scoped to.
  34885. * @returns Capsule Mesh
  34886. */
  34887. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  34888. }
  34889. }
  34890. declare module BABYLON {
  34891. /**
  34892. * Define an interface for all classes that will get and set the data on vertices
  34893. */
  34894. export interface IGetSetVerticesData {
  34895. /**
  34896. * Gets a boolean indicating if specific vertex data is present
  34897. * @param kind defines the vertex data kind to use
  34898. * @returns true is data kind is present
  34899. */
  34900. isVerticesDataPresent(kind: string): boolean;
  34901. /**
  34902. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  34903. * @param kind defines the data kind (Position, normal, etc...)
  34904. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  34905. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34906. * @returns a float array containing vertex data
  34907. */
  34908. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  34909. /**
  34910. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34911. * @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.
  34912. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34913. * @returns the indices array or an empty array if the mesh has no geometry
  34914. */
  34915. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34916. /**
  34917. * Set specific vertex data
  34918. * @param kind defines the data kind (Position, normal, etc...)
  34919. * @param data defines the vertex data to use
  34920. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  34921. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  34922. */
  34923. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  34924. /**
  34925. * Update a specific associated vertex buffer
  34926. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34927. * - VertexBuffer.PositionKind
  34928. * - VertexBuffer.UVKind
  34929. * - VertexBuffer.UV2Kind
  34930. * - VertexBuffer.UV3Kind
  34931. * - VertexBuffer.UV4Kind
  34932. * - VertexBuffer.UV5Kind
  34933. * - VertexBuffer.UV6Kind
  34934. * - VertexBuffer.ColorKind
  34935. * - VertexBuffer.MatricesIndicesKind
  34936. * - VertexBuffer.MatricesIndicesExtraKind
  34937. * - VertexBuffer.MatricesWeightsKind
  34938. * - VertexBuffer.MatricesWeightsExtraKind
  34939. * @param data defines the data source
  34940. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34941. * @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)
  34942. */
  34943. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  34944. /**
  34945. * Creates a new index buffer
  34946. * @param indices defines the indices to store in the index buffer
  34947. * @param totalVertices defines the total number of vertices (could be null)
  34948. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  34949. */
  34950. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  34951. }
  34952. /**
  34953. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  34954. */
  34955. export class VertexData {
  34956. /**
  34957. * Mesh side orientation : usually the external or front surface
  34958. */
  34959. static readonly FRONTSIDE: number;
  34960. /**
  34961. * Mesh side orientation : usually the internal or back surface
  34962. */
  34963. static readonly BACKSIDE: number;
  34964. /**
  34965. * Mesh side orientation : both internal and external or front and back surfaces
  34966. */
  34967. static readonly DOUBLESIDE: number;
  34968. /**
  34969. * Mesh side orientation : by default, `FRONTSIDE`
  34970. */
  34971. static readonly DEFAULTSIDE: number;
  34972. /**
  34973. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  34974. */
  34975. positions: Nullable<FloatArray>;
  34976. /**
  34977. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  34978. */
  34979. normals: Nullable<FloatArray>;
  34980. /**
  34981. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  34982. */
  34983. tangents: Nullable<FloatArray>;
  34984. /**
  34985. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34986. */
  34987. uvs: Nullable<FloatArray>;
  34988. /**
  34989. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34990. */
  34991. uvs2: Nullable<FloatArray>;
  34992. /**
  34993. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34994. */
  34995. uvs3: Nullable<FloatArray>;
  34996. /**
  34997. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34998. */
  34999. uvs4: Nullable<FloatArray>;
  35000. /**
  35001. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  35002. */
  35003. uvs5: Nullable<FloatArray>;
  35004. /**
  35005. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  35006. */
  35007. uvs6: Nullable<FloatArray>;
  35008. /**
  35009. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  35010. */
  35011. colors: Nullable<FloatArray>;
  35012. /**
  35013. * 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).
  35014. */
  35015. matricesIndices: Nullable<FloatArray>;
  35016. /**
  35017. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  35018. */
  35019. matricesWeights: Nullable<FloatArray>;
  35020. /**
  35021. * An array extending the number of possible indices
  35022. */
  35023. matricesIndicesExtra: Nullable<FloatArray>;
  35024. /**
  35025. * An array extending the number of possible weights when the number of indices is extended
  35026. */
  35027. matricesWeightsExtra: Nullable<FloatArray>;
  35028. /**
  35029. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  35030. */
  35031. indices: Nullable<IndicesArray>;
  35032. /**
  35033. * Uses the passed data array to set the set the values for the specified kind of data
  35034. * @param data a linear array of floating numbers
  35035. * @param kind the type of data that is being set, eg positions, colors etc
  35036. */
  35037. set(data: FloatArray, kind: string): void;
  35038. /**
  35039. * Associates the vertexData to the passed Mesh.
  35040. * Sets it as updatable or not (default `false`)
  35041. * @param mesh the mesh the vertexData is applied to
  35042. * @param updatable when used and having the value true allows new data to update the vertexData
  35043. * @returns the VertexData
  35044. */
  35045. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  35046. /**
  35047. * Associates the vertexData to the passed Geometry.
  35048. * Sets it as updatable or not (default `false`)
  35049. * @param geometry the geometry the vertexData is applied to
  35050. * @param updatable when used and having the value true allows new data to update the vertexData
  35051. * @returns VertexData
  35052. */
  35053. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  35054. /**
  35055. * Updates the associated mesh
  35056. * @param mesh the mesh to be updated
  35057. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  35058. * @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
  35059. * @returns VertexData
  35060. */
  35061. updateMesh(mesh: Mesh): VertexData;
  35062. /**
  35063. * Updates the associated geometry
  35064. * @param geometry the geometry to be updated
  35065. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  35066. * @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
  35067. * @returns VertexData.
  35068. */
  35069. updateGeometry(geometry: Geometry): VertexData;
  35070. private _applyTo;
  35071. private _update;
  35072. /**
  35073. * Transforms each position and each normal of the vertexData according to the passed Matrix
  35074. * @param matrix the transforming matrix
  35075. * @returns the VertexData
  35076. */
  35077. transform(matrix: Matrix): VertexData;
  35078. /**
  35079. * Merges the passed VertexData into the current one
  35080. * @param other the VertexData to be merged into the current one
  35081. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  35082. * @returns the modified VertexData
  35083. */
  35084. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  35085. private _mergeElement;
  35086. private _validate;
  35087. /**
  35088. * Serializes the VertexData
  35089. * @returns a serialized object
  35090. */
  35091. serialize(): any;
  35092. /**
  35093. * Extracts the vertexData from a mesh
  35094. * @param mesh the mesh from which to extract the VertexData
  35095. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  35096. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  35097. * @returns the object VertexData associated to the passed mesh
  35098. */
  35099. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  35100. /**
  35101. * Extracts the vertexData from the geometry
  35102. * @param geometry the geometry from which to extract the VertexData
  35103. * @param copyWhenShared defines if the VertexData must be cloned when the geometry is shared between multiple meshes, optional, default false
  35104. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  35105. * @returns the object VertexData associated to the passed mesh
  35106. */
  35107. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  35108. private static _ExtractFrom;
  35109. /**
  35110. * Creates the VertexData for a Ribbon
  35111. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  35112. * * pathArray array of paths, each of which an array of successive Vector3
  35113. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  35114. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  35115. * * 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
  35116. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35117. * * 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)
  35118. * * 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)
  35119. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  35120. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  35121. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  35122. * @returns the VertexData of the ribbon
  35123. */
  35124. static CreateRibbon(options: {
  35125. pathArray: Vector3[][];
  35126. closeArray?: boolean;
  35127. closePath?: boolean;
  35128. offset?: number;
  35129. sideOrientation?: number;
  35130. frontUVs?: Vector4;
  35131. backUVs?: Vector4;
  35132. invertUV?: boolean;
  35133. uvs?: Vector2[];
  35134. colors?: Color4[];
  35135. }): VertexData;
  35136. /**
  35137. * Creates the VertexData for a box
  35138. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35139. * * size sets the width, height and depth of the box to the value of size, optional default 1
  35140. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  35141. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  35142. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  35143. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  35144. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  35145. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35146. * * 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)
  35147. * * 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)
  35148. * @returns the VertexData of the box
  35149. */
  35150. static CreateBox(options: {
  35151. size?: number;
  35152. width?: number;
  35153. height?: number;
  35154. depth?: number;
  35155. faceUV?: Vector4[];
  35156. faceColors?: Color4[];
  35157. sideOrientation?: number;
  35158. frontUVs?: Vector4;
  35159. backUVs?: Vector4;
  35160. }): VertexData;
  35161. /**
  35162. * Creates the VertexData for a tiled box
  35163. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35164. * * faceTiles sets the pattern, tile size and number of tiles for a face
  35165. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  35166. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  35167. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35168. * @returns the VertexData of the box
  35169. */
  35170. static CreateTiledBox(options: {
  35171. pattern?: number;
  35172. width?: number;
  35173. height?: number;
  35174. depth?: number;
  35175. tileSize?: number;
  35176. tileWidth?: number;
  35177. tileHeight?: number;
  35178. alignHorizontal?: number;
  35179. alignVertical?: number;
  35180. faceUV?: Vector4[];
  35181. faceColors?: Color4[];
  35182. sideOrientation?: number;
  35183. }): VertexData;
  35184. /**
  35185. * Creates the VertexData for a tiled plane
  35186. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35187. * * pattern a limited pattern arrangement depending on the number
  35188. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  35189. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  35190. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  35191. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35192. * * 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)
  35193. * * 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)
  35194. * @returns the VertexData of the tiled plane
  35195. */
  35196. static CreateTiledPlane(options: {
  35197. pattern?: number;
  35198. tileSize?: number;
  35199. tileWidth?: number;
  35200. tileHeight?: number;
  35201. size?: number;
  35202. width?: number;
  35203. height?: number;
  35204. alignHorizontal?: number;
  35205. alignVertical?: number;
  35206. sideOrientation?: number;
  35207. frontUVs?: Vector4;
  35208. backUVs?: Vector4;
  35209. }): VertexData;
  35210. /**
  35211. * Creates the VertexData for an ellipsoid, defaults to a sphere
  35212. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35213. * * segments sets the number of horizontal strips optional, default 32
  35214. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  35215. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  35216. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  35217. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  35218. * * 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
  35219. * * 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
  35220. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35221. * * 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)
  35222. * * 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)
  35223. * @returns the VertexData of the ellipsoid
  35224. */
  35225. static CreateSphere(options: {
  35226. segments?: number;
  35227. diameter?: number;
  35228. diameterX?: number;
  35229. diameterY?: number;
  35230. diameterZ?: number;
  35231. arc?: number;
  35232. slice?: number;
  35233. sideOrientation?: number;
  35234. frontUVs?: Vector4;
  35235. backUVs?: Vector4;
  35236. }): VertexData;
  35237. /**
  35238. * Creates the VertexData for a cylinder, cone or prism
  35239. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35240. * * height sets the height (y direction) of the cylinder, optional, default 2
  35241. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  35242. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  35243. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  35244. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  35245. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  35246. * * 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
  35247. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35248. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35249. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  35250. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  35251. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35252. * * 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)
  35253. * * 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)
  35254. * @returns the VertexData of the cylinder, cone or prism
  35255. */
  35256. static CreateCylinder(options: {
  35257. height?: number;
  35258. diameterTop?: number;
  35259. diameterBottom?: number;
  35260. diameter?: number;
  35261. tessellation?: number;
  35262. subdivisions?: number;
  35263. arc?: number;
  35264. faceColors?: Color4[];
  35265. faceUV?: Vector4[];
  35266. hasRings?: boolean;
  35267. enclose?: boolean;
  35268. sideOrientation?: number;
  35269. frontUVs?: Vector4;
  35270. backUVs?: Vector4;
  35271. }): VertexData;
  35272. /**
  35273. * Creates the VertexData for a torus
  35274. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35275. * * diameter the diameter of the torus, optional default 1
  35276. * * thickness the diameter of the tube forming the torus, optional default 0.5
  35277. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  35278. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35279. * * 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)
  35280. * * 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)
  35281. * @returns the VertexData of the torus
  35282. */
  35283. static CreateTorus(options: {
  35284. diameter?: number;
  35285. thickness?: number;
  35286. tessellation?: number;
  35287. sideOrientation?: number;
  35288. frontUVs?: Vector4;
  35289. backUVs?: Vector4;
  35290. }): VertexData;
  35291. /**
  35292. * Creates the VertexData of the LineSystem
  35293. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  35294. * - lines an array of lines, each line being an array of successive Vector3
  35295. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  35296. * @returns the VertexData of the LineSystem
  35297. */
  35298. static CreateLineSystem(options: {
  35299. lines: Vector3[][];
  35300. colors?: Nullable<Color4[][]>;
  35301. }): VertexData;
  35302. /**
  35303. * Create the VertexData for a DashedLines
  35304. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  35305. * - points an array successive Vector3
  35306. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  35307. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  35308. * - dashNb the intended total number of dashes, optional, default 200
  35309. * @returns the VertexData for the DashedLines
  35310. */
  35311. static CreateDashedLines(options: {
  35312. points: Vector3[];
  35313. dashSize?: number;
  35314. gapSize?: number;
  35315. dashNb?: number;
  35316. }): VertexData;
  35317. /**
  35318. * Creates the VertexData for a Ground
  35319. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  35320. * - width the width (x direction) of the ground, optional, default 1
  35321. * - height the height (z direction) of the ground, optional, default 1
  35322. * - subdivisions the number of subdivisions per side, optional, default 1
  35323. * @returns the VertexData of the Ground
  35324. */
  35325. static CreateGround(options: {
  35326. width?: number;
  35327. height?: number;
  35328. subdivisions?: number;
  35329. subdivisionsX?: number;
  35330. subdivisionsY?: number;
  35331. }): VertexData;
  35332. /**
  35333. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  35334. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  35335. * * xmin the ground minimum X coordinate, optional, default -1
  35336. * * zmin the ground minimum Z coordinate, optional, default -1
  35337. * * xmax the ground maximum X coordinate, optional, default 1
  35338. * * zmax the ground maximum Z coordinate, optional, default 1
  35339. * * 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}
  35340. * * 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}
  35341. * @returns the VertexData of the TiledGround
  35342. */
  35343. static CreateTiledGround(options: {
  35344. xmin: number;
  35345. zmin: number;
  35346. xmax: number;
  35347. zmax: number;
  35348. subdivisions?: {
  35349. w: number;
  35350. h: number;
  35351. };
  35352. precision?: {
  35353. w: number;
  35354. h: number;
  35355. };
  35356. }): VertexData;
  35357. /**
  35358. * Creates the VertexData of the Ground designed from a heightmap
  35359. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  35360. * * width the width (x direction) of the ground
  35361. * * height the height (z direction) of the ground
  35362. * * subdivisions the number of subdivisions per side
  35363. * * minHeight the minimum altitude on the ground, optional, default 0
  35364. * * maxHeight the maximum altitude on the ground, optional default 1
  35365. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  35366. * * buffer the array holding the image color data
  35367. * * bufferWidth the width of image
  35368. * * bufferHeight the height of image
  35369. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  35370. * @returns the VertexData of the Ground designed from a heightmap
  35371. */
  35372. static CreateGroundFromHeightMap(options: {
  35373. width: number;
  35374. height: number;
  35375. subdivisions: number;
  35376. minHeight: number;
  35377. maxHeight: number;
  35378. colorFilter: Color3;
  35379. buffer: Uint8Array;
  35380. bufferWidth: number;
  35381. bufferHeight: number;
  35382. alphaFilter: number;
  35383. }): VertexData;
  35384. /**
  35385. * Creates the VertexData for a Plane
  35386. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  35387. * * size sets the width and height of the plane to the value of size, optional default 1
  35388. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  35389. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  35390. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35391. * * 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)
  35392. * * 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)
  35393. * @returns the VertexData of the box
  35394. */
  35395. static CreatePlane(options: {
  35396. size?: number;
  35397. width?: number;
  35398. height?: number;
  35399. sideOrientation?: number;
  35400. frontUVs?: Vector4;
  35401. backUVs?: Vector4;
  35402. }): VertexData;
  35403. /**
  35404. * Creates the VertexData of the Disc or regular Polygon
  35405. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  35406. * * radius the radius of the disc, optional default 0.5
  35407. * * tessellation the number of polygon sides, optional, default 64
  35408. * * 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
  35409. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35410. * * 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)
  35411. * * 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)
  35412. * @returns the VertexData of the box
  35413. */
  35414. static CreateDisc(options: {
  35415. radius?: number;
  35416. tessellation?: number;
  35417. arc?: number;
  35418. sideOrientation?: number;
  35419. frontUVs?: Vector4;
  35420. backUVs?: Vector4;
  35421. }): VertexData;
  35422. /**
  35423. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  35424. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  35425. * @param polygon a mesh built from polygonTriangulation.build()
  35426. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35427. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35428. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35429. * @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)
  35430. * @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)
  35431. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  35432. * @returns the VertexData of the Polygon
  35433. */
  35434. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  35435. /**
  35436. * Creates the VertexData of the IcoSphere
  35437. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  35438. * * radius the radius of the IcoSphere, optional default 1
  35439. * * radiusX allows stretching in the x direction, optional, default radius
  35440. * * radiusY allows stretching in the y direction, optional, default radius
  35441. * * radiusZ allows stretching in the z direction, optional, default radius
  35442. * * flat when true creates a flat shaded mesh, optional, default true
  35443. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  35444. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35445. * * 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)
  35446. * * 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)
  35447. * @returns the VertexData of the IcoSphere
  35448. */
  35449. static CreateIcoSphere(options: {
  35450. radius?: number;
  35451. radiusX?: number;
  35452. radiusY?: number;
  35453. radiusZ?: number;
  35454. flat?: boolean;
  35455. subdivisions?: number;
  35456. sideOrientation?: number;
  35457. frontUVs?: Vector4;
  35458. backUVs?: Vector4;
  35459. }): VertexData;
  35460. /**
  35461. * Creates the VertexData for a Polyhedron
  35462. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  35463. * * type provided types are:
  35464. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  35465. * * 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)
  35466. * * size the size of the IcoSphere, optional default 1
  35467. * * sizeX allows stretching in the x direction, optional, default size
  35468. * * sizeY allows stretching in the y direction, optional, default size
  35469. * * sizeZ allows stretching in the z direction, optional, default size
  35470. * * 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
  35471. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35472. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35473. * * flat when true creates a flat shaded mesh, optional, default true
  35474. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  35475. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35476. * * 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)
  35477. * * 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)
  35478. * @returns the VertexData of the Polyhedron
  35479. */
  35480. static CreatePolyhedron(options: {
  35481. type?: number;
  35482. size?: number;
  35483. sizeX?: number;
  35484. sizeY?: number;
  35485. sizeZ?: number;
  35486. custom?: any;
  35487. faceUV?: Vector4[];
  35488. faceColors?: Color4[];
  35489. flat?: boolean;
  35490. sideOrientation?: number;
  35491. frontUVs?: Vector4;
  35492. backUVs?: Vector4;
  35493. }): VertexData;
  35494. /**
  35495. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  35496. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  35497. * @returns the VertexData of the Capsule
  35498. */
  35499. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  35500. /**
  35501. * Creates the VertexData for a TorusKnot
  35502. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  35503. * * radius the radius of the torus knot, optional, default 2
  35504. * * tube the thickness of the tube, optional, default 0.5
  35505. * * radialSegments the number of sides on each tube segments, optional, default 32
  35506. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  35507. * * p the number of windings around the z axis, optional, default 2
  35508. * * q the number of windings around the x axis, optional, default 3
  35509. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35510. * * 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)
  35511. * * 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)
  35512. * @returns the VertexData of the Torus Knot
  35513. */
  35514. static CreateTorusKnot(options: {
  35515. radius?: number;
  35516. tube?: number;
  35517. radialSegments?: number;
  35518. tubularSegments?: number;
  35519. p?: number;
  35520. q?: number;
  35521. sideOrientation?: number;
  35522. frontUVs?: Vector4;
  35523. backUVs?: Vector4;
  35524. }): VertexData;
  35525. /**
  35526. * Compute normals for given positions and indices
  35527. * @param positions an array of vertex positions, [...., x, y, z, ......]
  35528. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  35529. * @param normals an array of vertex normals, [...., x, y, z, ......]
  35530. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  35531. * * facetNormals : optional array of facet normals (vector3)
  35532. * * facetPositions : optional array of facet positions (vector3)
  35533. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  35534. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  35535. * * bInfo : optional bounding info, required for facetPartitioning computation
  35536. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  35537. * * subDiv : optional partitioning data about subdivisions on each axis (int), required for facetPartitioning computation
  35538. * * useRightHandedSystem: optional boolean to for right handed system computation
  35539. * * depthSort : optional boolean to enable the facet depth sort computation
  35540. * * distanceTo : optional Vector3 to compute the facet depth from this location
  35541. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  35542. */
  35543. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  35544. facetNormals?: any;
  35545. facetPositions?: any;
  35546. facetPartitioning?: any;
  35547. ratio?: number;
  35548. bInfo?: any;
  35549. bbSize?: Vector3;
  35550. subDiv?: any;
  35551. useRightHandedSystem?: boolean;
  35552. depthSort?: boolean;
  35553. distanceTo?: Vector3;
  35554. depthSortedFacets?: any;
  35555. }): void;
  35556. /** @hidden */
  35557. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  35558. /**
  35559. * Applies VertexData created from the imported parameters to the geometry
  35560. * @param parsedVertexData the parsed data from an imported file
  35561. * @param geometry the geometry to apply the VertexData to
  35562. */
  35563. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  35564. }
  35565. }
  35566. declare module BABYLON {
  35567. /**
  35568. * Class containing static functions to help procedurally build meshes
  35569. */
  35570. export class DiscBuilder {
  35571. /**
  35572. * Creates a plane polygonal mesh. By default, this is a disc
  35573. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  35574. * * 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
  35575. * * 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
  35576. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35577. * * 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
  35578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35579. * @param name defines the name of the mesh
  35580. * @param options defines the options used to create the mesh
  35581. * @param scene defines the hosting scene
  35582. * @returns the plane polygonal mesh
  35583. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  35584. */
  35585. static CreateDisc(name: string, options: {
  35586. radius?: number;
  35587. tessellation?: number;
  35588. arc?: number;
  35589. updatable?: boolean;
  35590. sideOrientation?: number;
  35591. frontUVs?: Vector4;
  35592. backUVs?: Vector4;
  35593. }, scene?: Nullable<Scene>): Mesh;
  35594. }
  35595. }
  35596. declare module BABYLON {
  35597. /**
  35598. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  35599. *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.
  35600. * The SPS is also a particle system. It provides some methods to manage the particles.
  35601. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  35602. *
  35603. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  35604. */
  35605. export class SolidParticleSystem implements IDisposable {
  35606. /**
  35607. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  35608. * Example : var p = SPS.particles[i];
  35609. */
  35610. particles: SolidParticle[];
  35611. /**
  35612. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  35613. */
  35614. nbParticles: number;
  35615. /**
  35616. * If the particles must ever face the camera (default false). Useful for planar particles.
  35617. */
  35618. billboard: boolean;
  35619. /**
  35620. * Recompute normals when adding a shape
  35621. */
  35622. recomputeNormals: boolean;
  35623. /**
  35624. * This a counter ofr your own usage. It's not set by any SPS functions.
  35625. */
  35626. counter: number;
  35627. /**
  35628. * The SPS name. This name is also given to the underlying mesh.
  35629. */
  35630. name: string;
  35631. /**
  35632. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are available.
  35633. */
  35634. mesh: Mesh;
  35635. /**
  35636. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  35637. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  35638. */
  35639. vars: any;
  35640. /**
  35641. * This array is populated when the SPS is set as 'pickable'.
  35642. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  35643. * Each element of this array is an object `{idx: int, faceId: int}`.
  35644. * `idx` is the picked particle index in the `SPS.particles` array
  35645. * `faceId` is the picked face index counted within this particle.
  35646. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  35647. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  35648. * Use the method SPS.pickedParticle(pickingInfo) instead.
  35649. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35650. */
  35651. pickedParticles: {
  35652. idx: number;
  35653. faceId: number;
  35654. }[];
  35655. /**
  35656. * This array is populated when the SPS is set as 'pickable'
  35657. * Each key of this array is a submesh index.
  35658. * Each element of this array is a second array defined like this :
  35659. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  35660. * Each element of this second array is an object `{idx: int, faceId: int}`.
  35661. * `idx` is the picked particle index in the `SPS.particles` array
  35662. * `faceId` is the picked face index counted within this particle.
  35663. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  35664. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35665. */
  35666. pickedBySubMesh: {
  35667. idx: number;
  35668. faceId: number;
  35669. }[][];
  35670. /**
  35671. * This array is populated when `enableDepthSort` is set to true.
  35672. * Each element of this array is an instance of the class DepthSortedParticle.
  35673. */
  35674. depthSortedParticles: DepthSortedParticle[];
  35675. /**
  35676. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  35677. * @hidden
  35678. */
  35679. _bSphereOnly: boolean;
  35680. /**
  35681. * A number to multiply the bounding sphere radius by in order to reduce it for instance. (Internal use only)
  35682. * @hidden
  35683. */
  35684. _bSphereRadiusFactor: number;
  35685. private _scene;
  35686. private _positions;
  35687. private _indices;
  35688. private _normals;
  35689. private _colors;
  35690. private _uvs;
  35691. private _indices32;
  35692. private _positions32;
  35693. private _normals32;
  35694. private _fixedNormal32;
  35695. private _colors32;
  35696. private _uvs32;
  35697. private _index;
  35698. private _updatable;
  35699. private _pickable;
  35700. private _isVisibilityBoxLocked;
  35701. private _alwaysVisible;
  35702. private _depthSort;
  35703. private _expandable;
  35704. private _shapeCounter;
  35705. private _copy;
  35706. private _color;
  35707. private _computeParticleColor;
  35708. private _computeParticleTexture;
  35709. private _computeParticleRotation;
  35710. private _computeParticleVertex;
  35711. private _computeBoundingBox;
  35712. private _depthSortParticles;
  35713. private _camera;
  35714. private _mustUnrotateFixedNormals;
  35715. private _particlesIntersect;
  35716. private _needs32Bits;
  35717. private _isNotBuilt;
  35718. private _lastParticleId;
  35719. private _idxOfId;
  35720. private _multimaterialEnabled;
  35721. private _useModelMaterial;
  35722. private _indicesByMaterial;
  35723. private _materialIndexes;
  35724. private _depthSortFunction;
  35725. private _materialSortFunction;
  35726. private _materials;
  35727. private _multimaterial;
  35728. private _materialIndexesById;
  35729. private _defaultMaterial;
  35730. private _autoUpdateSubMeshes;
  35731. private _tmpVertex;
  35732. /**
  35733. * Creates a SPS (Solid Particle System) object.
  35734. * @param name (String) is the SPS name, this will be the underlying mesh name.
  35735. * @param scene (Scene) is the scene in which the SPS is added.
  35736. * @param options defines the options of the sps e.g.
  35737. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  35738. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  35739. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  35740. * * 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.
  35741. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  35742. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  35743. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  35744. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  35745. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the bounding sphere radius by in order to reduce it for instance.
  35746. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  35747. */
  35748. constructor(name: string, scene: Scene, options?: {
  35749. updatable?: boolean;
  35750. isPickable?: boolean;
  35751. enableDepthSort?: boolean;
  35752. particleIntersection?: boolean;
  35753. boundingSphereOnly?: boolean;
  35754. bSphereRadiusFactor?: number;
  35755. expandable?: boolean;
  35756. useModelMaterial?: boolean;
  35757. enableMultiMaterial?: boolean;
  35758. });
  35759. /**
  35760. * Builds the SPS underlying mesh. Returns a standard Mesh.
  35761. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  35762. * @returns the created mesh
  35763. */
  35764. buildMesh(): Mesh;
  35765. /**
  35766. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  35767. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  35768. * Thus the particles generated from `digest()` have their property `position` set yet.
  35769. * @param mesh ( Mesh ) is the mesh to be digested
  35770. * @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
  35771. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  35772. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  35773. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35774. * @returns the current SPS
  35775. */
  35776. digest(mesh: Mesh, options?: {
  35777. facetNb?: number;
  35778. number?: number;
  35779. delta?: number;
  35780. storage?: [];
  35781. }): SolidParticleSystem;
  35782. /**
  35783. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  35784. * @hidden
  35785. */
  35786. private _unrotateFixedNormals;
  35787. /**
  35788. * Resets the temporary working copy particle
  35789. * @hidden
  35790. */
  35791. private _resetCopy;
  35792. /**
  35793. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  35794. * @param p the current index in the positions array to be updated
  35795. * @param ind the current index in the indices array
  35796. * @param shape a Vector3 array, the shape geometry
  35797. * @param positions the positions array to be updated
  35798. * @param meshInd the shape indices array
  35799. * @param indices the indices array to be updated
  35800. * @param meshUV the shape uv array
  35801. * @param uvs the uv array to be updated
  35802. * @param meshCol the shape color array
  35803. * @param colors the color array to be updated
  35804. * @param meshNor the shape normals array
  35805. * @param normals the normals array to be updated
  35806. * @param idx the particle index
  35807. * @param idxInShape the particle index in its shape
  35808. * @param options the addShape() method passed options
  35809. * @model the particle model
  35810. * @hidden
  35811. */
  35812. private _meshBuilder;
  35813. /**
  35814. * Returns a shape Vector3 array from positions float array
  35815. * @param positions float array
  35816. * @returns a vector3 array
  35817. * @hidden
  35818. */
  35819. private _posToShape;
  35820. /**
  35821. * Returns a shapeUV array from a float uvs (array deep copy)
  35822. * @param uvs as a float array
  35823. * @returns a shapeUV array
  35824. * @hidden
  35825. */
  35826. private _uvsToShapeUV;
  35827. /**
  35828. * Adds a new particle object in the particles array
  35829. * @param idx particle index in particles array
  35830. * @param id particle id
  35831. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  35832. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  35833. * @param model particle ModelShape object
  35834. * @param shapeId model shape identifier
  35835. * @param idxInShape index of the particle in the current model
  35836. * @param bInfo model bounding info object
  35837. * @param storage target storage array, if any
  35838. * @hidden
  35839. */
  35840. private _addParticle;
  35841. /**
  35842. * Adds some particles to the SPS from the model shape. Returns the shape id.
  35843. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  35844. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  35845. * @param nb (positive integer) the number of particles to be created from this model
  35846. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  35847. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  35848. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35849. * @returns the number of shapes in the system
  35850. */
  35851. addShape(mesh: Mesh, nb: number, options?: {
  35852. positionFunction?: any;
  35853. vertexFunction?: any;
  35854. storage?: [];
  35855. }): number;
  35856. /**
  35857. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  35858. * @hidden
  35859. */
  35860. private _rebuildParticle;
  35861. /**
  35862. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  35863. * @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.
  35864. * @returns the SPS.
  35865. */
  35866. rebuildMesh(reset?: boolean): SolidParticleSystem;
  35867. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  35868. * Returns an array with the removed particles.
  35869. * 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.
  35870. * The SPS can't be empty so at least one particle needs to remain in place.
  35871. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  35872. * @param start index of the first particle to remove
  35873. * @param end index of the last particle to remove (included)
  35874. * @returns an array populated with the removed particles
  35875. */
  35876. removeParticles(start: number, end: number): SolidParticle[];
  35877. /**
  35878. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  35879. * @param solidParticleArray an array populated with Solid Particles objects
  35880. * @returns the SPS
  35881. */
  35882. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  35883. /**
  35884. * Creates a new particle and modifies the SPS mesh geometry :
  35885. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  35886. * - calls _addParticle() to populate the particle array
  35887. * factorized code from addShape() and insertParticlesFromArray()
  35888. * @param idx particle index in the particles array
  35889. * @param i particle index in its shape
  35890. * @param modelShape particle ModelShape object
  35891. * @param shape shape vertex array
  35892. * @param meshInd shape indices array
  35893. * @param meshUV shape uv array
  35894. * @param meshCol shape color array
  35895. * @param meshNor shape normals array
  35896. * @param bbInfo shape bounding info
  35897. * @param storage target particle storage
  35898. * @options addShape() passed options
  35899. * @hidden
  35900. */
  35901. private _insertNewParticle;
  35902. /**
  35903. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  35904. * This method calls `updateParticle()` for each particle of the SPS.
  35905. * For an animated SPS, it is usually called within the render loop.
  35906. * 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.
  35907. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  35908. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  35909. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  35910. * @returns the SPS.
  35911. */
  35912. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  35913. /**
  35914. * Disposes the SPS.
  35915. */
  35916. dispose(): void;
  35917. /** Returns an object {idx: number faceId: number} for the picked particle from the passed pickingInfo object.
  35918. * idx is the particle index in the SPS
  35919. * faceId is the picked face index counted within this particle.
  35920. * Returns null if the pickInfo can't identify a picked particle.
  35921. * @param pickingInfo (PickingInfo object)
  35922. * @returns {idx: number, faceId: number} or null
  35923. */
  35924. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  35925. idx: number;
  35926. faceId: number;
  35927. }>;
  35928. /**
  35929. * Returns a SolidParticle object from its identifier : particle.id
  35930. * @param id (integer) the particle Id
  35931. * @returns the searched particle or null if not found in the SPS.
  35932. */
  35933. getParticleById(id: number): Nullable<SolidParticle>;
  35934. /**
  35935. * Returns a new array populated with the particles having the passed shapeId.
  35936. * @param shapeId (integer) the shape identifier
  35937. * @returns a new solid particle array
  35938. */
  35939. getParticlesByShapeId(shapeId: number): SolidParticle[];
  35940. /**
  35941. * Populates the passed array "ref" with the particles having the passed shapeId.
  35942. * @param shapeId the shape identifier
  35943. * @returns the SPS
  35944. * @param ref
  35945. */
  35946. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  35947. /**
  35948. * Computes the required SubMeshes according the materials assigned to the particles.
  35949. * @returns the solid particle system.
  35950. * Does nothing if called before the SPS mesh is built.
  35951. */
  35952. computeSubMeshes(): SolidParticleSystem;
  35953. /**
  35954. * Sorts the solid particles by material when MultiMaterial is enabled.
  35955. * Updates the indices32 array.
  35956. * Updates the indicesByMaterial array.
  35957. * Updates the mesh indices array.
  35958. * @returns the SPS
  35959. * @hidden
  35960. */
  35961. private _sortParticlesByMaterial;
  35962. /**
  35963. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  35964. * @hidden
  35965. */
  35966. private _setMaterialIndexesById;
  35967. /**
  35968. * Returns an array with unique values of Materials from the passed array
  35969. * @param array the material array to be checked and filtered
  35970. * @hidden
  35971. */
  35972. private _filterUniqueMaterialId;
  35973. /**
  35974. * Sets a new Standard Material as _defaultMaterial if not already set.
  35975. * @hidden
  35976. */
  35977. private _setDefaultMaterial;
  35978. /**
  35979. * Visibility helper : Recomputes the visible size according to the mesh bounding box
  35980. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35981. * @returns the SPS.
  35982. */
  35983. refreshVisibleSize(): SolidParticleSystem;
  35984. /**
  35985. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  35986. * @param size the size (float) of the visibility box
  35987. * note : this doesn't lock the SPS mesh bounding box.
  35988. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35989. */
  35990. setVisibilityBox(size: number): void;
  35991. /**
  35992. * Gets whether the SPS as always visible or not
  35993. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35994. */
  35995. get isAlwaysVisible(): boolean;
  35996. /**
  35997. * Sets the SPS as always visible or not
  35998. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35999. */
  36000. set isAlwaysVisible(val: boolean);
  36001. /**
  36002. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  36003. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36004. */
  36005. set isVisibilityBoxLocked(val: boolean);
  36006. /**
  36007. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  36008. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36009. */
  36010. get isVisibilityBoxLocked(): boolean;
  36011. /**
  36012. * Tells to `setParticles()` to compute the particle rotations or not.
  36013. * Default value : true. The SPS is faster when it's set to false.
  36014. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  36015. */
  36016. set computeParticleRotation(val: boolean);
  36017. /**
  36018. * Tells to `setParticles()` to compute the particle colors or not.
  36019. * Default value : true. The SPS is faster when it's set to false.
  36020. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  36021. */
  36022. set computeParticleColor(val: boolean);
  36023. set computeParticleTexture(val: boolean);
  36024. /**
  36025. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  36026. * Default value : false. The SPS is faster when it's set to false.
  36027. * Note : the particle custom vertex positions aren't stored values.
  36028. */
  36029. set computeParticleVertex(val: boolean);
  36030. /**
  36031. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  36032. */
  36033. set computeBoundingBox(val: boolean);
  36034. /**
  36035. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  36036. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  36037. * Default : `true`
  36038. */
  36039. set depthSortParticles(val: boolean);
  36040. /**
  36041. * Gets if `setParticles()` computes the particle rotations or not.
  36042. * Default value : true. The SPS is faster when it's set to false.
  36043. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  36044. */
  36045. get computeParticleRotation(): boolean;
  36046. /**
  36047. * Gets if `setParticles()` computes the particle colors or not.
  36048. * Default value : true. The SPS is faster when it's set to false.
  36049. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  36050. */
  36051. get computeParticleColor(): boolean;
  36052. /**
  36053. * Gets if `setParticles()` computes the particle textures or not.
  36054. * Default value : true. The SPS is faster when it's set to false.
  36055. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  36056. */
  36057. get computeParticleTexture(): boolean;
  36058. /**
  36059. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  36060. * Default value : false. The SPS is faster when it's set to false.
  36061. * Note : the particle custom vertex positions aren't stored values.
  36062. */
  36063. get computeParticleVertex(): boolean;
  36064. /**
  36065. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  36066. */
  36067. get computeBoundingBox(): boolean;
  36068. /**
  36069. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  36070. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  36071. * Default : `true`
  36072. */
  36073. get depthSortParticles(): boolean;
  36074. /**
  36075. * Gets if the SPS is created as expandable at construction time.
  36076. * Default : `false`
  36077. */
  36078. get expandable(): boolean;
  36079. /**
  36080. * Gets if the SPS supports the Multi Materials
  36081. */
  36082. get multimaterialEnabled(): boolean;
  36083. /**
  36084. * Gets if the SPS uses the model materials for its own multimaterial.
  36085. */
  36086. get useModelMaterial(): boolean;
  36087. /**
  36088. * The SPS used material array.
  36089. */
  36090. get materials(): Material[];
  36091. /**
  36092. * Sets the SPS MultiMaterial from the passed materials.
  36093. * Note : the passed array is internally copied and not used then by reference.
  36094. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  36095. */
  36096. setMultiMaterial(materials: Material[]): void;
  36097. /**
  36098. * The SPS computed multimaterial object
  36099. */
  36100. get multimaterial(): MultiMaterial;
  36101. set multimaterial(mm: MultiMaterial);
  36102. /**
  36103. * If the subMeshes must be updated on the next call to setParticles()
  36104. */
  36105. get autoUpdateSubMeshes(): boolean;
  36106. set autoUpdateSubMeshes(val: boolean);
  36107. /**
  36108. * This function does nothing. It may be overwritten to set all the particle first values.
  36109. * The SPS doesn't call this function, you may have to call it by your own.
  36110. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36111. */
  36112. initParticles(): void;
  36113. /**
  36114. * This function does nothing. It may be overwritten to recycle a particle.
  36115. * The SPS doesn't call this function, you may have to call it by your own.
  36116. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36117. * @param particle The particle to recycle
  36118. * @returns the recycled particle
  36119. */
  36120. recycleParticle(particle: SolidParticle): SolidParticle;
  36121. /**
  36122. * Updates a particle : this function should be overwritten by the user.
  36123. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  36124. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36125. * @example : just set a particle position or velocity and recycle conditions
  36126. * @param particle The particle to update
  36127. * @returns the updated particle
  36128. */
  36129. updateParticle(particle: SolidParticle): SolidParticle;
  36130. /**
  36131. * Updates a vertex of a particle : it can be overwritten by the user.
  36132. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  36133. * @param particle the current particle
  36134. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  36135. * @param pt the index of the current vertex in the particle shape
  36136. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  36137. * @example : just set a vertex particle position or color
  36138. * @returns the sps
  36139. */
  36140. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  36141. /**
  36142. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  36143. * This does nothing and may be overwritten by the user.
  36144. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36145. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36146. * @param update the boolean update value actually passed to setParticles()
  36147. */
  36148. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36149. /**
  36150. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  36151. * This will be passed three parameters.
  36152. * This does nothing and may be overwritten by the user.
  36153. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36154. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36155. * @param update the boolean update value actually passed to setParticles()
  36156. */
  36157. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36158. }
  36159. }
  36160. declare module BABYLON {
  36161. /**
  36162. * Represents one particle of a solid particle system.
  36163. */
  36164. export class SolidParticle {
  36165. /**
  36166. * particle global index
  36167. */
  36168. idx: number;
  36169. /**
  36170. * particle identifier
  36171. */
  36172. id: number;
  36173. /**
  36174. * The color of the particle
  36175. */
  36176. color: Nullable<Color4>;
  36177. /**
  36178. * The world space position of the particle.
  36179. */
  36180. position: Vector3;
  36181. /**
  36182. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  36183. */
  36184. rotation: Vector3;
  36185. /**
  36186. * The world space rotation quaternion of the particle.
  36187. */
  36188. rotationQuaternion: Nullable<Quaternion>;
  36189. /**
  36190. * The scaling of the particle.
  36191. */
  36192. scaling: Vector3;
  36193. /**
  36194. * The uvs of the particle.
  36195. */
  36196. uvs: Vector4;
  36197. /**
  36198. * The current speed of the particle.
  36199. */
  36200. velocity: Vector3;
  36201. /**
  36202. * The pivot point in the particle local space.
  36203. */
  36204. pivot: Vector3;
  36205. /**
  36206. * Must the particle be translated from its pivot point in its local space ?
  36207. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  36208. * Default : false
  36209. */
  36210. translateFromPivot: boolean;
  36211. /**
  36212. * Is the particle active or not ?
  36213. */
  36214. alive: boolean;
  36215. /**
  36216. * Is the particle visible or not ?
  36217. */
  36218. isVisible: boolean;
  36219. /**
  36220. * Index of this particle in the global "positions" array (Internal use)
  36221. * @hidden
  36222. */
  36223. _pos: number;
  36224. /**
  36225. * @hidden Index of this particle in the global "indices" array (Internal use)
  36226. */
  36227. _ind: number;
  36228. /**
  36229. * @hidden ModelShape of this particle (Internal use)
  36230. */
  36231. _model: ModelShape;
  36232. /**
  36233. * ModelShape id of this particle
  36234. */
  36235. shapeId: number;
  36236. /**
  36237. * Index of the particle in its shape id
  36238. */
  36239. idxInShape: number;
  36240. /**
  36241. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  36242. */
  36243. _modelBoundingInfo: BoundingInfo;
  36244. /**
  36245. * @hidden Particle BoundingInfo object (Internal use)
  36246. */
  36247. _boundingInfo: BoundingInfo;
  36248. /**
  36249. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  36250. */
  36251. _sps: SolidParticleSystem;
  36252. /**
  36253. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  36254. */
  36255. _stillInvisible: boolean;
  36256. /**
  36257. * @hidden Last computed particle rotation matrix
  36258. */
  36259. _rotationMatrix: number[];
  36260. /**
  36261. * Parent particle Id, if any.
  36262. * Default null.
  36263. */
  36264. parentId: Nullable<number>;
  36265. /**
  36266. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  36267. */
  36268. materialIndex: Nullable<number>;
  36269. /**
  36270. * Custom object or properties.
  36271. */
  36272. props: Nullable<any>;
  36273. /**
  36274. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  36275. * The possible values are :
  36276. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36277. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36278. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36279. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36280. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36281. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  36282. * */
  36283. cullingStrategy: number;
  36284. /**
  36285. * @hidden Internal global position in the SPS.
  36286. */
  36287. _globalPosition: Vector3;
  36288. /**
  36289. * Creates a Solid Particle object.
  36290. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  36291. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  36292. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  36293. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  36294. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  36295. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  36296. * @param shapeId (integer) is the model shape identifier in the SPS.
  36297. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  36298. * @param sps defines the sps it is associated to
  36299. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  36300. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  36301. */
  36302. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  36303. /**
  36304. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  36305. * @param target the particle target
  36306. * @returns the current particle
  36307. */
  36308. copyToRef(target: SolidParticle): SolidParticle;
  36309. /**
  36310. * Legacy support, changed scale to scaling
  36311. */
  36312. get scale(): Vector3;
  36313. /**
  36314. * Legacy support, changed scale to scaling
  36315. */
  36316. set scale(scale: Vector3);
  36317. /**
  36318. * Legacy support, changed quaternion to rotationQuaternion
  36319. */
  36320. get quaternion(): Nullable<Quaternion>;
  36321. /**
  36322. * Legacy support, changed quaternion to rotationQuaternion
  36323. */
  36324. set quaternion(q: Nullable<Quaternion>);
  36325. /**
  36326. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  36327. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  36328. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  36329. * @returns true if it intersects
  36330. */
  36331. intersectsMesh(target: Mesh | SolidParticle): boolean;
  36332. /**
  36333. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  36334. * A particle is in the frustum if its bounding box intersects the frustum
  36335. * @param frustumPlanes defines the frustum to test
  36336. * @returns true if the particle is in the frustum planes
  36337. */
  36338. isInFrustum(frustumPlanes: Plane[]): boolean;
  36339. /**
  36340. * get the rotation matrix of the particle
  36341. * @hidden
  36342. */
  36343. getRotationMatrix(m: Matrix): void;
  36344. }
  36345. /**
  36346. * Represents the shape of the model used by one particle of a solid particle system.
  36347. * SPS internal tool, don't use it manually.
  36348. */
  36349. export class ModelShape {
  36350. /**
  36351. * The shape id
  36352. * @hidden
  36353. */
  36354. shapeID: number;
  36355. /**
  36356. * flat array of model positions (internal use)
  36357. * @hidden
  36358. */
  36359. _shape: Vector3[];
  36360. /**
  36361. * flat array of model UVs (internal use)
  36362. * @hidden
  36363. */
  36364. _shapeUV: number[];
  36365. /**
  36366. * color array of the model
  36367. * @hidden
  36368. */
  36369. _shapeColors: number[];
  36370. /**
  36371. * indices array of the model
  36372. * @hidden
  36373. */
  36374. _indices: number[];
  36375. /**
  36376. * normals array of the model
  36377. * @hidden
  36378. */
  36379. _normals: number[];
  36380. /**
  36381. * length of the shape in the model indices array (internal use)
  36382. * @hidden
  36383. */
  36384. _indicesLength: number;
  36385. /**
  36386. * Custom position function (internal use)
  36387. * @hidden
  36388. */
  36389. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  36390. /**
  36391. * Custom vertex function (internal use)
  36392. * @hidden
  36393. */
  36394. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  36395. /**
  36396. * Model material (internal use)
  36397. * @hidden
  36398. */
  36399. _material: Nullable<Material>;
  36400. /**
  36401. * 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.
  36402. * SPS internal tool, don't use it manually.
  36403. * @hidden
  36404. */
  36405. 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>);
  36406. }
  36407. /**
  36408. * Represents a Depth Sorted Particle in the solid particle system.
  36409. * @hidden
  36410. */
  36411. export class DepthSortedParticle {
  36412. /**
  36413. * Particle index
  36414. */
  36415. idx: number;
  36416. /**
  36417. * Index of the particle in the "indices" array
  36418. */
  36419. ind: number;
  36420. /**
  36421. * Length of the particle shape in the "indices" array
  36422. */
  36423. indicesLength: number;
  36424. /**
  36425. * Squared distance from the particle to the camera
  36426. */
  36427. sqDistance: number;
  36428. /**
  36429. * Material index when used with MultiMaterials
  36430. */
  36431. materialIndex: number;
  36432. /**
  36433. * Creates a new sorted particle
  36434. * @param materialIndex
  36435. */
  36436. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  36437. }
  36438. /**
  36439. * Represents a solid particle vertex
  36440. */
  36441. export class SolidParticleVertex {
  36442. /**
  36443. * Vertex position
  36444. */
  36445. position: Vector3;
  36446. /**
  36447. * Vertex color
  36448. */
  36449. color: Color4;
  36450. /**
  36451. * Vertex UV
  36452. */
  36453. uv: Vector2;
  36454. /**
  36455. * Creates a new solid particle vertex
  36456. */
  36457. constructor();
  36458. /** Vertex x coordinate */
  36459. get x(): number;
  36460. set x(val: number);
  36461. /** Vertex y coordinate */
  36462. get y(): number;
  36463. set y(val: number);
  36464. /** Vertex z coordinate */
  36465. get z(): number;
  36466. set z(val: number);
  36467. }
  36468. }
  36469. declare module BABYLON {
  36470. /**
  36471. * @hidden
  36472. */
  36473. export class _MeshCollisionData {
  36474. _checkCollisions: boolean;
  36475. _collisionMask: number;
  36476. _collisionGroup: number;
  36477. _surroundingMeshes: Nullable<AbstractMesh[]>;
  36478. _collider: Nullable<Collider>;
  36479. _oldPositionForCollisions: Vector3;
  36480. _diffPositionForCollisions: Vector3;
  36481. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  36482. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  36483. _collisionResponse: boolean;
  36484. }
  36485. }
  36486. declare module BABYLON {
  36487. /** @hidden */
  36488. class _FacetDataStorage {
  36489. facetPositions: Vector3[];
  36490. facetNormals: Vector3[];
  36491. facetPartitioning: number[][];
  36492. facetNb: number;
  36493. partitioningSubdivisions: number;
  36494. partitioningBBoxRatio: number;
  36495. facetDataEnabled: boolean;
  36496. facetParameters: any;
  36497. bbSize: Vector3;
  36498. subDiv: {
  36499. max: number;
  36500. X: number;
  36501. Y: number;
  36502. Z: number;
  36503. };
  36504. facetDepthSort: boolean;
  36505. facetDepthSortEnabled: boolean;
  36506. depthSortedIndices: IndicesArray;
  36507. depthSortedFacets: {
  36508. ind: number;
  36509. sqDistance: number;
  36510. }[];
  36511. facetDepthSortFunction: (f1: {
  36512. ind: number;
  36513. sqDistance: number;
  36514. }, f2: {
  36515. ind: number;
  36516. sqDistance: number;
  36517. }) => number;
  36518. facetDepthSortFrom: Vector3;
  36519. facetDepthSortOrigin: Vector3;
  36520. invertedMatrix: Matrix;
  36521. }
  36522. /**
  36523. * @hidden
  36524. **/
  36525. class _InternalAbstractMeshDataInfo {
  36526. _hasVertexAlpha: boolean;
  36527. _useVertexColors: boolean;
  36528. _numBoneInfluencers: number;
  36529. _applyFog: boolean;
  36530. _receiveShadows: boolean;
  36531. _facetData: _FacetDataStorage;
  36532. _visibility: number;
  36533. _skeleton: Nullable<Skeleton>;
  36534. _layerMask: number;
  36535. _computeBonesUsingShaders: boolean;
  36536. _isActive: boolean;
  36537. _onlyForInstances: boolean;
  36538. _isActiveIntermediate: boolean;
  36539. _onlyForInstancesIntermediate: boolean;
  36540. _actAsRegularMesh: boolean;
  36541. _currentLOD: Nullable<AbstractMesh>;
  36542. _currentLODIsUpToDate: boolean;
  36543. _collisionRetryCount: number;
  36544. }
  36545. /**
  36546. * Class used to store all common mesh properties
  36547. */
  36548. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  36549. /** No occlusion */
  36550. static OCCLUSION_TYPE_NONE: number;
  36551. /** Occlusion set to optimistic */
  36552. static OCCLUSION_TYPE_OPTIMISTIC: number;
  36553. /** Occlusion set to strict */
  36554. static OCCLUSION_TYPE_STRICT: number;
  36555. /** Use an accurate occlusion algorithm */
  36556. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  36557. /** Use a conservative occlusion algorithm */
  36558. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  36559. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  36560. * Test order :
  36561. * Is the bounding sphere outside the frustum ?
  36562. * If not, are the bounding box vertices outside the frustum ?
  36563. * It not, then the cullable object is in the frustum.
  36564. */
  36565. static readonly CULLINGSTRATEGY_STANDARD: number;
  36566. /** Culling strategy : Bounding Sphere Only.
  36567. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  36568. * It's also less accurate than the standard because some not visible objects can still be selected.
  36569. * Test : is the bounding sphere outside the frustum ?
  36570. * If not, then the cullable object is in the frustum.
  36571. */
  36572. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  36573. /** Culling strategy : Optimistic Inclusion.
  36574. * This in an inclusion test first, then the standard exclusion test.
  36575. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  36576. * 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.
  36577. * Anyway, it's as accurate as the standard strategy.
  36578. * Test :
  36579. * Is the cullable object bounding sphere center in the frustum ?
  36580. * If not, apply the default culling strategy.
  36581. */
  36582. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  36583. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  36584. * This in an inclusion test first, then the bounding sphere only exclusion test.
  36585. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  36586. * 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.
  36587. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  36588. * Test :
  36589. * Is the cullable object bounding sphere center in the frustum ?
  36590. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  36591. */
  36592. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  36593. /**
  36594. * No billboard
  36595. */
  36596. static get BILLBOARDMODE_NONE(): number;
  36597. /** Billboard on X axis */
  36598. static get BILLBOARDMODE_X(): number;
  36599. /** Billboard on Y axis */
  36600. static get BILLBOARDMODE_Y(): number;
  36601. /** Billboard on Z axis */
  36602. static get BILLBOARDMODE_Z(): number;
  36603. /** Billboard on all axes */
  36604. static get BILLBOARDMODE_ALL(): number;
  36605. /** Billboard on using position instead of orientation */
  36606. static get BILLBOARDMODE_USE_POSITION(): number;
  36607. /** @hidden */
  36608. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  36609. /**
  36610. * The culling strategy to use to check whether the mesh must be rendered or not.
  36611. * This value can be changed at any time and will be used on the next render mesh selection.
  36612. * The possible values are :
  36613. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36614. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36615. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36616. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36617. * Please read each static variable documentation to get details about the culling process.
  36618. * */
  36619. cullingStrategy: number;
  36620. /**
  36621. * Gets the number of facets in the mesh
  36622. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36623. */
  36624. get facetNb(): number;
  36625. /**
  36626. * Gets or set the number (integer) of subdivisions per axis in the partitioning space
  36627. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36628. */
  36629. get partitioningSubdivisions(): number;
  36630. set partitioningSubdivisions(nb: number);
  36631. /**
  36632. * The ratio (float) to apply to the bounding box size to set to the partitioning space.
  36633. * Ex : 1.01 (default) the partitioning space is 1% bigger than the bounding box
  36634. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36635. */
  36636. get partitioningBBoxRatio(): number;
  36637. set partitioningBBoxRatio(ratio: number);
  36638. /**
  36639. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  36640. * Works only for updatable meshes.
  36641. * Doesn't work with multi-materials
  36642. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36643. */
  36644. get mustDepthSortFacets(): boolean;
  36645. set mustDepthSortFacets(sort: boolean);
  36646. /**
  36647. * The location (Vector3) where the facet depth sort must be computed from.
  36648. * By default, the active camera position.
  36649. * Used only when facet depth sort is enabled
  36650. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36651. */
  36652. get facetDepthSortFrom(): Vector3;
  36653. set facetDepthSortFrom(location: Vector3);
  36654. /** number of collision detection tries. Change this value if not all colisions are detected and handled properly. */
  36655. get collisionRetryCount(): number;
  36656. set collisionRetryCount(retryCount: number);
  36657. /**
  36658. * gets a boolean indicating if facetData is enabled
  36659. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36660. */
  36661. get isFacetDataEnabled(): boolean;
  36662. /** @hidden */
  36663. _updateNonUniformScalingState(value: boolean): boolean;
  36664. /**
  36665. * An event triggered when this mesh collides with another one
  36666. */
  36667. onCollideObservable: Observable<AbstractMesh>;
  36668. /** Set a function to call when this mesh collides with another one */
  36669. set onCollide(callback: () => void);
  36670. /**
  36671. * An event triggered when the collision's position changes
  36672. */
  36673. onCollisionPositionChangeObservable: Observable<Vector3>;
  36674. /** Set a function to call when the collision's position changes */
  36675. set onCollisionPositionChange(callback: () => void);
  36676. /**
  36677. * An event triggered when material is changed
  36678. */
  36679. onMaterialChangedObservable: Observable<AbstractMesh>;
  36680. /**
  36681. * Gets or sets the orientation for POV movement & rotation
  36682. */
  36683. definedFacingForward: boolean;
  36684. /** @hidden */
  36685. _occlusionQuery: Nullable<WebGLQuery>;
  36686. /** @hidden */
  36687. _renderingGroup: Nullable<RenderingGroup>;
  36688. /**
  36689. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36690. */
  36691. get visibility(): number;
  36692. /**
  36693. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36694. */
  36695. set visibility(value: number);
  36696. /** Gets or sets the alpha index used to sort transparent meshes
  36697. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  36698. */
  36699. alphaIndex: number;
  36700. /**
  36701. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  36702. */
  36703. isVisible: boolean;
  36704. /**
  36705. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36706. */
  36707. isPickable: boolean;
  36708. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  36709. showSubMeshesBoundingBox: boolean;
  36710. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  36711. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  36712. */
  36713. isBlocker: boolean;
  36714. /**
  36715. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  36716. */
  36717. enablePointerMoveEvents: boolean;
  36718. private _renderingGroupId;
  36719. /**
  36720. * Specifies the rendering group id for this mesh (0 by default)
  36721. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36722. */
  36723. get renderingGroupId(): number;
  36724. set renderingGroupId(value: number);
  36725. private _material;
  36726. /** Gets or sets current material */
  36727. get material(): Nullable<Material>;
  36728. set material(value: Nullable<Material>);
  36729. /**
  36730. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  36731. * @see https://doc.babylonjs.com/babylon101/shadows
  36732. */
  36733. get receiveShadows(): boolean;
  36734. set receiveShadows(value: boolean);
  36735. /** Defines color to use when rendering outline */
  36736. outlineColor: Color3;
  36737. /** Define width to use when rendering outline */
  36738. outlineWidth: number;
  36739. /** Defines color to use when rendering overlay */
  36740. overlayColor: Color3;
  36741. /** Defines alpha to use when rendering overlay */
  36742. overlayAlpha: number;
  36743. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  36744. get hasVertexAlpha(): boolean;
  36745. set hasVertexAlpha(value: boolean);
  36746. /** 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) */
  36747. get useVertexColors(): boolean;
  36748. set useVertexColors(value: boolean);
  36749. /**
  36750. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  36751. */
  36752. get computeBonesUsingShaders(): boolean;
  36753. set computeBonesUsingShaders(value: boolean);
  36754. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  36755. get numBoneInfluencers(): number;
  36756. set numBoneInfluencers(value: number);
  36757. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  36758. get applyFog(): boolean;
  36759. set applyFog(value: boolean);
  36760. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  36761. useOctreeForRenderingSelection: boolean;
  36762. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  36763. useOctreeForPicking: boolean;
  36764. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  36765. useOctreeForCollisions: boolean;
  36766. /**
  36767. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  36768. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  36769. */
  36770. get layerMask(): number;
  36771. set layerMask(value: number);
  36772. /**
  36773. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  36774. */
  36775. alwaysSelectAsActiveMesh: boolean;
  36776. /**
  36777. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  36778. */
  36779. doNotSyncBoundingInfo: boolean;
  36780. /**
  36781. * Gets or sets the current action manager
  36782. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36783. */
  36784. actionManager: Nullable<AbstractActionManager>;
  36785. private _meshCollisionData;
  36786. /**
  36787. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  36788. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36789. */
  36790. ellipsoid: Vector3;
  36791. /**
  36792. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  36793. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36794. */
  36795. ellipsoidOffset: Vector3;
  36796. /**
  36797. * Gets or sets a collision mask used to mask collisions (default is -1).
  36798. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36799. */
  36800. get collisionMask(): number;
  36801. set collisionMask(mask: number);
  36802. /**
  36803. * Gets or sets a collision response flag (default is true).
  36804. * when collisionResponse is false, events are still triggered but colliding entity has no response
  36805. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  36806. * to respond to the collision.
  36807. */
  36808. get collisionResponse(): boolean;
  36809. set collisionResponse(response: boolean);
  36810. /**
  36811. * Gets or sets the current collision group mask (-1 by default).
  36812. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36813. */
  36814. get collisionGroup(): number;
  36815. set collisionGroup(mask: number);
  36816. /**
  36817. * Gets or sets current surrounding meshes (null by default).
  36818. *
  36819. * By default collision detection is tested against every mesh in the scene.
  36820. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  36821. * meshes will be tested for the collision.
  36822. *
  36823. * Note: if set to an empty array no collision will happen when this mesh is moved.
  36824. */
  36825. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  36826. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  36827. /**
  36828. * Defines edge width used when edgesRenderer is enabled
  36829. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36830. */
  36831. edgesWidth: number;
  36832. /**
  36833. * Defines edge color used when edgesRenderer is enabled
  36834. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36835. */
  36836. edgesColor: Color4;
  36837. /** @hidden */
  36838. _edgesRenderer: Nullable<IEdgesRenderer>;
  36839. /** @hidden */
  36840. _masterMesh: Nullable<AbstractMesh>;
  36841. /** @hidden */
  36842. _boundingInfo: Nullable<BoundingInfo>;
  36843. /** @hidden */
  36844. _renderId: number;
  36845. /**
  36846. * Gets or sets the list of subMeshes
  36847. * @see https://doc.babylonjs.com/how_to/multi_materials
  36848. */
  36849. subMeshes: SubMesh[];
  36850. /** @hidden */
  36851. _intersectionsInProgress: AbstractMesh[];
  36852. /** @hidden */
  36853. _unIndexed: boolean;
  36854. /** @hidden */
  36855. _lightSources: Light[];
  36856. /** Gets the list of lights affecting that mesh */
  36857. get lightSources(): Light[];
  36858. /** @hidden */
  36859. get _positions(): Nullable<Vector3[]>;
  36860. /** @hidden */
  36861. _waitingData: {
  36862. lods: Nullable<any>;
  36863. actions: Nullable<any>;
  36864. freezeWorldMatrix: Nullable<boolean>;
  36865. };
  36866. /** @hidden */
  36867. _bonesTransformMatrices: Nullable<Float32Array>;
  36868. /** @hidden */
  36869. _transformMatrixTexture: Nullable<RawTexture>;
  36870. /**
  36871. * Gets or sets a skeleton to apply skinning transformations
  36872. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36873. */
  36874. set skeleton(value: Nullable<Skeleton>);
  36875. get skeleton(): Nullable<Skeleton>;
  36876. /**
  36877. * An event triggered when the mesh is rebuilt.
  36878. */
  36879. onRebuildObservable: Observable<AbstractMesh>;
  36880. /**
  36881. * The current mesh uniform buffer.
  36882. * @hidden Internal use only.
  36883. */
  36884. _uniformBuffer: UniformBuffer;
  36885. /**
  36886. * Creates a new AbstractMesh
  36887. * @param name defines the name of the mesh
  36888. * @param scene defines the hosting scene
  36889. */
  36890. constructor(name: string, scene?: Nullable<Scene>);
  36891. protected _buildUniformLayout(): void;
  36892. /**
  36893. * Transfer the mesh values to its UBO.
  36894. * @param world The world matrix associated with the mesh
  36895. */
  36896. transferToEffect(world: Matrix): void;
  36897. /**
  36898. * Gets the mesh uniform buffer.
  36899. * @return the uniform buffer of the mesh.
  36900. */
  36901. getMeshUniformBuffer(): UniformBuffer;
  36902. /**
  36903. * Returns the string "AbstractMesh"
  36904. * @returns "AbstractMesh"
  36905. */
  36906. getClassName(): string;
  36907. /**
  36908. * Gets a string representation of the current mesh
  36909. * @param fullDetails defines a boolean indicating if full details must be included
  36910. * @returns a string representation of the current mesh
  36911. */
  36912. toString(fullDetails?: boolean): string;
  36913. /**
  36914. * @hidden
  36915. */
  36916. protected _getEffectiveParent(): Nullable<Node>;
  36917. /** @hidden */
  36918. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36919. /** @hidden */
  36920. _rebuild(): void;
  36921. /** @hidden */
  36922. _resyncLightSources(): void;
  36923. /** @hidden */
  36924. _resyncLightSource(light: Light): void;
  36925. /** @hidden */
  36926. _unBindEffect(): void;
  36927. /** @hidden */
  36928. _removeLightSource(light: Light, dispose: boolean): void;
  36929. private _markSubMeshesAsDirty;
  36930. /** @hidden */
  36931. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  36932. /** @hidden */
  36933. _markSubMeshesAsAttributesDirty(): void;
  36934. /** @hidden */
  36935. _markSubMeshesAsMiscDirty(): void;
  36936. /**
  36937. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  36938. */
  36939. get scaling(): Vector3;
  36940. set scaling(newScaling: Vector3);
  36941. /**
  36942. * Returns true if the mesh is blocked. Implemented by child classes
  36943. */
  36944. get isBlocked(): boolean;
  36945. /**
  36946. * Returns the mesh itself by default. Implemented by child classes
  36947. * @param camera defines the camera to use to pick the right LOD level
  36948. * @returns the currentAbstractMesh
  36949. */
  36950. getLOD(camera: Camera): Nullable<AbstractMesh>;
  36951. /**
  36952. * Returns 0 by default. Implemented by child classes
  36953. * @returns an integer
  36954. */
  36955. getTotalVertices(): number;
  36956. /**
  36957. * Returns a positive integer : the total number of indices in this mesh geometry.
  36958. * @returns the number of indices or zero if the mesh has no geometry.
  36959. */
  36960. getTotalIndices(): number;
  36961. /**
  36962. * Returns null by default. Implemented by child classes
  36963. * @returns null
  36964. */
  36965. getIndices(): Nullable<IndicesArray>;
  36966. /**
  36967. * Returns the array of the requested vertex data kind. Implemented by child classes
  36968. * @param kind defines the vertex data kind to use
  36969. * @returns null
  36970. */
  36971. getVerticesData(kind: string): Nullable<FloatArray>;
  36972. /**
  36973. * Sets the vertex data of the mesh geometry for the requested `kind`.
  36974. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  36975. * Note that a new underlying VertexBuffer object is created each call.
  36976. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  36977. * @param kind defines vertex data kind:
  36978. * * VertexBuffer.PositionKind
  36979. * * VertexBuffer.UVKind
  36980. * * VertexBuffer.UV2Kind
  36981. * * VertexBuffer.UV3Kind
  36982. * * VertexBuffer.UV4Kind
  36983. * * VertexBuffer.UV5Kind
  36984. * * VertexBuffer.UV6Kind
  36985. * * VertexBuffer.ColorKind
  36986. * * VertexBuffer.MatricesIndicesKind
  36987. * * VertexBuffer.MatricesIndicesExtraKind
  36988. * * VertexBuffer.MatricesWeightsKind
  36989. * * VertexBuffer.MatricesWeightsExtraKind
  36990. * @param data defines the data source
  36991. * @param updatable defines if the data must be flagged as updatable (or static)
  36992. * @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
  36993. * @returns the current mesh
  36994. */
  36995. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  36996. /**
  36997. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  36998. * If the mesh has no geometry, it is simply returned as it is.
  36999. * @param kind defines vertex data kind:
  37000. * * VertexBuffer.PositionKind
  37001. * * VertexBuffer.UVKind
  37002. * * VertexBuffer.UV2Kind
  37003. * * VertexBuffer.UV3Kind
  37004. * * VertexBuffer.UV4Kind
  37005. * * VertexBuffer.UV5Kind
  37006. * * VertexBuffer.UV6Kind
  37007. * * VertexBuffer.ColorKind
  37008. * * VertexBuffer.MatricesIndicesKind
  37009. * * VertexBuffer.MatricesIndicesExtraKind
  37010. * * VertexBuffer.MatricesWeightsKind
  37011. * * VertexBuffer.MatricesWeightsExtraKind
  37012. * @param data defines the data source
  37013. * @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
  37014. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  37015. * @returns the current mesh
  37016. */
  37017. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  37018. /**
  37019. * Sets the mesh indices,
  37020. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  37021. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  37022. * @param totalVertices Defines the total number of vertices
  37023. * @returns the current mesh
  37024. */
  37025. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  37026. /**
  37027. * Gets a boolean indicating if specific vertex data is present
  37028. * @param kind defines the vertex data kind to use
  37029. * @returns true is data kind is present
  37030. */
  37031. isVerticesDataPresent(kind: string): boolean;
  37032. /**
  37033. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  37034. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  37035. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  37036. * @returns a BoundingInfo
  37037. */
  37038. getBoundingInfo(): BoundingInfo;
  37039. /**
  37040. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  37041. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  37042. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  37043. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  37044. * @returns the current mesh
  37045. */
  37046. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  37047. /**
  37048. * Overwrite the current bounding info
  37049. * @param boundingInfo defines the new bounding info
  37050. * @returns the current mesh
  37051. */
  37052. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  37053. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  37054. get useBones(): boolean;
  37055. /** @hidden */
  37056. _preActivate(): void;
  37057. /** @hidden */
  37058. _preActivateForIntermediateRendering(renderId: number): void;
  37059. /** @hidden */
  37060. _activate(renderId: number, intermediateRendering: boolean): boolean;
  37061. /** @hidden */
  37062. _postActivate(): void;
  37063. /** @hidden */
  37064. _freeze(): void;
  37065. /** @hidden */
  37066. _unFreeze(): void;
  37067. /**
  37068. * Gets the current world matrix
  37069. * @returns a Matrix
  37070. */
  37071. getWorldMatrix(): Matrix;
  37072. /** @hidden */
  37073. _getWorldMatrixDeterminant(): number;
  37074. /**
  37075. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  37076. */
  37077. get isAnInstance(): boolean;
  37078. /**
  37079. * Gets a boolean indicating if this mesh has instances
  37080. */
  37081. get hasInstances(): boolean;
  37082. /**
  37083. * Gets a boolean indicating if this mesh has thin instances
  37084. */
  37085. get hasThinInstances(): boolean;
  37086. /**
  37087. * Perform relative position change from the point of view of behind the front of the mesh.
  37088. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37089. * Supports definition of mesh facing forward or backward
  37090. * @param amountRight defines the distance on the right axis
  37091. * @param amountUp defines the distance on the up axis
  37092. * @param amountForward defines the distance on the forward axis
  37093. * @returns the current mesh
  37094. */
  37095. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  37096. /**
  37097. * Calculate relative position change from the point of view of behind the front of the mesh.
  37098. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37099. * Supports definition of mesh facing forward or backward
  37100. * @param amountRight defines the distance on the right axis
  37101. * @param amountUp defines the distance on the up axis
  37102. * @param amountForward defines the distance on the forward axis
  37103. * @returns the new displacement vector
  37104. */
  37105. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  37106. /**
  37107. * Perform relative rotation change from the point of view of behind the front of the mesh.
  37108. * Supports definition of mesh facing forward or backward
  37109. * @param flipBack defines the flip
  37110. * @param twirlClockwise defines the twirl
  37111. * @param tiltRight defines the tilt
  37112. * @returns the current mesh
  37113. */
  37114. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  37115. /**
  37116. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  37117. * Supports definition of mesh facing forward or backward.
  37118. * @param flipBack defines the flip
  37119. * @param twirlClockwise defines the twirl
  37120. * @param tiltRight defines the tilt
  37121. * @returns the new rotation vector
  37122. */
  37123. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  37124. /**
  37125. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  37126. * This means the mesh underlying bounding box and sphere are recomputed.
  37127. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  37128. * @returns the current mesh
  37129. */
  37130. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  37131. /** @hidden */
  37132. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  37133. /** @hidden */
  37134. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  37135. /** @hidden */
  37136. _updateBoundingInfo(): AbstractMesh;
  37137. /** @hidden */
  37138. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  37139. /** @hidden */
  37140. protected _afterComputeWorldMatrix(): void;
  37141. /** @hidden */
  37142. get _effectiveMesh(): AbstractMesh;
  37143. /**
  37144. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  37145. * A mesh is in the frustum if its bounding box intersects the frustum
  37146. * @param frustumPlanes defines the frustum to test
  37147. * @returns true if the mesh is in the frustum planes
  37148. */
  37149. isInFrustum(frustumPlanes: Plane[]): boolean;
  37150. /**
  37151. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  37152. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  37153. * @param frustumPlanes defines the frustum to test
  37154. * @returns true if the mesh is completely in the frustum planes
  37155. */
  37156. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  37157. /**
  37158. * True if the mesh intersects another mesh or a SolidParticle object
  37159. * @param mesh defines a target mesh or SolidParticle to test
  37160. * @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)
  37161. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  37162. * @returns true if there is an intersection
  37163. */
  37164. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  37165. /**
  37166. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  37167. * @param point defines the point to test
  37168. * @returns true if there is an intersection
  37169. */
  37170. intersectsPoint(point: Vector3): boolean;
  37171. /**
  37172. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  37173. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37174. */
  37175. get checkCollisions(): boolean;
  37176. set checkCollisions(collisionEnabled: boolean);
  37177. /**
  37178. * Gets Collider object used to compute collisions (not physics)
  37179. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37180. */
  37181. get collider(): Nullable<Collider>;
  37182. /**
  37183. * Move the mesh using collision engine
  37184. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37185. * @param displacement defines the requested displacement vector
  37186. * @returns the current mesh
  37187. */
  37188. moveWithCollisions(displacement: Vector3): AbstractMesh;
  37189. private _onCollisionPositionChange;
  37190. /** @hidden */
  37191. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  37192. /** @hidden */
  37193. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  37194. /** @hidden */
  37195. _checkCollision(collider: Collider): AbstractMesh;
  37196. /** @hidden */
  37197. _generatePointsArray(): boolean;
  37198. /**
  37199. * Checks if the passed Ray intersects with the mesh
  37200. * @param ray defines the ray to use
  37201. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  37202. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37203. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  37204. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  37205. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  37206. * @returns the picking info
  37207. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  37208. */
  37209. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  37210. /**
  37211. * Clones the current mesh
  37212. * @param name defines the mesh name
  37213. * @param newParent defines the new mesh parent
  37214. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  37215. * @returns the new mesh
  37216. */
  37217. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  37218. /**
  37219. * Disposes all the submeshes of the current meshnp
  37220. * @returns the current mesh
  37221. */
  37222. releaseSubMeshes(): AbstractMesh;
  37223. /**
  37224. * Releases resources associated with this abstract mesh.
  37225. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37226. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37227. */
  37228. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37229. /**
  37230. * Adds the passed mesh as a child to the current mesh
  37231. * @param mesh defines the child mesh
  37232. * @returns the current mesh
  37233. */
  37234. addChild(mesh: AbstractMesh): AbstractMesh;
  37235. /**
  37236. * Removes the passed mesh from the current mesh children list
  37237. * @param mesh defines the child mesh
  37238. * @returns the current mesh
  37239. */
  37240. removeChild(mesh: AbstractMesh): AbstractMesh;
  37241. /** @hidden */
  37242. private _initFacetData;
  37243. /**
  37244. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  37245. * This method can be called within the render loop.
  37246. * 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
  37247. * @returns the current mesh
  37248. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37249. */
  37250. updateFacetData(): AbstractMesh;
  37251. /**
  37252. * Returns the facetLocalNormals array.
  37253. * The normals are expressed in the mesh local spac
  37254. * @returns an array of Vector3
  37255. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37256. */
  37257. getFacetLocalNormals(): Vector3[];
  37258. /**
  37259. * Returns the facetLocalPositions array.
  37260. * The facet positions are expressed in the mesh local space
  37261. * @returns an array of Vector3
  37262. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37263. */
  37264. getFacetLocalPositions(): Vector3[];
  37265. /**
  37266. * Returns the facetLocalPartitioning array
  37267. * @returns an array of array of numbers
  37268. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37269. */
  37270. getFacetLocalPartitioning(): number[][];
  37271. /**
  37272. * Returns the i-th facet position in the world system.
  37273. * This method allocates a new Vector3 per call
  37274. * @param i defines the facet index
  37275. * @returns a new Vector3
  37276. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37277. */
  37278. getFacetPosition(i: number): Vector3;
  37279. /**
  37280. * Sets the reference Vector3 with the i-th facet position in the world system
  37281. * @param i defines the facet index
  37282. * @param ref defines the target vector
  37283. * @returns the current mesh
  37284. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37285. */
  37286. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  37287. /**
  37288. * Returns the i-th facet normal in the world system.
  37289. * This method allocates a new Vector3 per call
  37290. * @param i defines the facet index
  37291. * @returns a new Vector3
  37292. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37293. */
  37294. getFacetNormal(i: number): Vector3;
  37295. /**
  37296. * Sets the reference Vector3 with the i-th facet normal in the world system
  37297. * @param i defines the facet index
  37298. * @param ref defines the target vector
  37299. * @returns the current mesh
  37300. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37301. */
  37302. getFacetNormalToRef(i: number, ref: Vector3): this;
  37303. /**
  37304. * 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)
  37305. * @param x defines x coordinate
  37306. * @param y defines y coordinate
  37307. * @param z defines z coordinate
  37308. * @returns the array of facet indexes
  37309. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37310. */
  37311. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  37312. /**
  37313. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  37314. * @param projected sets as the (x,y,z) world projection on the facet
  37315. * @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
  37316. * @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
  37317. * @param x defines x coordinate
  37318. * @param y defines y coordinate
  37319. * @param z defines z coordinate
  37320. * @returns the face index if found (or null instead)
  37321. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37322. */
  37323. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37324. /**
  37325. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  37326. * @param projected sets as the (x,y,z) local projection on the facet
  37327. * @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
  37328. * @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
  37329. * @param x defines x coordinate
  37330. * @param y defines y coordinate
  37331. * @param z defines z coordinate
  37332. * @returns the face index if found (or null instead)
  37333. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37334. */
  37335. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37336. /**
  37337. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  37338. * @returns the parameters
  37339. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37340. */
  37341. getFacetDataParameters(): any;
  37342. /**
  37343. * Disables the feature FacetData and frees the related memory
  37344. * @returns the current mesh
  37345. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37346. */
  37347. disableFacetData(): AbstractMesh;
  37348. /**
  37349. * Updates the AbstractMesh indices array
  37350. * @param indices defines the data source
  37351. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  37352. * @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)
  37353. * @returns the current mesh
  37354. */
  37355. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  37356. /**
  37357. * Creates new normals data for the mesh
  37358. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  37359. * @returns the current mesh
  37360. */
  37361. createNormals(updatable: boolean): AbstractMesh;
  37362. /**
  37363. * Align the mesh with a normal
  37364. * @param normal defines the normal to use
  37365. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  37366. * @returns the current mesh
  37367. */
  37368. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  37369. /** @hidden */
  37370. _checkOcclusionQuery(): boolean;
  37371. /**
  37372. * Disables the mesh edge rendering mode
  37373. * @returns the currentAbstractMesh
  37374. */
  37375. disableEdgesRendering(): AbstractMesh;
  37376. /**
  37377. * Enables the edge rendering mode on the mesh.
  37378. * This mode makes the mesh edges visible
  37379. * @param epsilon defines the maximal distance between two angles to detect a face
  37380. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  37381. * @param options options to the edge renderer
  37382. * @returns the currentAbstractMesh
  37383. * @see https://www.babylonjs-playground.com/#19O9TU#0
  37384. */
  37385. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  37386. /**
  37387. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  37388. * @returns an array of particle systems in the scene that use the mesh as an emitter
  37389. */
  37390. getConnectedParticleSystems(): IParticleSystem[];
  37391. }
  37392. }
  37393. declare module BABYLON {
  37394. /**
  37395. * Interface used to define ActionEvent
  37396. */
  37397. export interface IActionEvent {
  37398. /** The mesh or sprite that triggered the action */
  37399. source: any;
  37400. /** The X mouse cursor position at the time of the event */
  37401. pointerX: number;
  37402. /** The Y mouse cursor position at the time of the event */
  37403. pointerY: number;
  37404. /** The mesh that is currently pointed at (can be null) */
  37405. meshUnderPointer: Nullable<AbstractMesh>;
  37406. /** the original (browser) event that triggered the ActionEvent */
  37407. sourceEvent?: any;
  37408. /** additional data for the event */
  37409. additionalData?: any;
  37410. }
  37411. /**
  37412. * ActionEvent is the event being sent when an action is triggered.
  37413. */
  37414. export class ActionEvent implements IActionEvent {
  37415. /** The mesh or sprite that triggered the action */
  37416. source: any;
  37417. /** The X mouse cursor position at the time of the event */
  37418. pointerX: number;
  37419. /** The Y mouse cursor position at the time of the event */
  37420. pointerY: number;
  37421. /** The mesh that is currently pointed at (can be null) */
  37422. meshUnderPointer: Nullable<AbstractMesh>;
  37423. /** the original (browser) event that triggered the ActionEvent */
  37424. sourceEvent?: any;
  37425. /** additional data for the event */
  37426. additionalData?: any;
  37427. /**
  37428. * Creates a new ActionEvent
  37429. * @param source The mesh or sprite that triggered the action
  37430. * @param pointerX The X mouse cursor position at the time of the event
  37431. * @param pointerY The Y mouse cursor position at the time of the event
  37432. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  37433. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  37434. * @param additionalData additional data for the event
  37435. */
  37436. constructor(
  37437. /** The mesh or sprite that triggered the action */
  37438. source: any,
  37439. /** The X mouse cursor position at the time of the event */
  37440. pointerX: number,
  37441. /** The Y mouse cursor position at the time of the event */
  37442. pointerY: number,
  37443. /** The mesh that is currently pointed at (can be null) */
  37444. meshUnderPointer: Nullable<AbstractMesh>,
  37445. /** the original (browser) event that triggered the ActionEvent */
  37446. sourceEvent?: any,
  37447. /** additional data for the event */
  37448. additionalData?: any);
  37449. /**
  37450. * Helper function to auto-create an ActionEvent from a source mesh.
  37451. * @param source The source mesh that triggered the event
  37452. * @param evt The original (browser) event
  37453. * @param additionalData additional data for the event
  37454. * @returns the new ActionEvent
  37455. */
  37456. static CreateNew(source: AbstractMesh, evt?: IEvent, additionalData?: any): ActionEvent;
  37457. /**
  37458. * Helper function to auto-create an ActionEvent from a source sprite
  37459. * @param source The source sprite that triggered the event
  37460. * @param scene Scene associated with the sprite
  37461. * @param evt The original (browser) event
  37462. * @param additionalData additional data for the event
  37463. * @returns the new ActionEvent
  37464. */
  37465. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: IEvent, additionalData?: any): ActionEvent;
  37466. /**
  37467. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  37468. * @param scene the scene where the event occurred
  37469. * @param evt The original (browser) event
  37470. * @returns the new ActionEvent
  37471. */
  37472. static CreateNewFromScene(scene: Scene, evt: IEvent): ActionEvent;
  37473. /**
  37474. * Helper function to auto-create an ActionEvent from a primitive
  37475. * @param prim defines the target primitive
  37476. * @param pointerPos defines the pointer position
  37477. * @param evt The original (browser) event
  37478. * @param additionalData additional data for the event
  37479. * @returns the new ActionEvent
  37480. */
  37481. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  37482. }
  37483. }
  37484. declare module BABYLON {
  37485. /**
  37486. * Abstract class used to decouple action Manager from scene and meshes.
  37487. * Do not instantiate.
  37488. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  37489. */
  37490. export abstract class AbstractActionManager implements IDisposable {
  37491. /** Gets the list of active triggers */
  37492. static Triggers: {
  37493. [key: string]: number;
  37494. };
  37495. /** Gets the cursor to use when hovering items */
  37496. hoverCursor: string;
  37497. /** Gets the list of actions */
  37498. actions: IAction[];
  37499. /**
  37500. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  37501. */
  37502. isRecursive: boolean;
  37503. /**
  37504. * Releases all associated resources
  37505. */
  37506. abstract dispose(): void;
  37507. /**
  37508. * Does this action manager has pointer triggers
  37509. */
  37510. abstract get hasPointerTriggers(): boolean;
  37511. /**
  37512. * Does this action manager has pick triggers
  37513. */
  37514. abstract get hasPickTriggers(): boolean;
  37515. /**
  37516. * Process a specific trigger
  37517. * @param trigger defines the trigger to process
  37518. * @param evt defines the event details to be processed
  37519. */
  37520. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  37521. /**
  37522. * Does this action manager handles actions of any of the given triggers
  37523. * @param triggers defines the triggers to be tested
  37524. * @return a boolean indicating whether one (or more) of the triggers is handled
  37525. */
  37526. abstract hasSpecificTriggers(triggers: number[]): boolean;
  37527. /**
  37528. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  37529. * speed.
  37530. * @param triggerA defines the trigger to be tested
  37531. * @param triggerB defines the trigger to be tested
  37532. * @return a boolean indicating whether one (or more) of the triggers is handled
  37533. */
  37534. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  37535. /**
  37536. * Does this action manager handles actions of a given trigger
  37537. * @param trigger defines the trigger to be tested
  37538. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  37539. * @return whether the trigger is handled
  37540. */
  37541. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  37542. /**
  37543. * Serialize this manager to a JSON object
  37544. * @param name defines the property name to store this manager
  37545. * @returns a JSON representation of this manager
  37546. */
  37547. abstract serialize(name: string): any;
  37548. /**
  37549. * Registers an action to this action manager
  37550. * @param action defines the action to be registered
  37551. * @return the action amended (prepared) after registration
  37552. */
  37553. abstract registerAction(action: IAction): Nullable<IAction>;
  37554. /**
  37555. * Unregisters an action to this action manager
  37556. * @param action defines the action to be unregistered
  37557. * @return a boolean indicating whether the action has been unregistered
  37558. */
  37559. abstract unregisterAction(action: IAction): Boolean;
  37560. /**
  37561. * Does exist one action manager with at least one trigger
  37562. **/
  37563. static get HasTriggers(): boolean;
  37564. /**
  37565. * Does exist one action manager with at least one pick trigger
  37566. **/
  37567. static get HasPickTriggers(): boolean;
  37568. /**
  37569. * Does exist one action manager that handles actions of a given trigger
  37570. * @param trigger defines the trigger to be tested
  37571. * @return a boolean indicating whether the trigger is handled by at least one action manager
  37572. **/
  37573. static HasSpecificTrigger(trigger: number): boolean;
  37574. }
  37575. }
  37576. declare module BABYLON {
  37577. /**
  37578. * Defines how a node can be built from a string name.
  37579. */
  37580. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  37581. /**
  37582. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  37583. */
  37584. export class Node implements IBehaviorAware<Node> {
  37585. /** @hidden */
  37586. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  37587. private static _NodeConstructors;
  37588. /**
  37589. * Add a new node constructor
  37590. * @param type defines the type name of the node to construct
  37591. * @param constructorFunc defines the constructor function
  37592. */
  37593. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  37594. /**
  37595. * Returns a node constructor based on type name
  37596. * @param type defines the type name
  37597. * @param name defines the new node name
  37598. * @param scene defines the hosting scene
  37599. * @param options defines optional options to transmit to constructors
  37600. * @returns the new constructor or null
  37601. */
  37602. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  37603. /**
  37604. * Gets or sets the name of the node
  37605. */
  37606. name: string;
  37607. /**
  37608. * Gets or sets the id of the node
  37609. */
  37610. id: string;
  37611. /**
  37612. * Gets or sets the unique id of the node
  37613. */
  37614. uniqueId: number;
  37615. /**
  37616. * Gets or sets a string used to store user defined state for the node
  37617. */
  37618. state: string;
  37619. /**
  37620. * Gets or sets an object used to store user defined information for the node
  37621. */
  37622. metadata: any;
  37623. /**
  37624. * For internal use only. Please do not use.
  37625. */
  37626. reservedDataStore: any;
  37627. /**
  37628. * List of inspectable custom properties (used by the Inspector)
  37629. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  37630. */
  37631. inspectableCustomProperties: IInspectable[];
  37632. private _doNotSerialize;
  37633. /**
  37634. * Gets or sets a boolean used to define if the node must be serialized
  37635. */
  37636. get doNotSerialize(): boolean;
  37637. set doNotSerialize(value: boolean);
  37638. /** @hidden */
  37639. _isDisposed: boolean;
  37640. /**
  37641. * Gets a list of Animations associated with the node
  37642. */
  37643. animations: Animation[];
  37644. protected _ranges: {
  37645. [name: string]: Nullable<AnimationRange>;
  37646. };
  37647. /**
  37648. * Callback raised when the node is ready to be used
  37649. */
  37650. onReady: Nullable<(node: Node) => void>;
  37651. private _isEnabled;
  37652. private _isParentEnabled;
  37653. private _isReady;
  37654. /** @hidden */
  37655. _currentRenderId: number;
  37656. private _parentUpdateId;
  37657. /** @hidden */
  37658. _childUpdateId: number;
  37659. /** @hidden */
  37660. _waitingParentId: Nullable<string>;
  37661. /** @hidden */
  37662. _scene: Scene;
  37663. /** @hidden */
  37664. _cache: any;
  37665. private _parentNode;
  37666. private _children;
  37667. /** @hidden */
  37668. _worldMatrix: Matrix;
  37669. /** @hidden */
  37670. _worldMatrixDeterminant: number;
  37671. /** @hidden */
  37672. _worldMatrixDeterminantIsDirty: boolean;
  37673. /** @hidden */
  37674. private _sceneRootNodesIndex;
  37675. /**
  37676. * Gets a boolean indicating if the node has been disposed
  37677. * @returns true if the node was disposed
  37678. */
  37679. isDisposed(): boolean;
  37680. /**
  37681. * Gets or sets the parent of the node (without keeping the current position in the scene)
  37682. * @see https://doc.babylonjs.com/how_to/parenting
  37683. */
  37684. set parent(parent: Nullable<Node>);
  37685. get parent(): Nullable<Node>;
  37686. /** @hidden */
  37687. _addToSceneRootNodes(): void;
  37688. /** @hidden */
  37689. _removeFromSceneRootNodes(): void;
  37690. private _animationPropertiesOverride;
  37691. /**
  37692. * Gets or sets the animation properties override
  37693. */
  37694. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  37695. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  37696. /**
  37697. * Gets a string identifying the name of the class
  37698. * @returns "Node" string
  37699. */
  37700. getClassName(): string;
  37701. /** @hidden */
  37702. readonly _isNode: boolean;
  37703. /**
  37704. * An event triggered when the mesh is disposed
  37705. */
  37706. onDisposeObservable: Observable<Node>;
  37707. private _onDisposeObserver;
  37708. /**
  37709. * Sets a callback that will be raised when the node will be disposed
  37710. */
  37711. set onDispose(callback: () => void);
  37712. /**
  37713. * Creates a new Node
  37714. * @param name the name and id to be given to this node
  37715. * @param scene the scene this node will be added to
  37716. */
  37717. constructor(name: string, scene?: Nullable<Scene>);
  37718. /**
  37719. * Gets the scene of the node
  37720. * @returns a scene
  37721. */
  37722. getScene(): Scene;
  37723. /**
  37724. * Gets the engine of the node
  37725. * @returns a Engine
  37726. */
  37727. getEngine(): Engine;
  37728. private _behaviors;
  37729. /**
  37730. * Attach a behavior to the node
  37731. * @see https://doc.babylonjs.com/features/behaviour
  37732. * @param behavior defines the behavior to attach
  37733. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  37734. * @returns the current Node
  37735. */
  37736. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  37737. /**
  37738. * Remove an attached behavior
  37739. * @see https://doc.babylonjs.com/features/behaviour
  37740. * @param behavior defines the behavior to attach
  37741. * @returns the current Node
  37742. */
  37743. removeBehavior(behavior: Behavior<Node>): Node;
  37744. /**
  37745. * Gets the list of attached behaviors
  37746. * @see https://doc.babylonjs.com/features/behaviour
  37747. */
  37748. get behaviors(): Behavior<Node>[];
  37749. /**
  37750. * Gets an attached behavior by name
  37751. * @param name defines the name of the behavior to look for
  37752. * @see https://doc.babylonjs.com/features/behaviour
  37753. * @returns null if behavior was not found else the requested behavior
  37754. */
  37755. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  37756. /**
  37757. * Returns the latest update of the World matrix
  37758. * @returns a Matrix
  37759. */
  37760. getWorldMatrix(): Matrix;
  37761. /** @hidden */
  37762. _getWorldMatrixDeterminant(): number;
  37763. /**
  37764. * Returns directly the latest state of the mesh World matrix.
  37765. * A Matrix is returned.
  37766. */
  37767. get worldMatrixFromCache(): Matrix;
  37768. /** @hidden */
  37769. _initCache(): void;
  37770. /** @hidden */
  37771. updateCache(force?: boolean): void;
  37772. /** @hidden */
  37773. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37774. /** @hidden */
  37775. _updateCache(ignoreParentClass?: boolean): void;
  37776. /** @hidden */
  37777. _isSynchronized(): boolean;
  37778. /** @hidden */
  37779. _markSyncedWithParent(): void;
  37780. /** @hidden */
  37781. isSynchronizedWithParent(): boolean;
  37782. /** @hidden */
  37783. isSynchronized(): boolean;
  37784. /**
  37785. * Is this node ready to be used/rendered
  37786. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  37787. * @return true if the node is ready
  37788. */
  37789. isReady(completeCheck?: boolean): boolean;
  37790. /**
  37791. * Is this node enabled?
  37792. * 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
  37793. * @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
  37794. * @return whether this node (and its parent) is enabled
  37795. */
  37796. isEnabled(checkAncestors?: boolean): boolean;
  37797. /** @hidden */
  37798. protected _syncParentEnabledState(): void;
  37799. /**
  37800. * Set the enabled state of this node
  37801. * @param value defines the new enabled state
  37802. */
  37803. setEnabled(value: boolean): void;
  37804. /**
  37805. * Is this node a descendant of the given node?
  37806. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  37807. * @param ancestor defines the parent node to inspect
  37808. * @returns a boolean indicating if this node is a descendant of the given node
  37809. */
  37810. isDescendantOf(ancestor: Node): boolean;
  37811. /** @hidden */
  37812. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  37813. /**
  37814. * Will return all nodes that have this node as ascendant
  37815. * @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
  37816. * @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
  37817. * @return all children nodes of all types
  37818. */
  37819. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  37820. /**
  37821. * Get all child-meshes of this node
  37822. * @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)
  37823. * @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
  37824. * @returns an array of AbstractMesh
  37825. */
  37826. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  37827. /**
  37828. * Get all direct children of this node
  37829. * @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
  37830. * @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)
  37831. * @returns an array of Node
  37832. */
  37833. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  37834. /** @hidden */
  37835. _setReady(state: boolean): void;
  37836. /**
  37837. * Get an animation by name
  37838. * @param name defines the name of the animation to look for
  37839. * @returns null if not found else the requested animation
  37840. */
  37841. getAnimationByName(name: string): Nullable<Animation>;
  37842. /**
  37843. * Creates an animation range for this node
  37844. * @param name defines the name of the range
  37845. * @param from defines the starting key
  37846. * @param to defines the end key
  37847. */
  37848. createAnimationRange(name: string, from: number, to: number): void;
  37849. /**
  37850. * Delete a specific animation range
  37851. * @param name defines the name of the range to delete
  37852. * @param deleteFrames defines if animation frames from the range must be deleted as well
  37853. */
  37854. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  37855. /**
  37856. * Get an animation range by name
  37857. * @param name defines the name of the animation range to look for
  37858. * @returns null if not found else the requested animation range
  37859. */
  37860. getAnimationRange(name: string): Nullable<AnimationRange>;
  37861. /**
  37862. * Gets the list of all animation ranges defined on this node
  37863. * @returns an array
  37864. */
  37865. getAnimationRanges(): Nullable<AnimationRange>[];
  37866. /**
  37867. * Will start the animation sequence
  37868. * @param name defines the range frames for animation sequence
  37869. * @param loop defines if the animation should loop (false by default)
  37870. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  37871. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  37872. * @returns the object created for this animation. If range does not exist, it will return null
  37873. */
  37874. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  37875. /**
  37876. * Serialize animation ranges into a JSON compatible object
  37877. * @returns serialization object
  37878. */
  37879. serializeAnimationRanges(): any;
  37880. /**
  37881. * Computes the world matrix of the node
  37882. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  37883. * @returns the world matrix
  37884. */
  37885. computeWorldMatrix(force?: boolean): Matrix;
  37886. /**
  37887. * Releases resources associated with this node.
  37888. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37889. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37890. */
  37891. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37892. /**
  37893. * Parse animation range data from a serialization object and store them into a given node
  37894. * @param node defines where to store the animation ranges
  37895. * @param parsedNode defines the serialization object to read data from
  37896. * @param scene defines the hosting scene
  37897. */
  37898. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  37899. /**
  37900. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  37901. * @param includeDescendants Include bounding info from descendants as well (true by default)
  37902. * @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
  37903. * @returns the new bounding vectors
  37904. */
  37905. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  37906. min: Vector3;
  37907. max: Vector3;
  37908. };
  37909. }
  37910. }
  37911. declare module BABYLON {
  37912. /**
  37913. * @hidden
  37914. */
  37915. export class _IAnimationState {
  37916. key: number;
  37917. repeatCount: number;
  37918. workValue?: any;
  37919. loopMode?: number;
  37920. offsetValue?: any;
  37921. highLimitValue?: any;
  37922. }
  37923. /**
  37924. * Class used to store any kind of animation
  37925. */
  37926. export class Animation {
  37927. /**Name of the animation */
  37928. name: string;
  37929. /**Property to animate */
  37930. targetProperty: string;
  37931. /**The frames per second of the animation */
  37932. framePerSecond: number;
  37933. /**The data type of the animation */
  37934. dataType: number;
  37935. /**The loop mode of the animation */
  37936. loopMode?: number | undefined;
  37937. /**Specifies if blending should be enabled */
  37938. enableBlending?: boolean | undefined;
  37939. /**
  37940. * Use matrix interpolation instead of using direct key value when animating matrices
  37941. */
  37942. static AllowMatricesInterpolation: boolean;
  37943. /**
  37944. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  37945. */
  37946. static AllowMatrixDecomposeForInterpolation: boolean;
  37947. /** Define the Url to load snippets */
  37948. static SnippetUrl: string;
  37949. /** Snippet ID if the animation was created from the snippet server */
  37950. snippetId: string;
  37951. /**
  37952. * Stores the key frames of the animation
  37953. */
  37954. private _keys;
  37955. /**
  37956. * Stores the easing function of the animation
  37957. */
  37958. private _easingFunction;
  37959. /**
  37960. * @hidden Internal use only
  37961. */
  37962. _runtimeAnimations: RuntimeAnimation[];
  37963. /**
  37964. * The set of event that will be linked to this animation
  37965. */
  37966. private _events;
  37967. /**
  37968. * Stores an array of target property paths
  37969. */
  37970. targetPropertyPath: string[];
  37971. /**
  37972. * Stores the blending speed of the animation
  37973. */
  37974. blendingSpeed: number;
  37975. /**
  37976. * Stores the animation ranges for the animation
  37977. */
  37978. private _ranges;
  37979. /**
  37980. * @hidden Internal use
  37981. */
  37982. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  37983. /**
  37984. * Sets up an animation
  37985. * @param property The property to animate
  37986. * @param animationType The animation type to apply
  37987. * @param framePerSecond The frames per second of the animation
  37988. * @param easingFunction The easing function used in the animation
  37989. * @returns The created animation
  37990. */
  37991. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  37992. /**
  37993. * Create and start an animation on a node
  37994. * @param name defines the name of the global animation that will be run on all nodes
  37995. * @param node defines the root node where the animation will take place
  37996. * @param targetProperty defines property to animate
  37997. * @param framePerSecond defines the number of frame per second yo use
  37998. * @param totalFrame defines the number of frames in total
  37999. * @param from defines the initial value
  38000. * @param to defines the final value
  38001. * @param loopMode defines which loop mode you want to use (off by default)
  38002. * @param easingFunction defines the easing function to use (linear by default)
  38003. * @param onAnimationEnd defines the callback to call when animation end
  38004. * @returns the animatable created for this animation
  38005. */
  38006. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  38007. /**
  38008. * Create and start an animation on a node and its descendants
  38009. * @param name defines the name of the global animation that will be run on all nodes
  38010. * @param node defines the root node where the animation will take place
  38011. * @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
  38012. * @param targetProperty defines property to animate
  38013. * @param framePerSecond defines the number of frame per second to use
  38014. * @param totalFrame defines the number of frames in total
  38015. * @param from defines the initial value
  38016. * @param to defines the final value
  38017. * @param loopMode defines which loop mode you want to use (off by default)
  38018. * @param easingFunction defines the easing function to use (linear by default)
  38019. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  38020. * @returns the list of animatables created for all nodes
  38021. * @example https://www.babylonjs-playground.com/#MH0VLI
  38022. */
  38023. 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[]>;
  38024. /**
  38025. * Creates a new animation, merges it with the existing animations and starts it
  38026. * @param name Name of the animation
  38027. * @param node Node which contains the scene that begins the animations
  38028. * @param targetProperty Specifies which property to animate
  38029. * @param framePerSecond The frames per second of the animation
  38030. * @param totalFrame The total number of frames
  38031. * @param from The frame at the beginning of the animation
  38032. * @param to The frame at the end of the animation
  38033. * @param loopMode Specifies the loop mode of the animation
  38034. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  38035. * @param onAnimationEnd Callback to run once the animation is complete
  38036. * @returns Nullable animation
  38037. */
  38038. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  38039. /**
  38040. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38041. * @param sourceAnimation defines the Animation containing keyframes to convert
  38042. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38043. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  38044. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  38045. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  38046. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  38047. */
  38048. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  38049. /**
  38050. * Transition property of an host to the target Value
  38051. * @param property The property to transition
  38052. * @param targetValue The target Value of the property
  38053. * @param host The object where the property to animate belongs
  38054. * @param scene Scene used to run the animation
  38055. * @param frameRate Framerate (in frame/s) to use
  38056. * @param transition The transition type we want to use
  38057. * @param duration The duration of the animation, in milliseconds
  38058. * @param onAnimationEnd Callback trigger at the end of the animation
  38059. * @returns Nullable animation
  38060. */
  38061. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  38062. /**
  38063. * Return the array of runtime animations currently using this animation
  38064. */
  38065. get runtimeAnimations(): RuntimeAnimation[];
  38066. /**
  38067. * Specifies if any of the runtime animations are currently running
  38068. */
  38069. get hasRunningRuntimeAnimations(): boolean;
  38070. /**
  38071. * Initializes the animation
  38072. * @param name Name of the animation
  38073. * @param targetProperty Property to animate
  38074. * @param framePerSecond The frames per second of the animation
  38075. * @param dataType The data type of the animation
  38076. * @param loopMode The loop mode of the animation
  38077. * @param enableBlending Specifies if blending should be enabled
  38078. */
  38079. constructor(
  38080. /**Name of the animation */
  38081. name: string,
  38082. /**Property to animate */
  38083. targetProperty: string,
  38084. /**The frames per second of the animation */
  38085. framePerSecond: number,
  38086. /**The data type of the animation */
  38087. dataType: number,
  38088. /**The loop mode of the animation */
  38089. loopMode?: number | undefined,
  38090. /**Specifies if blending should be enabled */
  38091. enableBlending?: boolean | undefined);
  38092. /**
  38093. * Converts the animation to a string
  38094. * @param fullDetails support for multiple levels of logging within scene loading
  38095. * @returns String form of the animation
  38096. */
  38097. toString(fullDetails?: boolean): string;
  38098. /**
  38099. * Add an event to this animation
  38100. * @param event Event to add
  38101. */
  38102. addEvent(event: AnimationEvent): void;
  38103. /**
  38104. * Remove all events found at the given frame
  38105. * @param frame The frame to remove events from
  38106. */
  38107. removeEvents(frame: number): void;
  38108. /**
  38109. * Retrieves all the events from the animation
  38110. * @returns Events from the animation
  38111. */
  38112. getEvents(): AnimationEvent[];
  38113. /**
  38114. * Creates an animation range
  38115. * @param name Name of the animation range
  38116. * @param from Starting frame of the animation range
  38117. * @param to Ending frame of the animation
  38118. */
  38119. createRange(name: string, from: number, to: number): void;
  38120. /**
  38121. * Deletes an animation range by name
  38122. * @param name Name of the animation range to delete
  38123. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  38124. */
  38125. deleteRange(name: string, deleteFrames?: boolean): void;
  38126. /**
  38127. * Gets the animation range by name, or null if not defined
  38128. * @param name Name of the animation range
  38129. * @returns Nullable animation range
  38130. */
  38131. getRange(name: string): Nullable<AnimationRange>;
  38132. /**
  38133. * Gets the key frames from the animation
  38134. * @returns The key frames of the animation
  38135. */
  38136. getKeys(): Array<IAnimationKey>;
  38137. /**
  38138. * Gets the highest frame rate of the animation
  38139. * @returns Highest frame rate of the animation
  38140. */
  38141. getHighestFrame(): number;
  38142. /**
  38143. * Gets the easing function of the animation
  38144. * @returns Easing function of the animation
  38145. */
  38146. getEasingFunction(): IEasingFunction;
  38147. /**
  38148. * Sets the easing function of the animation
  38149. * @param easingFunction A custom mathematical formula for animation
  38150. */
  38151. setEasingFunction(easingFunction: EasingFunction): void;
  38152. /**
  38153. * Interpolates a scalar linearly
  38154. * @param startValue Start value of the animation curve
  38155. * @param endValue End value of the animation curve
  38156. * @param gradient Scalar amount to interpolate
  38157. * @returns Interpolated scalar value
  38158. */
  38159. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  38160. /**
  38161. * Interpolates a scalar cubically
  38162. * @param startValue Start value of the animation curve
  38163. * @param outTangent End tangent of the animation
  38164. * @param endValue End value of the animation curve
  38165. * @param inTangent Start tangent of the animation curve
  38166. * @param gradient Scalar amount to interpolate
  38167. * @returns Interpolated scalar value
  38168. */
  38169. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  38170. /**
  38171. * Interpolates a quaternion using a spherical linear interpolation
  38172. * @param startValue Start value of the animation curve
  38173. * @param endValue End value of the animation curve
  38174. * @param gradient Scalar amount to interpolate
  38175. * @returns Interpolated quaternion value
  38176. */
  38177. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  38178. /**
  38179. * Interpolates a quaternion cubically
  38180. * @param startValue Start value of the animation curve
  38181. * @param outTangent End tangent of the animation curve
  38182. * @param endValue End value of the animation curve
  38183. * @param inTangent Start tangent of the animation curve
  38184. * @param gradient Scalar amount to interpolate
  38185. * @returns Interpolated quaternion value
  38186. */
  38187. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  38188. /**
  38189. * Interpolates a Vector3 linearly
  38190. * @param startValue Start value of the animation curve
  38191. * @param endValue End value of the animation curve
  38192. * @param gradient Scalar amount to interpolate
  38193. * @returns Interpolated scalar value
  38194. */
  38195. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  38196. /**
  38197. * Interpolates a Vector3 cubically
  38198. * @param startValue Start value of the animation curve
  38199. * @param outTangent End tangent of the animation
  38200. * @param endValue End value of the animation curve
  38201. * @param inTangent Start tangent of the animation curve
  38202. * @param gradient Scalar amount to interpolate
  38203. * @returns InterpolatedVector3 value
  38204. */
  38205. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  38206. /**
  38207. * Interpolates a Vector2 linearly
  38208. * @param startValue Start value of the animation curve
  38209. * @param endValue End value of the animation curve
  38210. * @param gradient Scalar amount to interpolate
  38211. * @returns Interpolated Vector2 value
  38212. */
  38213. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  38214. /**
  38215. * Interpolates a Vector2 cubically
  38216. * @param startValue Start value of the animation curve
  38217. * @param outTangent End tangent of the animation
  38218. * @param endValue End value of the animation curve
  38219. * @param inTangent Start tangent of the animation curve
  38220. * @param gradient Scalar amount to interpolate
  38221. * @returns Interpolated Vector2 value
  38222. */
  38223. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  38224. /**
  38225. * Interpolates a size linearly
  38226. * @param startValue Start value of the animation curve
  38227. * @param endValue End value of the animation curve
  38228. * @param gradient Scalar amount to interpolate
  38229. * @returns Interpolated Size value
  38230. */
  38231. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  38232. /**
  38233. * Interpolates a Color3 linearly
  38234. * @param startValue Start value of the animation curve
  38235. * @param endValue End value of the animation curve
  38236. * @param gradient Scalar amount to interpolate
  38237. * @returns Interpolated Color3 value
  38238. */
  38239. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  38240. /**
  38241. * Interpolates a Color4 linearly
  38242. * @param startValue Start value of the animation curve
  38243. * @param endValue End value of the animation curve
  38244. * @param gradient Scalar amount to interpolate
  38245. * @returns Interpolated Color3 value
  38246. */
  38247. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  38248. /**
  38249. * @hidden Internal use only
  38250. */
  38251. _getKeyValue(value: any): any;
  38252. /**
  38253. * @hidden Internal use only
  38254. */
  38255. _interpolate(currentFrame: number, state: _IAnimationState): any;
  38256. /**
  38257. * Defines the function to use to interpolate matrices
  38258. * @param startValue defines the start matrix
  38259. * @param endValue defines the end matrix
  38260. * @param gradient defines the gradient between both matrices
  38261. * @param result defines an optional target matrix where to store the interpolation
  38262. * @returns the interpolated matrix
  38263. */
  38264. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  38265. /**
  38266. * Makes a copy of the animation
  38267. * @returns Cloned animation
  38268. */
  38269. clone(): Animation;
  38270. /**
  38271. * Sets the key frames of the animation
  38272. * @param values The animation key frames to set
  38273. */
  38274. setKeys(values: Array<IAnimationKey>): void;
  38275. /**
  38276. * Serializes the animation to an object
  38277. * @returns Serialized object
  38278. */
  38279. serialize(): any;
  38280. /**
  38281. * Float animation type
  38282. */
  38283. static readonly ANIMATIONTYPE_FLOAT: number;
  38284. /**
  38285. * Vector3 animation type
  38286. */
  38287. static readonly ANIMATIONTYPE_VECTOR3: number;
  38288. /**
  38289. * Quaternion animation type
  38290. */
  38291. static readonly ANIMATIONTYPE_QUATERNION: number;
  38292. /**
  38293. * Matrix animation type
  38294. */
  38295. static readonly ANIMATIONTYPE_MATRIX: number;
  38296. /**
  38297. * Color3 animation type
  38298. */
  38299. static readonly ANIMATIONTYPE_COLOR3: number;
  38300. /**
  38301. * Color3 animation type
  38302. */
  38303. static readonly ANIMATIONTYPE_COLOR4: number;
  38304. /**
  38305. * Vector2 animation type
  38306. */
  38307. static readonly ANIMATIONTYPE_VECTOR2: number;
  38308. /**
  38309. * Size animation type
  38310. */
  38311. static readonly ANIMATIONTYPE_SIZE: number;
  38312. /**
  38313. * Relative Loop Mode
  38314. */
  38315. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  38316. /**
  38317. * Cycle Loop Mode
  38318. */
  38319. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  38320. /**
  38321. * Constant Loop Mode
  38322. */
  38323. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  38324. /** @hidden */
  38325. static _UniversalLerp(left: any, right: any, amount: number): any;
  38326. /**
  38327. * Parses an animation object and creates an animation
  38328. * @param parsedAnimation Parsed animation object
  38329. * @returns Animation object
  38330. */
  38331. static Parse(parsedAnimation: any): Animation;
  38332. /**
  38333. * Appends the serialized animations from the source animations
  38334. * @param source Source containing the animations
  38335. * @param destination Target to store the animations
  38336. */
  38337. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38338. /**
  38339. * Creates a new animation or an array of animations from a snippet saved in a remote file
  38340. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  38341. * @param url defines the url to load from
  38342. * @returns a promise that will resolve to the new animation or an array of animations
  38343. */
  38344. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  38345. /**
  38346. * Creates an animation or an array of animations from a snippet saved by the Inspector
  38347. * @param snippetId defines the snippet to load
  38348. * @returns a promise that will resolve to the new animation or a new array of animations
  38349. */
  38350. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  38351. }
  38352. }
  38353. declare module BABYLON {
  38354. /**
  38355. * Interface containing an array of animations
  38356. */
  38357. export interface IAnimatable {
  38358. /**
  38359. * Array of animations
  38360. */
  38361. animations: Nullable<Array<Animation>>;
  38362. }
  38363. }
  38364. declare module BABYLON {
  38365. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  38366. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38367. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38368. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38369. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38370. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38371. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38372. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38373. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38374. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38375. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38376. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38377. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38378. /**
  38379. * Decorator used to define property that can be serialized as reference to a camera
  38380. * @param sourceName defines the name of the property to decorate
  38381. */
  38382. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38383. /**
  38384. * Class used to help serialization objects
  38385. */
  38386. export class SerializationHelper {
  38387. /** @hidden */
  38388. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  38389. /** @hidden */
  38390. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  38391. /** @hidden */
  38392. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  38393. /** @hidden */
  38394. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  38395. /**
  38396. * Appends the serialized animations from the source animations
  38397. * @param source Source containing the animations
  38398. * @param destination Target to store the animations
  38399. */
  38400. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38401. /**
  38402. * Static function used to serialized a specific entity
  38403. * @param entity defines the entity to serialize
  38404. * @param serializationObject defines the optional target object where serialization data will be stored
  38405. * @returns a JSON compatible object representing the serialization of the entity
  38406. */
  38407. static Serialize<T>(entity: T, serializationObject?: any): any;
  38408. /**
  38409. * Creates a new entity from a serialization data object
  38410. * @param creationFunction defines a function used to instanciated the new entity
  38411. * @param source defines the source serialization data
  38412. * @param scene defines the hosting scene
  38413. * @param rootUrl defines the root url for resources
  38414. * @returns a new entity
  38415. */
  38416. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38417. /**
  38418. * Clones an object
  38419. * @param creationFunction defines the function used to instanciate the new object
  38420. * @param source defines the source object
  38421. * @returns the cloned object
  38422. */
  38423. static Clone<T>(creationFunction: () => T, source: T): T;
  38424. /**
  38425. * Instanciates a new object based on a source one (some data will be shared between both object)
  38426. * @param creationFunction defines the function used to instanciate the new object
  38427. * @param source defines the source object
  38428. * @returns the new object
  38429. */
  38430. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38431. }
  38432. }
  38433. declare module BABYLON {
  38434. /**
  38435. * This is the base class of all the camera used in the application.
  38436. * @see https://doc.babylonjs.com/features/cameras
  38437. */
  38438. export class Camera extends Node {
  38439. /** @hidden */
  38440. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  38441. /**
  38442. * This is the default projection mode used by the cameras.
  38443. * It helps recreating a feeling of perspective and better appreciate depth.
  38444. * This is the best way to simulate real life cameras.
  38445. */
  38446. static readonly PERSPECTIVE_CAMERA: number;
  38447. /**
  38448. * This helps creating camera with an orthographic mode.
  38449. * 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.
  38450. */
  38451. static readonly ORTHOGRAPHIC_CAMERA: number;
  38452. /**
  38453. * This is the default FOV mode for perspective cameras.
  38454. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  38455. */
  38456. static readonly FOVMODE_VERTICAL_FIXED: number;
  38457. /**
  38458. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  38459. */
  38460. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  38461. /**
  38462. * This specifies there is no need for a camera rig.
  38463. * Basically only one eye is rendered corresponding to the camera.
  38464. */
  38465. static readonly RIG_MODE_NONE: number;
  38466. /**
  38467. * Simulates a camera Rig with one blue eye and one red eye.
  38468. * This can be use with 3d blue and red glasses.
  38469. */
  38470. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  38471. /**
  38472. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  38473. */
  38474. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  38475. /**
  38476. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  38477. */
  38478. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  38479. /**
  38480. * Defines that both eyes of the camera will be rendered over under each other.
  38481. */
  38482. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  38483. /**
  38484. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  38485. */
  38486. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  38487. /**
  38488. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  38489. */
  38490. static readonly RIG_MODE_VR: number;
  38491. /**
  38492. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  38493. */
  38494. static readonly RIG_MODE_WEBVR: number;
  38495. /**
  38496. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  38497. */
  38498. static readonly RIG_MODE_CUSTOM: number;
  38499. /**
  38500. * Defines if by default attaching controls should prevent the default javascript event to continue.
  38501. */
  38502. static ForceAttachControlToAlwaysPreventDefault: boolean;
  38503. /**
  38504. * Define the input manager associated with the camera.
  38505. */
  38506. inputs: CameraInputsManager<Camera>;
  38507. /** @hidden */
  38508. _position: Vector3;
  38509. /**
  38510. * Define the current local position of the camera in the scene
  38511. */
  38512. get position(): Vector3;
  38513. set position(newPosition: Vector3);
  38514. protected _upVector: Vector3;
  38515. /**
  38516. * The vector the camera should consider as up.
  38517. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  38518. */
  38519. set upVector(vec: Vector3);
  38520. get upVector(): Vector3;
  38521. /**
  38522. * Define the current limit on the left side for an orthographic camera
  38523. * In scene unit
  38524. */
  38525. orthoLeft: Nullable<number>;
  38526. /**
  38527. * Define the current limit on the right side for an orthographic camera
  38528. * In scene unit
  38529. */
  38530. orthoRight: Nullable<number>;
  38531. /**
  38532. * Define the current limit on the bottom side for an orthographic camera
  38533. * In scene unit
  38534. */
  38535. orthoBottom: Nullable<number>;
  38536. /**
  38537. * Define the current limit on the top side for an orthographic camera
  38538. * In scene unit
  38539. */
  38540. orthoTop: Nullable<number>;
  38541. /**
  38542. * Field Of View is set in Radians. (default is 0.8)
  38543. */
  38544. fov: number;
  38545. /**
  38546. * Define the minimum distance the camera can see from.
  38547. * This is important to note that the depth buffer are not infinite and the closer it starts
  38548. * the more your scene might encounter depth fighting issue.
  38549. */
  38550. minZ: number;
  38551. /**
  38552. * Define the maximum distance the camera can see to.
  38553. * This is important to note that the depth buffer are not infinite and the further it end
  38554. * the more your scene might encounter depth fighting issue.
  38555. */
  38556. maxZ: number;
  38557. /**
  38558. * Define the default inertia of the camera.
  38559. * This helps giving a smooth feeling to the camera movement.
  38560. */
  38561. inertia: number;
  38562. /**
  38563. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  38564. */
  38565. mode: number;
  38566. /**
  38567. * Define whether the camera is intermediate.
  38568. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  38569. */
  38570. isIntermediate: boolean;
  38571. /**
  38572. * Define the viewport of the camera.
  38573. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  38574. */
  38575. viewport: Viewport;
  38576. /**
  38577. * Restricts the camera to viewing objects with the same layerMask.
  38578. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  38579. */
  38580. layerMask: number;
  38581. /**
  38582. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  38583. */
  38584. fovMode: number;
  38585. /**
  38586. * Rig mode of the camera.
  38587. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  38588. * This is normally controlled byt the camera themselves as internal use.
  38589. */
  38590. cameraRigMode: number;
  38591. /**
  38592. * Defines the distance between both "eyes" in case of a RIG
  38593. */
  38594. interaxialDistance: number;
  38595. /**
  38596. * Defines if stereoscopic rendering is done side by side or over under.
  38597. */
  38598. isStereoscopicSideBySide: boolean;
  38599. /**
  38600. * 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
  38601. * This is pretty helpful if you wish to make a camera render to a texture you could reuse somewhere
  38602. * else in the scene. (Eg. security camera)
  38603. *
  38604. * 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)
  38605. */
  38606. customRenderTargets: RenderTargetTexture[];
  38607. /**
  38608. * When set, the camera will render to this render target instead of the default canvas
  38609. *
  38610. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  38611. */
  38612. outputRenderTarget: Nullable<RenderTargetTexture>;
  38613. /**
  38614. * Observable triggered when the camera view matrix has changed.
  38615. */
  38616. onViewMatrixChangedObservable: Observable<Camera>;
  38617. /**
  38618. * Observable triggered when the camera Projection matrix has changed.
  38619. */
  38620. onProjectionMatrixChangedObservable: Observable<Camera>;
  38621. /**
  38622. * Observable triggered when the inputs have been processed.
  38623. */
  38624. onAfterCheckInputsObservable: Observable<Camera>;
  38625. /**
  38626. * Observable triggered when reset has been called and applied to the camera.
  38627. */
  38628. onRestoreStateObservable: Observable<Camera>;
  38629. /**
  38630. * Is this camera a part of a rig system?
  38631. */
  38632. isRigCamera: boolean;
  38633. /**
  38634. * If isRigCamera set to true this will be set with the parent camera.
  38635. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  38636. */
  38637. rigParent?: Camera;
  38638. /** @hidden */
  38639. _cameraRigParams: any;
  38640. /** @hidden */
  38641. _rigCameras: Camera[];
  38642. /** @hidden */
  38643. _rigPostProcess: Nullable<PostProcess>;
  38644. protected _webvrViewMatrix: Matrix;
  38645. /** @hidden */
  38646. _skipRendering: boolean;
  38647. /** @hidden */
  38648. _projectionMatrix: Matrix;
  38649. /** @hidden */
  38650. _postProcesses: Nullable<PostProcess>[];
  38651. /** @hidden */
  38652. _activeMeshes: SmartArray<AbstractMesh>;
  38653. protected _globalPosition: Vector3;
  38654. /** @hidden */
  38655. _computedViewMatrix: Matrix;
  38656. private _doNotComputeProjectionMatrix;
  38657. private _transformMatrix;
  38658. private _frustumPlanes;
  38659. private _refreshFrustumPlanes;
  38660. private _storedFov;
  38661. private _stateStored;
  38662. /**
  38663. * Instantiates a new camera object.
  38664. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  38665. * @see https://doc.babylonjs.com/features/cameras
  38666. * @param name Defines the name of the camera in the scene
  38667. * @param position Defines the position of the camera
  38668. * @param scene Defines the scene the camera belongs too
  38669. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  38670. */
  38671. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38672. /**
  38673. * Store current camera state (fov, position, etc..)
  38674. * @returns the camera
  38675. */
  38676. storeState(): Camera;
  38677. /**
  38678. * Restores the camera state values if it has been stored. You must call storeState() first
  38679. */
  38680. protected _restoreStateValues(): boolean;
  38681. /**
  38682. * Restored camera state. You must call storeState() first.
  38683. * @returns true if restored and false otherwise
  38684. */
  38685. restoreState(): boolean;
  38686. /**
  38687. * Gets the class name of the camera.
  38688. * @returns the class name
  38689. */
  38690. getClassName(): string;
  38691. /** @hidden */
  38692. readonly _isCamera: boolean;
  38693. /**
  38694. * Gets a string representation of the camera useful for debug purpose.
  38695. * @param fullDetails Defines that a more verboe level of logging is required
  38696. * @returns the string representation
  38697. */
  38698. toString(fullDetails?: boolean): string;
  38699. /**
  38700. * Gets the current world space position of the camera.
  38701. */
  38702. get globalPosition(): Vector3;
  38703. /**
  38704. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  38705. * @returns the active meshe list
  38706. */
  38707. getActiveMeshes(): SmartArray<AbstractMesh>;
  38708. /**
  38709. * Check whether a mesh is part of the current active mesh list of the camera
  38710. * @param mesh Defines the mesh to check
  38711. * @returns true if active, false otherwise
  38712. */
  38713. isActiveMesh(mesh: Mesh): boolean;
  38714. /**
  38715. * Is this camera ready to be used/rendered
  38716. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  38717. * @return true if the camera is ready
  38718. */
  38719. isReady(completeCheck?: boolean): boolean;
  38720. /** @hidden */
  38721. _initCache(): void;
  38722. /** @hidden */
  38723. _updateCache(ignoreParentClass?: boolean): void;
  38724. /** @hidden */
  38725. _isSynchronized(): boolean;
  38726. /** @hidden */
  38727. _isSynchronizedViewMatrix(): boolean;
  38728. /** @hidden */
  38729. _isSynchronizedProjectionMatrix(): boolean;
  38730. /**
  38731. * Attach the input controls to a specific dom element to get the input from.
  38732. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38733. */
  38734. attachControl(noPreventDefault?: boolean): void;
  38735. /**
  38736. * Attach the input controls to a specific dom element to get the input from.
  38737. * @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
  38738. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38739. * BACK COMPAT SIGNATURE ONLY.
  38740. */
  38741. attachControl(ignored: any, noPreventDefault?: boolean): void;
  38742. /**
  38743. * Detach the current controls from the specified dom element.
  38744. */
  38745. detachControl(): void;
  38746. /**
  38747. * Detach the current controls from the specified dom element.
  38748. * @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
  38749. */
  38750. detachControl(ignored: any): void;
  38751. /**
  38752. * Update the camera state according to the different inputs gathered during the frame.
  38753. */
  38754. update(): void;
  38755. /** @hidden */
  38756. _checkInputs(): void;
  38757. /** @hidden */
  38758. get rigCameras(): Camera[];
  38759. /**
  38760. * Gets the post process used by the rig cameras
  38761. */
  38762. get rigPostProcess(): Nullable<PostProcess>;
  38763. /**
  38764. * Internal, gets the first post process.
  38765. * @returns the first post process to be run on this camera.
  38766. */
  38767. _getFirstPostProcess(): Nullable<PostProcess>;
  38768. private _cascadePostProcessesToRigCams;
  38769. /**
  38770. * Attach a post process to the camera.
  38771. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38772. * @param postProcess The post process to attach to the camera
  38773. * @param insertAt The position of the post process in case several of them are in use in the scene
  38774. * @returns the position the post process has been inserted at
  38775. */
  38776. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  38777. /**
  38778. * Detach a post process to the camera.
  38779. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38780. * @param postProcess The post process to detach from the camera
  38781. */
  38782. detachPostProcess(postProcess: PostProcess): void;
  38783. /**
  38784. * Gets the current world matrix of the camera
  38785. */
  38786. getWorldMatrix(): Matrix;
  38787. /** @hidden */
  38788. _getViewMatrix(): Matrix;
  38789. /**
  38790. * Gets the current view matrix of the camera.
  38791. * @param force forces the camera to recompute the matrix without looking at the cached state
  38792. * @returns the view matrix
  38793. */
  38794. getViewMatrix(force?: boolean): Matrix;
  38795. /**
  38796. * Freeze the projection matrix.
  38797. * It will prevent the cache check of the camera projection compute and can speed up perf
  38798. * if no parameter of the camera are meant to change
  38799. * @param projection Defines manually a projection if necessary
  38800. */
  38801. freezeProjectionMatrix(projection?: Matrix): void;
  38802. /**
  38803. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  38804. */
  38805. unfreezeProjectionMatrix(): void;
  38806. /**
  38807. * Gets the current projection matrix of the camera.
  38808. * @param force forces the camera to recompute the matrix without looking at the cached state
  38809. * @returns the projection matrix
  38810. */
  38811. getProjectionMatrix(force?: boolean): Matrix;
  38812. /**
  38813. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  38814. * @returns a Matrix
  38815. */
  38816. getTransformationMatrix(): Matrix;
  38817. private _updateFrustumPlanes;
  38818. /**
  38819. * Checks if a cullable object (mesh...) is in the camera frustum
  38820. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  38821. * @param target The object to check
  38822. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  38823. * @returns true if the object is in frustum otherwise false
  38824. */
  38825. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  38826. /**
  38827. * Checks if a cullable object (mesh...) is in the camera frustum
  38828. * Unlike isInFrustum this checks the full bounding box
  38829. * @param target The object to check
  38830. * @returns true if the object is in frustum otherwise false
  38831. */
  38832. isCompletelyInFrustum(target: ICullable): boolean;
  38833. /**
  38834. * Gets a ray in the forward direction from the camera.
  38835. * @param length Defines the length of the ray to create
  38836. * @param transform Defines the transform to apply to the ray, by default the world matrix is used to create a workd space ray
  38837. * @param origin Defines the start point of the ray which defaults to the camera position
  38838. * @returns the forward ray
  38839. */
  38840. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38841. /**
  38842. * Gets a ray in the forward direction from the camera.
  38843. * @param refRay the ray to (re)use when setting the values
  38844. * @param length Defines the length of the ray to create
  38845. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38846. * @param origin Defines the start point of the ray which defaults to the camera position
  38847. * @returns the forward ray
  38848. */
  38849. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38850. /**
  38851. * Releases resources associated with this node.
  38852. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  38853. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  38854. */
  38855. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  38856. /** @hidden */
  38857. _isLeftCamera: boolean;
  38858. /**
  38859. * Gets the left camera of a rig setup in case of Rigged Camera
  38860. */
  38861. get isLeftCamera(): boolean;
  38862. /** @hidden */
  38863. _isRightCamera: boolean;
  38864. /**
  38865. * Gets the right camera of a rig setup in case of Rigged Camera
  38866. */
  38867. get isRightCamera(): boolean;
  38868. /**
  38869. * Gets the left camera of a rig setup in case of Rigged Camera
  38870. */
  38871. get leftCamera(): Nullable<FreeCamera>;
  38872. /**
  38873. * Gets the right camera of a rig setup in case of Rigged Camera
  38874. */
  38875. get rightCamera(): Nullable<FreeCamera>;
  38876. /**
  38877. * Gets the left camera target of a rig setup in case of Rigged Camera
  38878. * @returns the target position
  38879. */
  38880. getLeftTarget(): Nullable<Vector3>;
  38881. /**
  38882. * Gets the right camera target of a rig setup in case of Rigged Camera
  38883. * @returns the target position
  38884. */
  38885. getRightTarget(): Nullable<Vector3>;
  38886. /**
  38887. * @hidden
  38888. */
  38889. setCameraRigMode(mode: number, rigParams: any): void;
  38890. /** @hidden */
  38891. static _setStereoscopicRigMode(camera: Camera): void;
  38892. /** @hidden */
  38893. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  38894. /** @hidden */
  38895. static _setVRRigMode(camera: Camera, rigParams: any): void;
  38896. /** @hidden */
  38897. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  38898. /** @hidden */
  38899. _getVRProjectionMatrix(): Matrix;
  38900. protected _updateCameraRotationMatrix(): void;
  38901. protected _updateWebVRCameraRotationMatrix(): void;
  38902. /**
  38903. * This function MUST be overwritten by the different WebVR cameras available.
  38904. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38905. * @hidden
  38906. */
  38907. _getWebVRProjectionMatrix(): Matrix;
  38908. /**
  38909. * This function MUST be overwritten by the different WebVR cameras available.
  38910. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38911. * @hidden
  38912. */
  38913. _getWebVRViewMatrix(): Matrix;
  38914. /** @hidden */
  38915. setCameraRigParameter(name: string, value: any): void;
  38916. /**
  38917. * needs to be overridden by children so sub has required properties to be copied
  38918. * @hidden
  38919. */
  38920. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  38921. /**
  38922. * May need to be overridden by children
  38923. * @hidden
  38924. */
  38925. _updateRigCameras(): void;
  38926. /** @hidden */
  38927. _setupInputs(): void;
  38928. /**
  38929. * Serialiaze the camera setup to a json representation
  38930. * @returns the JSON representation
  38931. */
  38932. serialize(): any;
  38933. /**
  38934. * Clones the current camera.
  38935. * @param name The cloned camera name
  38936. * @returns the cloned camera
  38937. */
  38938. clone(name: string): Camera;
  38939. /**
  38940. * Gets the direction of the camera relative to a given local axis.
  38941. * @param localAxis Defines the reference axis to provide a relative direction.
  38942. * @return the direction
  38943. */
  38944. getDirection(localAxis: Vector3): Vector3;
  38945. /**
  38946. * Returns the current camera absolute rotation
  38947. */
  38948. get absoluteRotation(): Quaternion;
  38949. /**
  38950. * Gets the direction of the camera relative to a given local axis into a passed vector.
  38951. * @param localAxis Defines the reference axis to provide a relative direction.
  38952. * @param result Defines the vector to store the result in
  38953. */
  38954. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  38955. /**
  38956. * Gets a camera constructor for a given camera type
  38957. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  38958. * @param name The name of the camera the result will be able to instantiate
  38959. * @param scene The scene the result will construct the camera in
  38960. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  38961. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  38962. * @returns a factory method to construct the camera
  38963. */
  38964. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  38965. /**
  38966. * Compute the world matrix of the camera.
  38967. * @returns the camera world matrix
  38968. */
  38969. computeWorldMatrix(): Matrix;
  38970. /**
  38971. * Parse a JSON and creates the camera from the parsed information
  38972. * @param parsedCamera The JSON to parse
  38973. * @param scene The scene to instantiate the camera in
  38974. * @returns the newly constructed camera
  38975. */
  38976. static Parse(parsedCamera: any, scene: Scene): Camera;
  38977. }
  38978. }
  38979. declare module BABYLON {
  38980. /**
  38981. * PostProcessManager is used to manage one or more post processes or post process pipelines
  38982. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  38983. */
  38984. export class PostProcessManager {
  38985. private _scene;
  38986. private _indexBuffer;
  38987. private _vertexBuffers;
  38988. /**
  38989. * Creates a new instance PostProcess
  38990. * @param scene The scene that the post process is associated with.
  38991. */
  38992. constructor(scene: Scene);
  38993. private _prepareBuffers;
  38994. private _buildIndexBuffer;
  38995. /**
  38996. * Rebuilds the vertex buffers of the manager.
  38997. * @hidden
  38998. */
  38999. _rebuild(): void;
  39000. /**
  39001. * Prepares a frame to be run through a post process.
  39002. * @param sourceTexture The input texture to the post processes. (default: null)
  39003. * @param postProcesses An array of post processes to be run. (default: null)
  39004. * @returns True if the post processes were able to be run.
  39005. * @hidden
  39006. */
  39007. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  39008. /**
  39009. * Manually render a set of post processes to a texture.
  39010. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  39011. * @param postProcesses An array of post processes to be run.
  39012. * @param targetTexture The target texture to render to.
  39013. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  39014. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  39015. * @param lodLevel defines which lod of the texture to render to
  39016. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  39017. */
  39018. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  39019. /**
  39020. * Finalize the result of the output of the postprocesses.
  39021. * @param doNotPresent If true the result will not be displayed to the screen.
  39022. * @param targetTexture The target texture to render to.
  39023. * @param faceIndex The index of the face to bind the target texture to.
  39024. * @param postProcesses The array of post processes to render.
  39025. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  39026. * @hidden
  39027. */
  39028. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  39029. /**
  39030. * Disposes of the post process manager.
  39031. */
  39032. dispose(): void;
  39033. }
  39034. }
  39035. declare module BABYLON {
  39036. /**
  39037. * This Helps creating a texture that will be created from a camera in your scene.
  39038. * It is basically a dynamic texture that could be used to create special effects for instance.
  39039. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  39040. */
  39041. export class RenderTargetTexture extends Texture {
  39042. /**
  39043. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  39044. */
  39045. static readonly REFRESHRATE_RENDER_ONCE: number;
  39046. /**
  39047. * The texture will only be rendered rendered every frame and is recommended for dynamic contents.
  39048. */
  39049. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  39050. /**
  39051. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  39052. * the central point of your effect and can save a lot of performances.
  39053. */
  39054. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  39055. /**
  39056. * Use this predicate to dynamically define the list of mesh you want to render.
  39057. * If set, the renderList property will be overwritten.
  39058. */
  39059. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  39060. private _renderList;
  39061. /**
  39062. * Use this list to define the list of mesh you want to render.
  39063. */
  39064. get renderList(): Nullable<Array<AbstractMesh>>;
  39065. set renderList(value: Nullable<Array<AbstractMesh>>);
  39066. /**
  39067. * Use this function to overload the renderList array at rendering time.
  39068. * Return null to render with the current renderList, else return the list of meshes to use for rendering.
  39069. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  39070. * the cube (if the RTT is a cube, else layerOrFace=0).
  39071. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  39072. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  39073. * hold dummy elements!
  39074. */
  39075. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  39076. private _hookArray;
  39077. /**
  39078. * Define if particles should be rendered in your texture.
  39079. */
  39080. renderParticles: boolean;
  39081. /**
  39082. * Define if sprites should be rendered in your texture.
  39083. */
  39084. renderSprites: boolean;
  39085. /**
  39086. * Define the camera used to render the texture.
  39087. */
  39088. activeCamera: Nullable<Camera>;
  39089. /**
  39090. * Override the mesh isReady function with your own one.
  39091. */
  39092. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  39093. /**
  39094. * Override the render function of the texture with your own one.
  39095. */
  39096. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  39097. /**
  39098. * Define if camera post processes should be use while rendering the texture.
  39099. */
  39100. useCameraPostProcesses: boolean;
  39101. /**
  39102. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  39103. */
  39104. ignoreCameraViewport: boolean;
  39105. private _postProcessManager;
  39106. /**
  39107. * Post-processes for this render target
  39108. */
  39109. get postProcesses(): PostProcess[];
  39110. private _postProcesses;
  39111. private _resizeObserver;
  39112. private get _prePassEnabled();
  39113. /**
  39114. * An event triggered when the texture is unbind.
  39115. */
  39116. onBeforeBindObservable: Observable<RenderTargetTexture>;
  39117. /**
  39118. * An event triggered when the texture is unbind.
  39119. */
  39120. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  39121. private _onAfterUnbindObserver;
  39122. /**
  39123. * Set a after unbind callback in the texture.
  39124. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  39125. */
  39126. set onAfterUnbind(callback: () => void);
  39127. /**
  39128. * An event triggered before rendering the texture
  39129. */
  39130. onBeforeRenderObservable: Observable<number>;
  39131. private _onBeforeRenderObserver;
  39132. /**
  39133. * Set a before render callback in the texture.
  39134. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  39135. */
  39136. set onBeforeRender(callback: (faceIndex: number) => void);
  39137. /**
  39138. * An event triggered after rendering the texture
  39139. */
  39140. onAfterRenderObservable: Observable<number>;
  39141. private _onAfterRenderObserver;
  39142. /**
  39143. * Set a after render callback in the texture.
  39144. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  39145. */
  39146. set onAfterRender(callback: (faceIndex: number) => void);
  39147. /**
  39148. * An event triggered after the texture clear
  39149. */
  39150. onClearObservable: Observable<Engine>;
  39151. private _onClearObserver;
  39152. /**
  39153. * Set a clear callback in the texture.
  39154. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  39155. */
  39156. set onClear(callback: (Engine: Engine) => void);
  39157. /**
  39158. * An event triggered when the texture is resized.
  39159. */
  39160. onResizeObservable: Observable<RenderTargetTexture>;
  39161. /**
  39162. * Define the clear color of the Render Target if it should be different from the scene.
  39163. */
  39164. clearColor: Color4;
  39165. protected _size: number | {
  39166. width: number;
  39167. height: number;
  39168. layers?: number;
  39169. };
  39170. protected _initialSizeParameter: number | {
  39171. width: number;
  39172. height: number;
  39173. } | {
  39174. ratio: number;
  39175. };
  39176. protected _sizeRatio: Nullable<number>;
  39177. /** @hidden */
  39178. _generateMipMaps: boolean;
  39179. protected _renderingManager: RenderingManager;
  39180. /** @hidden */
  39181. _waitingRenderList?: string[];
  39182. protected _doNotChangeAspectRatio: boolean;
  39183. protected _currentRefreshId: number;
  39184. protected _refreshRate: number;
  39185. protected _textureMatrix: Matrix;
  39186. protected _samples: number;
  39187. protected _renderTargetOptions: RenderTargetCreationOptions;
  39188. /**
  39189. * Gets render target creation options that were used.
  39190. */
  39191. get renderTargetOptions(): RenderTargetCreationOptions;
  39192. protected _onRatioRescale(): void;
  39193. /**
  39194. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  39195. * It must define where the camera used to render the texture is set
  39196. */
  39197. boundingBoxPosition: Vector3;
  39198. private _boundingBoxSize;
  39199. /**
  39200. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  39201. * When defined, the cubemap will switch to local mode
  39202. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  39203. * @example https://www.babylonjs-playground.com/#RNASML
  39204. */
  39205. set boundingBoxSize(value: Vector3);
  39206. get boundingBoxSize(): Vector3;
  39207. /**
  39208. * In case the RTT has been created with a depth texture, get the associated
  39209. * depth texture.
  39210. * Otherwise, return null.
  39211. */
  39212. get depthStencilTexture(): Nullable<InternalTexture>;
  39213. /**
  39214. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post process
  39215. * or used a shadow, depth texture...
  39216. * @param name The friendly name of the texture
  39217. * @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)
  39218. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  39219. * @param generateMipMaps True if mip maps need to be generated after render.
  39220. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  39221. * @param type The type of the buffer in the RTT (int, half float, float...)
  39222. * @param isCube True if a cube texture needs to be created
  39223. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  39224. * @param generateDepthBuffer True to generate a depth buffer
  39225. * @param generateStencilBuffer True to generate a stencil buffer
  39226. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  39227. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  39228. * @param delayAllocation if the texture allocation should be delayed (default: false)
  39229. * @param samples sample count to use when creating the RTT
  39230. */
  39231. constructor(name: string, size: number | {
  39232. width: number;
  39233. height: number;
  39234. layers?: number;
  39235. } | {
  39236. ratio: number;
  39237. }, 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);
  39238. /**
  39239. * Creates a depth stencil texture.
  39240. * This is only available in WebGL 2 or with the depth texture extension available.
  39241. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  39242. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  39243. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  39244. * @param samples sample count of the depth/stencil texture
  39245. */
  39246. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean, samples?: number): void;
  39247. private _processSizeParameter;
  39248. /**
  39249. * Define the number of samples to use in case of MSAA.
  39250. * It defaults to one meaning no MSAA has been enabled.
  39251. */
  39252. get samples(): number;
  39253. set samples(value: number);
  39254. /**
  39255. * Resets the refresh counter of the texture and start bak from scratch.
  39256. * Could be useful to regenerate the texture if it is setup to render only once.
  39257. */
  39258. resetRefreshCounter(): void;
  39259. /**
  39260. * Define the refresh rate of the texture or the rendering frequency.
  39261. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  39262. */
  39263. get refreshRate(): number;
  39264. set refreshRate(value: number);
  39265. /**
  39266. * Adds a post process to the render target rendering passes.
  39267. * @param postProcess define the post process to add
  39268. */
  39269. addPostProcess(postProcess: PostProcess): void;
  39270. /**
  39271. * Clear all the post processes attached to the render target
  39272. * @param dispose define if the cleared post processes should also be disposed (false by default)
  39273. */
  39274. clearPostProcesses(dispose?: boolean): void;
  39275. /**
  39276. * Remove one of the post process from the list of attached post processes to the texture
  39277. * @param postProcess define the post process to remove from the list
  39278. */
  39279. removePostProcess(postProcess: PostProcess): void;
  39280. /** @hidden */
  39281. _shouldRender(): boolean;
  39282. /**
  39283. * Gets the actual render size of the texture.
  39284. * @returns the width of the render size
  39285. */
  39286. getRenderSize(): number;
  39287. /**
  39288. * Gets the actual render width of the texture.
  39289. * @returns the width of the render size
  39290. */
  39291. getRenderWidth(): number;
  39292. /**
  39293. * Gets the actual render height of the texture.
  39294. * @returns the height of the render size
  39295. */
  39296. getRenderHeight(): number;
  39297. /**
  39298. * Gets the actual number of layers of the texture.
  39299. * @returns the number of layers
  39300. */
  39301. getRenderLayers(): number;
  39302. /**
  39303. * Get if the texture can be rescaled or not.
  39304. */
  39305. get canRescale(): boolean;
  39306. /**
  39307. * Resize the texture using a ratio.
  39308. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  39309. */
  39310. scale(ratio: number): void;
  39311. /**
  39312. * Get the texture reflection matrix used to rotate/transform the reflection.
  39313. * @returns the reflection matrix
  39314. */
  39315. getReflectionTextureMatrix(): Matrix;
  39316. /**
  39317. * Resize the texture to a new desired size.
  39318. * Be careful as it will recreate all the data in the new texture.
  39319. * @param size Define the new size. It can be:
  39320. * - a number for squared texture,
  39321. * - an object containing { width: number, height: number }
  39322. * - or an object containing a ratio { ratio: number }
  39323. */
  39324. resize(size: number | {
  39325. width: number;
  39326. height: number;
  39327. } | {
  39328. ratio: number;
  39329. }): void;
  39330. private _defaultRenderListPrepared;
  39331. /**
  39332. * Renders all the objects from the render list into the texture.
  39333. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  39334. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  39335. */
  39336. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  39337. private _bestReflectionRenderTargetDimension;
  39338. private _prepareRenderingManager;
  39339. /**
  39340. * @hidden
  39341. * @param faceIndex face index to bind to if this is a cubetexture
  39342. * @param layer defines the index of the texture to bind in the array
  39343. */
  39344. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  39345. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  39346. /**
  39347. * @hidden
  39348. */
  39349. _prepareFrame(scene: Scene, faceIndex?: number, layer?: number, useCameraPostProcess?: boolean): void;
  39350. private renderToTarget;
  39351. /**
  39352. * Overrides the default sort function applied in the rendering group to prepare the meshes.
  39353. * This allowed control for front to back rendering or reversely depending of the special needs.
  39354. *
  39355. * @param renderingGroupId The rendering group id corresponding to its index
  39356. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  39357. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  39358. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  39359. */
  39360. 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;
  39361. /**
  39362. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  39363. *
  39364. * @param renderingGroupId The rendering group id corresponding to its index
  39365. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  39366. */
  39367. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  39368. /**
  39369. * Clones the texture.
  39370. * @returns the cloned texture
  39371. */
  39372. clone(): RenderTargetTexture;
  39373. /**
  39374. * Serialize the texture to a JSON representation we can easily use in the respective Parse function.
  39375. * @returns The JSON representation of the texture
  39376. */
  39377. serialize(): any;
  39378. /**
  39379. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  39380. */
  39381. disposeFramebufferObjects(): void;
  39382. /**
  39383. * Dispose the texture and release its associated resources.
  39384. */
  39385. dispose(): void;
  39386. /** @hidden */
  39387. _rebuild(): void;
  39388. /**
  39389. * Clear the info related to rendering groups preventing retention point in material dispose.
  39390. */
  39391. freeRenderingGroups(): void;
  39392. /**
  39393. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  39394. * @returns the view count
  39395. */
  39396. getViewCount(): number;
  39397. }
  39398. }
  39399. declare module BABYLON {
  39400. /**
  39401. * Options to be used when creating an effect.
  39402. */
  39403. export interface IEffectCreationOptions {
  39404. /**
  39405. * Attributes that will be used in the shader.
  39406. */
  39407. attributes: string[];
  39408. /**
  39409. * Uniform variable names that will be set in the shader.
  39410. */
  39411. uniformsNames: string[];
  39412. /**
  39413. * Uniform buffer variable names that will be set in the shader.
  39414. */
  39415. uniformBuffersNames: string[];
  39416. /**
  39417. * Sampler texture variable names that will be set in the shader.
  39418. */
  39419. samplers: string[];
  39420. /**
  39421. * Define statements that will be set in the shader.
  39422. */
  39423. defines: any;
  39424. /**
  39425. * Possible fallbacks for this effect to improve performance when needed.
  39426. */
  39427. fallbacks: Nullable<IEffectFallbacks>;
  39428. /**
  39429. * Callback that will be called when the shader is compiled.
  39430. */
  39431. onCompiled: Nullable<(effect: Effect) => void>;
  39432. /**
  39433. * Callback that will be called if an error occurs during shader compilation.
  39434. */
  39435. onError: Nullable<(effect: Effect, errors: string) => void>;
  39436. /**
  39437. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39438. */
  39439. indexParameters?: any;
  39440. /**
  39441. * Max number of lights that can be used in the shader.
  39442. */
  39443. maxSimultaneousLights?: number;
  39444. /**
  39445. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  39446. */
  39447. transformFeedbackVaryings?: Nullable<string[]>;
  39448. /**
  39449. * 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
  39450. */
  39451. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  39452. /**
  39453. * Is this effect rendering to several color attachments ?
  39454. */
  39455. multiTarget?: boolean;
  39456. }
  39457. /**
  39458. * Effect containing vertex and fragment shader that can be executed on an object.
  39459. */
  39460. export class Effect implements IDisposable {
  39461. /**
  39462. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39463. */
  39464. static ShadersRepository: string;
  39465. /**
  39466. * Enable logging of the shader code when a compilation error occurs
  39467. */
  39468. static LogShaderCodeOnCompilationError: boolean;
  39469. /**
  39470. * Name of the effect.
  39471. */
  39472. name: any;
  39473. /**
  39474. * String container all the define statements that should be set on the shader.
  39475. */
  39476. defines: string;
  39477. /**
  39478. * Callback that will be called when the shader is compiled.
  39479. */
  39480. onCompiled: Nullable<(effect: Effect) => void>;
  39481. /**
  39482. * Callback that will be called if an error occurs during shader compilation.
  39483. */
  39484. onError: Nullable<(effect: Effect, errors: string) => void>;
  39485. /**
  39486. * Callback that will be called when effect is bound.
  39487. */
  39488. onBind: Nullable<(effect: Effect) => void>;
  39489. /**
  39490. * Unique ID of the effect.
  39491. */
  39492. uniqueId: number;
  39493. /**
  39494. * Observable that will be called when the shader is compiled.
  39495. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  39496. */
  39497. onCompileObservable: Observable<Effect>;
  39498. /**
  39499. * Observable that will be called if an error occurs during shader compilation.
  39500. */
  39501. onErrorObservable: Observable<Effect>;
  39502. /** @hidden */
  39503. _onBindObservable: Nullable<Observable<Effect>>;
  39504. /**
  39505. * @hidden
  39506. * Specifies if the effect was previously ready
  39507. */
  39508. _wasPreviouslyReady: boolean;
  39509. /**
  39510. * Observable that will be called when effect is bound.
  39511. */
  39512. get onBindObservable(): Observable<Effect>;
  39513. /** @hidden */
  39514. _bonesComputationForcedToCPU: boolean;
  39515. /** @hidden */
  39516. _uniformBuffersNames: {
  39517. [key: string]: number;
  39518. };
  39519. /** @hidden */
  39520. _samplerList: string[];
  39521. /** @hidden */
  39522. _multiTarget: boolean;
  39523. private static _uniqueIdSeed;
  39524. private _engine;
  39525. private _uniformBuffersNamesList;
  39526. private _uniformsNames;
  39527. private _samplers;
  39528. private _isReady;
  39529. private _compilationError;
  39530. private _allFallbacksProcessed;
  39531. private _attributesNames;
  39532. private _attributes;
  39533. private _attributeLocationByName;
  39534. private _uniforms;
  39535. /**
  39536. * Key for the effect.
  39537. * @hidden
  39538. */
  39539. _key: string;
  39540. private _indexParameters;
  39541. private _fallbacks;
  39542. private _vertexSourceCodeOverride;
  39543. private _fragmentSourceCodeOverride;
  39544. private _transformFeedbackVaryings;
  39545. /**
  39546. * Compiled shader to webGL program.
  39547. * @hidden
  39548. */
  39549. _pipelineContext: Nullable<IPipelineContext>;
  39550. /** @hidden */
  39551. _vertexSourceCode: string;
  39552. /** @hidden */
  39553. _fragmentSourceCode: string;
  39554. /** @hidden */
  39555. private _rawVertexSourceCode;
  39556. /** @hidden */
  39557. private _rawFragmentSourceCode;
  39558. private static _baseCache;
  39559. private _processingContext;
  39560. /**
  39561. * Instantiates an effect.
  39562. * An effect can be used to create/manage/execute vertex and fragment shaders.
  39563. * @param baseName Name of the effect.
  39564. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  39565. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  39566. * @param samplers List of sampler variables that will be passed to the shader.
  39567. * @param engine Engine to be used to render the effect
  39568. * @param defines Define statements to be added to the shader.
  39569. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  39570. * @param onCompiled Callback that will be called when the shader is compiled.
  39571. * @param onError Callback that will be called if an error occurs during shader compilation.
  39572. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39573. * @param key Effect Key identifying uniquely compiled shader variants
  39574. */
  39575. 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);
  39576. private _useFinalCode;
  39577. /**
  39578. * Unique key for this effect
  39579. */
  39580. get key(): string;
  39581. /**
  39582. * If the effect has been compiled and prepared.
  39583. * @returns if the effect is compiled and prepared.
  39584. */
  39585. isReady(): boolean;
  39586. private _isReadyInternal;
  39587. /**
  39588. * The engine the effect was initialized with.
  39589. * @returns the engine.
  39590. */
  39591. getEngine(): Engine;
  39592. /**
  39593. * The pipeline context for this effect
  39594. * @returns the associated pipeline context
  39595. */
  39596. getPipelineContext(): Nullable<IPipelineContext>;
  39597. /**
  39598. * The set of names of attribute variables for the shader.
  39599. * @returns An array of attribute names.
  39600. */
  39601. getAttributesNames(): string[];
  39602. /**
  39603. * Returns the attribute at the given index.
  39604. * @param index The index of the attribute.
  39605. * @returns The location of the attribute.
  39606. */
  39607. getAttributeLocation(index: number): number;
  39608. /**
  39609. * Returns the attribute based on the name of the variable.
  39610. * @param name of the attribute to look up.
  39611. * @returns the attribute location.
  39612. */
  39613. getAttributeLocationByName(name: string): number;
  39614. /**
  39615. * The number of attributes.
  39616. * @returns the number of attributes.
  39617. */
  39618. getAttributesCount(): number;
  39619. /**
  39620. * Gets the index of a uniform variable.
  39621. * @param uniformName of the uniform to look up.
  39622. * @returns the index.
  39623. */
  39624. getUniformIndex(uniformName: string): number;
  39625. /**
  39626. * Returns the attribute based on the name of the variable.
  39627. * @param uniformName of the uniform to look up.
  39628. * @returns the location of the uniform.
  39629. */
  39630. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  39631. /**
  39632. * Returns an array of sampler variable names
  39633. * @returns The array of sampler variable names.
  39634. */
  39635. getSamplers(): string[];
  39636. /**
  39637. * Returns an array of uniform variable names
  39638. * @returns The array of uniform variable names.
  39639. */
  39640. getUniformNames(): string[];
  39641. /**
  39642. * Returns an array of uniform buffer variable names
  39643. * @returns The array of uniform buffer variable names.
  39644. */
  39645. getUniformBuffersNames(): string[];
  39646. /**
  39647. * Returns the index parameters used to create the effect
  39648. * @returns The index parameters object
  39649. */
  39650. getIndexParameters(): any;
  39651. /**
  39652. * The error from the last compilation.
  39653. * @returns the error string.
  39654. */
  39655. getCompilationError(): string;
  39656. /**
  39657. * Gets a boolean indicating that all fallbacks were used during compilation
  39658. * @returns true if all fallbacks were used
  39659. */
  39660. allFallbacksProcessed(): boolean;
  39661. /**
  39662. * Adds a callback to the onCompiled observable and call the callback immediately if already ready.
  39663. * @param func The callback to be used.
  39664. */
  39665. executeWhenCompiled(func: (effect: Effect) => void): void;
  39666. private _checkIsReady;
  39667. private _loadShader;
  39668. /**
  39669. * Gets the vertex shader source code of this effect
  39670. */
  39671. get vertexSourceCode(): string;
  39672. /**
  39673. * Gets the fragment shader source code of this effect
  39674. */
  39675. get fragmentSourceCode(): string;
  39676. /**
  39677. * Gets the vertex shader source code before it has been processed by the preprocessor
  39678. */
  39679. get rawVertexSourceCode(): string;
  39680. /**
  39681. * Gets the fragment shader source code before it has been processed by the preprocessor
  39682. */
  39683. get rawFragmentSourceCode(): string;
  39684. /**
  39685. * Recompiles the webGL program
  39686. * @param vertexSourceCode The source code for the vertex shader.
  39687. * @param fragmentSourceCode The source code for the fragment shader.
  39688. * @param onCompiled Callback called when completed.
  39689. * @param onError Callback called on error.
  39690. * @hidden
  39691. */
  39692. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  39693. /**
  39694. * Prepares the effect
  39695. * @hidden
  39696. */
  39697. _prepareEffect(): void;
  39698. private _getShaderCodeAndErrorLine;
  39699. private _processCompilationErrors;
  39700. /**
  39701. * Checks if the effect is supported. (Must be called after compilation)
  39702. */
  39703. get isSupported(): boolean;
  39704. /**
  39705. * Binds a texture to the engine to be used as output of the shader.
  39706. * @param channel Name of the output variable.
  39707. * @param texture Texture to bind.
  39708. * @hidden
  39709. */
  39710. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  39711. /**
  39712. * Sets a texture on the engine to be used in the shader.
  39713. * @param channel Name of the sampler variable.
  39714. * @param texture Texture to set.
  39715. */
  39716. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  39717. /**
  39718. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  39719. * @param channel Name of the sampler variable.
  39720. * @param texture Texture to set.
  39721. */
  39722. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  39723. /**
  39724. * Sets an array of textures on the engine to be used in the shader.
  39725. * @param channel Name of the variable.
  39726. * @param textures Textures to set.
  39727. */
  39728. setTextureArray(channel: string, textures: ThinTexture[]): void;
  39729. /**
  39730. * 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)
  39731. * @param channel Name of the sampler variable.
  39732. * @param postProcess Post process to get the input texture from.
  39733. */
  39734. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  39735. /**
  39736. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  39737. * 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)
  39738. * @param channel Name of the sampler variable.
  39739. * @param postProcess Post process to get the output texture from.
  39740. */
  39741. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  39742. /**
  39743. * Binds a buffer to a uniform.
  39744. * @param buffer Buffer to bind.
  39745. * @param name Name of the uniform variable to bind to.
  39746. */
  39747. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  39748. /**
  39749. * Binds block to a uniform.
  39750. * @param blockName Name of the block to bind.
  39751. * @param index Index to bind.
  39752. */
  39753. bindUniformBlock(blockName: string, index: number): void;
  39754. /**
  39755. * Sets an integer value on a uniform variable.
  39756. * @param uniformName Name of the variable.
  39757. * @param value Value to be set.
  39758. * @returns this effect.
  39759. */
  39760. setInt(uniformName: string, value: number): Effect;
  39761. /**
  39762. * Sets an int2 value on a uniform variable.
  39763. * @param uniformName Name of the variable.
  39764. * @param x First int in int2.
  39765. * @param y Second int in int2.
  39766. * @returns this effect.
  39767. */
  39768. setInt2(uniformName: string, x: number, y: number): Effect;
  39769. /**
  39770. * Sets an int3 value on a uniform variable.
  39771. * @param uniformName Name of the variable.
  39772. * @param x First int in int3.
  39773. * @param y Second int in int3.
  39774. * @param z Third int in int3.
  39775. * @returns this effect.
  39776. */
  39777. setInt3(uniformName: string, x: number, y: number, z: number): Effect;
  39778. /**
  39779. * Sets an int4 value on a uniform variable.
  39780. * @param uniformName Name of the variable.
  39781. * @param x First int in int4.
  39782. * @param y Second int in int4.
  39783. * @param z Third int in int4.
  39784. * @param w Fourth int in int4.
  39785. * @returns this effect.
  39786. */
  39787. setInt4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39788. /**
  39789. * Sets an int array on a uniform variable.
  39790. * @param uniformName Name of the variable.
  39791. * @param array array to be set.
  39792. * @returns this effect.
  39793. */
  39794. setIntArray(uniformName: string, array: Int32Array): Effect;
  39795. /**
  39796. * 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)
  39797. * @param uniformName Name of the variable.
  39798. * @param array array to be set.
  39799. * @returns this effect.
  39800. */
  39801. setIntArray2(uniformName: string, array: Int32Array): Effect;
  39802. /**
  39803. * 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)
  39804. * @param uniformName Name of the variable.
  39805. * @param array array to be set.
  39806. * @returns this effect.
  39807. */
  39808. setIntArray3(uniformName: string, array: Int32Array): Effect;
  39809. /**
  39810. * 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)
  39811. * @param uniformName Name of the variable.
  39812. * @param array array to be set.
  39813. * @returns this effect.
  39814. */
  39815. setIntArray4(uniformName: string, array: Int32Array): Effect;
  39816. /**
  39817. * Sets an float array on a uniform variable.
  39818. * @param uniformName Name of the variable.
  39819. * @param array array to be set.
  39820. * @returns this effect.
  39821. */
  39822. setFloatArray(uniformName: string, array: FloatArray): Effect;
  39823. /**
  39824. * 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)
  39825. * @param uniformName Name of the variable.
  39826. * @param array array to be set.
  39827. * @returns this effect.
  39828. */
  39829. setFloatArray2(uniformName: string, array: FloatArray): Effect;
  39830. /**
  39831. * 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)
  39832. * @param uniformName Name of the variable.
  39833. * @param array array to be set.
  39834. * @returns this effect.
  39835. */
  39836. setFloatArray3(uniformName: string, array: FloatArray): Effect;
  39837. /**
  39838. * 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)
  39839. * @param uniformName Name of the variable.
  39840. * @param array array to be set.
  39841. * @returns this effect.
  39842. */
  39843. setFloatArray4(uniformName: string, array: FloatArray): Effect;
  39844. /**
  39845. * Sets an array on a uniform variable.
  39846. * @param uniformName Name of the variable.
  39847. * @param array array to be set.
  39848. * @returns this effect.
  39849. */
  39850. setArray(uniformName: string, array: number[]): Effect;
  39851. /**
  39852. * 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)
  39853. * @param uniformName Name of the variable.
  39854. * @param array array to be set.
  39855. * @returns this effect.
  39856. */
  39857. setArray2(uniformName: string, array: number[]): Effect;
  39858. /**
  39859. * 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)
  39860. * @param uniformName Name of the variable.
  39861. * @param array array to be set.
  39862. * @returns this effect.
  39863. */
  39864. setArray3(uniformName: string, array: number[]): Effect;
  39865. /**
  39866. * 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)
  39867. * @param uniformName Name of the variable.
  39868. * @param array array to be set.
  39869. * @returns this effect.
  39870. */
  39871. setArray4(uniformName: string, array: number[]): Effect;
  39872. /**
  39873. * Sets matrices on a uniform variable.
  39874. * @param uniformName Name of the variable.
  39875. * @param matrices matrices to be set.
  39876. * @returns this effect.
  39877. */
  39878. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  39879. /**
  39880. * Sets matrix on a uniform variable.
  39881. * @param uniformName Name of the variable.
  39882. * @param matrix matrix to be set.
  39883. * @returns this effect.
  39884. */
  39885. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  39886. /**
  39887. * 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)
  39888. * @param uniformName Name of the variable.
  39889. * @param matrix matrix to be set.
  39890. * @returns this effect.
  39891. */
  39892. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39893. /**
  39894. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  39895. * @param uniformName Name of the variable.
  39896. * @param matrix matrix to be set.
  39897. * @returns this effect.
  39898. */
  39899. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39900. /**
  39901. * Sets a float on a uniform variable.
  39902. * @param uniformName Name of the variable.
  39903. * @param value value to be set.
  39904. * @returns this effect.
  39905. */
  39906. setFloat(uniformName: string, value: number): Effect;
  39907. /**
  39908. * Sets a boolean on a uniform variable.
  39909. * @param uniformName Name of the variable.
  39910. * @param bool value to be set.
  39911. * @returns this effect.
  39912. */
  39913. setBool(uniformName: string, bool: boolean): Effect;
  39914. /**
  39915. * Sets a Vector2 on a uniform variable.
  39916. * @param uniformName Name of the variable.
  39917. * @param vector2 vector2 to be set.
  39918. * @returns this effect.
  39919. */
  39920. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  39921. /**
  39922. * Sets a float2 on a uniform variable.
  39923. * @param uniformName Name of the variable.
  39924. * @param x First float in float2.
  39925. * @param y Second float in float2.
  39926. * @returns this effect.
  39927. */
  39928. setFloat2(uniformName: string, x: number, y: number): Effect;
  39929. /**
  39930. * Sets a Vector3 on a uniform variable.
  39931. * @param uniformName Name of the variable.
  39932. * @param vector3 Value to be set.
  39933. * @returns this effect.
  39934. */
  39935. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  39936. /**
  39937. * Sets a float3 on a uniform variable.
  39938. * @param uniformName Name of the variable.
  39939. * @param x First float in float3.
  39940. * @param y Second float in float3.
  39941. * @param z Third float in float3.
  39942. * @returns this effect.
  39943. */
  39944. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  39945. /**
  39946. * Sets a Vector4 on a uniform variable.
  39947. * @param uniformName Name of the variable.
  39948. * @param vector4 Value to be set.
  39949. * @returns this effect.
  39950. */
  39951. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  39952. /**
  39953. * Sets a float4 on a uniform variable.
  39954. * @param uniformName Name of the variable.
  39955. * @param x First float in float4.
  39956. * @param y Second float in float4.
  39957. * @param z Third float in float4.
  39958. * @param w Fourth float in float4.
  39959. * @returns this effect.
  39960. */
  39961. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39962. /**
  39963. * Sets a Color3 on a uniform variable.
  39964. * @param uniformName Name of the variable.
  39965. * @param color3 Value to be set.
  39966. * @returns this effect.
  39967. */
  39968. setColor3(uniformName: string, color3: IColor3Like): Effect;
  39969. /**
  39970. * Sets a Color4 on a uniform variable.
  39971. * @param uniformName Name of the variable.
  39972. * @param color3 Value to be set.
  39973. * @param alpha Alpha value to be set.
  39974. * @returns this effect.
  39975. */
  39976. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  39977. /**
  39978. * Sets a Color4 on a uniform variable
  39979. * @param uniformName defines the name of the variable
  39980. * @param color4 defines the value to be set
  39981. * @returns this effect.
  39982. */
  39983. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  39984. /**
  39985. * Release all associated resources.
  39986. **/
  39987. dispose(): void;
  39988. /**
  39989. * This function will add a new shader to the shader store
  39990. * @param name the name of the shader
  39991. * @param pixelShader optional pixel shader content
  39992. * @param vertexShader optional vertex shader content
  39993. */
  39994. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  39995. /**
  39996. * Store of each shader (The can be looked up using effect.key)
  39997. */
  39998. static ShadersStore: {
  39999. [key: string]: string;
  40000. };
  40001. /**
  40002. * Store of each included file for a shader (The can be looked up using effect.key)
  40003. */
  40004. static IncludesShadersStore: {
  40005. [key: string]: string;
  40006. };
  40007. /**
  40008. * Resets the cache of effects.
  40009. */
  40010. static ResetCache(): void;
  40011. }
  40012. }
  40013. declare module BABYLON {
  40014. /**
  40015. * Interface used to describe the capabilities of the engine relatively to the current browser
  40016. */
  40017. export interface EngineCapabilities {
  40018. /** Maximum textures units per fragment shader */
  40019. maxTexturesImageUnits: number;
  40020. /** Maximum texture units per vertex shader */
  40021. maxVertexTextureImageUnits: number;
  40022. /** Maximum textures units in the entire pipeline */
  40023. maxCombinedTexturesImageUnits: number;
  40024. /** Maximum texture size */
  40025. maxTextureSize: number;
  40026. /** Maximum texture samples */
  40027. maxSamples?: number;
  40028. /** Maximum cube texture size */
  40029. maxCubemapTextureSize: number;
  40030. /** Maximum render texture size */
  40031. maxRenderTextureSize: number;
  40032. /** Maximum number of vertex attributes */
  40033. maxVertexAttribs: number;
  40034. /** Maximum number of varyings */
  40035. maxVaryingVectors: number;
  40036. /** Maximum number of uniforms per vertex shader */
  40037. maxVertexUniformVectors: number;
  40038. /** Maximum number of uniforms per fragment shader */
  40039. maxFragmentUniformVectors: number;
  40040. /** Defines if standard derivatives (dx/dy) are supported */
  40041. standardDerivatives: boolean;
  40042. /** Defines if s3tc texture compression is supported */
  40043. s3tc?: WEBGL_compressed_texture_s3tc;
  40044. /** Defines if pvrtc texture compression is supported */
  40045. pvrtc: any;
  40046. /** Defines if etc1 texture compression is supported */
  40047. etc1: any;
  40048. /** Defines if etc2 texture compression is supported */
  40049. etc2: any;
  40050. /** Defines if astc texture compression is supported */
  40051. astc: any;
  40052. /** Defines if bptc texture compression is supported */
  40053. bptc: any;
  40054. /** Defines if float textures are supported */
  40055. textureFloat: boolean;
  40056. /** Defines if vertex array objects are supported */
  40057. vertexArrayObject: boolean;
  40058. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  40059. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  40060. /** Gets the maximum level of anisotropy supported */
  40061. maxAnisotropy: number;
  40062. /** Defines if instancing is supported */
  40063. instancedArrays: boolean;
  40064. /** Defines if 32 bits indices are supported */
  40065. uintIndices: boolean;
  40066. /** Defines if high precision shaders are supported */
  40067. highPrecisionShaderSupported: boolean;
  40068. /** Defines if depth reading in the fragment shader is supported */
  40069. fragmentDepthSupported: boolean;
  40070. /** Defines if float texture linear filtering is supported*/
  40071. textureFloatLinearFiltering: boolean;
  40072. /** Defines if rendering to float textures is supported */
  40073. textureFloatRender: boolean;
  40074. /** Defines if half float textures are supported*/
  40075. textureHalfFloat: boolean;
  40076. /** Defines if half float texture linear filtering is supported*/
  40077. textureHalfFloatLinearFiltering: boolean;
  40078. /** Defines if rendering to half float textures is supported */
  40079. textureHalfFloatRender: boolean;
  40080. /** Defines if textureLOD shader command is supported */
  40081. textureLOD: boolean;
  40082. /** Defines if draw buffers extension is supported */
  40083. drawBuffersExtension: boolean;
  40084. /** Defines if depth textures are supported */
  40085. depthTextureExtension: boolean;
  40086. /** Defines if float color buffer are supported */
  40087. colorBufferFloat: boolean;
  40088. /** Gets disjoint timer query extension (null if not supported) */
  40089. timerQuery?: EXT_disjoint_timer_query;
  40090. /** Defines if timestamp can be used with timer query */
  40091. canUseTimestampForTimerQuery: boolean;
  40092. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  40093. multiview?: any;
  40094. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  40095. oculusMultiview?: any;
  40096. /** Function used to let the system compiles shaders in background */
  40097. parallelShaderCompile?: {
  40098. COMPLETION_STATUS_KHR: number;
  40099. };
  40100. /** Max number of texture samples for MSAA */
  40101. maxMSAASamples: number;
  40102. /** Defines if the blend min max extension is supported */
  40103. blendMinMax: boolean;
  40104. /** 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 */
  40105. canUseGLInstanceID: boolean;
  40106. /** Defines if gl_vertexID is available */
  40107. canUseGLVertexID: boolean;
  40108. }
  40109. }
  40110. declare module BABYLON {
  40111. /**
  40112. * @hidden
  40113. **/
  40114. export class DepthCullingState {
  40115. protected _isDepthTestDirty: boolean;
  40116. protected _isDepthMaskDirty: boolean;
  40117. protected _isDepthFuncDirty: boolean;
  40118. protected _isCullFaceDirty: boolean;
  40119. protected _isCullDirty: boolean;
  40120. protected _isZOffsetDirty: boolean;
  40121. protected _isFrontFaceDirty: boolean;
  40122. protected _depthTest: boolean;
  40123. protected _depthMask: boolean;
  40124. protected _depthFunc: Nullable<number>;
  40125. protected _cull: Nullable<boolean>;
  40126. protected _cullFace: Nullable<number>;
  40127. protected _zOffset: number;
  40128. protected _frontFace: Nullable<number>;
  40129. /**
  40130. * Initializes the state.
  40131. */
  40132. constructor(reset?: boolean);
  40133. get isDirty(): boolean;
  40134. get zOffset(): number;
  40135. set zOffset(value: number);
  40136. get cullFace(): Nullable<number>;
  40137. set cullFace(value: Nullable<number>);
  40138. get cull(): Nullable<boolean>;
  40139. set cull(value: Nullable<boolean>);
  40140. get depthFunc(): Nullable<number>;
  40141. set depthFunc(value: Nullable<number>);
  40142. get depthMask(): boolean;
  40143. set depthMask(value: boolean);
  40144. get depthTest(): boolean;
  40145. set depthTest(value: boolean);
  40146. get frontFace(): Nullable<number>;
  40147. set frontFace(value: Nullable<number>);
  40148. reset(): void;
  40149. apply(gl: WebGLRenderingContext): void;
  40150. }
  40151. }
  40152. declare module BABYLON {
  40153. /**
  40154. * @hidden
  40155. **/
  40156. export class StencilState {
  40157. /** 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 */
  40158. static readonly ALWAYS: number;
  40159. /** Passed to stencilOperation to specify that stencil value must be kept */
  40160. static readonly KEEP: number;
  40161. /** Passed to stencilOperation to specify that stencil value must be replaced */
  40162. static readonly REPLACE: number;
  40163. protected _isStencilTestDirty: boolean;
  40164. protected _isStencilMaskDirty: boolean;
  40165. protected _isStencilFuncDirty: boolean;
  40166. protected _isStencilOpDirty: boolean;
  40167. protected _stencilTest: boolean;
  40168. protected _stencilMask: number;
  40169. protected _stencilFunc: number;
  40170. protected _stencilFuncRef: number;
  40171. protected _stencilFuncMask: number;
  40172. protected _stencilOpStencilFail: number;
  40173. protected _stencilOpDepthFail: number;
  40174. protected _stencilOpStencilDepthPass: number;
  40175. get isDirty(): boolean;
  40176. get stencilFunc(): number;
  40177. set stencilFunc(value: number);
  40178. get stencilFuncRef(): number;
  40179. set stencilFuncRef(value: number);
  40180. get stencilFuncMask(): number;
  40181. set stencilFuncMask(value: number);
  40182. get stencilOpStencilFail(): number;
  40183. set stencilOpStencilFail(value: number);
  40184. get stencilOpDepthFail(): number;
  40185. set stencilOpDepthFail(value: number);
  40186. get stencilOpStencilDepthPass(): number;
  40187. set stencilOpStencilDepthPass(value: number);
  40188. get stencilMask(): number;
  40189. set stencilMask(value: number);
  40190. get stencilTest(): boolean;
  40191. set stencilTest(value: boolean);
  40192. constructor(reset?: boolean);
  40193. reset(): void;
  40194. apply(gl: WebGLRenderingContext): void;
  40195. }
  40196. }
  40197. declare module BABYLON {
  40198. /**
  40199. * @hidden
  40200. **/
  40201. export class AlphaState {
  40202. _blendFunctionParameters: Nullable<number>[];
  40203. _blendEquationParameters: Nullable<number>[];
  40204. _blendConstants: Nullable<number>[];
  40205. _isBlendConstantsDirty: boolean;
  40206. private _alphaBlend;
  40207. private _isAlphaBlendDirty;
  40208. private _isBlendFunctionParametersDirty;
  40209. private _isBlendEquationParametersDirty;
  40210. /**
  40211. * Initializes the state.
  40212. */
  40213. constructor();
  40214. get isDirty(): boolean;
  40215. get alphaBlend(): boolean;
  40216. set alphaBlend(value: boolean);
  40217. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  40218. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  40219. setAlphaEquationParameters(rgb: number, alpha: number): void;
  40220. reset(): void;
  40221. apply(gl: WebGLRenderingContext): void;
  40222. }
  40223. }
  40224. declare module BABYLON {
  40225. /** @hidden */
  40226. export class WebGLShaderProcessor implements IShaderProcessor {
  40227. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  40228. }
  40229. }
  40230. declare module BABYLON {
  40231. /** @hidden */
  40232. export class WebGL2ShaderProcessor implements IShaderProcessor {
  40233. attributeProcessor(attribute: string): string;
  40234. varyingProcessor(varying: string, isFragment: boolean): string;
  40235. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  40236. }
  40237. }
  40238. declare module BABYLON {
  40239. /**
  40240. * Interface for attribute information associated with buffer instantiation
  40241. */
  40242. export interface InstancingAttributeInfo {
  40243. /**
  40244. * Name of the GLSL attribute
  40245. * if attribute index is not specified, this is used to retrieve the index from the effect
  40246. */
  40247. attributeName: string;
  40248. /**
  40249. * Index/offset of the attribute in the vertex shader
  40250. * if not specified, this will be computes from the name.
  40251. */
  40252. index?: number;
  40253. /**
  40254. * size of the attribute, 1, 2, 3 or 4
  40255. */
  40256. attributeSize: number;
  40257. /**
  40258. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  40259. */
  40260. offset: number;
  40261. /**
  40262. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  40263. * default to 1
  40264. */
  40265. divisor?: number;
  40266. /**
  40267. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  40268. * default is FLOAT
  40269. */
  40270. attributeType?: number;
  40271. /**
  40272. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  40273. */
  40274. normalized?: boolean;
  40275. }
  40276. }
  40277. declare module BABYLON {
  40278. /** @hidden */
  40279. export interface EngineFeatures {
  40280. /** Force using Bitmap when Bitmap or HTMLImageElement can be used */
  40281. forceBitmapOverHTMLImageElement: boolean;
  40282. /** Indicates that the engine support rendering to as well as copying to lod float textures */
  40283. supportRenderAndCopyToLodForFloatTextures: boolean;
  40284. /** Indicates that the engine support handling depth/stencil textures */
  40285. supportDepthStencilTexture: boolean;
  40286. /** Indicates that the engine support shadow samplers */
  40287. supportShadowSamplers: boolean;
  40288. /** 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 */
  40289. uniformBufferHardCheckMatrix: boolean;
  40290. /** Indicates that prefiltered mipmaps can be generated in some processes (for eg when loading an HDR cube texture) */
  40291. allowTexturePrefiltering: boolean;
  40292. /** Indicates to track the usage of ubos and to create new ones as necessary during a frame duration */
  40293. trackUbosInFrame: boolean;
  40294. /** Indicates that the Cascaded Shadow Map technic is supported */
  40295. supportCSM: boolean;
  40296. /** Indicates that the textures transcoded by the basis transcoder must have power of 2 width and height */
  40297. basisNeedsPOT: boolean;
  40298. /** Indicates that the engine supports 3D textures */
  40299. support3DTextures: boolean;
  40300. /** Indicates that constants need a type suffix in shaders (used by realtime filtering...) */
  40301. needTypeSuffixInShaderConstants: boolean;
  40302. /** Indicates that MSAA is supported */
  40303. supportMSAA: boolean;
  40304. /** Indicates that SSAO2 is supported */
  40305. supportSSAO2: boolean;
  40306. /** Indicates that some additional texture formats are supported (like TEXTUREFORMAT_R for eg) */
  40307. supportExtendedTextureFormats: boolean;
  40308. /** Indicates that the switch/case construct is supported in shaders */
  40309. supportSwitchCaseInShader: boolean;
  40310. /** Indicates that synchronous texture reading is supported */
  40311. supportSyncTextureRead: boolean;
  40312. /** Indicates that y should be inverted when dealing with bitmaps (notably in environment tools) */
  40313. needsInvertingBitmap: boolean;
  40314. /** @hidden */
  40315. _collectUbosUpdatedInFrame: boolean;
  40316. }
  40317. }
  40318. declare module BABYLON {
  40319. /** @hidden */
  40320. export class WebGLHardwareTexture implements HardwareTextureWrapper {
  40321. private _webGLTexture;
  40322. private _context;
  40323. get underlyingResource(): Nullable<WebGLTexture>;
  40324. constructor(existingTexture: WebGLTexture | null | undefined, context: WebGLRenderingContext);
  40325. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  40326. set(hardwareTexture: WebGLTexture): void;
  40327. reset(): void;
  40328. release(): void;
  40329. }
  40330. }
  40331. declare module BABYLON {
  40332. interface ThinEngine {
  40333. /**
  40334. * Update a video texture
  40335. * @param texture defines the texture to update
  40336. * @param video defines the video element to use
  40337. * @param invertY defines if data must be stored with Y axis inverted
  40338. */
  40339. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  40340. }
  40341. }
  40342. declare module BABYLON {
  40343. interface ThinEngine {
  40344. /**
  40345. * Creates a dynamic texture
  40346. * @param width defines the width of the texture
  40347. * @param height defines the height of the texture
  40348. * @param generateMipMaps defines if the engine should generate the mip levels
  40349. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  40350. * @returns the dynamic texture inside an InternalTexture
  40351. */
  40352. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  40353. /**
  40354. * Update the content of a dynamic texture
  40355. * @param texture defines the texture to update
  40356. * @param source defines the source containing the data
  40357. * @param invertY defines if data must be stored with Y axis inverted
  40358. * @param premulAlpha defines if alpha is stored as premultiplied
  40359. * @param format defines the format of the data
  40360. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  40361. */
  40362. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  40363. }
  40364. }
  40365. declare module BABYLON {
  40366. /**
  40367. * Settings for finer control over video usage
  40368. */
  40369. export interface VideoTextureSettings {
  40370. /**
  40371. * Applies `autoplay` to video, if specified
  40372. */
  40373. autoPlay?: boolean;
  40374. /**
  40375. * Applies `muted` to video, if specified
  40376. */
  40377. muted?: boolean;
  40378. /**
  40379. * Applies `loop` to video, if specified
  40380. */
  40381. loop?: boolean;
  40382. /**
  40383. * Automatically updates internal texture from video at every frame in the render loop
  40384. */
  40385. autoUpdateTexture: boolean;
  40386. /**
  40387. * Image src displayed during the video loading or until the user interacts with the video.
  40388. */
  40389. poster?: string;
  40390. }
  40391. /**
  40392. * If you want to display a video in your scene, this is the special texture for that.
  40393. * This special texture works similar to other textures, with the exception of a few parameters.
  40394. * @see https://doc.babylonjs.com/how_to/video_texture
  40395. */
  40396. export class VideoTexture extends Texture {
  40397. /**
  40398. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  40399. */
  40400. readonly autoUpdateTexture: boolean;
  40401. /**
  40402. * The video instance used by the texture internally
  40403. */
  40404. readonly video: HTMLVideoElement;
  40405. private _onUserActionRequestedObservable;
  40406. /**
  40407. * Event triggered when a dom action is required by the user to play the video.
  40408. * This happens due to recent changes in browser policies preventing video to auto start.
  40409. */
  40410. get onUserActionRequestedObservable(): Observable<Texture>;
  40411. private _generateMipMaps;
  40412. private _stillImageCaptured;
  40413. private _displayingPosterTexture;
  40414. private _settings;
  40415. private _createInternalTextureOnEvent;
  40416. private _frameId;
  40417. private _currentSrc;
  40418. /**
  40419. * Creates a video texture.
  40420. * If you want to display a video in your scene, this is the special texture for that.
  40421. * This special texture works similar to other textures, with the exception of a few parameters.
  40422. * @see https://doc.babylonjs.com/how_to/video_texture
  40423. * @param name optional name, will detect from video source, if not defined
  40424. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  40425. * @param scene is obviously the current scene.
  40426. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  40427. * @param invertY is false by default but can be used to invert video on Y axis
  40428. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  40429. * @param settings allows finer control over video usage
  40430. */
  40431. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  40432. private _getName;
  40433. private _getVideo;
  40434. private _createInternalTexture;
  40435. private reset;
  40436. /**
  40437. * @hidden Internal method to initiate `update`.
  40438. */
  40439. _rebuild(): void;
  40440. /**
  40441. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  40442. */
  40443. update(): void;
  40444. /**
  40445. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  40446. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or otherwise.
  40447. */
  40448. updateTexture(isVisible: boolean): void;
  40449. protected _updateInternalTexture: () => void;
  40450. /**
  40451. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  40452. * @param url New url.
  40453. */
  40454. updateURL(url: string): void;
  40455. /**
  40456. * Clones the texture.
  40457. * @returns the cloned texture
  40458. */
  40459. clone(): VideoTexture;
  40460. /**
  40461. * Dispose the texture and release its associated resources.
  40462. */
  40463. dispose(): void;
  40464. /**
  40465. * Creates a video texture straight from a stream.
  40466. * @param scene Define the scene the texture should be created in
  40467. * @param stream Define the stream the texture should be created from
  40468. * @returns The created video texture as a promise
  40469. */
  40470. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  40471. /**
  40472. * Creates a video texture straight from your WebCam video feed.
  40473. * @param scene Define the scene the texture should be created in
  40474. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40475. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40476. * @returns The created video texture as a promise
  40477. */
  40478. static CreateFromWebCamAsync(scene: Scene, constraints: {
  40479. minWidth: number;
  40480. maxWidth: number;
  40481. minHeight: number;
  40482. maxHeight: number;
  40483. deviceId: string;
  40484. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  40485. /**
  40486. * Creates a video texture straight from your WebCam video feed.
  40487. * @param scene Define the scene the texture should be created in
  40488. * @param onReady Define a callback to triggered once the texture will be ready
  40489. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40490. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40491. */
  40492. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  40493. minWidth: number;
  40494. maxWidth: number;
  40495. minHeight: number;
  40496. maxHeight: number;
  40497. deviceId: string;
  40498. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  40499. }
  40500. }
  40501. declare module BABYLON {
  40502. /**
  40503. * Defines the interface used by objects working like Scene
  40504. * @hidden
  40505. */
  40506. export interface ISceneLike {
  40507. _addPendingData(data: any): void;
  40508. _removePendingData(data: any): void;
  40509. offlineProvider: IOfflineProvider;
  40510. }
  40511. /**
  40512. * Information about the current host
  40513. */
  40514. export interface HostInformation {
  40515. /**
  40516. * Defines if the current host is a mobile
  40517. */
  40518. isMobile: boolean;
  40519. }
  40520. /** Interface defining initialization parameters for Engine class */
  40521. export interface EngineOptions extends WebGLContextAttributes {
  40522. /**
  40523. * Defines if the engine should no exceed a specified device ratio
  40524. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  40525. */
  40526. limitDeviceRatio?: number;
  40527. /**
  40528. * Defines if webvr should be enabled automatically
  40529. * @see https://doc.babylonjs.com/how_to/webvr_camera
  40530. */
  40531. autoEnableWebVR?: boolean;
  40532. /**
  40533. * Defines if webgl2 should be turned off even if supported
  40534. * @see https://doc.babylonjs.com/features/webgl2
  40535. */
  40536. disableWebGL2Support?: boolean;
  40537. /**
  40538. * Defines if webaudio should be initialized as well
  40539. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40540. */
  40541. audioEngine?: boolean;
  40542. /**
  40543. * Defines if animations should run using a deterministic lock step
  40544. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40545. */
  40546. deterministicLockstep?: boolean;
  40547. /** Defines the maximum steps to use with deterministic lock step mode */
  40548. lockstepMaxSteps?: number;
  40549. /** Defines the seconds between each deterministic lock step */
  40550. timeStep?: number;
  40551. /**
  40552. * Defines that engine should ignore context lost events
  40553. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  40554. */
  40555. doNotHandleContextLost?: boolean;
  40556. /**
  40557. * Defines that engine should ignore modifying touch action attribute and style
  40558. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  40559. */
  40560. doNotHandleTouchAction?: boolean;
  40561. /**
  40562. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  40563. */
  40564. useHighPrecisionFloats?: boolean;
  40565. /**
  40566. * Make the canvas XR Compatible for XR sessions
  40567. */
  40568. xrCompatible?: boolean;
  40569. /**
  40570. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  40571. */
  40572. useHighPrecisionMatrix?: boolean;
  40573. /**
  40574. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  40575. */
  40576. failIfMajorPerformanceCaveat?: boolean;
  40577. /**
  40578. * Defines whether to adapt to the device's viewport characteristics (default: false)
  40579. */
  40580. adaptToDeviceRatio?: boolean;
  40581. }
  40582. /**
  40583. * The base engine class (root of all engines)
  40584. */
  40585. export class ThinEngine {
  40586. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  40587. static ExceptionList: ({
  40588. key: string;
  40589. capture: string;
  40590. captureConstraint: number;
  40591. targets: string[];
  40592. } | {
  40593. key: string;
  40594. capture: null;
  40595. captureConstraint: null;
  40596. targets: string[];
  40597. })[];
  40598. /** @hidden */
  40599. static _TextureLoaders: IInternalTextureLoader[];
  40600. /**
  40601. * Returns the current npm package of the sdk
  40602. */
  40603. static get NpmPackage(): string;
  40604. /**
  40605. * Returns the current version of the framework
  40606. */
  40607. static get Version(): string;
  40608. /**
  40609. * Returns a string describing the current engine
  40610. */
  40611. get description(): string;
  40612. /**
  40613. * Returns the name of the engine
  40614. */
  40615. get name(): string;
  40616. /**
  40617. * Returns the version of the engine
  40618. */
  40619. get version(): number;
  40620. /**
  40621. * Gets or sets the epsilon value used by collision engine
  40622. */
  40623. static CollisionsEpsilon: number;
  40624. /**
  40625. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  40626. */
  40627. static get ShadersRepository(): string;
  40628. static set ShadersRepository(value: string);
  40629. /** @hidden */
  40630. _shaderProcessor: Nullable<IShaderProcessor>;
  40631. /**
  40632. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  40633. */
  40634. forcePOTTextures: boolean;
  40635. /**
  40636. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  40637. */
  40638. isFullscreen: boolean;
  40639. /**
  40640. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  40641. */
  40642. cullBackFaces: boolean;
  40643. /**
  40644. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  40645. */
  40646. renderEvenInBackground: boolean;
  40647. /**
  40648. * Gets or sets a boolean indicating that cache can be kept between frames
  40649. */
  40650. preventCacheWipeBetweenFrames: boolean;
  40651. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  40652. validateShaderPrograms: boolean;
  40653. /**
  40654. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  40655. * This can provide greater z depth for distant objects.
  40656. */
  40657. useReverseDepthBuffer: boolean;
  40658. /**
  40659. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  40660. */
  40661. disableUniformBuffers: boolean;
  40662. private _frameId;
  40663. /**
  40664. * Gets the current frame id
  40665. */
  40666. get frameId(): number;
  40667. /** @hidden */
  40668. _uniformBuffers: UniformBuffer[];
  40669. /**
  40670. * Gets a boolean indicating that the engine supports uniform buffers
  40671. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  40672. */
  40673. get supportsUniformBuffers(): boolean;
  40674. /** @hidden */
  40675. _gl: WebGLRenderingContext;
  40676. /** @hidden */
  40677. _webGLVersion: number;
  40678. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  40679. protected _windowIsBackground: boolean;
  40680. protected _creationOptions: EngineOptions;
  40681. protected _highPrecisionShadersAllowed: boolean;
  40682. /** @hidden */
  40683. get _shouldUseHighPrecisionShader(): boolean;
  40684. /**
  40685. * Gets a boolean indicating that only power of 2 textures are supported
  40686. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  40687. */
  40688. get needPOTTextures(): boolean;
  40689. /** @hidden */
  40690. _badOS: boolean;
  40691. /** @hidden */
  40692. _badDesktopOS: boolean;
  40693. protected _hardwareScalingLevel: number;
  40694. /** @hidden */
  40695. _caps: EngineCapabilities;
  40696. /** @hidden */
  40697. _features: EngineFeatures;
  40698. protected _isStencilEnable: boolean;
  40699. private _glVersion;
  40700. private _glRenderer;
  40701. private _glVendor;
  40702. /** @hidden */
  40703. _videoTextureSupported: boolean;
  40704. protected _renderingQueueLaunched: boolean;
  40705. protected _activeRenderLoops: (() => void)[];
  40706. /**
  40707. * Observable signaled when a context lost event is raised
  40708. */
  40709. onContextLostObservable: Observable<ThinEngine>;
  40710. /**
  40711. * Observable signaled when a context restored event is raised
  40712. */
  40713. onContextRestoredObservable: Observable<ThinEngine>;
  40714. private _onContextLost;
  40715. private _onContextRestored;
  40716. protected _contextWasLost: boolean;
  40717. /** @hidden */
  40718. _doNotHandleContextLost: boolean;
  40719. /**
  40720. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  40721. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  40722. */
  40723. get doNotHandleContextLost(): boolean;
  40724. set doNotHandleContextLost(value: boolean);
  40725. /**
  40726. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  40727. */
  40728. disableVertexArrayObjects: boolean;
  40729. /** @hidden */
  40730. protected _colorWrite: boolean;
  40731. /** @hidden */
  40732. protected _colorWriteChanged: boolean;
  40733. /** @hidden */
  40734. protected _depthCullingState: DepthCullingState;
  40735. /** @hidden */
  40736. protected _stencilState: StencilState;
  40737. /** @hidden */
  40738. _alphaState: AlphaState;
  40739. /** @hidden */
  40740. _alphaMode: number;
  40741. /** @hidden */
  40742. _alphaEquation: number;
  40743. /** @hidden */
  40744. _internalTexturesCache: InternalTexture[];
  40745. /** @hidden */
  40746. protected _activeChannel: number;
  40747. private _currentTextureChannel;
  40748. /** @hidden */
  40749. protected _boundTexturesCache: {
  40750. [key: string]: Nullable<InternalTexture>;
  40751. };
  40752. /** @hidden */
  40753. protected _currentEffect: Nullable<Effect>;
  40754. /** @hidden */
  40755. protected _currentProgram: Nullable<WebGLProgram>;
  40756. protected _compiledEffects: {
  40757. [key: string]: Effect;
  40758. };
  40759. private _vertexAttribArraysEnabled;
  40760. /** @hidden */
  40761. protected _cachedViewport: Nullable<IViewportLike>;
  40762. private _cachedVertexArrayObject;
  40763. /** @hidden */
  40764. protected _cachedVertexBuffers: any;
  40765. /** @hidden */
  40766. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  40767. /** @hidden */
  40768. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  40769. /** @hidden */
  40770. _currentRenderTarget: Nullable<InternalTexture>;
  40771. private _uintIndicesCurrentlySet;
  40772. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  40773. /** @hidden */
  40774. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  40775. /** @hidden */
  40776. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  40777. private _currentBufferPointers;
  40778. private _currentInstanceLocations;
  40779. private _currentInstanceBuffers;
  40780. private _textureUnits;
  40781. /** @hidden */
  40782. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40783. /** @hidden */
  40784. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40785. /** @hidden */
  40786. _boundRenderFunction: any;
  40787. private _vaoRecordInProgress;
  40788. private _mustWipeVertexAttributes;
  40789. private _emptyTexture;
  40790. private _emptyCubeTexture;
  40791. private _emptyTexture3D;
  40792. private _emptyTexture2DArray;
  40793. /** @hidden */
  40794. _frameHandler: number;
  40795. private _nextFreeTextureSlots;
  40796. private _maxSimultaneousTextures;
  40797. private _activeRequests;
  40798. /** @hidden */
  40799. _transformTextureUrl: Nullable<(url: string) => string>;
  40800. /**
  40801. * Gets information about the current host
  40802. */
  40803. hostInformation: HostInformation;
  40804. protected get _supportsHardwareTextureRescaling(): boolean;
  40805. private _framebufferDimensionsObject;
  40806. /**
  40807. * sets the object from which width and height will be taken from when getting render width and height
  40808. * Will fallback to the gl object
  40809. * @param dimensions the framebuffer width and height that will be used.
  40810. */
  40811. set framebufferDimensionsObject(dimensions: Nullable<{
  40812. framebufferWidth: number;
  40813. framebufferHeight: number;
  40814. }>);
  40815. /**
  40816. * Gets the current viewport
  40817. */
  40818. get currentViewport(): Nullable<IViewportLike>;
  40819. /**
  40820. * Gets the default empty texture
  40821. */
  40822. get emptyTexture(): InternalTexture;
  40823. /**
  40824. * Gets the default empty 3D texture
  40825. */
  40826. get emptyTexture3D(): InternalTexture;
  40827. /**
  40828. * Gets the default empty 2D array texture
  40829. */
  40830. get emptyTexture2DArray(): InternalTexture;
  40831. /**
  40832. * Gets the default empty cube texture
  40833. */
  40834. get emptyCubeTexture(): InternalTexture;
  40835. /**
  40836. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  40837. */
  40838. premultipliedAlpha: boolean;
  40839. /**
  40840. * Observable event triggered before each texture is initialized
  40841. */
  40842. onBeforeTextureInitObservable: Observable<Texture>;
  40843. /** @hidden */
  40844. protected _isWebGPU: boolean;
  40845. /**
  40846. * Gets a boolean indicating if the engine runs in WebGPU or not.
  40847. */
  40848. get isWebGPU(): boolean;
  40849. /** @hidden */
  40850. protected _shaderPlatformName: string;
  40851. /**
  40852. * Gets the shader platfrom name used by the effects.
  40853. */
  40854. get shaderPlatformName(): string;
  40855. /**
  40856. * Creates a new engine
  40857. * @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
  40858. * @param antialias defines enable antialiasing (default: false)
  40859. * @param options defines further options to be sent to the getContext() function
  40860. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40861. */
  40862. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40863. /**
  40864. * @hidden
  40865. */
  40866. _debugPushGroup(groupName: string, targetObject?: number): void;
  40867. /**
  40868. * @hidden
  40869. */
  40870. _debugPopGroup(targetObject?: number): void;
  40871. /**
  40872. * @hidden
  40873. */
  40874. _debugInsertMarker(text: string, targetObject?: number): void;
  40875. /**
  40876. * Shared initialization across engines types.
  40877. * @param canvas The canvas associated with this instance of the engine.
  40878. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  40879. * @param audioEngine Defines if an audio engine should be created by default
  40880. */
  40881. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  40882. /**
  40883. * Gets a shader processor implementation fitting with the current engine type.
  40884. * @returns The shader processor implementation.
  40885. */
  40886. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  40887. /** @hidden */
  40888. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  40889. private _rebuildInternalTextures;
  40890. private _rebuildEffects;
  40891. /**
  40892. * Gets a boolean indicating if all created effects are ready
  40893. * @returns true if all effects are ready
  40894. */
  40895. areAllEffectsReady(): boolean;
  40896. protected _rebuildBuffers(): void;
  40897. protected _initGLContext(): void;
  40898. protected _initFeatures(): void;
  40899. /**
  40900. * Gets version of the current webGL context
  40901. * Keep it for back compat - use version instead
  40902. */
  40903. get webGLVersion(): number;
  40904. /**
  40905. * Gets a string identifying the name of the class
  40906. * @returns "Engine" string
  40907. */
  40908. getClassName(): string;
  40909. /**
  40910. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  40911. */
  40912. get isStencilEnable(): boolean;
  40913. /** @hidden */
  40914. _prepareWorkingCanvas(): void;
  40915. /**
  40916. * Reset the texture cache to empty state
  40917. */
  40918. resetTextureCache(): void;
  40919. /**
  40920. * Gets an object containing information about the current webGL context
  40921. * @returns an object containing the vendor, the renderer and the version of the current webGL context
  40922. */
  40923. getGlInfo(): {
  40924. vendor: string;
  40925. renderer: string;
  40926. version: string;
  40927. };
  40928. /**
  40929. * Defines the hardware scaling level.
  40930. * By default the hardware scaling level is computed from the window device ratio.
  40931. * 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.
  40932. * @param level defines the level to use
  40933. */
  40934. setHardwareScalingLevel(level: number): void;
  40935. /**
  40936. * Gets the current hardware scaling level.
  40937. * By default the hardware scaling level is computed from the window device ratio.
  40938. * 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.
  40939. * @returns a number indicating the current hardware scaling level
  40940. */
  40941. getHardwareScalingLevel(): number;
  40942. /**
  40943. * Gets the list of loaded textures
  40944. * @returns an array containing all loaded textures
  40945. */
  40946. getLoadedTexturesCache(): InternalTexture[];
  40947. /**
  40948. * Gets the object containing all engine capabilities
  40949. * @returns the EngineCapabilities object
  40950. */
  40951. getCaps(): EngineCapabilities;
  40952. /**
  40953. * stop executing a render loop function and remove it from the execution array
  40954. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  40955. */
  40956. stopRenderLoop(renderFunction?: () => void): void;
  40957. /** @hidden */
  40958. _renderLoop(): void;
  40959. /**
  40960. * Gets the HTML canvas attached with the current webGL context
  40961. * @returns a HTML canvas
  40962. */
  40963. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  40964. /**
  40965. * Gets host window
  40966. * @returns the host window object
  40967. */
  40968. getHostWindow(): Nullable<Window>;
  40969. /**
  40970. * Gets the current render width
  40971. * @param useScreen defines if screen size must be used (or the current render target if any)
  40972. * @returns a number defining the current render width
  40973. */
  40974. getRenderWidth(useScreen?: boolean): number;
  40975. /**
  40976. * Gets the current render height
  40977. * @param useScreen defines if screen size must be used (or the current render target if any)
  40978. * @returns a number defining the current render height
  40979. */
  40980. getRenderHeight(useScreen?: boolean): number;
  40981. /**
  40982. * Can be used to override the current requestAnimationFrame requester.
  40983. * @hidden
  40984. */
  40985. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  40986. /**
  40987. * Register and execute a render loop. The engine can have more than one render function
  40988. * @param renderFunction defines the function to continuously execute
  40989. */
  40990. runRenderLoop(renderFunction: () => void): void;
  40991. /**
  40992. * Clear the current render buffer or the current render target (if any is set up)
  40993. * @param color defines the color to use
  40994. * @param backBuffer defines if the back buffer must be cleared
  40995. * @param depth defines if the depth buffer must be cleared
  40996. * @param stencil defines if the stencil buffer must be cleared
  40997. */
  40998. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40999. protected _viewportCached: {
  41000. x: number;
  41001. y: number;
  41002. z: number;
  41003. w: number;
  41004. };
  41005. /** @hidden */
  41006. _viewport(x: number, y: number, width: number, height: number): void;
  41007. /**
  41008. * Set the WebGL's viewport
  41009. * @param viewport defines the viewport element to be used
  41010. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  41011. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  41012. */
  41013. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  41014. /**
  41015. * Begin a new frame
  41016. */
  41017. beginFrame(): void;
  41018. /**
  41019. * Enf the current frame
  41020. */
  41021. endFrame(): void;
  41022. /**
  41023. * Resize the view according to the canvas' size
  41024. * @param forceSetSize true to force setting the sizes of the underlying canvas
  41025. */
  41026. resize(forceSetSize?: boolean): void;
  41027. /**
  41028. * Force a specific size of the canvas
  41029. * @param width defines the new canvas' width
  41030. * @param height defines the new canvas' height
  41031. * @param forceSetSize true to force setting the sizes of the underlying canvas
  41032. * @returns true if the size was changed
  41033. */
  41034. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  41035. /**
  41036. * Binds the frame buffer to the specified texture.
  41037. * @param texture The texture to render to or null for the default canvas
  41038. * @param faceIndex The face of the texture to render to in case of cube texture
  41039. * @param requiredWidth The width of the target to render to
  41040. * @param requiredHeight The height of the target to render to
  41041. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  41042. * @param lodLevel defines the lod level to bind to the frame buffer
  41043. * @param layer defines the 2d array index to bind to frame buffer to
  41044. */
  41045. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  41046. /** @hidden */
  41047. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  41048. /**
  41049. * Unbind the current render target texture from the webGL context
  41050. * @param texture defines the render target texture to unbind
  41051. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  41052. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  41053. */
  41054. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41055. /**
  41056. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  41057. */
  41058. flushFramebuffer(): void;
  41059. /**
  41060. * Unbind the current render target and bind the default framebuffer
  41061. */
  41062. restoreDefaultFramebuffer(): void;
  41063. /** @hidden */
  41064. protected _resetVertexBufferBinding(): void;
  41065. /**
  41066. * Creates a vertex buffer
  41067. * @param data the data for the vertex buffer
  41068. * @returns the new WebGL static buffer
  41069. */
  41070. createVertexBuffer(data: DataArray): DataBuffer;
  41071. private _createVertexBuffer;
  41072. /**
  41073. * Creates a dynamic vertex buffer
  41074. * @param data the data for the dynamic vertex buffer
  41075. * @returns the new WebGL dynamic buffer
  41076. */
  41077. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  41078. protected _resetIndexBufferBinding(): void;
  41079. /**
  41080. * Creates a new index buffer
  41081. * @param indices defines the content of the index buffer
  41082. * @param updatable defines if the index buffer must be updatable
  41083. * @returns a new webGL buffer
  41084. */
  41085. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  41086. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  41087. /**
  41088. * Bind a webGL buffer to the webGL context
  41089. * @param buffer defines the buffer to bind
  41090. */
  41091. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  41092. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  41093. private bindBuffer;
  41094. /**
  41095. * update the bound buffer with the given data
  41096. * @param data defines the data to update
  41097. */
  41098. updateArrayBuffer(data: Float32Array): void;
  41099. private _vertexAttribPointer;
  41100. /** @hidden */
  41101. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  41102. private _bindVertexBuffersAttributes;
  41103. /**
  41104. * Records a vertex array object
  41105. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  41106. * @param vertexBuffers defines the list of vertex buffers to store
  41107. * @param indexBuffer defines the index buffer to store
  41108. * @param effect defines the effect to store
  41109. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  41110. * @returns the new vertex array object
  41111. */
  41112. recordVertexArrayObject(vertexBuffers: {
  41113. [key: string]: VertexBuffer;
  41114. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  41115. [kind: string]: Nullable<VertexBuffer>;
  41116. }): WebGLVertexArrayObject;
  41117. /**
  41118. * Bind a specific vertex array object
  41119. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  41120. * @param vertexArrayObject defines the vertex array object to bind
  41121. * @param indexBuffer defines the index buffer to bind
  41122. */
  41123. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  41124. /**
  41125. * Bind webGl buffers directly to the webGL context
  41126. * @param vertexBuffer defines the vertex buffer to bind
  41127. * @param indexBuffer defines the index buffer to bind
  41128. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  41129. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  41130. * @param effect defines the effect associated with the vertex buffer
  41131. */
  41132. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  41133. private _unbindVertexArrayObject;
  41134. /**
  41135. * Bind a list of vertex buffers to the webGL context
  41136. * @param vertexBuffers defines the list of vertex buffers to bind
  41137. * @param indexBuffer defines the index buffer to bind
  41138. * @param effect defines the effect associated with the vertex buffers
  41139. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  41140. */
  41141. bindBuffers(vertexBuffers: {
  41142. [key: string]: Nullable<VertexBuffer>;
  41143. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  41144. [kind: string]: Nullable<VertexBuffer>;
  41145. }): void;
  41146. /**
  41147. * Unbind all instance attributes
  41148. */
  41149. unbindInstanceAttributes(): void;
  41150. /**
  41151. * Release and free the memory of a vertex array object
  41152. * @param vao defines the vertex array object to delete
  41153. */
  41154. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  41155. /** @hidden */
  41156. _releaseBuffer(buffer: DataBuffer): boolean;
  41157. protected _deleteBuffer(buffer: DataBuffer): void;
  41158. /**
  41159. * Update the content of a webGL buffer used with instantiation and bind it to the webGL context
  41160. * @param instancesBuffer defines the webGL buffer to update and bind
  41161. * @param data defines the data to store in the buffer
  41162. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  41163. */
  41164. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  41165. /**
  41166. * Bind the content of a webGL buffer used with instantiation
  41167. * @param instancesBuffer defines the webGL buffer to bind
  41168. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  41169. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  41170. */
  41171. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  41172. /**
  41173. * Disable the instance attribute corresponding to the name in parameter
  41174. * @param name defines the name of the attribute to disable
  41175. */
  41176. disableInstanceAttributeByName(name: string): void;
  41177. /**
  41178. * Disable the instance attribute corresponding to the location in parameter
  41179. * @param attributeLocation defines the attribute location of the attribute to disable
  41180. */
  41181. disableInstanceAttribute(attributeLocation: number): void;
  41182. /**
  41183. * Disable the attribute corresponding to the location in parameter
  41184. * @param attributeLocation defines the attribute location of the attribute to disable
  41185. */
  41186. disableAttributeByIndex(attributeLocation: number): void;
  41187. /**
  41188. * Send a draw order
  41189. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  41190. * @param indexStart defines the starting index
  41191. * @param indexCount defines the number of index to draw
  41192. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  41193. */
  41194. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41195. /**
  41196. * Draw a list of points
  41197. * @param verticesStart defines the index of first vertex to draw
  41198. * @param verticesCount defines the count of vertices to draw
  41199. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  41200. */
  41201. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41202. /**
  41203. * Draw a list of unindexed primitives
  41204. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  41205. * @param verticesStart defines the index of first vertex to draw
  41206. * @param verticesCount defines the count of vertices to draw
  41207. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  41208. */
  41209. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41210. /**
  41211. * Draw a list of indexed primitives
  41212. * @param fillMode defines the primitive to use
  41213. * @param indexStart defines the starting index
  41214. * @param indexCount defines the number of index to draw
  41215. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  41216. */
  41217. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41218. /**
  41219. * Draw a list of unindexed primitives
  41220. * @param fillMode defines the primitive to use
  41221. * @param verticesStart defines the index of first vertex to draw
  41222. * @param verticesCount defines the count of vertices to draw
  41223. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  41224. */
  41225. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41226. private _drawMode;
  41227. /** @hidden */
  41228. protected _reportDrawCall(): void;
  41229. /** @hidden */
  41230. _releaseEffect(effect: Effect): void;
  41231. /** @hidden */
  41232. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  41233. /**
  41234. * Create a new effect (used to store vertex/fragment shaders)
  41235. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  41236. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  41237. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  41238. * @param samplers defines an array of string used to represent textures
  41239. * @param defines defines the string containing the defines to use to compile the shaders
  41240. * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails
  41241. * @param onCompiled defines a function to call when the effect creation is successful
  41242. * @param onError defines a function to call when the effect creation has failed
  41243. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  41244. * @returns the new Effect
  41245. */
  41246. 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;
  41247. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  41248. private _compileShader;
  41249. private _compileRawShader;
  41250. /** @hidden */
  41251. _getShaderSource(shader: WebGLShader): Nullable<string>;
  41252. /**
  41253. * Directly creates a webGL program
  41254. * @param pipelineContext defines the pipeline context to attach to
  41255. * @param vertexCode defines the vertex shader code to use
  41256. * @param fragmentCode defines the fragment shader code to use
  41257. * @param context defines the webGL context to use (if not set, the current one will be used)
  41258. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  41259. * @returns the new webGL program
  41260. */
  41261. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41262. /**
  41263. * Creates a webGL program
  41264. * @param pipelineContext defines the pipeline context to attach to
  41265. * @param vertexCode defines the vertex shader code to use
  41266. * @param fragmentCode defines the fragment shader code to use
  41267. * @param defines defines the string containing the defines to use to compile the shaders
  41268. * @param context defines the webGL context to use (if not set, the current one will be used)
  41269. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  41270. * @returns the new webGL program
  41271. */
  41272. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41273. /**
  41274. * Creates a new pipeline context
  41275. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  41276. * @returns the new pipeline
  41277. */
  41278. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  41279. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41280. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  41281. /** @hidden */
  41282. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  41283. /** @hidden */
  41284. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  41285. /** @hidden */
  41286. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  41287. /**
  41288. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  41289. * @param pipelineContext defines the pipeline context to use
  41290. * @param uniformsNames defines the list of uniform names
  41291. * @returns an array of webGL uniform locations
  41292. */
  41293. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  41294. /**
  41295. * Gets the list of active attributes for a given webGL program
  41296. * @param pipelineContext defines the pipeline context to use
  41297. * @param attributesNames defines the list of attribute names to get
  41298. * @returns an array of indices indicating the offset of each attribute
  41299. */
  41300. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  41301. /**
  41302. * Activates an effect, making it the current one (ie. the one used for rendering)
  41303. * @param effect defines the effect to activate
  41304. */
  41305. enableEffect(effect: Nullable<Effect>): void;
  41306. /**
  41307. * Set the value of an uniform to a number (int)
  41308. * @param uniform defines the webGL uniform location where to store the value
  41309. * @param value defines the int number to store
  41310. * @returns true if the value was set
  41311. */
  41312. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  41313. /**
  41314. * Set the value of an uniform to a int2
  41315. * @param uniform defines the webGL uniform location where to store the value
  41316. * @param x defines the 1st component of the value
  41317. * @param y defines the 2nd component of the value
  41318. * @returns true if the value was set
  41319. */
  41320. setInt2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  41321. /**
  41322. * Set the value of an uniform to a int3
  41323. * @param uniform defines the webGL uniform location where to store the value
  41324. * @param x defines the 1st component of the value
  41325. * @param y defines the 2nd component of the value
  41326. * @param z defines the 3rd component of the value
  41327. * @returns true if the value was set
  41328. */
  41329. setInt3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  41330. /**
  41331. * Set the value of an uniform to a int4
  41332. * @param uniform defines the webGL uniform location where to store the value
  41333. * @param x defines the 1st component of the value
  41334. * @param y defines the 2nd component of the value
  41335. * @param z defines the 3rd component of the value
  41336. * @param w defines the 4th component of the value
  41337. * @returns true if the value was set
  41338. */
  41339. setInt4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  41340. /**
  41341. * Set the value of an uniform to an array of int32
  41342. * @param uniform defines the webGL uniform location where to store the value
  41343. * @param array defines the array of int32 to store
  41344. * @returns true if the value was set
  41345. */
  41346. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41347. /**
  41348. * Set the value of an uniform to an array of int32 (stored as vec2)
  41349. * @param uniform defines the webGL uniform location where to store the value
  41350. * @param array defines the array of int32 to store
  41351. * @returns true if the value was set
  41352. */
  41353. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41354. /**
  41355. * Set the value of an uniform to an array of int32 (stored as vec3)
  41356. * @param uniform defines the webGL uniform location where to store the value
  41357. * @param array defines the array of int32 to store
  41358. * @returns true if the value was set
  41359. */
  41360. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41361. /**
  41362. * Set the value of an uniform to an array of int32 (stored as vec4)
  41363. * @param uniform defines the webGL uniform location where to store the value
  41364. * @param array defines the array of int32 to store
  41365. * @returns true if the value was set
  41366. */
  41367. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41368. /**
  41369. * Set the value of an uniform to an array of number
  41370. * @param uniform defines the webGL uniform location where to store the value
  41371. * @param array defines the array of number to store
  41372. * @returns true if the value was set
  41373. */
  41374. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41375. /**
  41376. * Set the value of an uniform to an array of number (stored as vec2)
  41377. * @param uniform defines the webGL uniform location where to store the value
  41378. * @param array defines the array of number to store
  41379. * @returns true if the value was set
  41380. */
  41381. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41382. /**
  41383. * Set the value of an uniform to an array of number (stored as vec3)
  41384. * @param uniform defines the webGL uniform location where to store the value
  41385. * @param array defines the array of number to store
  41386. * @returns true if the value was set
  41387. */
  41388. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41389. /**
  41390. * Set the value of an uniform to an array of number (stored as vec4)
  41391. * @param uniform defines the webGL uniform location where to store the value
  41392. * @param array defines the array of number to store
  41393. * @returns true if the value was set
  41394. */
  41395. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41396. /**
  41397. * Set the value of an uniform to an array of float32 (stored as matrices)
  41398. * @param uniform defines the webGL uniform location where to store the value
  41399. * @param matrices defines the array of float32 to store
  41400. * @returns true if the value was set
  41401. */
  41402. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  41403. /**
  41404. * Set the value of an uniform to a matrix (3x3)
  41405. * @param uniform defines the webGL uniform location where to store the value
  41406. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  41407. * @returns true if the value was set
  41408. */
  41409. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  41410. /**
  41411. * Set the value of an uniform to a matrix (2x2)
  41412. * @param uniform defines the webGL uniform location where to store the value
  41413. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  41414. * @returns true if the value was set
  41415. */
  41416. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  41417. /**
  41418. * Set the value of an uniform to a number (float)
  41419. * @param uniform defines the webGL uniform location where to store the value
  41420. * @param value defines the float number to store
  41421. * @returns true if the value was transferred
  41422. */
  41423. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  41424. /**
  41425. * Set the value of an uniform to a vec2
  41426. * @param uniform defines the webGL uniform location where to store the value
  41427. * @param x defines the 1st component of the value
  41428. * @param y defines the 2nd component of the value
  41429. * @returns true if the value was set
  41430. */
  41431. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  41432. /**
  41433. * Set the value of an uniform to a vec3
  41434. * @param uniform defines the webGL uniform location where to store the value
  41435. * @param x defines the 1st component of the value
  41436. * @param y defines the 2nd component of the value
  41437. * @param z defines the 3rd component of the value
  41438. * @returns true if the value was set
  41439. */
  41440. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  41441. /**
  41442. * Set the value of an uniform to a vec4
  41443. * @param uniform defines the webGL uniform location where to store the value
  41444. * @param x defines the 1st component of the value
  41445. * @param y defines the 2nd component of the value
  41446. * @param z defines the 3rd component of the value
  41447. * @param w defines the 4th component of the value
  41448. * @returns true if the value was set
  41449. */
  41450. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  41451. /**
  41452. * Apply all cached states (depth, culling, stencil and alpha)
  41453. */
  41454. applyStates(): void;
  41455. /**
  41456. * Enable or disable color writing
  41457. * @param enable defines the state to set
  41458. */
  41459. setColorWrite(enable: boolean): void;
  41460. /**
  41461. * Gets a boolean indicating if color writing is enabled
  41462. * @returns the current color writing state
  41463. */
  41464. getColorWrite(): boolean;
  41465. /**
  41466. * Gets the depth culling state manager
  41467. */
  41468. get depthCullingState(): DepthCullingState;
  41469. /**
  41470. * Gets the alpha state manager
  41471. */
  41472. get alphaState(): AlphaState;
  41473. /**
  41474. * Gets the stencil state manager
  41475. */
  41476. get stencilState(): StencilState;
  41477. /**
  41478. * Clears the list of texture accessible through engine.
  41479. * This can help preventing texture load conflict due to name collision.
  41480. */
  41481. clearInternalTexturesCache(): void;
  41482. /**
  41483. * Force the entire cache to be cleared
  41484. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  41485. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  41486. */
  41487. wipeCaches(bruteForce?: boolean): void;
  41488. /** @hidden */
  41489. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  41490. min: number;
  41491. mag: number;
  41492. };
  41493. /** @hidden */
  41494. protected _createTexture(): WebGLTexture;
  41495. /** @hidden */
  41496. _createHardwareTexture(): HardwareTextureWrapper;
  41497. 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 | {
  41498. width: number;
  41499. height: number;
  41500. }, invertY: boolean, noMipmap: boolean, isCompressed: boolean, processFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  41501. width: number;
  41502. height: number;
  41503. }, extension: string, texture: InternalTexture, continuationCallback: () => void) => boolean, samplingMode: number) => void, prepareTextureProcessFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  41504. width: number;
  41505. height: number;
  41506. }, 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;
  41507. /**
  41508. * Usually called from Texture.ts.
  41509. * Passed information to create a WebGLTexture
  41510. * @param url defines a value which contains one of the following:
  41511. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  41512. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  41513. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  41514. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  41515. * @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)
  41516. * @param scene needed for loading to the correct scene
  41517. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  41518. * @param onLoad optional callback to be called upon successful completion
  41519. * @param onError optional callback to be called upon failure
  41520. * @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
  41521. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  41522. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  41523. * @param forcedExtension defines the extension to use to pick the right loader
  41524. * @param mimeType defines an optional mime type
  41525. * @param loaderOptions options to be passed to the loader
  41526. * @returns a InternalTexture for assignment back into BABYLON.Texture
  41527. */
  41528. 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;
  41529. /**
  41530. * Loads an image as an HTMLImageElement.
  41531. * @param input url string, ArrayBuffer, or Blob to load
  41532. * @param onLoad callback called when the image successfully loads
  41533. * @param onError callback called when the image fails to load
  41534. * @param offlineProvider offline provider for caching
  41535. * @param mimeType optional mime type
  41536. * @returns the HTMLImageElement of the loaded image
  41537. * @hidden
  41538. */
  41539. 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>;
  41540. /**
  41541. * @hidden
  41542. */
  41543. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41544. private _unpackFlipYCached;
  41545. /**
  41546. * In case you are sharing the context with other applications, it might
  41547. * be interested to not cache the unpack flip y state to ensure a consistent
  41548. * value would be set.
  41549. */
  41550. enableUnpackFlipYCached: boolean;
  41551. /** @hidden */
  41552. _unpackFlipY(value: boolean): void;
  41553. /** @hidden */
  41554. _getUnpackAlignement(): number;
  41555. private _getTextureTarget;
  41556. /**
  41557. * Update the sampling mode of a given texture
  41558. * @param samplingMode defines the required sampling mode
  41559. * @param texture defines the texture to update
  41560. * @param generateMipMaps defines whether to generate mipmaps for the texture
  41561. */
  41562. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  41563. /**
  41564. * Update the dimensions of a texture
  41565. * @param texture texture to update
  41566. * @param width new width of the texture
  41567. * @param height new height of the texture
  41568. * @param depth new depth of the texture
  41569. */
  41570. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  41571. /**
  41572. * Update the sampling mode of a given texture
  41573. * @param texture defines the texture to update
  41574. * @param wrapU defines the texture wrap mode of the u coordinates
  41575. * @param wrapV defines the texture wrap mode of the v coordinates
  41576. * @param wrapR defines the texture wrap mode of the r coordinates
  41577. */
  41578. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  41579. /** @hidden */
  41580. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  41581. width: number;
  41582. height: number;
  41583. layers?: number;
  41584. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  41585. /** @hidden */
  41586. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41587. /** @hidden */
  41588. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  41589. /**
  41590. * Update a portion of an internal texture
  41591. * @param texture defines the texture to update
  41592. * @param imageData defines the data to store into the texture
  41593. * @param xOffset defines the x coordinates of the update rectangle
  41594. * @param yOffset defines the y coordinates of the update rectangle
  41595. * @param width defines the width of the update rectangle
  41596. * @param height defines the height of the update rectangle
  41597. * @param faceIndex defines the face index if texture is a cube (0 by default)
  41598. * @param lod defines the lod level to update (0 by default)
  41599. */
  41600. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  41601. /** @hidden */
  41602. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41603. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  41604. private _prepareWebGLTexture;
  41605. /** @hidden */
  41606. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  41607. private _getDepthStencilBuffer;
  41608. /** @hidden */
  41609. _releaseFramebufferObjects(texture: InternalTexture): void;
  41610. /** @hidden */
  41611. _releaseTexture(texture: InternalTexture): void;
  41612. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  41613. protected _setProgram(program: WebGLProgram): void;
  41614. protected _boundUniforms: {
  41615. [key: number]: WebGLUniformLocation;
  41616. };
  41617. /**
  41618. * Binds an effect to the webGL context
  41619. * @param effect defines the effect to bind
  41620. */
  41621. bindSamplers(effect: Effect): void;
  41622. private _activateCurrentTexture;
  41623. /** @hidden */
  41624. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  41625. /** @hidden */
  41626. _bindTexture(channel: number, texture: Nullable<InternalTexture>, name: string): void;
  41627. /**
  41628. * Unbind all textures from the webGL context
  41629. */
  41630. unbindAllTextures(): void;
  41631. /**
  41632. * Sets a texture to the according uniform.
  41633. * @param channel The texture channel
  41634. * @param uniform The uniform to set
  41635. * @param texture The texture to apply
  41636. * @param name The name of the uniform in the effect
  41637. */
  41638. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>, name: string): void;
  41639. private _bindSamplerUniformToChannel;
  41640. private _getTextureWrapMode;
  41641. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string): boolean;
  41642. /**
  41643. * Sets an array of texture to the webGL context
  41644. * @param channel defines the channel where the texture array must be set
  41645. * @param uniform defines the associated uniform location
  41646. * @param textures defines the array of textures to bind
  41647. * @param name name of the channel
  41648. */
  41649. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[], name: string): void;
  41650. /** @hidden */
  41651. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  41652. private _setTextureParameterFloat;
  41653. private _setTextureParameterInteger;
  41654. /**
  41655. * Unbind all vertex attributes from the webGL context
  41656. */
  41657. unbindAllAttributes(): void;
  41658. /**
  41659. * 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
  41660. */
  41661. releaseEffects(): void;
  41662. /**
  41663. * Dispose and release all associated resources
  41664. */
  41665. dispose(): void;
  41666. /**
  41667. * Attach a new callback raised when context lost event is fired
  41668. * @param callback defines the callback to call
  41669. */
  41670. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41671. /**
  41672. * Attach a new callback raised when context restored event is fired
  41673. * @param callback defines the callback to call
  41674. */
  41675. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41676. /**
  41677. * Get the current error code of the webGL context
  41678. * @returns the error code
  41679. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41680. */
  41681. getError(): number;
  41682. private _canRenderToFloatFramebuffer;
  41683. private _canRenderToHalfFloatFramebuffer;
  41684. private _canRenderToFramebuffer;
  41685. /** @hidden */
  41686. _getWebGLTextureType(type: number): number;
  41687. /** @hidden */
  41688. _getInternalFormat(format: number): number;
  41689. /** @hidden */
  41690. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  41691. /** @hidden */
  41692. _getRGBAMultiSampleBufferFormat(type: number): number;
  41693. /** @hidden */
  41694. _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;
  41695. /**
  41696. * Loads a file from a url
  41697. * @param url url to load
  41698. * @param onSuccess callback called when the file successfully loads
  41699. * @param onProgress callback called while file is loading (if the server supports this mode)
  41700. * @param offlineProvider defines the offline provider for caching
  41701. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41702. * @param onError callback called when the file fails to load
  41703. * @returns a file request object
  41704. * @hidden
  41705. */
  41706. 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;
  41707. /**
  41708. * Reads pixels from the current frame buffer. Please note that this function can be slow
  41709. * @param x defines the x coordinate of the rectangle where pixels must be read
  41710. * @param y defines the y coordinate of the rectangle where pixels must be read
  41711. * @param width defines the width of the rectangle where pixels must be read
  41712. * @param height defines the height of the rectangle where pixels must be read
  41713. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  41714. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  41715. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  41716. */
  41717. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  41718. private static _IsSupported;
  41719. private static _HasMajorPerformanceCaveat;
  41720. /**
  41721. * Gets a boolean indicating if the engine can be instantiated (ie. if a webGL context can be found)
  41722. */
  41723. static get IsSupported(): boolean;
  41724. /**
  41725. * Gets a boolean indicating if the engine can be instantiated (ie. if a webGL context can be found)
  41726. * @returns true if the engine can be created
  41727. * @ignorenaming
  41728. */
  41729. static isSupported(): boolean;
  41730. /**
  41731. * 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)
  41732. */
  41733. static get HasMajorPerformanceCaveat(): boolean;
  41734. /**
  41735. * Find the next highest power of two.
  41736. * @param x Number to start search from.
  41737. * @return Next highest power of two.
  41738. */
  41739. static CeilingPOT(x: number): number;
  41740. /**
  41741. * Find the next lowest power of two.
  41742. * @param x Number to start search from.
  41743. * @return Next lowest power of two.
  41744. */
  41745. static FloorPOT(x: number): number;
  41746. /**
  41747. * Find the nearest power of two.
  41748. * @param x Number to start search from.
  41749. * @return Next nearest power of two.
  41750. */
  41751. static NearestPOT(x: number): number;
  41752. /**
  41753. * Get the closest exponent of two
  41754. * @param value defines the value to approximate
  41755. * @param max defines the maximum value to return
  41756. * @param mode defines how to define the closest value
  41757. * @returns closest exponent of two of the given value
  41758. */
  41759. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  41760. /**
  41761. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  41762. * @param func - the function to be called
  41763. * @param requester - the object that will request the next frame. Falls back to window.
  41764. * @returns frame number
  41765. */
  41766. static QueueNewFrame(func: () => void, requester?: any): number;
  41767. /**
  41768. * Gets host document
  41769. * @returns the host document object
  41770. */
  41771. getHostDocument(): Nullable<Document>;
  41772. }
  41773. }
  41774. declare module BABYLON {
  41775. /**
  41776. * Defines the source of the internal texture
  41777. */
  41778. export enum InternalTextureSource {
  41779. /**
  41780. * The source of the texture data is unknown
  41781. */
  41782. Unknown = 0,
  41783. /**
  41784. * Texture data comes from an URL
  41785. */
  41786. Url = 1,
  41787. /**
  41788. * Texture data is only used for temporary storage
  41789. */
  41790. Temp = 2,
  41791. /**
  41792. * Texture data comes from raw data (ArrayBuffer)
  41793. */
  41794. Raw = 3,
  41795. /**
  41796. * Texture content is dynamic (video or dynamic texture)
  41797. */
  41798. Dynamic = 4,
  41799. /**
  41800. * Texture content is generated by rendering to it
  41801. */
  41802. RenderTarget = 5,
  41803. /**
  41804. * Texture content is part of a multi render target process
  41805. */
  41806. MultiRenderTarget = 6,
  41807. /**
  41808. * Texture data comes from a cube data file
  41809. */
  41810. Cube = 7,
  41811. /**
  41812. * Texture data comes from a raw cube data
  41813. */
  41814. CubeRaw = 8,
  41815. /**
  41816. * Texture data come from a prefiltered cube data file
  41817. */
  41818. CubePrefiltered = 9,
  41819. /**
  41820. * Texture content is raw 3D data
  41821. */
  41822. Raw3D = 10,
  41823. /**
  41824. * Texture content is raw 2D array data
  41825. */
  41826. Raw2DArray = 11,
  41827. /**
  41828. * Texture content is a depth texture
  41829. */
  41830. Depth = 12,
  41831. /**
  41832. * Texture data comes from a raw cube data encoded with RGBD
  41833. */
  41834. CubeRawRGBD = 13
  41835. }
  41836. /**
  41837. * Class used to store data associated with WebGL texture data for the engine
  41838. * This class should not be used directly
  41839. */
  41840. export class InternalTexture {
  41841. /** @hidden */
  41842. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  41843. /**
  41844. * Defines if the texture is ready
  41845. */
  41846. isReady: boolean;
  41847. /**
  41848. * Defines if the texture is a cube texture
  41849. */
  41850. isCube: boolean;
  41851. /**
  41852. * Defines if the texture contains 3D data
  41853. */
  41854. is3D: boolean;
  41855. /**
  41856. * Defines if the texture contains 2D array data
  41857. */
  41858. is2DArray: boolean;
  41859. /**
  41860. * Defines if the texture contains multiview data
  41861. */
  41862. isMultiview: boolean;
  41863. /**
  41864. * Gets the URL used to load this texture
  41865. */
  41866. url: string;
  41867. /** @hidden */
  41868. _originalUrl: string;
  41869. /**
  41870. * Gets the sampling mode of the texture
  41871. */
  41872. samplingMode: number;
  41873. /**
  41874. * Gets a boolean indicating if the texture needs mipmaps generation
  41875. */
  41876. generateMipMaps: boolean;
  41877. /**
  41878. * Gets the number of samples used by the texture (WebGL2+ only)
  41879. */
  41880. samples: number;
  41881. /**
  41882. * Gets the type of the texture (int, float...)
  41883. */
  41884. type: number;
  41885. /**
  41886. * Gets the format of the texture (RGB, RGBA...)
  41887. */
  41888. format: number;
  41889. /**
  41890. * Observable called when the texture is loaded
  41891. */
  41892. onLoadedObservable: Observable<InternalTexture>;
  41893. /**
  41894. * Gets the width of the texture
  41895. */
  41896. width: number;
  41897. /**
  41898. * Gets the height of the texture
  41899. */
  41900. height: number;
  41901. /**
  41902. * Gets the depth of the texture
  41903. */
  41904. depth: number;
  41905. /**
  41906. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41907. */
  41908. baseWidth: number;
  41909. /**
  41910. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41911. */
  41912. baseHeight: number;
  41913. /**
  41914. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41915. */
  41916. baseDepth: number;
  41917. /**
  41918. * Gets a boolean indicating if the texture is inverted on Y axis
  41919. */
  41920. invertY: boolean;
  41921. /** @hidden */
  41922. _invertVScale: boolean;
  41923. /** @hidden */
  41924. _associatedChannel: number;
  41925. /** @hidden */
  41926. _source: InternalTextureSource;
  41927. /** @hidden */
  41928. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  41929. /** @hidden */
  41930. _bufferView: Nullable<ArrayBufferView>;
  41931. /** @hidden */
  41932. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41933. /** @hidden */
  41934. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41935. /** @hidden */
  41936. _size: number;
  41937. /** @hidden */
  41938. _extension: string;
  41939. /** @hidden */
  41940. _files: Nullable<string[]>;
  41941. /** @hidden */
  41942. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41943. /** @hidden */
  41944. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41945. /** @hidden */
  41946. _framebuffer: Nullable<WebGLFramebuffer>;
  41947. /** @hidden */
  41948. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41949. /** @hidden */
  41950. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41951. /** @hidden */
  41952. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41953. /** @hidden */
  41954. _attachments: Nullable<number[]>;
  41955. /** @hidden */
  41956. _textureArray: Nullable<InternalTexture[]>;
  41957. /** @hidden */
  41958. _cachedCoordinatesMode: Nullable<number>;
  41959. /** @hidden */
  41960. _cachedWrapU: Nullable<number>;
  41961. /** @hidden */
  41962. _cachedWrapV: Nullable<number>;
  41963. /** @hidden */
  41964. _cachedWrapR: Nullable<number>;
  41965. /** @hidden */
  41966. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41967. /** @hidden */
  41968. _isDisabled: boolean;
  41969. /** @hidden */
  41970. _compression: Nullable<string>;
  41971. /** @hidden */
  41972. _generateStencilBuffer: boolean;
  41973. /** @hidden */
  41974. _generateDepthBuffer: boolean;
  41975. /** @hidden */
  41976. _comparisonFunction: number;
  41977. /** @hidden */
  41978. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41979. /** @hidden */
  41980. _sphericalPolynomialPromise: Nullable<Promise<SphericalPolynomial>>;
  41981. /** @hidden */
  41982. _sphericalPolynomialComputed: boolean;
  41983. /** @hidden */
  41984. _lodGenerationScale: number;
  41985. /** @hidden */
  41986. _lodGenerationOffset: number;
  41987. /** @hidden */
  41988. _depthStencilTexture: Nullable<InternalTexture>;
  41989. /** @hidden */
  41990. _colorTextureArray: Nullable<WebGLTexture>;
  41991. /** @hidden */
  41992. _depthStencilTextureArray: Nullable<WebGLTexture>;
  41993. /** @hidden */
  41994. _lodTextureHigh: Nullable<BaseTexture>;
  41995. /** @hidden */
  41996. _lodTextureMid: Nullable<BaseTexture>;
  41997. /** @hidden */
  41998. _lodTextureLow: Nullable<BaseTexture>;
  41999. /** @hidden */
  42000. _isRGBD: boolean;
  42001. /** @hidden */
  42002. _linearSpecularLOD: boolean;
  42003. /** @hidden */
  42004. _irradianceTexture: Nullable<BaseTexture>;
  42005. /** @hidden */
  42006. _hardwareTexture: Nullable<HardwareTextureWrapper>;
  42007. /** @hidden */
  42008. _references: number;
  42009. /** @hidden */
  42010. _gammaSpace: Nullable<boolean>;
  42011. private _engine;
  42012. private _uniqueId;
  42013. private static _Counter;
  42014. /** Gets the unique id of the internal texture */
  42015. get uniqueId(): number;
  42016. /**
  42017. * Gets the Engine the texture belongs to.
  42018. * @returns The babylon engine
  42019. */
  42020. getEngine(): ThinEngine;
  42021. /**
  42022. * Gets the data source type of the texture
  42023. */
  42024. get source(): InternalTextureSource;
  42025. /**
  42026. * Creates a new InternalTexture
  42027. * @param engine defines the engine to use
  42028. * @param source defines the type of data that will be used
  42029. * @param delayAllocation if the texture allocation should be delayed (default: false)
  42030. */
  42031. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  42032. /**
  42033. * Increments the number of references (ie. the number of Texture that point to it)
  42034. */
  42035. incrementReferences(): void;
  42036. /**
  42037. * Change the size of the texture (not the size of the content)
  42038. * @param width defines the new width
  42039. * @param height defines the new height
  42040. * @param depth defines the new depth (1 by default)
  42041. */
  42042. updateSize(width: int, height: int, depth?: int): void;
  42043. /** @hidden */
  42044. _rebuild(): void;
  42045. /** @hidden */
  42046. _swapAndDie(target: InternalTexture): void;
  42047. /**
  42048. * Dispose the current allocated resources
  42049. */
  42050. dispose(): void;
  42051. }
  42052. }
  42053. declare module BABYLON {
  42054. /**
  42055. * Interface used to present a loading screen while loading a scene
  42056. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42057. */
  42058. export interface ILoadingScreen {
  42059. /**
  42060. * Function called to display the loading screen
  42061. */
  42062. displayLoadingUI: () => void;
  42063. /**
  42064. * Function called to hide the loading screen
  42065. */
  42066. hideLoadingUI: () => void;
  42067. /**
  42068. * Gets or sets the color to use for the background
  42069. */
  42070. loadingUIBackgroundColor: string;
  42071. /**
  42072. * Gets or sets the text to display while loading
  42073. */
  42074. loadingUIText: string;
  42075. }
  42076. /**
  42077. * Class used for the default loading screen
  42078. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42079. */
  42080. export class DefaultLoadingScreen implements ILoadingScreen {
  42081. private _renderingCanvas;
  42082. private _loadingText;
  42083. private _loadingDivBackgroundColor;
  42084. private _loadingDiv;
  42085. private _loadingTextDiv;
  42086. /** Gets or sets the logo url to use for the default loading screen */
  42087. static DefaultLogoUrl: string;
  42088. /** Gets or sets the spinner url to use for the default loading screen */
  42089. static DefaultSpinnerUrl: string;
  42090. /**
  42091. * Creates a new default loading screen
  42092. * @param _renderingCanvas defines the canvas used to render the scene
  42093. * @param _loadingText defines the default text to display
  42094. * @param _loadingDivBackgroundColor defines the default background color
  42095. */
  42096. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  42097. /**
  42098. * Function called to display the loading screen
  42099. */
  42100. displayLoadingUI(): void;
  42101. /**
  42102. * Function called to hide the loading screen
  42103. */
  42104. hideLoadingUI(): void;
  42105. /**
  42106. * Gets or sets the text to display while loading
  42107. */
  42108. set loadingUIText(text: string);
  42109. get loadingUIText(): string;
  42110. /**
  42111. * Gets or sets the color to use for the background
  42112. */
  42113. get loadingUIBackgroundColor(): string;
  42114. set loadingUIBackgroundColor(color: string);
  42115. private _resizeLoadingUI;
  42116. }
  42117. }
  42118. declare module BABYLON {
  42119. /**
  42120. * Interface for any object that can request an animation frame
  42121. */
  42122. export interface ICustomAnimationFrameRequester {
  42123. /**
  42124. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  42125. */
  42126. renderFunction?: Function;
  42127. /**
  42128. * Called to request the next frame to render to
  42129. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  42130. */
  42131. requestAnimationFrame: Function;
  42132. /**
  42133. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  42134. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  42135. */
  42136. requestID?: number;
  42137. }
  42138. }
  42139. declare module BABYLON {
  42140. /**
  42141. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  42142. */
  42143. export class PerformanceMonitor {
  42144. private _enabled;
  42145. private _rollingFrameTime;
  42146. private _lastFrameTimeMs;
  42147. /**
  42148. * constructor
  42149. * @param frameSampleSize The number of samples required to saturate the sliding window
  42150. */
  42151. constructor(frameSampleSize?: number);
  42152. /**
  42153. * Samples current frame
  42154. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  42155. */
  42156. sampleFrame(timeMs?: number): void;
  42157. /**
  42158. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  42159. */
  42160. get averageFrameTime(): number;
  42161. /**
  42162. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  42163. */
  42164. get averageFrameTimeVariance(): number;
  42165. /**
  42166. * Returns the frame time of the most recent frame
  42167. */
  42168. get instantaneousFrameTime(): number;
  42169. /**
  42170. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  42171. */
  42172. get averageFPS(): number;
  42173. /**
  42174. * Returns the average framerate in frames per second using the most recent frame time
  42175. */
  42176. get instantaneousFPS(): number;
  42177. /**
  42178. * Returns true if enough samples have been taken to completely fill the sliding window
  42179. */
  42180. get isSaturated(): boolean;
  42181. /**
  42182. * Enables contributions to the sliding window sample set
  42183. */
  42184. enable(): void;
  42185. /**
  42186. * Disables contributions to the sliding window sample set
  42187. * Samples will not be interpolated over the disabled period
  42188. */
  42189. disable(): void;
  42190. /**
  42191. * Returns true if sampling is enabled
  42192. */
  42193. get isEnabled(): boolean;
  42194. /**
  42195. * Resets performance monitor
  42196. */
  42197. reset(): void;
  42198. }
  42199. /**
  42200. * RollingAverage
  42201. *
  42202. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  42203. */
  42204. export class RollingAverage {
  42205. /**
  42206. * Current average
  42207. */
  42208. average: number;
  42209. /**
  42210. * Current variance
  42211. */
  42212. variance: number;
  42213. protected _samples: Array<number>;
  42214. protected _sampleCount: number;
  42215. protected _pos: number;
  42216. protected _m2: number;
  42217. /**
  42218. * constructor
  42219. * @param length The number of samples required to saturate the sliding window
  42220. */
  42221. constructor(length: number);
  42222. /**
  42223. * Adds a sample to the sample set
  42224. * @param v The sample value
  42225. */
  42226. add(v: number): void;
  42227. /**
  42228. * Returns previously added values or null if outside of history or outside the sliding window domain
  42229. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  42230. * @return Value previously recorded with add() or null if outside of range
  42231. */
  42232. history(i: number): number;
  42233. /**
  42234. * Returns true if enough samples have been taken to completely fill the sliding window
  42235. * @return true if sample-set saturated
  42236. */
  42237. isSaturated(): boolean;
  42238. /**
  42239. * Resets the rolling average (equivalent to 0 samples taken so far)
  42240. */
  42241. reset(): void;
  42242. /**
  42243. * Wraps a value around the sample range boundaries
  42244. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  42245. * @return Wrapped position in sample range
  42246. */
  42247. protected _wrapPosition(i: number): number;
  42248. }
  42249. }
  42250. declare module BABYLON {
  42251. /**
  42252. * This class is used to track a performance counter which is number based.
  42253. * The user has access to many properties which give statistics of different nature.
  42254. *
  42255. * The implementer can track two kinds of Performance Counter: time and count.
  42256. * 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.
  42257. * 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.
  42258. */
  42259. export class PerfCounter {
  42260. /**
  42261. * Gets or sets a global boolean to turn on and off all the counters
  42262. */
  42263. static Enabled: boolean;
  42264. /**
  42265. * Returns the smallest value ever
  42266. */
  42267. get min(): number;
  42268. /**
  42269. * Returns the biggest value ever
  42270. */
  42271. get max(): number;
  42272. /**
  42273. * Returns the average value since the performance counter is running
  42274. */
  42275. get average(): number;
  42276. /**
  42277. * Returns the average value of the last second the counter was monitored
  42278. */
  42279. get lastSecAverage(): number;
  42280. /**
  42281. * Returns the current value
  42282. */
  42283. get current(): number;
  42284. /**
  42285. * Gets the accumulated total
  42286. */
  42287. get total(): number;
  42288. /**
  42289. * Gets the total value count
  42290. */
  42291. get count(): number;
  42292. /**
  42293. * Creates a new counter
  42294. */
  42295. constructor();
  42296. /**
  42297. * Call this method to start monitoring a new frame.
  42298. * 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.
  42299. */
  42300. fetchNewFrame(): void;
  42301. /**
  42302. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  42303. * @param newCount the count value to add to the monitored count
  42304. * @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.
  42305. */
  42306. addCount(newCount: number, fetchResult: boolean): void;
  42307. /**
  42308. * Start monitoring this performance counter
  42309. */
  42310. beginMonitoring(): void;
  42311. /**
  42312. * Compute the time lapsed since the previous beginMonitoring() call.
  42313. * @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
  42314. */
  42315. endMonitoring(newFrame?: boolean): void;
  42316. private _fetchResult;
  42317. private _startMonitoringTime;
  42318. private _min;
  42319. private _max;
  42320. private _average;
  42321. private _current;
  42322. private _totalValueCount;
  42323. private _totalAccumulated;
  42324. private _lastSecAverage;
  42325. private _lastSecAccumulated;
  42326. private _lastSecTime;
  42327. private _lastSecValueCount;
  42328. }
  42329. }
  42330. declare module BABYLON {
  42331. interface ThinEngine {
  42332. /** @hidden */
  42333. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  42334. /** @hidden */
  42335. _readTexturePixelsSync(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): ArrayBufferView;
  42336. }
  42337. }
  42338. declare module BABYLON {
  42339. /**
  42340. * Class used to work with sound analyzer using fast fourier transform (FFT)
  42341. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42342. */
  42343. export class Analyser {
  42344. /**
  42345. * Gets or sets the smoothing
  42346. * @ignorenaming
  42347. */
  42348. SMOOTHING: number;
  42349. /**
  42350. * Gets or sets the FFT table size
  42351. * @ignorenaming
  42352. */
  42353. FFT_SIZE: number;
  42354. /**
  42355. * Gets or sets the bar graph amplitude
  42356. * @ignorenaming
  42357. */
  42358. BARGRAPHAMPLITUDE: number;
  42359. /**
  42360. * Gets or sets the position of the debug canvas
  42361. * @ignorenaming
  42362. */
  42363. DEBUGCANVASPOS: {
  42364. x: number;
  42365. y: number;
  42366. };
  42367. /**
  42368. * Gets or sets the debug canvas size
  42369. * @ignorenaming
  42370. */
  42371. DEBUGCANVASSIZE: {
  42372. width: number;
  42373. height: number;
  42374. };
  42375. private _byteFreqs;
  42376. private _byteTime;
  42377. private _floatFreqs;
  42378. private _webAudioAnalyser;
  42379. private _debugCanvas;
  42380. private _debugCanvasContext;
  42381. private _scene;
  42382. private _registerFunc;
  42383. private _audioEngine;
  42384. /**
  42385. * Creates a new analyser
  42386. * @param scene defines hosting scene
  42387. */
  42388. constructor(scene: Scene);
  42389. /**
  42390. * Get the number of data values you will have to play with for the visualization
  42391. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  42392. * @returns a number
  42393. */
  42394. getFrequencyBinCount(): number;
  42395. /**
  42396. * Gets the current frequency data as a byte array
  42397. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  42398. * @returns a Uint8Array
  42399. */
  42400. getByteFrequencyData(): Uint8Array;
  42401. /**
  42402. * Gets the current waveform as a byte array
  42403. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  42404. * @returns a Uint8Array
  42405. */
  42406. getByteTimeDomainData(): Uint8Array;
  42407. /**
  42408. * Gets the current frequency data as a float array
  42409. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  42410. * @returns a Float32Array
  42411. */
  42412. getFloatFrequencyData(): Float32Array;
  42413. /**
  42414. * Renders the debug canvas
  42415. */
  42416. drawDebugCanvas(): void;
  42417. /**
  42418. * Stops rendering the debug canvas and removes it
  42419. */
  42420. stopDebugCanvas(): void;
  42421. /**
  42422. * Connects two audio nodes
  42423. * @param inputAudioNode defines first node to connect
  42424. * @param outputAudioNode defines second node to connect
  42425. */
  42426. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  42427. /**
  42428. * Releases all associated resources
  42429. */
  42430. dispose(): void;
  42431. }
  42432. }
  42433. declare module BABYLON {
  42434. /**
  42435. * This represents an audio engine and it is responsible
  42436. * to play, synchronize and analyse sounds throughout the application.
  42437. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42438. */
  42439. export interface IAudioEngine extends IDisposable {
  42440. /**
  42441. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  42442. */
  42443. readonly canUseWebAudio: boolean;
  42444. /**
  42445. * Gets the current AudioContext if available.
  42446. */
  42447. readonly audioContext: Nullable<AudioContext>;
  42448. /**
  42449. * The master gain node defines the global audio volume of your audio engine.
  42450. */
  42451. readonly masterGain: GainNode;
  42452. /**
  42453. * Gets whether or not mp3 are supported by your browser.
  42454. */
  42455. readonly isMP3supported: boolean;
  42456. /**
  42457. * Gets whether or not ogg are supported by your browser.
  42458. */
  42459. readonly isOGGsupported: boolean;
  42460. /**
  42461. * Defines if Babylon should emit a warning if WebAudio is not supported.
  42462. * @ignoreNaming
  42463. */
  42464. WarnedWebAudioUnsupported: boolean;
  42465. /**
  42466. * Defines if the audio engine relies on a custom unlocked button.
  42467. * In this case, the embedded button will not be displayed.
  42468. */
  42469. useCustomUnlockedButton: boolean;
  42470. /**
  42471. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  42472. */
  42473. readonly unlocked: boolean;
  42474. /**
  42475. * Event raised when audio has been unlocked on the browser.
  42476. */
  42477. onAudioUnlockedObservable: Observable<IAudioEngine>;
  42478. /**
  42479. * Event raised when audio has been locked on the browser.
  42480. */
  42481. onAudioLockedObservable: Observable<IAudioEngine>;
  42482. /**
  42483. * Flags the audio engine in Locked state.
  42484. * This happens due to new browser policies preventing audio to autoplay.
  42485. */
  42486. lock(): void;
  42487. /**
  42488. * Unlocks the audio engine once a user action has been done on the dom.
  42489. * This is helpful to resume play once browser policies have been satisfied.
  42490. */
  42491. unlock(): void;
  42492. /**
  42493. * Gets the global volume sets on the master gain.
  42494. * @returns the global volume if set or -1 otherwise
  42495. */
  42496. getGlobalVolume(): number;
  42497. /**
  42498. * Sets the global volume of your experience (sets on the master gain).
  42499. * @param newVolume Defines the new global volume of the application
  42500. */
  42501. setGlobalVolume(newVolume: number): void;
  42502. /**
  42503. * Connect the audio engine to an audio analyser allowing some amazing
  42504. * synchronization between the sounds/music and your visualization (VuMeter for instance).
  42505. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42506. * @param analyser The analyser to connect to the engine
  42507. */
  42508. connectToAnalyser(analyser: Analyser): void;
  42509. }
  42510. }
  42511. declare module BABYLON {
  42512. /**
  42513. * Defines the interface used by display changed events
  42514. */
  42515. export interface IDisplayChangedEventArgs {
  42516. /** Gets the vrDisplay object (if any) */
  42517. vrDisplay: Nullable<any>;
  42518. /** Gets a boolean indicating if webVR is supported */
  42519. vrSupported: boolean;
  42520. }
  42521. /**
  42522. * Defines the interface used by objects containing a viewport (like a camera)
  42523. */
  42524. interface IViewportOwnerLike {
  42525. /**
  42526. * Gets or sets the viewport
  42527. */
  42528. viewport: IViewportLike;
  42529. }
  42530. /**
  42531. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  42532. */
  42533. export class Engine extends ThinEngine {
  42534. /** Defines that alpha blending is disabled */
  42535. static readonly ALPHA_DISABLE: number;
  42536. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  42537. static readonly ALPHA_ADD: number;
  42538. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  42539. static readonly ALPHA_COMBINE: number;
  42540. /** Defines that alpha blending to DEST - SRC * DEST */
  42541. static readonly ALPHA_SUBTRACT: number;
  42542. /** Defines that alpha blending to SRC * DEST */
  42543. static readonly ALPHA_MULTIPLY: number;
  42544. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  42545. static readonly ALPHA_MAXIMIZED: number;
  42546. /** Defines that alpha blending to SRC + DEST */
  42547. static readonly ALPHA_ONEONE: number;
  42548. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  42549. static readonly ALPHA_PREMULTIPLIED: number;
  42550. /**
  42551. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  42552. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  42553. */
  42554. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  42555. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  42556. static readonly ALPHA_INTERPOLATE: number;
  42557. /**
  42558. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  42559. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  42560. */
  42561. static readonly ALPHA_SCREENMODE: number;
  42562. /** Defines that the resource is not delayed*/
  42563. static readonly DELAYLOADSTATE_NONE: number;
  42564. /** Defines that the resource was successfully delay loaded */
  42565. static readonly DELAYLOADSTATE_LOADED: number;
  42566. /** Defines that the resource is currently delay loading */
  42567. static readonly DELAYLOADSTATE_LOADING: number;
  42568. /** Defines that the resource is delayed and has not started loading */
  42569. static readonly DELAYLOADSTATE_NOTLOADED: number;
  42570. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  42571. static readonly NEVER: number;
  42572. /** 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 */
  42573. static readonly ALWAYS: number;
  42574. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  42575. static readonly LESS: number;
  42576. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  42577. static readonly EQUAL: number;
  42578. /** 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 */
  42579. static readonly LEQUAL: number;
  42580. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  42581. static readonly GREATER: number;
  42582. /** 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 */
  42583. static readonly GEQUAL: number;
  42584. /** 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 */
  42585. static readonly NOTEQUAL: number;
  42586. /** Passed to stencilOperation to specify that stencil value must be kept */
  42587. static readonly KEEP: number;
  42588. /** Passed to stencilOperation to specify that stencil value must be replaced */
  42589. static readonly REPLACE: number;
  42590. /** Passed to stencilOperation to specify that stencil value must be incremented */
  42591. static readonly INCR: number;
  42592. /** Passed to stencilOperation to specify that stencil value must be decremented */
  42593. static readonly DECR: number;
  42594. /** Passed to stencilOperation to specify that stencil value must be inverted */
  42595. static readonly INVERT: number;
  42596. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  42597. static readonly INCR_WRAP: number;
  42598. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  42599. static readonly DECR_WRAP: number;
  42600. /** Texture is not repeating outside of 0..1 UVs */
  42601. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  42602. /** Texture is repeating outside of 0..1 UVs */
  42603. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  42604. /** Texture is repeating and mirrored */
  42605. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  42606. /** ALPHA */
  42607. static readonly TEXTUREFORMAT_ALPHA: number;
  42608. /** LUMINANCE */
  42609. static readonly TEXTUREFORMAT_LUMINANCE: number;
  42610. /** LUMINANCE_ALPHA */
  42611. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  42612. /** RGB */
  42613. static readonly TEXTUREFORMAT_RGB: number;
  42614. /** RGBA */
  42615. static readonly TEXTUREFORMAT_RGBA: number;
  42616. /** RED */
  42617. static readonly TEXTUREFORMAT_RED: number;
  42618. /** RED (2nd reference) */
  42619. static readonly TEXTUREFORMAT_R: number;
  42620. /** RG */
  42621. static readonly TEXTUREFORMAT_RG: number;
  42622. /** RED_INTEGER */
  42623. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  42624. /** RED_INTEGER (2nd reference) */
  42625. static readonly TEXTUREFORMAT_R_INTEGER: number;
  42626. /** RG_INTEGER */
  42627. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  42628. /** RGB_INTEGER */
  42629. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  42630. /** RGBA_INTEGER */
  42631. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  42632. /** UNSIGNED_BYTE */
  42633. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  42634. /** UNSIGNED_BYTE (2nd reference) */
  42635. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  42636. /** FLOAT */
  42637. static readonly TEXTURETYPE_FLOAT: number;
  42638. /** HALF_FLOAT */
  42639. static readonly TEXTURETYPE_HALF_FLOAT: number;
  42640. /** BYTE */
  42641. static readonly TEXTURETYPE_BYTE: number;
  42642. /** SHORT */
  42643. static readonly TEXTURETYPE_SHORT: number;
  42644. /** UNSIGNED_SHORT */
  42645. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  42646. /** INT */
  42647. static readonly TEXTURETYPE_INT: number;
  42648. /** UNSIGNED_INT */
  42649. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  42650. /** UNSIGNED_SHORT_4_4_4_4 */
  42651. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  42652. /** UNSIGNED_SHORT_5_5_5_1 */
  42653. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  42654. /** UNSIGNED_SHORT_5_6_5 */
  42655. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  42656. /** UNSIGNED_INT_2_10_10_10_REV */
  42657. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  42658. /** UNSIGNED_INT_24_8 */
  42659. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  42660. /** UNSIGNED_INT_10F_11F_11F_REV */
  42661. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  42662. /** UNSIGNED_INT_5_9_9_9_REV */
  42663. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  42664. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  42665. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  42666. /** nearest is mag = nearest and min = nearest and mip = none */
  42667. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  42668. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42669. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  42670. /** Trilinear is mag = linear and min = linear and mip = linear */
  42671. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  42672. /** nearest is mag = nearest and min = nearest and mip = linear */
  42673. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  42674. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42675. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  42676. /** Trilinear is mag = linear and min = linear and mip = linear */
  42677. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  42678. /** mag = nearest and min = nearest and mip = nearest */
  42679. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  42680. /** mag = nearest and min = linear and mip = nearest */
  42681. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  42682. /** mag = nearest and min = linear and mip = linear */
  42683. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  42684. /** mag = nearest and min = linear and mip = none */
  42685. static readonly TEXTURE_NEAREST_LINEAR: number;
  42686. /** mag = nearest and min = nearest and mip = none */
  42687. static readonly TEXTURE_NEAREST_NEAREST: number;
  42688. /** mag = linear and min = nearest and mip = nearest */
  42689. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  42690. /** mag = linear and min = nearest and mip = linear */
  42691. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  42692. /** mag = linear and min = linear and mip = none */
  42693. static readonly TEXTURE_LINEAR_LINEAR: number;
  42694. /** mag = linear and min = nearest and mip = none */
  42695. static readonly TEXTURE_LINEAR_NEAREST: number;
  42696. /** Explicit coordinates mode */
  42697. static readonly TEXTURE_EXPLICIT_MODE: number;
  42698. /** Spherical coordinates mode */
  42699. static readonly TEXTURE_SPHERICAL_MODE: number;
  42700. /** Planar coordinates mode */
  42701. static readonly TEXTURE_PLANAR_MODE: number;
  42702. /** Cubic coordinates mode */
  42703. static readonly TEXTURE_CUBIC_MODE: number;
  42704. /** Projection coordinates mode */
  42705. static readonly TEXTURE_PROJECTION_MODE: number;
  42706. /** Skybox coordinates mode */
  42707. static readonly TEXTURE_SKYBOX_MODE: number;
  42708. /** Inverse Cubic coordinates mode */
  42709. static readonly TEXTURE_INVCUBIC_MODE: number;
  42710. /** Equirectangular coordinates mode */
  42711. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  42712. /** Equirectangular Fixed coordinates mode */
  42713. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  42714. /** Equirectangular Fixed Mirrored coordinates mode */
  42715. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  42716. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  42717. static readonly SCALEMODE_FLOOR: number;
  42718. /** Defines that texture rescaling will look for the nearest power of 2 size */
  42719. static readonly SCALEMODE_NEAREST: number;
  42720. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  42721. static readonly SCALEMODE_CEILING: number;
  42722. /**
  42723. * Returns the current npm package of the sdk
  42724. */
  42725. static get NpmPackage(): string;
  42726. /**
  42727. * Returns the current version of the framework
  42728. */
  42729. static get Version(): string;
  42730. /** Gets the list of created engines */
  42731. static get Instances(): Engine[];
  42732. /**
  42733. * Gets the latest created engine
  42734. */
  42735. static get LastCreatedEngine(): Nullable<Engine>;
  42736. /**
  42737. * Gets the latest created scene
  42738. */
  42739. static get LastCreatedScene(): Nullable<Scene>;
  42740. /**
  42741. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  42742. * @param flag defines which part of the materials must be marked as dirty
  42743. * @param predicate defines a predicate used to filter which materials should be affected
  42744. */
  42745. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42746. /**
  42747. * Method called to create the default loading screen.
  42748. * This can be overridden in your own app.
  42749. * @param canvas The rendering canvas element
  42750. * @returns The loading screen
  42751. */
  42752. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  42753. /**
  42754. * Method called to create the default rescale post process on each engine.
  42755. */
  42756. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  42757. /**
  42758. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  42759. **/
  42760. enableOfflineSupport: boolean;
  42761. /**
  42762. * 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)
  42763. **/
  42764. disableManifestCheck: boolean;
  42765. /**
  42766. * Gets the list of created scenes
  42767. */
  42768. scenes: Scene[];
  42769. /**
  42770. * Event raised when a new scene is created
  42771. */
  42772. onNewSceneAddedObservable: Observable<Scene>;
  42773. /**
  42774. * Gets the list of created postprocesses
  42775. */
  42776. postProcesses: PostProcess[];
  42777. /**
  42778. * Gets a boolean indicating if the pointer is currently locked
  42779. */
  42780. isPointerLock: boolean;
  42781. /**
  42782. * Observable event triggered each time the rendering canvas is resized
  42783. */
  42784. onResizeObservable: Observable<Engine>;
  42785. /**
  42786. * Observable event triggered each time the canvas loses focus
  42787. */
  42788. onCanvasBlurObservable: Observable<Engine>;
  42789. /**
  42790. * Observable event triggered each time the canvas gains focus
  42791. */
  42792. onCanvasFocusObservable: Observable<Engine>;
  42793. /**
  42794. * Observable event triggered each time the canvas receives pointerout event
  42795. */
  42796. onCanvasPointerOutObservable: Observable<IPointerEvent>;
  42797. /**
  42798. * Observable raised when the engine begins a new frame
  42799. */
  42800. onBeginFrameObservable: Observable<Engine>;
  42801. /**
  42802. * If set, will be used to request the next animation frame for the render loop
  42803. */
  42804. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  42805. /**
  42806. * Observable raised when the engine ends the current frame
  42807. */
  42808. onEndFrameObservable: Observable<Engine>;
  42809. /**
  42810. * Observable raised when the engine is about to compile a shader
  42811. */
  42812. onBeforeShaderCompilationObservable: Observable<Engine>;
  42813. /**
  42814. * Observable raised when the engine has just compiled a shader
  42815. */
  42816. onAfterShaderCompilationObservable: Observable<Engine>;
  42817. /**
  42818. * Gets the audio engine
  42819. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42820. * @ignorenaming
  42821. */
  42822. static audioEngine: IAudioEngine;
  42823. /**
  42824. * Default AudioEngine factory responsible of creating the Audio Engine.
  42825. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  42826. */
  42827. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  42828. /**
  42829. * Default offline support factory responsible of creating a tool used to store data locally.
  42830. * By default, this will create a Database object if the workload has been embedded.
  42831. */
  42832. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  42833. private _loadingScreen;
  42834. private _pointerLockRequested;
  42835. private _rescalePostProcess;
  42836. protected _deterministicLockstep: boolean;
  42837. protected _lockstepMaxSteps: number;
  42838. protected _timeStep: number;
  42839. protected get _supportsHardwareTextureRescaling(): boolean;
  42840. private _fps;
  42841. private _deltaTime;
  42842. /** @hidden */
  42843. _drawCalls: PerfCounter;
  42844. /** 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 */
  42845. canvasTabIndex: number;
  42846. /**
  42847. * Turn this value on if you want to pause FPS computation when in background
  42848. */
  42849. disablePerformanceMonitorInBackground: boolean;
  42850. private _performanceMonitor;
  42851. /**
  42852. * Gets the performance monitor attached to this engine
  42853. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42854. */
  42855. get performanceMonitor(): PerformanceMonitor;
  42856. private _onFocus;
  42857. private _onBlur;
  42858. private _onCanvasPointerOut;
  42859. private _onCanvasBlur;
  42860. private _onCanvasFocus;
  42861. private _onFullscreenChange;
  42862. private _onPointerLockChange;
  42863. /**
  42864. * Gets the HTML element used to attach event listeners
  42865. * @returns a HTML element
  42866. */
  42867. getInputElement(): Nullable<HTMLElement>;
  42868. /**
  42869. * Creates a new engine
  42870. * @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
  42871. * @param antialias defines enable antialiasing (default: false)
  42872. * @param options defines further options to be sent to the getContext() function
  42873. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42874. */
  42875. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42876. /**
  42877. * Shared initialization across engines types.
  42878. * @param canvas The canvas associated with this instance of the engine.
  42879. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  42880. * @param audioEngine Defines if an audio engine should be created by default
  42881. */
  42882. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  42883. /**
  42884. * Gets current aspect ratio
  42885. * @param viewportOwner defines the camera to use to get the aspect ratio
  42886. * @param useScreen defines if screen size must be used (or the current render target if any)
  42887. * @returns a number defining the aspect ratio
  42888. */
  42889. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  42890. /**
  42891. * Gets current screen aspect ratio
  42892. * @returns a number defining the aspect ratio
  42893. */
  42894. getScreenAspectRatio(): number;
  42895. /**
  42896. * Gets the client rect of the HTML canvas attached with the current webGL context
  42897. * @returns a client rectangle
  42898. */
  42899. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  42900. /**
  42901. * Gets the client rect of the HTML element used for events
  42902. * @returns a client rectangle
  42903. */
  42904. getInputElementClientRect(): Nullable<ClientRect>;
  42905. /**
  42906. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42907. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42908. * @returns true if engine is in deterministic lock step mode
  42909. */
  42910. isDeterministicLockStep(): boolean;
  42911. /**
  42912. * Gets the max steps when engine is running in deterministic lock step
  42913. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42914. * @returns the max steps
  42915. */
  42916. getLockstepMaxSteps(): number;
  42917. /**
  42918. * Returns the time in ms between steps when using deterministic lock step.
  42919. * @returns time step in (ms)
  42920. */
  42921. getTimeStep(): number;
  42922. /**
  42923. * Force the mipmap generation for the given render target texture
  42924. * @param texture defines the render target texture to use
  42925. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  42926. */
  42927. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  42928. /** States */
  42929. /**
  42930. * Set various states to the webGL context
  42931. * @param culling defines backface culling state
  42932. * @param zOffset defines the value to apply to zOffset (0 by default)
  42933. * @param force defines if states must be applied even if cache is up to date
  42934. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42935. */
  42936. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42937. /**
  42938. * Set the z offset to apply to current rendering
  42939. * @param value defines the offset to apply
  42940. */
  42941. setZOffset(value: number): void;
  42942. /**
  42943. * Gets the current value of the zOffset
  42944. * @returns the current zOffset state
  42945. */
  42946. getZOffset(): number;
  42947. /**
  42948. * Gets a boolean indicating if depth testing is enabled
  42949. * @returns the current state
  42950. */
  42951. getDepthBuffer(): boolean;
  42952. /**
  42953. * Enable or disable depth buffering
  42954. * @param enable defines the state to set
  42955. */
  42956. setDepthBuffer(enable: boolean): void;
  42957. /**
  42958. * Gets a boolean indicating if depth writing is enabled
  42959. * @returns the current depth writing state
  42960. */
  42961. getDepthWrite(): boolean;
  42962. /**
  42963. * Enable or disable depth writing
  42964. * @param enable defines the state to set
  42965. */
  42966. setDepthWrite(enable: boolean): void;
  42967. /**
  42968. * Gets a boolean indicating if stencil buffer is enabled
  42969. * @returns the current stencil buffer state
  42970. */
  42971. getStencilBuffer(): boolean;
  42972. /**
  42973. * Enable or disable the stencil buffer
  42974. * @param enable defines if the stencil buffer must be enabled or disabled
  42975. */
  42976. setStencilBuffer(enable: boolean): void;
  42977. /**
  42978. * Gets the current stencil mask
  42979. * @returns a number defining the new stencil mask to use
  42980. */
  42981. getStencilMask(): number;
  42982. /**
  42983. * Sets the current stencil mask
  42984. * @param mask defines the new stencil mask to use
  42985. */
  42986. setStencilMask(mask: number): void;
  42987. /**
  42988. * Gets the current stencil function
  42989. * @returns a number defining the stencil function to use
  42990. */
  42991. getStencilFunction(): number;
  42992. /**
  42993. * Gets the current stencil reference value
  42994. * @returns a number defining the stencil reference value to use
  42995. */
  42996. getStencilFunctionReference(): number;
  42997. /**
  42998. * Gets the current stencil mask
  42999. * @returns a number defining the stencil mask to use
  43000. */
  43001. getStencilFunctionMask(): number;
  43002. /**
  43003. * Sets the current stencil function
  43004. * @param stencilFunc defines the new stencil function to use
  43005. */
  43006. setStencilFunction(stencilFunc: number): void;
  43007. /**
  43008. * Sets the current stencil reference
  43009. * @param reference defines the new stencil reference to use
  43010. */
  43011. setStencilFunctionReference(reference: number): void;
  43012. /**
  43013. * Sets the current stencil mask
  43014. * @param mask defines the new stencil mask to use
  43015. */
  43016. setStencilFunctionMask(mask: number): void;
  43017. /**
  43018. * Gets the current stencil operation when stencil fails
  43019. * @returns a number defining stencil operation to use when stencil fails
  43020. */
  43021. getStencilOperationFail(): number;
  43022. /**
  43023. * Gets the current stencil operation when depth fails
  43024. * @returns a number defining stencil operation to use when depth fails
  43025. */
  43026. getStencilOperationDepthFail(): number;
  43027. /**
  43028. * Gets the current stencil operation when stencil passes
  43029. * @returns a number defining stencil operation to use when stencil passes
  43030. */
  43031. getStencilOperationPass(): number;
  43032. /**
  43033. * Sets the stencil operation to use when stencil fails
  43034. * @param operation defines the stencil operation to use when stencil fails
  43035. */
  43036. setStencilOperationFail(operation: number): void;
  43037. /**
  43038. * Sets the stencil operation to use when depth fails
  43039. * @param operation defines the stencil operation to use when depth fails
  43040. */
  43041. setStencilOperationDepthFail(operation: number): void;
  43042. /**
  43043. * Sets the stencil operation to use when stencil passes
  43044. * @param operation defines the stencil operation to use when stencil passes
  43045. */
  43046. setStencilOperationPass(operation: number): void;
  43047. /**
  43048. * Sets a boolean indicating if the dithering state is enabled or disabled
  43049. * @param value defines the dithering state
  43050. */
  43051. setDitheringState(value: boolean): void;
  43052. /**
  43053. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  43054. * @param value defines the rasterizer state
  43055. */
  43056. setRasterizerState(value: boolean): void;
  43057. /**
  43058. * Gets the current depth function
  43059. * @returns a number defining the depth function
  43060. */
  43061. getDepthFunction(): Nullable<number>;
  43062. /**
  43063. * Sets the current depth function
  43064. * @param depthFunc defines the function to use
  43065. */
  43066. setDepthFunction(depthFunc: number): void;
  43067. /**
  43068. * Sets the current depth function to GREATER
  43069. */
  43070. setDepthFunctionToGreater(): void;
  43071. /**
  43072. * Sets the current depth function to GEQUAL
  43073. */
  43074. setDepthFunctionToGreaterOrEqual(): void;
  43075. /**
  43076. * Sets the current depth function to LESS
  43077. */
  43078. setDepthFunctionToLess(): void;
  43079. /**
  43080. * Sets the current depth function to LEQUAL
  43081. */
  43082. setDepthFunctionToLessOrEqual(): void;
  43083. private _cachedStencilBuffer;
  43084. private _cachedStencilFunction;
  43085. private _cachedStencilMask;
  43086. private _cachedStencilOperationPass;
  43087. private _cachedStencilOperationFail;
  43088. private _cachedStencilOperationDepthFail;
  43089. private _cachedStencilReference;
  43090. /**
  43091. * Caches the the state of the stencil buffer
  43092. */
  43093. cacheStencilState(): void;
  43094. /**
  43095. * Restores the state of the stencil buffer
  43096. */
  43097. restoreStencilState(): void;
  43098. /**
  43099. * Directly set the WebGL Viewport
  43100. * @param x defines the x coordinate of the viewport (in screen space)
  43101. * @param y defines the y coordinate of the viewport (in screen space)
  43102. * @param width defines the width of the viewport (in screen space)
  43103. * @param height defines the height of the viewport (in screen space)
  43104. * @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
  43105. */
  43106. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  43107. /**
  43108. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  43109. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  43110. * @param y defines the y-coordinate of the corner of the clear rectangle
  43111. * @param width defines the width of the clear rectangle
  43112. * @param height defines the height of the clear rectangle
  43113. * @param clearColor defines the clear color
  43114. */
  43115. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  43116. /**
  43117. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  43118. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  43119. * @param y defines the y-coordinate of the corner of the clear rectangle
  43120. * @param width defines the width of the clear rectangle
  43121. * @param height defines the height of the clear rectangle
  43122. */
  43123. enableScissor(x: number, y: number, width: number, height: number): void;
  43124. /**
  43125. * Disable previously set scissor test rectangle
  43126. */
  43127. disableScissor(): void;
  43128. protected _reportDrawCall(): void;
  43129. /**
  43130. * Initializes a webVR display and starts listening to display change events
  43131. * The onVRDisplayChangedObservable will be notified upon these changes
  43132. * @returns The onVRDisplayChangedObservable
  43133. */
  43134. initWebVR(): Observable<IDisplayChangedEventArgs>;
  43135. /** @hidden */
  43136. _prepareVRComponent(): void;
  43137. /** @hidden */
  43138. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  43139. /** @hidden */
  43140. _submitVRFrame(): void;
  43141. /**
  43142. * Call this function to leave webVR mode
  43143. * Will do nothing if webVR is not supported or if there is no webVR device
  43144. * @see https://doc.babylonjs.com/how_to/webvr_camera
  43145. */
  43146. disableVR(): void;
  43147. /**
  43148. * Gets a boolean indicating that the system is in VR mode and is presenting
  43149. * @returns true if VR mode is engaged
  43150. */
  43151. isVRPresenting(): boolean;
  43152. /** @hidden */
  43153. _requestVRFrame(): void;
  43154. /** @hidden */
  43155. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  43156. /**
  43157. * Gets the source code of the vertex shader associated with a specific webGL program
  43158. * @param program defines the program to use
  43159. * @returns a string containing the source code of the vertex shader associated with the program
  43160. */
  43161. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  43162. /**
  43163. * Gets the source code of the fragment shader associated with a specific webGL program
  43164. * @param program defines the program to use
  43165. * @returns a string containing the source code of the fragment shader associated with the program
  43166. */
  43167. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  43168. /**
  43169. * Sets a depth stencil texture from a render target to the according uniform.
  43170. * @param channel The texture channel
  43171. * @param uniform The uniform to set
  43172. * @param texture The render target texture containing the depth stencil texture to apply
  43173. * @param name The texture name
  43174. */
  43175. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>, name?: string): void;
  43176. /**
  43177. * Sets a texture to the webGL context from a postprocess
  43178. * @param channel defines the channel to use
  43179. * @param postProcess defines the source postprocess
  43180. * @param name name of the channel
  43181. */
  43182. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  43183. /**
  43184. * Binds the output of the passed in post process to the texture channel specified
  43185. * @param channel The channel the texture should be bound to
  43186. * @param postProcess The post process which's output should be bound
  43187. * @param name name of the channel
  43188. */
  43189. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  43190. protected _rebuildBuffers(): void;
  43191. /** @hidden */
  43192. _renderFrame(): void;
  43193. _renderLoop(): void;
  43194. /** @hidden */
  43195. _renderViews(): boolean;
  43196. /**
  43197. * Toggle full screen mode
  43198. * @param requestPointerLock defines if a pointer lock should be requested from the user
  43199. */
  43200. switchFullscreen(requestPointerLock: boolean): void;
  43201. /**
  43202. * Enters full screen mode
  43203. * @param requestPointerLock defines if a pointer lock should be requested from the user
  43204. */
  43205. enterFullscreen(requestPointerLock: boolean): void;
  43206. /**
  43207. * Exits full screen mode
  43208. */
  43209. exitFullscreen(): void;
  43210. /**
  43211. * Enters Pointerlock mode
  43212. */
  43213. enterPointerlock(): void;
  43214. /**
  43215. * Exits Pointerlock mode
  43216. */
  43217. exitPointerlock(): void;
  43218. /**
  43219. * Begin a new frame
  43220. */
  43221. beginFrame(): void;
  43222. /**
  43223. * End the current frame
  43224. */
  43225. endFrame(): void;
  43226. /**
  43227. * Resize the view according to the canvas' size
  43228. * @param forceSetSize true to force setting the sizes of the underlying canvas
  43229. */
  43230. resize(forceSetSize?: boolean): void;
  43231. /**
  43232. * Force a specific size of the canvas
  43233. * @param width defines the new canvas' width
  43234. * @param height defines the new canvas' height
  43235. * @param forceSetSize true to force setting the sizes of the underlying canvas
  43236. * @returns true if the size was changed
  43237. */
  43238. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  43239. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  43240. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  43241. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  43242. _releaseTexture(texture: InternalTexture): void;
  43243. /**
  43244. * @hidden
  43245. * Rescales a texture
  43246. * @param source input texture
  43247. * @param destination destination texture
  43248. * @param scene scene to use to render the resize
  43249. * @param internalFormat format to use when resizing
  43250. * @param onComplete callback to be called when resize has completed
  43251. */
  43252. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  43253. /**
  43254. * Gets the current framerate
  43255. * @returns a number representing the framerate
  43256. */
  43257. getFps(): number;
  43258. /**
  43259. * Gets the time spent between current and previous frame
  43260. * @returns a number representing the delta time in ms
  43261. */
  43262. getDeltaTime(): number;
  43263. private _measureFps;
  43264. /** @hidden */
  43265. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  43266. /**
  43267. * Updates the sample count of a render target texture
  43268. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43269. * @param texture defines the texture to update
  43270. * @param samples defines the sample count to set
  43271. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43272. */
  43273. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  43274. /**
  43275. * Updates a depth texture Comparison Mode and Function.
  43276. * If the comparison Function is equal to 0, the mode will be set to none.
  43277. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  43278. * @param texture The texture to set the comparison function for
  43279. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  43280. */
  43281. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  43282. /**
  43283. * Creates a webGL buffer to use with instantiation
  43284. * @param capacity defines the size of the buffer
  43285. * @returns the webGL buffer
  43286. */
  43287. createInstancesBuffer(capacity: number): DataBuffer;
  43288. /**
  43289. * Delete a webGL buffer used with instantiation
  43290. * @param buffer defines the webGL buffer to delete
  43291. */
  43292. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  43293. private _clientWaitAsync;
  43294. /** @hidden */
  43295. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Nullable<Promise<ArrayBufferView>>;
  43296. dispose(): void;
  43297. private _disableTouchAction;
  43298. /**
  43299. * Display the loading screen
  43300. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43301. */
  43302. displayLoadingUI(): void;
  43303. /**
  43304. * Hide the loading screen
  43305. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43306. */
  43307. hideLoadingUI(): void;
  43308. /**
  43309. * Gets the current loading screen object
  43310. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43311. */
  43312. get loadingScreen(): ILoadingScreen;
  43313. /**
  43314. * Sets the current loading screen object
  43315. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43316. */
  43317. set loadingScreen(loadingScreen: ILoadingScreen);
  43318. /**
  43319. * Sets the current loading screen text
  43320. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43321. */
  43322. set loadingUIText(text: string);
  43323. /**
  43324. * Sets the current loading screen background color
  43325. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43326. */
  43327. set loadingUIBackgroundColor(color: string);
  43328. /** Pointerlock and fullscreen */
  43329. /**
  43330. * Ask the browser to promote the current element to pointerlock mode
  43331. * @param element defines the DOM element to promote
  43332. */
  43333. static _RequestPointerlock(element: HTMLElement): void;
  43334. /**
  43335. * Asks the browser to exit pointerlock mode
  43336. */
  43337. static _ExitPointerlock(): void;
  43338. /**
  43339. * Ask the browser to promote the current element to fullscreen rendering mode
  43340. * @param element defines the DOM element to promote
  43341. */
  43342. static _RequestFullscreen(element: HTMLElement): void;
  43343. /**
  43344. * Asks the browser to exit fullscreen mode
  43345. */
  43346. static _ExitFullscreen(): void;
  43347. }
  43348. }
  43349. declare module BABYLON {
  43350. /**
  43351. * The engine store class is responsible to hold all the instances of Engine and Scene created
  43352. * during the life time of the application.
  43353. */
  43354. export class EngineStore {
  43355. /** Gets the list of created engines */
  43356. static Instances: Engine[];
  43357. /** @hidden */
  43358. static _LastCreatedScene: Nullable<Scene>;
  43359. /**
  43360. * Gets the latest created engine
  43361. */
  43362. static get LastCreatedEngine(): Nullable<Engine>;
  43363. /**
  43364. * Gets the latest created scene
  43365. */
  43366. static get LastCreatedScene(): Nullable<Scene>;
  43367. /**
  43368. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  43369. * @ignorenaming
  43370. */
  43371. static UseFallbackTexture: boolean;
  43372. /**
  43373. * Texture content used if a texture cannot loaded
  43374. * @ignorenaming
  43375. */
  43376. static FallbackTexture: string;
  43377. }
  43378. }
  43379. declare module BABYLON {
  43380. /**
  43381. * Helper class that provides a small promise polyfill
  43382. */
  43383. export class PromisePolyfill {
  43384. /**
  43385. * Static function used to check if the polyfill is required
  43386. * If this is the case then the function will inject the polyfill to window.Promise
  43387. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  43388. */
  43389. static Apply(force?: boolean): void;
  43390. }
  43391. }
  43392. declare module BABYLON {
  43393. /**
  43394. * Interface for screenshot methods with describe argument called `size` as object with options
  43395. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  43396. */
  43397. export interface IScreenshotSize {
  43398. /**
  43399. * number in pixels for canvas height
  43400. */
  43401. height?: number;
  43402. /**
  43403. * multiplier allowing render at a higher or lower resolution
  43404. * If value is defined then height and width will be ignored and taken from camera
  43405. */
  43406. precision?: number;
  43407. /**
  43408. * number in pixels for canvas width
  43409. */
  43410. width?: number;
  43411. }
  43412. }
  43413. declare module BABYLON {
  43414. interface IColor4Like {
  43415. r: float;
  43416. g: float;
  43417. b: float;
  43418. a: float;
  43419. }
  43420. /**
  43421. * Class containing a set of static utilities functions
  43422. */
  43423. export class Tools {
  43424. /**
  43425. * Gets or sets the base URL to use to load assets
  43426. */
  43427. static get BaseUrl(): string;
  43428. static set BaseUrl(value: string);
  43429. /**
  43430. * Enable/Disable Custom HTTP Request Headers globally.
  43431. * default = false
  43432. * @see CustomRequestHeaders
  43433. */
  43434. static UseCustomRequestHeaders: boolean;
  43435. /**
  43436. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  43437. * i.e. when loading files, where the server/service expects an Authorization header
  43438. */
  43439. static CustomRequestHeaders: {
  43440. [key: string]: string;
  43441. };
  43442. /**
  43443. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  43444. */
  43445. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  43446. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  43447. /**
  43448. * Default behaviour for cors in the application.
  43449. * It can be a string if the expected behavior is identical in the entire app.
  43450. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  43451. */
  43452. static get CorsBehavior(): string | ((url: string | string[]) => string);
  43453. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  43454. /**
  43455. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  43456. * @ignorenaming
  43457. */
  43458. static get UseFallbackTexture(): boolean;
  43459. static set UseFallbackTexture(value: boolean);
  43460. /**
  43461. * Use this object to register external classes like custom textures or material
  43462. * to allow the loaders to instantiate them
  43463. */
  43464. static get RegisteredExternalClasses(): {
  43465. [key: string]: Object;
  43466. };
  43467. static set RegisteredExternalClasses(classes: {
  43468. [key: string]: Object;
  43469. });
  43470. /**
  43471. * Texture content used if a texture cannot loaded
  43472. * @ignorenaming
  43473. */
  43474. static get fallbackTexture(): string;
  43475. static set fallbackTexture(value: string);
  43476. /**
  43477. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  43478. * @param u defines the coordinate on X axis
  43479. * @param v defines the coordinate on Y axis
  43480. * @param width defines the width of the source data
  43481. * @param height defines the height of the source data
  43482. * @param pixels defines the source byte array
  43483. * @param color defines the output color
  43484. */
  43485. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  43486. /**
  43487. * Interpolates between a and b via alpha
  43488. * @param a The lower value (returned when alpha = 0)
  43489. * @param b The upper value (returned when alpha = 1)
  43490. * @param alpha The interpolation-factor
  43491. * @return The mixed value
  43492. */
  43493. static Mix(a: number, b: number, alpha: number): number;
  43494. /**
  43495. * Tries to instantiate a new object from a given class name
  43496. * @param className defines the class name to instantiate
  43497. * @returns the new object or null if the system was not able to do the instantiation
  43498. */
  43499. static Instantiate(className: string): any;
  43500. /**
  43501. * Provides a slice function that will work even on IE
  43502. * @param data defines the array to slice
  43503. * @param start defines the start of the data (optional)
  43504. * @param end defines the end of the data (optional)
  43505. * @returns the new sliced array
  43506. */
  43507. static Slice<T>(data: T, start?: number, end?: number): T;
  43508. /**
  43509. * Provides a slice function that will work even on IE
  43510. * The difference between this and Slice is that this will force-convert to array
  43511. * @param data defines the array to slice
  43512. * @param start defines the start of the data (optional)
  43513. * @param end defines the end of the data (optional)
  43514. * @returns the new sliced array
  43515. */
  43516. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  43517. /**
  43518. * Polyfill for setImmediate
  43519. * @param action defines the action to execute after the current execution block
  43520. */
  43521. static SetImmediate(action: () => void): void;
  43522. /**
  43523. * Function indicating if a number is an exponent of 2
  43524. * @param value defines the value to test
  43525. * @returns true if the value is an exponent of 2
  43526. */
  43527. static IsExponentOfTwo(value: number): boolean;
  43528. private static _tmpFloatArray;
  43529. /**
  43530. * Returns the nearest 32-bit single precision float representation of a Number
  43531. * @param value A Number. If the parameter is of a different type, it will get converted
  43532. * to a number or to NaN if it cannot be converted
  43533. * @returns number
  43534. */
  43535. static FloatRound(value: number): number;
  43536. /**
  43537. * Extracts the filename from a path
  43538. * @param path defines the path to use
  43539. * @returns the filename
  43540. */
  43541. static GetFilename(path: string): string;
  43542. /**
  43543. * Extracts the "folder" part of a path (everything before the filename).
  43544. * @param uri The URI to extract the info from
  43545. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  43546. * @returns The "folder" part of the path
  43547. */
  43548. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  43549. /**
  43550. * Extracts text content from a DOM element hierarchy
  43551. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  43552. */
  43553. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  43554. /**
  43555. * Convert an angle in radians to degrees
  43556. * @param angle defines the angle to convert
  43557. * @returns the angle in degrees
  43558. */
  43559. static ToDegrees(angle: number): number;
  43560. /**
  43561. * Convert an angle in degrees to radians
  43562. * @param angle defines the angle to convert
  43563. * @returns the angle in radians
  43564. */
  43565. static ToRadians(angle: number): number;
  43566. /**
  43567. * Returns an array if obj is not an array
  43568. * @param obj defines the object to evaluate as an array
  43569. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  43570. * @returns either obj directly if obj is an array or a new array containing obj
  43571. */
  43572. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  43573. /**
  43574. * Gets the pointer prefix to use
  43575. * @param engine defines the engine we are finding the prefix for
  43576. * @returns "pointer" if touch is enabled. Else returns "mouse"
  43577. */
  43578. static GetPointerPrefix(engine: Engine): string;
  43579. /**
  43580. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  43581. * @param url define the url we are trying
  43582. * @param element define the dom element where to configure the cors policy
  43583. */
  43584. static SetCorsBehavior(url: string | string[], element: {
  43585. crossOrigin: string | null;
  43586. }): void;
  43587. /**
  43588. * Removes unwanted characters from an url
  43589. * @param url defines the url to clean
  43590. * @returns the cleaned url
  43591. */
  43592. static CleanUrl(url: string): string;
  43593. /**
  43594. * Gets or sets a function used to pre-process url before using them to load assets
  43595. */
  43596. static get PreprocessUrl(): (url: string) => string;
  43597. static set PreprocessUrl(processor: (url: string) => string);
  43598. /**
  43599. * Loads an image as an HTMLImageElement.
  43600. * @param input url string, ArrayBuffer, or Blob to load
  43601. * @param onLoad callback called when the image successfully loads
  43602. * @param onError callback called when the image fails to load
  43603. * @param offlineProvider offline provider for caching
  43604. * @param mimeType optional mime type
  43605. * @returns the HTMLImageElement of the loaded image
  43606. */
  43607. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  43608. /**
  43609. * Loads a file from a url
  43610. * @param url url string, ArrayBuffer, or Blob to load
  43611. * @param onSuccess callback called when the file successfully loads
  43612. * @param onProgress callback called while file is loading (if the server supports this mode)
  43613. * @param offlineProvider defines the offline provider for caching
  43614. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43615. * @param onError callback called when the file fails to load
  43616. * @returns a file request object
  43617. */
  43618. 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;
  43619. /**
  43620. * Loads a file from a url
  43621. * @param url the file url to load
  43622. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43623. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  43624. */
  43625. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  43626. /**
  43627. * Load a script (identified by an url). When the url returns, the
  43628. * content of this file is added into a new script element, attached to the DOM (body element)
  43629. * @param scriptUrl defines the url of the script to laod
  43630. * @param onSuccess defines the callback called when the script is loaded
  43631. * @param onError defines the callback to call if an error occurs
  43632. * @param scriptId defines the id of the script element
  43633. */
  43634. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  43635. /**
  43636. * Load an asynchronous script (identified by an url). When the url returns, the
  43637. * content of this file is added into a new script element, attached to the DOM (body element)
  43638. * @param scriptUrl defines the url of the script to laod
  43639. * @param scriptId defines the id of the script element
  43640. * @returns a promise request object
  43641. */
  43642. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  43643. /**
  43644. * Loads a file from a blob
  43645. * @param fileToLoad defines the blob to use
  43646. * @param callback defines the callback to call when data is loaded
  43647. * @param progressCallback defines the callback to call during loading process
  43648. * @returns a file request object
  43649. */
  43650. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  43651. /**
  43652. * Reads a file from a File object
  43653. * @param file defines the file to load
  43654. * @param onSuccess defines the callback to call when data is loaded
  43655. * @param onProgress defines the callback to call during loading process
  43656. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43657. * @param onError defines the callback to call when an error occurs
  43658. * @returns a file request object
  43659. */
  43660. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  43661. /**
  43662. * Creates a data url from a given string content
  43663. * @param content defines the content to convert
  43664. * @returns the new data url link
  43665. */
  43666. static FileAsURL(content: string): string;
  43667. /**
  43668. * Format the given number to a specific decimal format
  43669. * @param value defines the number to format
  43670. * @param decimals defines the number of decimals to use
  43671. * @returns the formatted string
  43672. */
  43673. static Format(value: number, decimals?: number): string;
  43674. /**
  43675. * Tries to copy an object by duplicating every property
  43676. * @param source defines the source object
  43677. * @param destination defines the target object
  43678. * @param doNotCopyList defines a list of properties to avoid
  43679. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  43680. */
  43681. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  43682. /**
  43683. * Gets a boolean indicating if the given object has no own property
  43684. * @param obj defines the object to test
  43685. * @returns true if object has no own property
  43686. */
  43687. static IsEmpty(obj: any): boolean;
  43688. /**
  43689. * Function used to register events at window level
  43690. * @param windowElement defines the Window object to use
  43691. * @param events defines the events to register
  43692. */
  43693. static RegisterTopRootEvents(windowElement: Window, events: {
  43694. name: string;
  43695. handler: Nullable<(e: FocusEvent) => any>;
  43696. }[]): void;
  43697. /**
  43698. * Function used to unregister events from window level
  43699. * @param windowElement defines the Window object to use
  43700. * @param events defines the events to unregister
  43701. */
  43702. static UnregisterTopRootEvents(windowElement: Window, events: {
  43703. name: string;
  43704. handler: Nullable<(e: FocusEvent) => any>;
  43705. }[]): void;
  43706. /**
  43707. * @ignore
  43708. */
  43709. static _ScreenshotCanvas: HTMLCanvasElement;
  43710. /**
  43711. * Dumps the current bound framebuffer
  43712. * @param width defines the rendering width
  43713. * @param height defines the rendering height
  43714. * @param engine defines the hosting engine
  43715. * @param successCallback defines the callback triggered once the data are available
  43716. * @param mimeType defines the mime type of the result
  43717. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43718. * @return a void promise
  43719. */
  43720. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): Promise<void>;
  43721. /**
  43722. * Dumps an array buffer
  43723. * @param width defines the rendering width
  43724. * @param height defines the rendering height
  43725. * @param data the data array
  43726. * @param successCallback defines the callback triggered once the data are available
  43727. * @param mimeType defines the mime type of the result
  43728. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43729. * @param invertY true to invert the picture in the Y dimension
  43730. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  43731. */
  43732. static DumpData(width: number, height: number, data: ArrayBufferView, successCallback?: (data: string | ArrayBuffer) => void, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): void;
  43733. /**
  43734. * Dumps an array buffer
  43735. * @param width defines the rendering width
  43736. * @param height defines the rendering height
  43737. * @param data the data array
  43738. * @param successCallback defines the callback triggered once the data are available
  43739. * @param mimeType defines the mime type of the result
  43740. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43741. * @param invertY true to invert the picture in the Y dimension
  43742. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  43743. * @return a promise that resolve to the final data
  43744. */
  43745. static DumpDataAsync(width: number, height: number, data: ArrayBufferView, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  43746. /**
  43747. * Converts the canvas data to blob.
  43748. * This acts as a polyfill for browsers not supporting the to blob function.
  43749. * @param canvas Defines the canvas to extract the data from
  43750. * @param successCallback Defines the callback triggered once the data are available
  43751. * @param mimeType Defines the mime type of the result
  43752. */
  43753. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  43754. /**
  43755. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  43756. * @param successCallback defines the callback triggered once the data are available
  43757. * @param mimeType defines the mime type of the result
  43758. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  43759. * @param canvas canvas to get the data from. If not provided, use the default screenshot canvas
  43760. */
  43761. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string, canvas?: HTMLCanvasElement): void;
  43762. /**
  43763. * Downloads a blob in the browser
  43764. * @param blob defines the blob to download
  43765. * @param fileName defines the name of the downloaded file
  43766. */
  43767. static Download(blob: Blob, fileName: string): void;
  43768. /**
  43769. * Will return the right value of the noPreventDefault variable
  43770. * Needed to keep backwards compatibility to the old API.
  43771. *
  43772. * @param args arguments passed to the attachControl function
  43773. * @returns the correct value for noPreventDefault
  43774. */
  43775. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  43776. /**
  43777. * Captures a screenshot of the current rendering
  43778. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43779. * @param engine defines the rendering engine
  43780. * @param camera defines the source camera
  43781. * @param size This parameter can be set to a single number or to an object with the
  43782. * following (optional) properties: precision, width, height. If a single number is passed,
  43783. * it will be used for both width and height. If an object is passed, the screenshot size
  43784. * will be derived from the parameters. The precision property is a multiplier allowing
  43785. * rendering at a higher or lower resolution
  43786. * @param successCallback defines the callback receives a single parameter which contains the
  43787. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43788. * src parameter of an <img> to display it
  43789. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43790. * Check your browser for supported MIME types
  43791. */
  43792. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  43793. /**
  43794. * Captures a screenshot of the current rendering
  43795. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43796. * @param engine defines the rendering engine
  43797. * @param camera defines the source camera
  43798. * @param size This parameter can be set to a single number or to an object with the
  43799. * following (optional) properties: precision, width, height. If a single number is passed,
  43800. * it will be used for both width and height. If an object is passed, the screenshot size
  43801. * will be derived from the parameters. The precision property is a multiplier allowing
  43802. * rendering at a higher or lower resolution
  43803. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43804. * Check your browser for supported MIME types
  43805. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43806. * to the src parameter of an <img> to display it
  43807. */
  43808. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  43809. /**
  43810. * Generates an image screenshot from the specified camera.
  43811. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43812. * @param engine The engine to use for rendering
  43813. * @param camera The camera to use for rendering
  43814. * @param size This parameter can be set to a single number or to an object with the
  43815. * following (optional) properties: precision, width, height. If a single number is passed,
  43816. * it will be used for both width and height. If an object is passed, the screenshot size
  43817. * will be derived from the parameters. The precision property is a multiplier allowing
  43818. * rendering at a higher or lower resolution
  43819. * @param successCallback The callback receives a single parameter which contains the
  43820. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43821. * src parameter of an <img> to display it
  43822. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43823. * Check your browser for supported MIME types
  43824. * @param samples Texture samples (default: 1)
  43825. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43826. * @param fileName A name for for the downloaded file.
  43827. */
  43828. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  43829. /**
  43830. * Generates an image screenshot from the specified camera.
  43831. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43832. * @param engine The engine to use for rendering
  43833. * @param camera The camera to use for rendering
  43834. * @param size This parameter can be set to a single number or to an object with the
  43835. * following (optional) properties: precision, width, height. If a single number is passed,
  43836. * it will be used for both width and height. If an object is passed, the screenshot size
  43837. * will be derived from the parameters. The precision property is a multiplier allowing
  43838. * rendering at a higher or lower resolution
  43839. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43840. * Check your browser for supported MIME types
  43841. * @param samples Texture samples (default: 1)
  43842. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43843. * @param fileName A name for for the downloaded file.
  43844. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43845. * to the src parameter of an <img> to display it
  43846. */
  43847. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  43848. /**
  43849. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  43850. * Be aware Math.random() could cause collisions, but:
  43851. * "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"
  43852. * @returns a pseudo random id
  43853. */
  43854. static RandomId(): string;
  43855. /**
  43856. * Test if the given uri is a base64 string
  43857. * @param uri The uri to test
  43858. * @return True if the uri is a base64 string or false otherwise
  43859. */
  43860. static IsBase64(uri: string): boolean;
  43861. /**
  43862. * Decode the given base64 uri.
  43863. * @param uri The uri to decode
  43864. * @return The decoded base64 data.
  43865. */
  43866. static DecodeBase64(uri: string): ArrayBuffer;
  43867. /**
  43868. * Gets the absolute url.
  43869. * @param url the input url
  43870. * @return the absolute url
  43871. */
  43872. static GetAbsoluteUrl(url: string): string;
  43873. /**
  43874. * No log
  43875. */
  43876. static readonly NoneLogLevel: number;
  43877. /**
  43878. * Only message logs
  43879. */
  43880. static readonly MessageLogLevel: number;
  43881. /**
  43882. * Only warning logs
  43883. */
  43884. static readonly WarningLogLevel: number;
  43885. /**
  43886. * Only error logs
  43887. */
  43888. static readonly ErrorLogLevel: number;
  43889. /**
  43890. * All logs
  43891. */
  43892. static readonly AllLogLevel: number;
  43893. /**
  43894. * Gets a value indicating the number of loading errors
  43895. * @ignorenaming
  43896. */
  43897. static get errorsCount(): number;
  43898. /**
  43899. * Callback called when a new log is added
  43900. */
  43901. static OnNewCacheEntry: (entry: string) => void;
  43902. /**
  43903. * Log a message to the console
  43904. * @param message defines the message to log
  43905. */
  43906. static Log(message: string): void;
  43907. /**
  43908. * Write a warning message to the console
  43909. * @param message defines the message to log
  43910. */
  43911. static Warn(message: string): void;
  43912. /**
  43913. * Write an error message to the console
  43914. * @param message defines the message to log
  43915. */
  43916. static Error(message: string): void;
  43917. /**
  43918. * Gets current log cache (list of logs)
  43919. */
  43920. static get LogCache(): string;
  43921. /**
  43922. * Clears the log cache
  43923. */
  43924. static ClearLogCache(): void;
  43925. /**
  43926. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  43927. */
  43928. static set LogLevels(level: number);
  43929. /**
  43930. * Checks if the window object exists
  43931. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  43932. */
  43933. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  43934. /**
  43935. * No performance log
  43936. */
  43937. static readonly PerformanceNoneLogLevel: number;
  43938. /**
  43939. * Use user marks to log performance
  43940. */
  43941. static readonly PerformanceUserMarkLogLevel: number;
  43942. /**
  43943. * Log performance to the console
  43944. */
  43945. static readonly PerformanceConsoleLogLevel: number;
  43946. private static _performance;
  43947. /**
  43948. * Sets the current performance log level
  43949. */
  43950. static set PerformanceLogLevel(level: number);
  43951. private static _StartPerformanceCounterDisabled;
  43952. private static _EndPerformanceCounterDisabled;
  43953. private static _StartUserMark;
  43954. private static _EndUserMark;
  43955. private static _StartPerformanceConsole;
  43956. private static _EndPerformanceConsole;
  43957. /**
  43958. * Starts a performance counter
  43959. */
  43960. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43961. /**
  43962. * Ends a specific performance counter
  43963. */
  43964. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43965. /**
  43966. * Gets either window.performance.now() if supported or Date.now() else
  43967. */
  43968. static get Now(): number;
  43969. /**
  43970. * This method will return the name of the class used to create the instance of the given object.
  43971. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  43972. * @param object the object to get the class name from
  43973. * @param isType defines if the object is actually a type
  43974. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  43975. */
  43976. static GetClassName(object: any, isType?: boolean): string;
  43977. /**
  43978. * Gets the first element of an array satisfying a given predicate
  43979. * @param array defines the array to browse
  43980. * @param predicate defines the predicate to use
  43981. * @returns null if not found or the element
  43982. */
  43983. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  43984. /**
  43985. * This method will return the name of the full name of the class, including its owning module (if any).
  43986. * 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).
  43987. * @param object the object to get the class name from
  43988. * @param isType defines if the object is actually a type
  43989. * @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.
  43990. * @ignorenaming
  43991. */
  43992. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  43993. /**
  43994. * Returns a promise that resolves after the given amount of time.
  43995. * @param delay Number of milliseconds to delay
  43996. * @returns Promise that resolves after the given amount of time
  43997. */
  43998. static DelayAsync(delay: number): Promise<void>;
  43999. /**
  44000. * Utility function to detect if the current user agent is Safari
  44001. * @returns whether or not the current user agent is safari
  44002. */
  44003. static IsSafari(): boolean;
  44004. }
  44005. /**
  44006. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  44007. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  44008. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  44009. * @param name The name of the class, case should be preserved
  44010. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  44011. */
  44012. export function className(name: string, module?: string): (target: Object) => void;
  44013. /**
  44014. * An implementation of a loop for asynchronous functions.
  44015. */
  44016. export class AsyncLoop {
  44017. /**
  44018. * Defines the number of iterations for the loop
  44019. */
  44020. iterations: number;
  44021. /**
  44022. * Defines the current index of the loop.
  44023. */
  44024. index: number;
  44025. private _done;
  44026. private _fn;
  44027. private _successCallback;
  44028. /**
  44029. * Constructor.
  44030. * @param iterations the number of iterations.
  44031. * @param func the function to run each iteration
  44032. * @param successCallback the callback that will be called upon successful execution
  44033. * @param offset starting offset.
  44034. */
  44035. constructor(
  44036. /**
  44037. * Defines the number of iterations for the loop
  44038. */
  44039. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  44040. /**
  44041. * Execute the next iteration. Must be called after the last iteration was finished.
  44042. */
  44043. executeNext(): void;
  44044. /**
  44045. * Break the loop and run the success callback.
  44046. */
  44047. breakLoop(): void;
  44048. /**
  44049. * Create and run an async loop.
  44050. * @param iterations the number of iterations.
  44051. * @param fn the function to run each iteration
  44052. * @param successCallback the callback that will be called upon successful execution
  44053. * @param offset starting offset.
  44054. * @returns the created async loop object
  44055. */
  44056. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  44057. /**
  44058. * A for-loop that will run a given number of iterations synchronous and the rest async.
  44059. * @param iterations total number of iterations
  44060. * @param syncedIterations number of synchronous iterations in each async iteration.
  44061. * @param fn the function to call each iteration.
  44062. * @param callback a success call back that will be called when iterating stops.
  44063. * @param breakFunction a break condition (optional)
  44064. * @param timeout timeout settings for the setTimeout function. default - 0.
  44065. * @returns the created async loop object
  44066. */
  44067. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  44068. }
  44069. }
  44070. declare module BABYLON {
  44071. /**
  44072. * This class implement a typical dictionary using a string as key and the generic type T as value.
  44073. * The underlying implementation relies on an associative array to ensure the best performances.
  44074. * The value can be anything including 'null' but except 'undefined'
  44075. */
  44076. export class StringDictionary<T> {
  44077. /**
  44078. * This will clear this dictionary and copy the content from the 'source' one.
  44079. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  44080. * @param source the dictionary to take the content from and copy to this dictionary
  44081. */
  44082. copyFrom(source: StringDictionary<T>): void;
  44083. /**
  44084. * Get a value based from its key
  44085. * @param key the given key to get the matching value from
  44086. * @return the value if found, otherwise undefined is returned
  44087. */
  44088. get(key: string): T | undefined;
  44089. /**
  44090. * Get a value from its key or add it if it doesn't exist.
  44091. * This method will ensure you that a given key/data will be present in the dictionary.
  44092. * @param key the given key to get the matching value from
  44093. * @param factory the factory that will create the value if the key is not present in the dictionary.
  44094. * The factory will only be invoked if there's no data for the given key.
  44095. * @return the value corresponding to the key.
  44096. */
  44097. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  44098. /**
  44099. * Get a value from its key if present in the dictionary otherwise add it
  44100. * @param key the key to get the value from
  44101. * @param val if there's no such key/value pair in the dictionary add it with this value
  44102. * @return the value corresponding to the key
  44103. */
  44104. getOrAdd(key: string, val: T): T;
  44105. /**
  44106. * Check if there's a given key in the dictionary
  44107. * @param key the key to check for
  44108. * @return true if the key is present, false otherwise
  44109. */
  44110. contains(key: string): boolean;
  44111. /**
  44112. * Add a new key and its corresponding value
  44113. * @param key the key to add
  44114. * @param value the value corresponding to the key
  44115. * @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
  44116. */
  44117. add(key: string, value: T): boolean;
  44118. /**
  44119. * Update a specific value associated to a key
  44120. * @param key defines the key to use
  44121. * @param value defines the value to store
  44122. * @returns true if the value was updated (or false if the key was not found)
  44123. */
  44124. set(key: string, value: T): boolean;
  44125. /**
  44126. * Get the element of the given key and remove it from the dictionary
  44127. * @param key defines the key to search
  44128. * @returns the value associated with the key or null if not found
  44129. */
  44130. getAndRemove(key: string): Nullable<T>;
  44131. /**
  44132. * Remove a key/value from the dictionary.
  44133. * @param key the key to remove
  44134. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  44135. */
  44136. remove(key: string): boolean;
  44137. /**
  44138. * Clear the whole content of the dictionary
  44139. */
  44140. clear(): void;
  44141. /**
  44142. * Gets the current count
  44143. */
  44144. get count(): number;
  44145. /**
  44146. * Execute a callback on each key/val of the dictionary.
  44147. * Note that you can remove any element in this dictionary in the callback implementation
  44148. * @param callback the callback to execute on a given key/value pair
  44149. */
  44150. forEach(callback: (key: string, val: T) => void): void;
  44151. /**
  44152. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  44153. * If the callback returns null or undefined the method will iterate to the next key/value pair
  44154. * Note that you can remove any element in this dictionary in the callback implementation
  44155. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  44156. * @returns the first item
  44157. */
  44158. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  44159. private _count;
  44160. private _data;
  44161. }
  44162. }
  44163. declare module BABYLON {
  44164. /** @hidden */
  44165. export interface ICollisionCoordinator {
  44166. createCollider(): Collider;
  44167. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  44168. init(scene: Scene): void;
  44169. }
  44170. /** @hidden */
  44171. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  44172. private _scene;
  44173. private _scaledPosition;
  44174. private _scaledVelocity;
  44175. private _finalPosition;
  44176. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  44177. createCollider(): Collider;
  44178. init(scene: Scene): void;
  44179. private _collideWithWorld;
  44180. }
  44181. }
  44182. declare module BABYLON {
  44183. /**
  44184. * Enum for Device Types
  44185. */
  44186. export enum DeviceType {
  44187. /** Generic */
  44188. Generic = 0,
  44189. /** Keyboard */
  44190. Keyboard = 1,
  44191. /** Mouse */
  44192. Mouse = 2,
  44193. /** Touch Pointers */
  44194. Touch = 3,
  44195. /** PS4 Dual Shock */
  44196. DualShock = 4,
  44197. /** Xbox */
  44198. Xbox = 5,
  44199. /** Switch Controller */
  44200. Switch = 6
  44201. }
  44202. /**
  44203. * Enum for All Pointers (Touch/Mouse)
  44204. */
  44205. export enum PointerInput {
  44206. /** Horizontal Axis */
  44207. Horizontal = 0,
  44208. /** Vertical Axis */
  44209. Vertical = 1,
  44210. /** Left Click or Touch */
  44211. LeftClick = 2,
  44212. /** Middle Click */
  44213. MiddleClick = 3,
  44214. /** Right Click */
  44215. RightClick = 4,
  44216. /** Browser Back */
  44217. BrowserBack = 5,
  44218. /** Browser Forward */
  44219. BrowserForward = 6,
  44220. /** Mouse Wheel X */
  44221. MouseWheelX = 7,
  44222. /** Mouse Wheel Y */
  44223. MouseWheelY = 8,
  44224. /** Mouse Wheel Z */
  44225. MouseWheelZ = 9,
  44226. /** Delta X */
  44227. DeltaHorizontal = 10,
  44228. /** Delta Y */
  44229. DeltaVertical = 11
  44230. }
  44231. /**
  44232. * Enum for Dual Shock Gamepad
  44233. */
  44234. export enum DualShockInput {
  44235. /** Cross */
  44236. Cross = 0,
  44237. /** Circle */
  44238. Circle = 1,
  44239. /** Square */
  44240. Square = 2,
  44241. /** Triangle */
  44242. Triangle = 3,
  44243. /** L1 */
  44244. L1 = 4,
  44245. /** R1 */
  44246. R1 = 5,
  44247. /** L2 */
  44248. L2 = 6,
  44249. /** R2 */
  44250. R2 = 7,
  44251. /** Share */
  44252. Share = 8,
  44253. /** Options */
  44254. Options = 9,
  44255. /** L3 */
  44256. L3 = 10,
  44257. /** R3 */
  44258. R3 = 11,
  44259. /** DPadUp */
  44260. DPadUp = 12,
  44261. /** DPadDown */
  44262. DPadDown = 13,
  44263. /** DPadLeft */
  44264. DPadLeft = 14,
  44265. /** DRight */
  44266. DPadRight = 15,
  44267. /** Home */
  44268. Home = 16,
  44269. /** TouchPad */
  44270. TouchPad = 17,
  44271. /** LStickXAxis */
  44272. LStickXAxis = 18,
  44273. /** LStickYAxis */
  44274. LStickYAxis = 19,
  44275. /** RStickXAxis */
  44276. RStickXAxis = 20,
  44277. /** RStickYAxis */
  44278. RStickYAxis = 21
  44279. }
  44280. /**
  44281. * Enum for Xbox Gamepad
  44282. */
  44283. export enum XboxInput {
  44284. /** A */
  44285. A = 0,
  44286. /** B */
  44287. B = 1,
  44288. /** X */
  44289. X = 2,
  44290. /** Y */
  44291. Y = 3,
  44292. /** LB */
  44293. LB = 4,
  44294. /** RB */
  44295. RB = 5,
  44296. /** LT */
  44297. LT = 6,
  44298. /** RT */
  44299. RT = 7,
  44300. /** Back */
  44301. Back = 8,
  44302. /** Start */
  44303. Start = 9,
  44304. /** LS */
  44305. LS = 10,
  44306. /** RS */
  44307. RS = 11,
  44308. /** DPadUp */
  44309. DPadUp = 12,
  44310. /** DPadDown */
  44311. DPadDown = 13,
  44312. /** DPadLeft */
  44313. DPadLeft = 14,
  44314. /** DRight */
  44315. DPadRight = 15,
  44316. /** Home */
  44317. Home = 16,
  44318. /** LStickXAxis */
  44319. LStickXAxis = 17,
  44320. /** LStickYAxis */
  44321. LStickYAxis = 18,
  44322. /** RStickXAxis */
  44323. RStickXAxis = 19,
  44324. /** RStickYAxis */
  44325. RStickYAxis = 20
  44326. }
  44327. /**
  44328. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  44329. */
  44330. export enum SwitchInput {
  44331. /** B */
  44332. B = 0,
  44333. /** A */
  44334. A = 1,
  44335. /** Y */
  44336. Y = 2,
  44337. /** X */
  44338. X = 3,
  44339. /** L */
  44340. L = 4,
  44341. /** R */
  44342. R = 5,
  44343. /** ZL */
  44344. ZL = 6,
  44345. /** ZR */
  44346. ZR = 7,
  44347. /** Minus */
  44348. Minus = 8,
  44349. /** Plus */
  44350. Plus = 9,
  44351. /** LS */
  44352. LS = 10,
  44353. /** RS */
  44354. RS = 11,
  44355. /** DPadUp */
  44356. DPadUp = 12,
  44357. /** DPadDown */
  44358. DPadDown = 13,
  44359. /** DPadLeft */
  44360. DPadLeft = 14,
  44361. /** DRight */
  44362. DPadRight = 15,
  44363. /** Home */
  44364. Home = 16,
  44365. /** Capture */
  44366. Capture = 17,
  44367. /** LStickXAxis */
  44368. LStickXAxis = 18,
  44369. /** LStickYAxis */
  44370. LStickYAxis = 19,
  44371. /** RStickXAxis */
  44372. RStickXAxis = 20,
  44373. /** RStickYAxis */
  44374. RStickYAxis = 21
  44375. }
  44376. }
  44377. declare module BABYLON {
  44378. /**
  44379. * This class will take all inputs from Keyboard, Pointer, and
  44380. * any Gamepads and provide a polling system that all devices
  44381. * will use. This class assumes that there will only be one
  44382. * pointer device and one keyboard.
  44383. */
  44384. export class DeviceInputSystem implements IDisposable {
  44385. /**
  44386. * Returns onDeviceConnected callback property
  44387. * @returns Callback with function to execute when a device is connected
  44388. */
  44389. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  44390. /**
  44391. * Sets callback function when a device is connected and executes against all connected devices
  44392. * @param callback Function to execute when a device is connected
  44393. */
  44394. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  44395. /**
  44396. * Callback to be triggered when a device is disconnected
  44397. */
  44398. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  44399. /**
  44400. * Callback to be triggered when event driven input is updated
  44401. */
  44402. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>, eventData?: any) => void;
  44403. private _inputs;
  44404. private _gamepads;
  44405. private _keyboardActive;
  44406. private _pointerActive;
  44407. private _elementToAttachTo;
  44408. private _keyboardDownEvent;
  44409. private _keyboardUpEvent;
  44410. private _keyboardBlurEvent;
  44411. private _pointerMoveEvent;
  44412. private _pointerDownEvent;
  44413. private _pointerUpEvent;
  44414. private _pointerWheelEvent;
  44415. private _pointerBlurEvent;
  44416. private _wheelEventName;
  44417. private _gamepadConnectedEvent;
  44418. private _gamepadDisconnectedEvent;
  44419. private _onDeviceConnected;
  44420. private static _MAX_KEYCODES;
  44421. private static _MAX_POINTER_INPUTS;
  44422. private _eventPrefix;
  44423. private constructor();
  44424. /**
  44425. * Creates a new DeviceInputSystem instance
  44426. * @param engine Engine to pull input element from
  44427. * @returns The new instance
  44428. */
  44429. static Create(engine: Engine): DeviceInputSystem;
  44430. /**
  44431. * Checks for current device input value, given an id and input index
  44432. * @param deviceName Id of connected device
  44433. * @param inputIndex Index of device input
  44434. * @returns Current value of input
  44435. */
  44436. /**
  44437. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  44438. * @param deviceType Enum specifiying device type
  44439. * @param deviceSlot "Slot" or index that device is referenced in
  44440. * @param inputIndex Id of input to be checked
  44441. * @returns Current value of input
  44442. */
  44443. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  44444. /**
  44445. * Check for a specific device in the DeviceInputSystem
  44446. * @param deviceType Type of device to check for
  44447. * @returns bool with status of device's existence
  44448. */
  44449. isDeviceAvailable(deviceType: DeviceType): boolean;
  44450. /**
  44451. * Dispose of all the eventlisteners
  44452. */
  44453. dispose(): void;
  44454. /**
  44455. * Checks for existing connections to devices and register them, if necessary
  44456. * Currently handles gamepads and mouse
  44457. */
  44458. private _checkForConnectedDevices;
  44459. /**
  44460. * Add a gamepad to the DeviceInputSystem
  44461. * @param gamepad A single DOM Gamepad object
  44462. */
  44463. private _addGamePad;
  44464. /**
  44465. * Add pointer device to DeviceInputSystem
  44466. * @param deviceType Type of Pointer to add
  44467. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  44468. * @param currentX Current X at point of adding
  44469. * @param currentY Current Y at point of adding
  44470. */
  44471. private _addPointerDevice;
  44472. /**
  44473. * Add device and inputs to device array
  44474. * @param deviceType Enum specifiying device type
  44475. * @param deviceSlot "Slot" or index that device is referenced in
  44476. * @param numberOfInputs Number of input entries to create for given device
  44477. */
  44478. private _registerDevice;
  44479. /**
  44480. * Given a specific device name, remove that device from the device map
  44481. * @param deviceType Enum specifiying device type
  44482. * @param deviceSlot "Slot" or index that device is referenced in
  44483. */
  44484. private _unregisterDevice;
  44485. /**
  44486. * Handle all actions that come from keyboard interaction
  44487. */
  44488. private _handleKeyActions;
  44489. /**
  44490. * Handle all actions that come from pointer interaction
  44491. */
  44492. private _handlePointerActions;
  44493. /**
  44494. * Handle all actions that come from gamepad interaction
  44495. */
  44496. private _handleGamepadActions;
  44497. /**
  44498. * Update all non-event based devices with each frame
  44499. * @param deviceType Enum specifiying device type
  44500. * @param deviceSlot "Slot" or index that device is referenced in
  44501. * @param inputIndex Id of input to be checked
  44502. */
  44503. private _updateDevice;
  44504. /**
  44505. * Gets DeviceType from the device name
  44506. * @param deviceName Name of Device from DeviceInputSystem
  44507. * @returns DeviceType enum value
  44508. */
  44509. private _getGamepadDeviceType;
  44510. }
  44511. }
  44512. declare module BABYLON {
  44513. /**
  44514. * Class used to manage all inputs for the scene.
  44515. */
  44516. export class InputManager {
  44517. /** The distance in pixel that you have to move to prevent some events */
  44518. static DragMovementThreshold: number;
  44519. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  44520. static LongPressDelay: number;
  44521. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  44522. static DoubleClickDelay: number;
  44523. /** If you need to check double click without raising a single click at first click, enable this flag */
  44524. static ExclusiveDoubleClickMode: boolean;
  44525. /** 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. */
  44526. private _alreadyAttached;
  44527. private _alreadyAttachedTo;
  44528. private _onPointerMove;
  44529. private _onPointerDown;
  44530. private _onPointerUp;
  44531. private _initClickEvent;
  44532. private _initActionManager;
  44533. private _delayedSimpleClick;
  44534. private _delayedSimpleClickTimeout;
  44535. private _previousDelayedSimpleClickTimeout;
  44536. private _meshPickProceed;
  44537. private _previousButtonPressed;
  44538. private _currentPickResult;
  44539. private _previousPickResult;
  44540. private _totalPointersPressed;
  44541. private _doubleClickOccured;
  44542. private _pointerOverMesh;
  44543. private _pickedDownMesh;
  44544. private _pickedUpMesh;
  44545. private _pointerX;
  44546. private _pointerY;
  44547. private _unTranslatedPointerX;
  44548. private _unTranslatedPointerY;
  44549. private _startingPointerPosition;
  44550. private _previousStartingPointerPosition;
  44551. private _startingPointerTime;
  44552. private _previousStartingPointerTime;
  44553. private _pointerCaptures;
  44554. private _meshUnderPointerId;
  44555. private _onKeyDown;
  44556. private _onKeyUp;
  44557. private _scene;
  44558. private _deviceInputSystem;
  44559. /**
  44560. * Creates a new InputManager
  44561. * @param scene defines the hosting scene
  44562. */
  44563. constructor(scene: Scene);
  44564. /**
  44565. * Gets the mesh that is currently under the pointer
  44566. */
  44567. get meshUnderPointer(): Nullable<AbstractMesh>;
  44568. /**
  44569. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  44570. * @param pointerId the pointer id to use
  44571. * @returns The mesh under this pointer id or null if not found
  44572. */
  44573. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  44574. /**
  44575. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  44576. */
  44577. get unTranslatedPointer(): Vector2;
  44578. /**
  44579. * Gets or sets the current on-screen X position of the pointer
  44580. */
  44581. get pointerX(): number;
  44582. set pointerX(value: number);
  44583. /**
  44584. * Gets or sets the current on-screen Y position of the pointer
  44585. */
  44586. get pointerY(): number;
  44587. set pointerY(value: number);
  44588. private _updatePointerPosition;
  44589. private _processPointerMove;
  44590. private _setRayOnPointerInfo;
  44591. private _checkPrePointerObservable;
  44592. /**
  44593. * Use this method to simulate a pointer move 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. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  44599. /**
  44600. * Use this method to simulate a pointer down on a mesh
  44601. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44602. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44603. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44604. */
  44605. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  44606. private _processPointerDown;
  44607. /** @hidden */
  44608. _isPointerSwiping(): boolean;
  44609. /**
  44610. * Use this method to simulate a pointer up on a mesh
  44611. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44612. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44613. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44614. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  44615. */
  44616. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  44617. private _processPointerUp;
  44618. /**
  44619. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  44620. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  44621. * @returns true if the pointer was captured
  44622. */
  44623. isPointerCaptured(pointerId?: number): boolean;
  44624. /**
  44625. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  44626. * @param attachUp defines if you want to attach events to pointerup
  44627. * @param attachDown defines if you want to attach events to pointerdown
  44628. * @param attachMove defines if you want to attach events to pointermove
  44629. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  44630. */
  44631. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  44632. /**
  44633. * Detaches all event handlers
  44634. */
  44635. detachControl(): void;
  44636. /**
  44637. * Force the value of meshUnderPointer
  44638. * @param mesh defines the mesh to use
  44639. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  44640. */
  44641. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  44642. /**
  44643. * Gets the mesh under the pointer
  44644. * @returns a Mesh or null if no mesh is under the pointer
  44645. */
  44646. getPointerOverMesh(): Nullable<AbstractMesh>;
  44647. }
  44648. }
  44649. declare module BABYLON {
  44650. /**
  44651. * This class defines the direct association between an animation and a target
  44652. */
  44653. export class TargetedAnimation {
  44654. /**
  44655. * Animation to perform
  44656. */
  44657. animation: Animation;
  44658. /**
  44659. * Target to animate
  44660. */
  44661. target: any;
  44662. /**
  44663. * Returns the string "TargetedAnimation"
  44664. * @returns "TargetedAnimation"
  44665. */
  44666. getClassName(): string;
  44667. /**
  44668. * Serialize the object
  44669. * @returns the JSON object representing the current entity
  44670. */
  44671. serialize(): any;
  44672. }
  44673. /**
  44674. * Use this class to create coordinated animations on multiple targets
  44675. */
  44676. export class AnimationGroup implements IDisposable {
  44677. /** The name of the animation group */
  44678. name: string;
  44679. private _scene;
  44680. private _targetedAnimations;
  44681. private _animatables;
  44682. private _from;
  44683. private _to;
  44684. private _isStarted;
  44685. private _isPaused;
  44686. private _speedRatio;
  44687. private _loopAnimation;
  44688. private _isAdditive;
  44689. /**
  44690. * Gets or sets the unique id of the node
  44691. */
  44692. uniqueId: number;
  44693. /**
  44694. * This observable will notify when one animation have ended
  44695. */
  44696. onAnimationEndObservable: Observable<TargetedAnimation>;
  44697. /**
  44698. * Observer raised when one animation loops
  44699. */
  44700. onAnimationLoopObservable: Observable<TargetedAnimation>;
  44701. /**
  44702. * Observer raised when all animations have looped
  44703. */
  44704. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  44705. /**
  44706. * This observable will notify when all animations have ended.
  44707. */
  44708. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  44709. /**
  44710. * This observable will notify when all animations have paused.
  44711. */
  44712. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  44713. /**
  44714. * This observable will notify when all animations are playing.
  44715. */
  44716. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  44717. /**
  44718. * Gets the first frame
  44719. */
  44720. get from(): number;
  44721. /**
  44722. * Gets the last frame
  44723. */
  44724. get to(): number;
  44725. /**
  44726. * Define if the animations are started
  44727. */
  44728. get isStarted(): boolean;
  44729. /**
  44730. * Gets a value indicating that the current group is playing
  44731. */
  44732. get isPlaying(): boolean;
  44733. /**
  44734. * Gets or sets the speed ratio to use for all animations
  44735. */
  44736. get speedRatio(): number;
  44737. /**
  44738. * Gets or sets the speed ratio to use for all animations
  44739. */
  44740. set speedRatio(value: number);
  44741. /**
  44742. * Gets or sets if all animations should loop or not
  44743. */
  44744. get loopAnimation(): boolean;
  44745. set loopAnimation(value: boolean);
  44746. /**
  44747. * Gets or sets if all animations should be evaluated additively
  44748. */
  44749. get isAdditive(): boolean;
  44750. set isAdditive(value: boolean);
  44751. /**
  44752. * Gets the targeted animations for this animation group
  44753. */
  44754. get targetedAnimations(): Array<TargetedAnimation>;
  44755. /**
  44756. * returning the list of animatables controlled by this animation group.
  44757. */
  44758. get animatables(): Array<Animatable>;
  44759. /**
  44760. * Gets the list of target animations
  44761. */
  44762. get children(): TargetedAnimation[];
  44763. /**
  44764. * Instantiates a new Animation Group.
  44765. * This helps managing several animations at once.
  44766. * @see https://doc.babylonjs.com/how_to/group
  44767. * @param name Defines the name of the group
  44768. * @param scene Defines the scene the group belongs to
  44769. */
  44770. constructor(
  44771. /** The name of the animation group */
  44772. name: string, scene?: Nullable<Scene>);
  44773. /**
  44774. * Add an animation (with its target) in the group
  44775. * @param animation defines the animation we want to add
  44776. * @param target defines the target of the animation
  44777. * @returns the TargetedAnimation object
  44778. */
  44779. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  44780. /**
  44781. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  44782. * It can add constant keys at begin or end
  44783. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  44784. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  44785. * @returns the animation group
  44786. */
  44787. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  44788. private _animationLoopCount;
  44789. private _animationLoopFlags;
  44790. private _processLoop;
  44791. /**
  44792. * Start all animations on given targets
  44793. * @param loop defines if animations must loop
  44794. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  44795. * @param from defines the from key (optional)
  44796. * @param to defines the to key (optional)
  44797. * @param isAdditive defines the additive state for the resulting animatables (optional)
  44798. * @returns the current animation group
  44799. */
  44800. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  44801. /**
  44802. * Pause all animations
  44803. * @returns the animation group
  44804. */
  44805. pause(): AnimationGroup;
  44806. /**
  44807. * Play all animations to initial state
  44808. * This function will start() the animations if they were not started or will restart() them if they were paused
  44809. * @param loop defines if animations must loop
  44810. * @returns the animation group
  44811. */
  44812. play(loop?: boolean): AnimationGroup;
  44813. /**
  44814. * Reset all animations to initial state
  44815. * @returns the animation group
  44816. */
  44817. reset(): AnimationGroup;
  44818. /**
  44819. * Restart animations from key 0
  44820. * @returns the animation group
  44821. */
  44822. restart(): AnimationGroup;
  44823. /**
  44824. * Stop all animations
  44825. * @returns the animation group
  44826. */
  44827. stop(): AnimationGroup;
  44828. /**
  44829. * Set animation weight for all animatables
  44830. * @param weight defines the weight to use
  44831. * @return the animationGroup
  44832. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44833. */
  44834. setWeightForAllAnimatables(weight: number): AnimationGroup;
  44835. /**
  44836. * Synchronize and normalize all animatables with a source animatable
  44837. * @param root defines the root animatable to synchronize with
  44838. * @return the animationGroup
  44839. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44840. */
  44841. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  44842. /**
  44843. * Goes to a specific frame in this animation group
  44844. * @param frame the frame number to go to
  44845. * @return the animationGroup
  44846. */
  44847. goToFrame(frame: number): AnimationGroup;
  44848. /**
  44849. * Dispose all associated resources
  44850. */
  44851. dispose(): void;
  44852. private _checkAnimationGroupEnded;
  44853. /**
  44854. * Clone the current animation group and returns a copy
  44855. * @param newName defines the name of the new group
  44856. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  44857. * @returns the new animation group
  44858. */
  44859. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  44860. /**
  44861. * Serializes the animationGroup to an object
  44862. * @returns Serialized object
  44863. */
  44864. serialize(): any;
  44865. /**
  44866. * Returns a new AnimationGroup object parsed from the source provided.
  44867. * @param parsedAnimationGroup defines the source
  44868. * @param scene defines the scene that will receive the animationGroup
  44869. * @returns a new AnimationGroup
  44870. */
  44871. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  44872. /**
  44873. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  44874. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  44875. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  44876. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  44877. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  44878. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  44879. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  44880. */
  44881. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  44882. /**
  44883. * Returns the string "AnimationGroup"
  44884. * @returns "AnimationGroup"
  44885. */
  44886. getClassName(): string;
  44887. /**
  44888. * Creates a detailed string about the object
  44889. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  44890. * @returns a string representing the object
  44891. */
  44892. toString(fullDetails?: boolean): string;
  44893. }
  44894. }
  44895. declare module BABYLON {
  44896. /**
  44897. * @hidden
  44898. **/
  44899. export class _TimeToken {
  44900. _startTimeQuery: Nullable<WebGLQuery>;
  44901. _endTimeQuery: Nullable<WebGLQuery>;
  44902. _timeElapsedQuery: Nullable<WebGLQuery>;
  44903. _timeElapsedQueryEnded: boolean;
  44904. }
  44905. }
  44906. declare module BABYLON {
  44907. /** @hidden */
  44908. export enum ExtensionName {
  44909. DepthClamping = "depth-clamping",
  44910. Depth24UnormStencil8 = "depth24unorm-stencil8",
  44911. Depth32FloatStencil8 = "depth32float-stencil8",
  44912. PipelineStatisticsQuery = "pipeline-statistics-query",
  44913. TextureCompressionBC = "texture-compression-bc",
  44914. TimestampQuery = "timestamp-query"
  44915. }
  44916. /** @hidden */
  44917. export enum AddressMode {
  44918. ClampToEdge = "clamp-to-edge",
  44919. Repeat = "repeat",
  44920. MirrorRepeat = "mirror-repeat"
  44921. }
  44922. /** @hidden */
  44923. export enum BindingType {
  44924. UniformBuffer = "uniform-buffer",
  44925. StorageBuffer = "storage-buffer",
  44926. ReadonlyStorageBuffer = "readonly-storage-buffer",
  44927. Sampler = "sampler",
  44928. ComparisonSampler = "comparison-sampler",
  44929. SampledTexture = "sampled-texture",
  44930. ReadonlyStorageTexture = "readonly-storage-texture",
  44931. WriteonlyStorageTexture = "writeonly-storage-texture"
  44932. }
  44933. /** @hidden */
  44934. export enum BlendFactor {
  44935. Zero = "zero",
  44936. One = "one",
  44937. SrcColor = "src-color",
  44938. OneMinusSrcColor = "one-minus-src-color",
  44939. SrcAlpha = "src-alpha",
  44940. OneMinusSrcAlpha = "one-minus-src-alpha",
  44941. DstColor = "dst-color",
  44942. OneMinusDstColor = "one-minus-dst-color",
  44943. DstAlpha = "dst-alpha",
  44944. OneMinusDstAlpha = "one-minus-dst-alpha",
  44945. SrcAlphaSaturated = "src-alpha-saturated",
  44946. BlendColor = "blend-color",
  44947. OneMinusBlendColor = "one-minus-blend-color"
  44948. }
  44949. /** @hidden */
  44950. export enum BlendOperation {
  44951. Add = "add",
  44952. Subtract = "subtract",
  44953. ReverseSubtract = "reverse-subtract",
  44954. Min = "min",
  44955. Max = "max"
  44956. }
  44957. /** @hidden */
  44958. export enum CompareFunction {
  44959. Never = "never",
  44960. Less = "less",
  44961. Equal = "equal",
  44962. LessEqual = "less-equal",
  44963. Greater = "greater",
  44964. NotEqual = "not-equal",
  44965. GreaterEqual = "greater-equal",
  44966. Always = "always"
  44967. }
  44968. /** @hidden */
  44969. export enum CullMode {
  44970. None = "none",
  44971. Front = "front",
  44972. Back = "back"
  44973. }
  44974. /** @hidden */
  44975. export enum FilterMode {
  44976. Nearest = "nearest",
  44977. Linear = "linear"
  44978. }
  44979. /** @hidden */
  44980. export enum FrontFace {
  44981. CCW = "ccw",
  44982. CW = "cw"
  44983. }
  44984. /** @hidden */
  44985. export enum IndexFormat {
  44986. Uint16 = "uint16",
  44987. Uint32 = "uint32"
  44988. }
  44989. /** @hidden */
  44990. export enum InputStepMode {
  44991. Vertex = "vertex",
  44992. Instance = "instance"
  44993. }
  44994. /** @hidden */
  44995. export enum LoadOp {
  44996. Load = "load"
  44997. }
  44998. /** @hidden */
  44999. export enum PrimitiveTopology {
  45000. PointList = "point-list",
  45001. LineList = "line-list",
  45002. LineStrip = "line-strip",
  45003. TriangleList = "triangle-list",
  45004. TriangleStrip = "triangle-strip"
  45005. }
  45006. /** @hidden */
  45007. export enum StencilOperation {
  45008. Keep = "keep",
  45009. Zero = "zero",
  45010. Replace = "replace",
  45011. Invert = "invert",
  45012. IncrementClamp = "increment-clamp",
  45013. DecrementClamp = "decrement-clamp",
  45014. IncrementWrap = "increment-wrap",
  45015. DecrementWrap = "decrement-wrap"
  45016. }
  45017. /** @hidden */
  45018. export enum StoreOp {
  45019. Store = "store",
  45020. Clear = "clear"
  45021. }
  45022. /** @hidden */
  45023. export enum TextureDimension {
  45024. E1d = "1d",
  45025. E2d = "2d",
  45026. E3d = "3d"
  45027. }
  45028. /** @hidden */
  45029. export enum TextureFormat {
  45030. R8Unorm = "r8unorm",
  45031. R8Snorm = "r8snorm",
  45032. R8Uint = "r8uint",
  45033. R8Sint = "r8sint",
  45034. R16Uint = "r16uint",
  45035. R16Sint = "r16sint",
  45036. R16Float = "r16float",
  45037. RG8Unorm = "rg8unorm",
  45038. RG8Snorm = "rg8snorm",
  45039. RG8Uint = "rg8uint",
  45040. RG8Sint = "rg8sint",
  45041. R32Uint = "r32uint",
  45042. R32Sint = "r32sint",
  45043. R32Float = "r32float",
  45044. RG16Uint = "rg16uint",
  45045. RG16Sint = "rg16sint",
  45046. RG16Float = "rg16float",
  45047. RGBA8Unorm = "rgba8unorm",
  45048. RGBA8UnormSRGB = "rgba8unorm-srgb",
  45049. RGBA8Snorm = "rgba8snorm",
  45050. RGBA8Uint = "rgba8uint",
  45051. RGBA8Sint = "rgba8sint",
  45052. BGRA8Unorm = "bgra8unorm",
  45053. BGRA8UnormSRGB = "bgra8unorm-srgb",
  45054. RGB9E5UFloat = "rgb9e5ufloat",
  45055. RGB10A2Unorm = "rgb10a2unorm",
  45056. RG11B10UFloat = "rg11b10ufloat",
  45057. RG32Uint = "rg32uint",
  45058. RG32Sint = "rg32sint",
  45059. RG32Float = "rg32float",
  45060. RGBA16Uint = "rgba16uint",
  45061. RGBA16Sint = "rgba16sint",
  45062. RGBA16Float = "rgba16float",
  45063. RGBA32Uint = "rgba32uint",
  45064. RGBA32Sint = "rgba32sint",
  45065. RGBA32Float = "rgba32float",
  45066. Stencil8 = "stencil8",
  45067. Depth16Unorm = "depth16unorm",
  45068. Depth24Plus = "depth24plus",
  45069. Depth24PlusStencil8 = "depth24plus-stencil8",
  45070. Depth32Float = "depth32float",
  45071. BC1RGBAUNorm = "bc1-rgba-unorm",
  45072. BC1RGBAUnormSRGB = "bc1-rgba-unorm-srgb",
  45073. BC2RGBAUnorm = "bc2-rgba-unorm",
  45074. BC2RGBAUnormSRGB = "bc2-rgba-unorm-srgb",
  45075. BC3RGBAUnorm = "bc3-rgba-unorm",
  45076. BC3RGBAUnormSRGB = "bc3-rgba-unorm-srgb",
  45077. BC4RUnorm = "bc4-r-unorm",
  45078. BC4RSnorm = "bc4-r-snorm",
  45079. BC5RGUnorm = "bc5-rg-unorm",
  45080. BC5RGSnorm = "bc5-rg-snorm",
  45081. BC6HRGBUFloat = "bc6h-rgb-ufloat",
  45082. BC6HRGBFloat = "bc6h-rgb-float",
  45083. BC7RGBAUnorm = "bc7-rgba-unorm",
  45084. BC7RGBAUnormSRGB = "bc7-rgba-unorm-srgb",
  45085. Depth24UnormStencil8 = "depth24unorm-stencil8",
  45086. Depth32FloatStencil8 = "depth32float-stencil8"
  45087. }
  45088. /** @hidden */
  45089. export enum TextureComponentType {
  45090. Float = "float",
  45091. Sint = "sint",
  45092. Uint = "uint",
  45093. DepthComparison = "depth-comparison"
  45094. }
  45095. /** @hidden */
  45096. export enum TextureViewDimension {
  45097. E1d = "1d",
  45098. E2d = "2d",
  45099. E2dArray = "2d-array",
  45100. Cube = "cube",
  45101. CubeArray = "cube-array",
  45102. E3d = "3d"
  45103. }
  45104. /** @hidden */
  45105. export enum VertexFormat {
  45106. Uchar2 = "uchar2",
  45107. Uchar4 = "uchar4",
  45108. Char2 = "char2",
  45109. Char4 = "char4",
  45110. Uchar2Norm = "uchar2norm",
  45111. Uchar4Norm = "uchar4norm",
  45112. Char2Norm = "char2norm",
  45113. Char4Norm = "char4norm",
  45114. Ushort2 = "ushort2",
  45115. Ushort4 = "ushort4",
  45116. Short2 = "short2",
  45117. Short4 = "short4",
  45118. Ushort2Norm = "ushort2norm",
  45119. Ushort4Norm = "ushort4norm",
  45120. Short2Norm = "short2norm",
  45121. Short4Norm = "short4norm",
  45122. Half2 = "half2",
  45123. Half4 = "half4",
  45124. Float = "float",
  45125. Float2 = "float2",
  45126. Float3 = "float3",
  45127. Float4 = "float4",
  45128. Uint = "uint",
  45129. Uint2 = "uint2",
  45130. Uint3 = "uint3",
  45131. Uint4 = "uint4",
  45132. Int = "int",
  45133. Int2 = "int2",
  45134. Int3 = "int3",
  45135. Int4 = "int4"
  45136. }
  45137. /** @hidden */
  45138. export enum TextureAspect {
  45139. All = "all",
  45140. StencilOnly = "stencil-only",
  45141. DepthOnly = "depth-only"
  45142. }
  45143. /** @hidden */
  45144. export enum CompilationMessageType {
  45145. Error = "error",
  45146. Warning = "warning",
  45147. Info = "info"
  45148. }
  45149. /** @hidden */
  45150. export enum QueryType {
  45151. Occlusion = "occlusion"
  45152. }
  45153. /** @hidden */
  45154. export enum BufferUsage {
  45155. MapRead = 1,
  45156. MapWrite = 2,
  45157. CopySrc = 4,
  45158. CopyDst = 8,
  45159. Index = 16,
  45160. Vertex = 32,
  45161. Uniform = 64,
  45162. Storage = 128,
  45163. Indirect = 256,
  45164. QueryResolve = 512
  45165. }
  45166. /** @hidden */
  45167. export enum ColorWrite {
  45168. Red = 1,
  45169. Green = 2,
  45170. Blue = 4,
  45171. Alpha = 8,
  45172. All = 15
  45173. }
  45174. /** @hidden */
  45175. export enum ShaderStage {
  45176. Vertex = 1,
  45177. Fragment = 2,
  45178. Compute = 4
  45179. }
  45180. /** @hidden */
  45181. export enum TextureUsage {
  45182. CopySrc = 1,
  45183. CopyDst = 2,
  45184. Sampled = 4,
  45185. Storage = 8,
  45186. OutputAttachment = 16
  45187. }
  45188. /** @hidden */
  45189. export enum MapMode {
  45190. Read = 1,
  45191. Write = 2
  45192. }
  45193. }
  45194. declare module BABYLON {
  45195. /** @hidden */
  45196. export interface WebGPUBindingInfo {
  45197. setIndex: number;
  45198. bindingIndex: number;
  45199. }
  45200. /** @hidden */
  45201. export interface WebGPUTextureSamplerBindingDescription {
  45202. sampler: WebGPUBindingInfo;
  45203. isTextureArray: boolean;
  45204. textures: Array<WebGPUBindingInfo>;
  45205. }
  45206. /** @hidden
  45207. * If the binding is a UBO, isSampler=isTexture=false
  45208. */
  45209. export interface WebGPUBindingDescription {
  45210. name: string;
  45211. usedInVertex: boolean;
  45212. usedInFragment: boolean;
  45213. isSampler: boolean;
  45214. isComparisonSampler?: boolean;
  45215. isTexture: boolean;
  45216. componentType?: GPUTextureComponentType;
  45217. textureDimension?: GPUTextureViewDimension;
  45218. }
  45219. /**
  45220. * @hidden
  45221. */
  45222. export class WebGPUShaderProcessingContext implements ShaderProcessingContext {
  45223. uboNextBindingIndex: number;
  45224. freeSetIndex: number;
  45225. freeBindingIndex: number;
  45226. availableVaryings: {
  45227. [key: string]: number;
  45228. };
  45229. availableAttributes: {
  45230. [key: string]: number;
  45231. };
  45232. availableUBOs: {
  45233. [key: string]: {
  45234. setIndex: number;
  45235. bindingIndex: number;
  45236. };
  45237. };
  45238. availableSamplers: {
  45239. [key: string]: WebGPUTextureSamplerBindingDescription;
  45240. };
  45241. leftOverUniforms: {
  45242. name: string;
  45243. type: string;
  45244. length: number;
  45245. }[];
  45246. orderedAttributes: string[];
  45247. orderedUBOsAndSamplers: WebGPUBindingDescription[][];
  45248. uniformBufferNames: string[];
  45249. attributeNamesFromEffect: string[];
  45250. attributeLocationsFromEffect: number[];
  45251. private _attributeNextLocation;
  45252. private _varyingNextLocation;
  45253. constructor();
  45254. getAttributeNextLocation(dataType: string, arrayLength?: number): number;
  45255. getVaryingNextLocation(dataType: string, arrayLength?: number): number;
  45256. getNextFreeUBOBinding(): {
  45257. setIndex: number;
  45258. bindingIndex: number;
  45259. };
  45260. private _getNextFreeBinding;
  45261. }
  45262. }
  45263. declare module BABYLON {
  45264. /** @hidden */
  45265. export interface IWebGPUPipelineContextSamplerCache {
  45266. samplerBinding: number;
  45267. firstTextureName: string;
  45268. }
  45269. /** @hidden */
  45270. export interface IWebGPUPipelineContextTextureCache {
  45271. textureBinding: number;
  45272. texture: InternalTexture;
  45273. }
  45274. /** @hidden */
  45275. export interface IWebGPUPipelineContextVertexInputsCache {
  45276. indexBuffer: Nullable<GPUBuffer>;
  45277. indexOffset: number;
  45278. vertexStartSlot: number;
  45279. vertexBuffers: GPUBuffer[];
  45280. vertexOffsets: number[];
  45281. }
  45282. /** @hidden */
  45283. export interface IWebGPURenderPipelineStageDescriptor {
  45284. vertexStage: GPUProgrammableStageDescriptor;
  45285. fragmentStage?: GPUProgrammableStageDescriptor;
  45286. }
  45287. /** @hidden */
  45288. export class WebGPUBindGroupCacheNode {
  45289. values: {
  45290. [id: number]: WebGPUBindGroupCacheNode;
  45291. };
  45292. bindGroups: GPUBindGroup[];
  45293. constructor();
  45294. }
  45295. /** @hidden */
  45296. export class WebGPUPipelineContext implements IPipelineContext {
  45297. engine: WebGPUEngine;
  45298. shaderProcessingContext: WebGPUShaderProcessingContext;
  45299. leftOverUniformsByName: {
  45300. [name: string]: string;
  45301. };
  45302. sources: {
  45303. vertex: string;
  45304. fragment: string;
  45305. rawVertex: string;
  45306. rawFragment: string;
  45307. };
  45308. stages: Nullable<IWebGPURenderPipelineStageDescriptor>;
  45309. samplers: {
  45310. [name: string]: Nullable<IWebGPUPipelineContextSamplerCache>;
  45311. };
  45312. textures: {
  45313. [name: string]: Nullable<IWebGPUPipelineContextTextureCache>;
  45314. };
  45315. bindGroupLayouts: GPUBindGroupLayout[];
  45316. bindGroupsCache: WebGPUBindGroupCacheNode;
  45317. /**
  45318. * Stores the uniform buffer
  45319. */
  45320. uniformBuffer: Nullable<UniformBuffer>;
  45321. onCompiled?: () => void;
  45322. get isAsync(): boolean;
  45323. get isReady(): boolean;
  45324. /** @hidden */
  45325. _name: string;
  45326. constructor(shaderProcessingContext: WebGPUShaderProcessingContext, engine: WebGPUEngine);
  45327. _handlesSpectorRebuildCallback(onCompiled: (program: any) => void): void;
  45328. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  45329. [key: string]: number;
  45330. }, uniformsNames: string[], uniforms: {
  45331. [key: string]: Nullable<WebGLUniformLocation>;
  45332. }, samplerList: string[], samplers: {
  45333. [key: string]: number;
  45334. }, attributesNames: string[], attributes: number[]): void;
  45335. /** @hidden */
  45336. /**
  45337. * Build the uniform buffer used in the material.
  45338. */
  45339. buildUniformLayout(): void;
  45340. /**
  45341. * Release all associated resources.
  45342. **/
  45343. dispose(): void;
  45344. /**
  45345. * Sets an integer value on a uniform variable.
  45346. * @param uniformName Name of the variable.
  45347. * @param value Value to be set.
  45348. */
  45349. setInt(uniformName: string, value: number): void;
  45350. /**
  45351. * Sets an int2 value on a uniform variable.
  45352. * @param uniformName Name of the variable.
  45353. * @param x First int in int2.
  45354. * @param y Second int in int2.
  45355. */
  45356. setInt2(uniformName: string, x: number, y: number): void;
  45357. /**
  45358. * Sets an int3 value on a uniform variable.
  45359. * @param uniformName Name of the variable.
  45360. * @param x First int in int3.
  45361. * @param y Second int in int3.
  45362. * @param z Third int in int3.
  45363. */
  45364. setInt3(uniformName: string, x: number, y: number, z: number): void;
  45365. /**
  45366. * Sets an int4 value on a uniform variable.
  45367. * @param uniformName Name of the variable.
  45368. * @param x First int in int4.
  45369. * @param y Second int in int4.
  45370. * @param z Third int in int4.
  45371. * @param w Fourth int in int4.
  45372. */
  45373. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  45374. /**
  45375. * Sets an int array on a uniform variable.
  45376. * @param uniformName Name of the variable.
  45377. * @param array array to be set.
  45378. */
  45379. setIntArray(uniformName: string, array: Int32Array): void;
  45380. /**
  45381. * 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)
  45382. * @param uniformName Name of the variable.
  45383. * @param array array to be set.
  45384. */
  45385. setIntArray2(uniformName: string, array: Int32Array): void;
  45386. /**
  45387. * 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)
  45388. * @param uniformName Name of the variable.
  45389. * @param array array to be set.
  45390. */
  45391. setIntArray3(uniformName: string, array: Int32Array): void;
  45392. /**
  45393. * 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)
  45394. * @param uniformName Name of the variable.
  45395. * @param array array to be set.
  45396. */
  45397. setIntArray4(uniformName: string, array: Int32Array): void;
  45398. /**
  45399. * Sets an array on a uniform variable.
  45400. * @param uniformName Name of the variable.
  45401. * @param array array to be set.
  45402. */
  45403. setArray(uniformName: string, array: number[]): void;
  45404. /**
  45405. * 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)
  45406. * @param uniformName Name of the variable.
  45407. * @param array array to be set.
  45408. */
  45409. setArray2(uniformName: string, array: number[]): void;
  45410. /**
  45411. * 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)
  45412. * @param uniformName Name of the variable.
  45413. * @param array array to be set.
  45414. * @returns this effect.
  45415. */
  45416. setArray3(uniformName: string, array: number[]): void;
  45417. /**
  45418. * 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)
  45419. * @param uniformName Name of the variable.
  45420. * @param array array to be set.
  45421. */
  45422. setArray4(uniformName: string, array: number[]): void;
  45423. /**
  45424. * Sets matrices on a uniform variable.
  45425. * @param uniformName Name of the variable.
  45426. * @param matrices matrices to be set.
  45427. */
  45428. setMatrices(uniformName: string, matrices: Float32Array): void;
  45429. /**
  45430. * Sets matrix on a uniform variable.
  45431. * @param uniformName Name of the variable.
  45432. * @param matrix matrix to be set.
  45433. */
  45434. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  45435. /**
  45436. * 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)
  45437. * @param uniformName Name of the variable.
  45438. * @param matrix matrix to be set.
  45439. */
  45440. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  45441. /**
  45442. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  45443. * @param uniformName Name of the variable.
  45444. * @param matrix matrix to be set.
  45445. */
  45446. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  45447. /**
  45448. * Sets a float on a uniform variable.
  45449. * @param uniformName Name of the variable.
  45450. * @param value value to be set.
  45451. * @returns this effect.
  45452. */
  45453. setFloat(uniformName: string, value: number): void;
  45454. /**
  45455. * Sets a Vector2 on a uniform variable.
  45456. * @param uniformName Name of the variable.
  45457. * @param vector2 vector2 to be set.
  45458. */
  45459. setVector2(uniformName: string, vector2: IVector2Like): void;
  45460. /**
  45461. * Sets a float2 on a uniform variable.
  45462. * @param uniformName Name of the variable.
  45463. * @param x First float in float2.
  45464. * @param y Second float in float2.
  45465. */
  45466. setFloat2(uniformName: string, x: number, y: number): void;
  45467. /**
  45468. * Sets a Vector3 on a uniform variable.
  45469. * @param uniformName Name of the variable.
  45470. * @param vector3 Value to be set.
  45471. */
  45472. setVector3(uniformName: string, vector3: IVector3Like): void;
  45473. /**
  45474. * Sets a float3 on a uniform variable.
  45475. * @param uniformName Name of the variable.
  45476. * @param x First float in float3.
  45477. * @param y Second float in float3.
  45478. * @param z Third float in float3.
  45479. */
  45480. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  45481. /**
  45482. * Sets a Vector4 on a uniform variable.
  45483. * @param uniformName Name of the variable.
  45484. * @param vector4 Value to be set.
  45485. */
  45486. setVector4(uniformName: string, vector4: IVector4Like): void;
  45487. /**
  45488. * Sets a float4 on a uniform variable.
  45489. * @param uniformName Name of the variable.
  45490. * @param x First float in float4.
  45491. * @param y Second float in float4.
  45492. * @param z Third float in float4.
  45493. * @param w Fourth float in float4.
  45494. * @returns this effect.
  45495. */
  45496. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  45497. /**
  45498. * Sets a Color3 on a uniform variable.
  45499. * @param uniformName Name of the variable.
  45500. * @param color3 Value to be set.
  45501. */
  45502. setColor3(uniformName: string, color3: IColor3Like): void;
  45503. /**
  45504. * Sets a Color4 on a uniform variable.
  45505. * @param uniformName Name of the variable.
  45506. * @param color3 Value to be set.
  45507. * @param alpha Alpha value to be set.
  45508. */
  45509. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  45510. /**
  45511. * Sets a Color4 on a uniform variable
  45512. * @param uniformName defines the name of the variable
  45513. * @param color4 defines the value to be set
  45514. */
  45515. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  45516. _getVertexShaderCode(): string | null;
  45517. _getFragmentShaderCode(): string | null;
  45518. }
  45519. }
  45520. declare module BABYLON {
  45521. /** @hidden */
  45522. export class WebGPUDataBuffer extends DataBuffer {
  45523. private _buffer;
  45524. constructor(resource: GPUBuffer);
  45525. get underlyingResource(): any;
  45526. }
  45527. }
  45528. declare module BABYLON {
  45529. /**
  45530. * Class used to inline functions in shader code
  45531. */
  45532. export class ShaderCodeInliner {
  45533. private static readonly _RegexpFindFunctionNameAndType;
  45534. private _sourceCode;
  45535. private _functionDescr;
  45536. private _numMaxIterations;
  45537. /** Gets or sets the token used to mark the functions to inline */
  45538. inlineToken: string;
  45539. /** Gets or sets the debug mode */
  45540. debug: boolean;
  45541. /** Gets the code after the inlining process */
  45542. get code(): string;
  45543. /**
  45544. * Initializes the inliner
  45545. * @param sourceCode shader code source to inline
  45546. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  45547. */
  45548. constructor(sourceCode: string, numMaxIterations?: number);
  45549. /**
  45550. * Start the processing of the shader code
  45551. */
  45552. processCode(): void;
  45553. private _collectFunctions;
  45554. private _processInlining;
  45555. private _extractBetweenMarkers;
  45556. private _skipWhitespaces;
  45557. private _isIdentifierChar;
  45558. private _removeComments;
  45559. private _replaceFunctionCallsByCode;
  45560. private _findBackward;
  45561. private _escapeRegExp;
  45562. private _replaceNames;
  45563. }
  45564. }
  45565. declare module BABYLON {
  45566. /** @hidden */
  45567. export class WebGPUShaderProcessor implements IShaderProcessor {
  45568. protected _missingVaryings: Array<string>;
  45569. protected _textureArrayProcessing: Array<string>;
  45570. protected _preProcessors: {
  45571. [key: string]: string;
  45572. };
  45573. private _getArraySize;
  45574. initializeShaders(processingContext: Nullable<ShaderProcessingContext>): void;
  45575. varyingProcessor(varying: string, isFragment: boolean, preProcessors: {
  45576. [key: string]: string;
  45577. }, processingContext: Nullable<ShaderProcessingContext>): string;
  45578. attributeProcessor(attribute: string, preProcessors: {
  45579. [key: string]: string;
  45580. }, processingContext: Nullable<ShaderProcessingContext>): string;
  45581. uniformProcessor(uniform: string, isFragment: boolean, preProcessors: {
  45582. [key: string]: string;
  45583. }, processingContext: Nullable<ShaderProcessingContext>): string;
  45584. uniformBufferProcessor(uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  45585. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  45586. private _applyTextureArrayProcessing;
  45587. finalizeShaders(vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>): {
  45588. vertexCode: string;
  45589. fragmentCode: string;
  45590. };
  45591. }
  45592. }
  45593. declare module BABYLON {
  45594. /** @hidden */
  45595. export class WebGPUBufferManager {
  45596. private _device;
  45597. private _deferredReleaseBuffers;
  45598. private static _IsGPUBuffer;
  45599. constructor(device: GPUDevice);
  45600. createRawBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags, mappedAtCreation?: boolean): GPUBuffer;
  45601. createBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags): DataBuffer;
  45602. setSubData(dataBuffer: WebGPUDataBuffer, dstByteOffset: number, src: ArrayBufferView, srcByteOffset?: number, byteLength?: number): void;
  45603. private _FromHalfFloat;
  45604. private _GetHalfFloatAsFloatRGBAArrayBuffer;
  45605. readDataFromBuffer(gpuBuffer: GPUBuffer, size: number, width: number, height: number, bytesPerRow: number, bytesPerRowAligned: number, floatFormat?: number, offset?: number, buffer?: Nullable<ArrayBufferView>, destroyBuffer?: boolean): Promise<ArrayBufferView>;
  45606. releaseBuffer(buffer: DataBuffer | GPUBuffer): boolean;
  45607. destroyDeferredBuffers(): void;
  45608. }
  45609. }
  45610. declare module BABYLON {
  45611. /** @hidden */
  45612. export class WebGPUHardwareTexture implements HardwareTextureWrapper {
  45613. private _webgpuTexture;
  45614. private _webgpuMSAATexture;
  45615. get underlyingResource(): Nullable<GPUTexture>;
  45616. get msaaTexture(): Nullable<GPUTexture>;
  45617. set msaaTexture(texture: Nullable<GPUTexture>);
  45618. view: Nullable<GPUTextureView>;
  45619. format: GPUTextureFormat;
  45620. textureUsages: number;
  45621. constructor(existingTexture?: Nullable<GPUTexture>);
  45622. set(hardwareTexture: GPUTexture): void;
  45623. setMSAATexture(hardwareTexture: GPUTexture): void;
  45624. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  45625. createView(descriptor?: GPUTextureViewDescriptor): void;
  45626. reset(): void;
  45627. release(): void;
  45628. }
  45629. }
  45630. declare module BABYLON {
  45631. /** @hidden */
  45632. export class WebGPUTextureHelper {
  45633. private _device;
  45634. private _glslang;
  45635. private _bufferManager;
  45636. private _mipmapSampler;
  45637. private _invertYPreMultiplyAlphaSampler;
  45638. private _pipelines;
  45639. private _compiledShaders;
  45640. private _deferredReleaseTextures;
  45641. private _commandEncoderForCreation;
  45642. static ComputeNumMipmapLevels(width: number, height: number): number;
  45643. constructor(device: GPUDevice, glslang: any, bufferManager: WebGPUBufferManager);
  45644. private _getPipeline;
  45645. private static _GetTextureTypeFromFormat;
  45646. private static _GetBlockInformationFromFormat;
  45647. private static _IsHardwareTexture;
  45648. private static _IsInternalTexture;
  45649. static GetCompareFunction(compareFunction: Nullable<number>): GPUCompareFunction;
  45650. static IsImageBitmap(imageBitmap: ImageBitmap | {
  45651. width: number;
  45652. height: number;
  45653. }): imageBitmap is ImageBitmap;
  45654. static IsImageBitmapArray(imageBitmap: ImageBitmap[] | {
  45655. width: number;
  45656. height: number;
  45657. }): imageBitmap is ImageBitmap[];
  45658. setCommandEncoder(encoder: GPUCommandEncoder): void;
  45659. static IsCompressedFormat(format: GPUTextureFormat): boolean;
  45660. static GetWebGPUTextureFormat(type: number, format: number): GPUTextureFormat;
  45661. invertYPreMultiplyAlpha(gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  45662. clear(format: GPUTextureFormat, color: IColor4Like, passEncoder: GPURenderPassEncoder): void;
  45663. createTexture(imageBitmap: ImageBitmap | {
  45664. width: number;
  45665. height: number;
  45666. layers: number;
  45667. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, is3D?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  45668. createCubeTexture(imageBitmaps: ImageBitmap[] | {
  45669. width: number;
  45670. height: number;
  45671. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  45672. generateCubeMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, commandEncoder?: GPUCommandEncoder): void;
  45673. generateMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  45674. createGPUTextureForInternalTexture(texture: InternalTexture, width?: number, height?: number, depth?: number): WebGPUHardwareTexture;
  45675. createMSAATexture(texture: InternalTexture, samples: number): void;
  45676. updateCubeTextures(imageBitmaps: ImageBitmap[] | Uint8Array[], gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, commandEncoder?: GPUCommandEncoder): void;
  45677. 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;
  45678. readPixels(texture: GPUTexture, x: number, y: number, width: number, height: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, buffer?: Nullable<ArrayBufferView>): Promise<ArrayBufferView>;
  45679. releaseTexture(texture: InternalTexture | GPUTexture): void;
  45680. destroyDeferredTextures(): void;
  45681. }
  45682. }
  45683. declare module BABYLON {
  45684. /** @hidden */
  45685. export class WebGPURenderPassWrapper {
  45686. renderPassDescriptor: Nullable<GPURenderPassDescriptor>;
  45687. renderPass: Nullable<GPURenderPassEncoder>;
  45688. colorAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  45689. depthAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  45690. colorAttachmentGPUTextures: WebGPUHardwareTexture[];
  45691. depthTextureFormat: GPUTextureFormat | undefined;
  45692. constructor();
  45693. reset(fullReset?: boolean): void;
  45694. }
  45695. }
  45696. declare module BABYLON {
  45697. /** @hidden */
  45698. export class WebGPUCacheSampler {
  45699. private _samplers;
  45700. private _device;
  45701. disabled: boolean;
  45702. constructor(device: GPUDevice);
  45703. private static _GetSamplerHashCode;
  45704. private static _GetSamplerFilterDescriptor;
  45705. private static _GetWrappingMode;
  45706. private static _GetSamplerWrappingDescriptor;
  45707. private static _GetSamplerDescriptor;
  45708. getSampler(internalTexture: InternalTexture, bypassCache?: boolean): GPUSampler;
  45709. }
  45710. }
  45711. declare module BABYLON {
  45712. /** @hidden */
  45713. export class WebGPUShaderManager {
  45714. private _shaders;
  45715. private _device;
  45716. constructor(device: GPUDevice);
  45717. getCompiledShaders(name: string): IWebGPURenderPipelineStageDescriptor;
  45718. }
  45719. }
  45720. declare module BABYLON {
  45721. /** @hidden */
  45722. export abstract class WebGPUCacheRenderPipeline {
  45723. static NumCacheHitWithoutHash: number;
  45724. static NumCacheHitWithHash: number;
  45725. static NumCacheMiss: number;
  45726. static NumPipelineCreationLastFrame: number;
  45727. disabled: boolean;
  45728. private static _NumPipelineCreationCurrentFrame;
  45729. protected _states: number[];
  45730. protected _stateDirtyLowestIndex: number;
  45731. lastStateDirtyLowestIndex: number;
  45732. private _device;
  45733. private _isDirty;
  45734. private _emptyVertexBuffer;
  45735. private _parameter;
  45736. private _shaderId;
  45737. private _alphaToCoverageEnabled;
  45738. private _frontFace;
  45739. private _cullEnabled;
  45740. private _cullFace;
  45741. private _clampDepth;
  45742. private _rasterizationState;
  45743. private _depthBias;
  45744. private _depthBiasClamp;
  45745. private _depthBiasSlopeScale;
  45746. private _colorFormat;
  45747. private _webgpuColorFormat;
  45748. private _mrtAttachments1;
  45749. private _mrtAttachments2;
  45750. private _mrtFormats;
  45751. private _alphaBlendEnabled;
  45752. private _alphaBlendFuncParams;
  45753. private _alphaBlendEqParams;
  45754. private _writeMask;
  45755. private _colorStates;
  45756. private _depthStencilFormat;
  45757. private _webgpuDepthStencilFormat;
  45758. private _depthTestEnabled;
  45759. private _depthWriteEnabled;
  45760. private _depthCompare;
  45761. private _stencilEnabled;
  45762. private _stencilFrontCompare;
  45763. private _stencilFrontDepthFailOp;
  45764. private _stencilFrontPassOp;
  45765. private _stencilFrontFailOp;
  45766. private _stencilReadMask;
  45767. private _stencilWriteMask;
  45768. private _depthStencilState;
  45769. private _vertexBuffers;
  45770. private _overrideVertexBuffers;
  45771. private _indexBuffer;
  45772. constructor(device: GPUDevice, emptyVertexBuffer: VertexBuffer);
  45773. reset(): void;
  45774. protected abstract _getRenderPipeline(param: {
  45775. token: any;
  45776. pipeline: Nullable<GPURenderPipeline>;
  45777. }): void;
  45778. protected abstract _setRenderPipeline(param: {
  45779. token: any;
  45780. pipeline: Nullable<GPURenderPipeline>;
  45781. }): void;
  45782. getRenderPipeline(fillMode: number, effect: Effect, sampleCount: number): GPURenderPipeline;
  45783. endFrame(): void;
  45784. setAlphaToCoverage(enabled: boolean): void;
  45785. setFrontFace(frontFace: number): void;
  45786. setCullEnabled(enabled: boolean): void;
  45787. setCullFace(cullFace: number): void;
  45788. setClampDepth(clampDepth: boolean): void;
  45789. resetDepthCullingState(): void;
  45790. setDepthCullingState(cullEnabled: boolean, frontFace: number, cullFace: number, zOffset: number, depthTestEnabled: boolean, depthWriteEnabled: boolean, depthCompare: Nullable<number>): void;
  45791. setDepthBiasSlopeScale(depthBiasSlopeScale: number): void;
  45792. setColorFormat(format: GPUTextureFormat): void;
  45793. setMRTAttachments(attachments: number[], textureArray: InternalTexture[]): void;
  45794. setAlphaBlendEnabled(enabled: boolean): void;
  45795. setAlphaBlendFactors(factors: Array<Nullable<number>>, operations: Array<Nullable<number>>): void;
  45796. setWriteMask(mask: number): void;
  45797. setDepthStencilFormat(format: GPUTextureFormat | undefined): void;
  45798. setDepthTestEnabled(enabled: boolean): void;
  45799. setDepthWriteEnabled(enabled: boolean): void;
  45800. setDepthCompare(func: Nullable<number>): void;
  45801. setStencilEnabled(enabled: boolean): void;
  45802. setStencilCompare(func: Nullable<number>): void;
  45803. setStencilDepthFailOp(op: Nullable<number>): void;
  45804. setStencilPassOp(op: Nullable<number>): void;
  45805. setStencilFailOp(op: Nullable<number>): void;
  45806. setStencilReadMask(mask: number): void;
  45807. setStencilWriteMask(mask: number): void;
  45808. resetStencilState(): void;
  45809. setStencilState(stencilEnabled: boolean, compare: Nullable<number>, depthFailOp: Nullable<number>, passOp: Nullable<number>, failOp: Nullable<number>, readMask: number, writeMask: number): void;
  45810. setBuffers(vertexBuffers: Nullable<{
  45811. [key: string]: Nullable<VertexBuffer>;
  45812. }>, indexBuffer: Nullable<DataBuffer>, overrideVertexBuffers: Nullable<{
  45813. [key: string]: Nullable<VertexBuffer>;
  45814. }>): void;
  45815. private static _GetTopology;
  45816. private static _GetAphaBlendOperation;
  45817. private static _GetAphaBlendFactor;
  45818. private static _GetCompareFunction;
  45819. private static _GetStencilOpFunction;
  45820. private static _GetVertexInputDescriptorFormat;
  45821. private _getAphaBlendState;
  45822. private _getColorBlendState;
  45823. private _setShaderStage;
  45824. private _setRasterizationState;
  45825. private _setColorStates;
  45826. private _setDepthStencilState;
  45827. private _setVertexState;
  45828. private _createPipelineLayout;
  45829. private _getVertexInputDescriptor;
  45830. private _createRenderPipeline;
  45831. }
  45832. }
  45833. declare module BABYLON {
  45834. /** @hidden */
  45835. class NodeState {
  45836. values: {
  45837. [name: number]: NodeState;
  45838. };
  45839. pipeline: GPURenderPipeline;
  45840. constructor();
  45841. count(): [number, number];
  45842. }
  45843. /** @hidden */
  45844. export class WebGPUCacheRenderPipelineTree extends WebGPUCacheRenderPipeline {
  45845. private static _Cache;
  45846. private _nodeStack;
  45847. static GetNodeCounts(): {
  45848. nodeCount: number;
  45849. pipelineCount: number;
  45850. };
  45851. constructor(device: GPUDevice, emptyVertexBuffer: VertexBuffer);
  45852. protected _getRenderPipeline(param: {
  45853. token: any;
  45854. pipeline: Nullable<GPURenderPipeline>;
  45855. }): void;
  45856. protected _setRenderPipeline(param: {
  45857. token: NodeState;
  45858. pipeline: Nullable<GPURenderPipeline>;
  45859. }): void;
  45860. }
  45861. }
  45862. declare module BABYLON {
  45863. /**
  45864. * @hidden
  45865. **/
  45866. export class WebGPUStencilState extends StencilState {
  45867. private _cache;
  45868. constructor(cache: WebGPUCacheRenderPipeline);
  45869. get stencilFunc(): number;
  45870. set stencilFunc(value: number);
  45871. get stencilFuncRef(): number;
  45872. set stencilFuncRef(value: number);
  45873. get stencilFuncMask(): number;
  45874. set stencilFuncMask(value: number);
  45875. get stencilOpStencilFail(): number;
  45876. set stencilOpStencilFail(value: number);
  45877. get stencilOpDepthFail(): number;
  45878. set stencilOpDepthFail(value: number);
  45879. get stencilOpStencilDepthPass(): number;
  45880. set stencilOpStencilDepthPass(value: number);
  45881. get stencilMask(): number;
  45882. set stencilMask(value: number);
  45883. get stencilTest(): boolean;
  45884. set stencilTest(value: boolean);
  45885. reset(): void;
  45886. apply(gl: WebGLRenderingContext): void;
  45887. }
  45888. }
  45889. declare module BABYLON {
  45890. /**
  45891. * @hidden
  45892. **/
  45893. export class WebGPUDepthCullingState extends DepthCullingState {
  45894. private _cache;
  45895. /**
  45896. * Initializes the state.
  45897. */
  45898. constructor(cache: WebGPUCacheRenderPipeline);
  45899. get zOffset(): number;
  45900. set zOffset(value: number);
  45901. get cullFace(): Nullable<number>;
  45902. set cullFace(value: Nullable<number>);
  45903. get cull(): Nullable<boolean>;
  45904. set cull(value: Nullable<boolean>);
  45905. get depthFunc(): Nullable<number>;
  45906. set depthFunc(value: Nullable<number>);
  45907. get depthMask(): boolean;
  45908. set depthMask(value: boolean);
  45909. get depthTest(): boolean;
  45910. set depthTest(value: boolean);
  45911. get frontFace(): Nullable<number>;
  45912. set frontFace(value: Nullable<number>);
  45913. reset(): void;
  45914. apply(gl: WebGLRenderingContext): void;
  45915. }
  45916. }
  45917. declare module BABYLON {
  45918. /** @hidden */
  45919. export var clearQuadVertexShader: {
  45920. name: string;
  45921. shader: string;
  45922. };
  45923. }
  45924. declare module BABYLON {
  45925. /** @hidden */
  45926. export var clearQuadPixelShader: {
  45927. name: string;
  45928. shader: string;
  45929. };
  45930. }
  45931. declare module BABYLON {
  45932. /**
  45933. * Options to load the associated Glslang library
  45934. */
  45935. export interface GlslangOptions {
  45936. /**
  45937. * Defines an existing instance of Glslang (useful in modules who do not access the global instance).
  45938. */
  45939. glslang?: any;
  45940. /**
  45941. * Defines the URL of the glslang JS File.
  45942. */
  45943. jsPath?: string;
  45944. /**
  45945. * Defines the URL of the glslang WASM File.
  45946. */
  45947. wasmPath?: string;
  45948. }
  45949. /**
  45950. * Options to create the WebGPU engine
  45951. */
  45952. export interface WebGPUEngineOptions extends GPURequestAdapterOptions {
  45953. /**
  45954. * If delta time between frames should be constant
  45955. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45956. */
  45957. deterministicLockstep?: boolean;
  45958. /**
  45959. * Maximum about of steps between frames (Default: 4)
  45960. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45961. */
  45962. lockstepMaxSteps?: number;
  45963. /**
  45964. * Defines the seconds between each deterministic lock step
  45965. */
  45966. timeStep?: number;
  45967. /**
  45968. * Defines that engine should ignore modifying touch action attribute and style
  45969. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  45970. */
  45971. doNotHandleTouchAction?: boolean;
  45972. /**
  45973. * Defines if webaudio should be initialized as well
  45974. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  45975. */
  45976. audioEngine?: boolean;
  45977. /**
  45978. * Defines the category of adapter to use.
  45979. * Is it the discrete or integrated device.
  45980. */
  45981. powerPreference?: GPUPowerPreference;
  45982. /**
  45983. * Defines the device descriptor used to create a device.
  45984. */
  45985. deviceDescriptor?: GPUDeviceDescriptor;
  45986. /**
  45987. * Defines the requested Swap Chain Format.
  45988. */
  45989. swapChainFormat?: GPUTextureFormat;
  45990. /**
  45991. * Defines whether MSAA is enabled on the canvas.
  45992. */
  45993. antialiasing?: boolean;
  45994. /**
  45995. * Defines whether the stencil buffer should be enabled.
  45996. */
  45997. stencil?: boolean;
  45998. /**
  45999. * Defines whether we should generate debug markers in the gpu command lists (can be seen with PIX for eg)
  46000. */
  46001. enableGPUDebugMarkers?: boolean;
  46002. /**
  46003. * Options to load the associated Glslang library
  46004. */
  46005. glslangOptions?: GlslangOptions;
  46006. }
  46007. /**
  46008. * The web GPU engine class provides support for WebGPU version of babylon.js.
  46009. */
  46010. export class WebGPUEngine extends Engine {
  46011. private static readonly _glslangDefaultOptions;
  46012. private readonly _uploadEncoderDescriptor;
  46013. private readonly _renderEncoderDescriptor;
  46014. private readonly _renderTargetEncoderDescriptor;
  46015. private readonly _clearDepthValue;
  46016. private readonly _clearReverseDepthValue;
  46017. private readonly _clearStencilValue;
  46018. private readonly _defaultSampleCount;
  46019. private _canvas;
  46020. private _options;
  46021. private _glslang;
  46022. private _adapter;
  46023. private _adapterSupportedExtensions;
  46024. private _device;
  46025. private _deviceEnabledExtensions;
  46026. private _context;
  46027. private _swapChain;
  46028. private _swapChainTexture;
  46029. private _mainPassSampleCount;
  46030. private _textureHelper;
  46031. private _bufferManager;
  46032. private _shaderManager;
  46033. private _cacheSampler;
  46034. private _cacheRenderPipeline;
  46035. private _emptyVertexBuffer;
  46036. private _lastCachedWrapU;
  46037. private _lastCachedWrapV;
  46038. private _lastCachedWrapR;
  46039. private _mrtAttachments;
  46040. private _counters;
  46041. private _mainTexture;
  46042. private _depthTexture;
  46043. private _mainTextureExtends;
  46044. private _depthTextureFormat;
  46045. private _colorFormat;
  46046. private _uploadEncoder;
  46047. private _renderEncoder;
  46048. private _renderTargetEncoder;
  46049. private _commandBuffers;
  46050. private _currentRenderPass;
  46051. private _mainRenderPassWrapper;
  46052. private _rttRenderPassWrapper;
  46053. private _pendingDebugCommands;
  46054. private _currentVertexBuffers;
  46055. private _currentOverrideVertexBuffers;
  46056. private _currentIndexBuffer;
  46057. private __colorWrite;
  46058. private _uniformsBuffers;
  46059. private _forceEnableEffect;
  46060. /** @hidden */
  46061. dbgShowShaderCode: boolean;
  46062. /** @hidden */
  46063. dbgSanityChecks: boolean;
  46064. /** @hidden */
  46065. dbgGenerateLogs: boolean;
  46066. /** @hidden */
  46067. dbgVerboseLogsForFirstFrames: boolean;
  46068. /** @hidden */
  46069. dbgVerboseLogsNumFrames: number;
  46070. /**
  46071. * Sets this to true to disable the cache for the samplers. You should do it only for testing purpose!
  46072. */
  46073. get disableCacheSamplers(): boolean;
  46074. set disableCacheSamplers(disable: boolean);
  46075. /**
  46076. * Sets this to true to disable the cache for the render pipelines. You should do it only for testing purpose!
  46077. */
  46078. get disableCacheRenderPipelines(): boolean;
  46079. set disableCacheRenderPipelines(disable: boolean);
  46080. /**
  46081. * Gets a boolean indicating if the engine can be instantiated (ie. if a WebGPU context can be found)
  46082. * @returns true if the engine can be created
  46083. */
  46084. static get IsSupported(): boolean;
  46085. /**
  46086. * Gets a boolean indicating that the engine supports uniform buffers
  46087. */
  46088. get supportsUniformBuffers(): boolean;
  46089. /** Gets the supported extensions by the WebGPU adapter */
  46090. get supportedExtensions(): Immutable<GPUExtensionName[]>;
  46091. /** Gets the currently enabled extensions on the WebGPU device */
  46092. get enabledExtensions(): Immutable<GPUExtensionName[]>;
  46093. /**
  46094. * Returns the name of the engine
  46095. */
  46096. get name(): string;
  46097. /**
  46098. * Returns a string describing the current engine
  46099. */
  46100. get description(): string;
  46101. /**
  46102. * Returns the version of the engine
  46103. */
  46104. get version(): number;
  46105. /**
  46106. * Create a new instance of the gpu engine asynchronously
  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. * @returns a promise that resolves with the created engine
  46110. */
  46111. static CreateAsync(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions): Promise<WebGPUEngine>;
  46112. /**
  46113. * Create a new instance of the gpu engine.
  46114. * @param canvas Defines the canvas to use to display the result
  46115. * @param options Defines the options passed to the engine to create the GPU context dependencies
  46116. */
  46117. constructor(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions);
  46118. /**
  46119. * Initializes the WebGPU context and dependencies.
  46120. * @param glslangOptions Defines the GLSLang compiler options if necessary
  46121. * @returns a promise notifying the readiness of the engine.
  46122. */
  46123. initAsync(glslangOptions?: GlslangOptions): Promise<void>;
  46124. private _initGlslang;
  46125. private _initializeLimits;
  46126. private _initializeContextAndSwapChain;
  46127. private _initializeMainAttachments;
  46128. /**
  46129. * Force a specific size of the canvas
  46130. * @param width defines the new canvas' width
  46131. * @param height defines the new canvas' height
  46132. * @param forceSetSize true to force setting the sizes of the underlying canvas
  46133. * @returns true if the size was changed
  46134. */
  46135. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  46136. /**
  46137. * Gets a shader processor implementation fitting with the current engine type.
  46138. * @returns The shader processor implementation.
  46139. */
  46140. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  46141. /** @hidden */
  46142. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  46143. /**
  46144. * Force the entire cache to be cleared
  46145. * You should not have to use this function unless your engine needs to share the WebGPU context with another engine
  46146. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46147. */
  46148. wipeCaches(bruteForce?: boolean): void;
  46149. /**
  46150. * Enable or disable color writing
  46151. * @param enable defines the state to set
  46152. */
  46153. setColorWrite(enable: boolean): void;
  46154. /**
  46155. * Gets a boolean indicating if color writing is enabled
  46156. * @returns the current color writing state
  46157. */
  46158. getColorWrite(): boolean;
  46159. private _viewportsCurrent;
  46160. private _resetCurrentViewport;
  46161. private _applyViewport;
  46162. /** @hidden */
  46163. _viewport(x: number, y: number, width: number, height: number): void;
  46164. private _scissorsCurrent;
  46165. protected _scissorCached: {
  46166. x: number;
  46167. y: number;
  46168. z: number;
  46169. w: number;
  46170. };
  46171. private _resetCurrentScissor;
  46172. private _applyScissor;
  46173. private _scissorIsActive;
  46174. enableScissor(x: number, y: number, width: number, height: number): void;
  46175. disableScissor(): void;
  46176. /**
  46177. * Clear the current render buffer or the current render target (if any is set up)
  46178. * @param color defines the color to use
  46179. * @param backBuffer defines if the back buffer must be cleared
  46180. * @param depth defines if the depth buffer must be cleared
  46181. * @param stencil defines if the stencil buffer must be cleared
  46182. */
  46183. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46184. /**
  46185. * Clears a list of attachments
  46186. * @param attachments list of the attachments
  46187. * @param colorMain clear color for the main attachment (the first one)
  46188. * @param colorOthers clear color for the other attachments
  46189. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  46190. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  46191. */
  46192. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  46193. /**
  46194. * Creates a vertex buffer
  46195. * @param data the data for the vertex buffer
  46196. * @returns the new buffer
  46197. */
  46198. createVertexBuffer(data: DataArray): DataBuffer;
  46199. /**
  46200. * Creates a vertex buffer
  46201. * @param data the data for the dynamic vertex buffer
  46202. * @returns the new buffer
  46203. */
  46204. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46205. /**
  46206. * Updates a vertex buffer.
  46207. * @param vertexBuffer the vertex buffer to update
  46208. * @param data the data used to update the vertex buffer
  46209. * @param byteOffset the byte offset of the data
  46210. * @param byteLength the byte length of the data
  46211. */
  46212. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46213. /**
  46214. * Creates a new index buffer
  46215. * @param indices defines the content of the index buffer
  46216. * @param updatable defines if the index buffer must be updatable - not used in WebGPU
  46217. * @returns a new buffer
  46218. */
  46219. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  46220. /**
  46221. * Update an index buffer
  46222. * @param indexBuffer defines the target index buffer
  46223. * @param indices defines the data to update
  46224. * @param offset defines the offset in the target index buffer where update should start
  46225. */
  46226. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46227. /** @hidden */
  46228. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  46229. /** @hidden */
  46230. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  46231. /**
  46232. * Bind a list of vertex buffers with the engine
  46233. * @param vertexBuffers defines the list of vertex buffers to bind
  46234. * @param indexBuffer defines the index buffer to bind
  46235. * @param effect defines the effect associated with the vertex buffers
  46236. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  46237. */
  46238. bindBuffers(vertexBuffers: {
  46239. [key: string]: Nullable<VertexBuffer>;
  46240. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  46241. [kind: string]: Nullable<VertexBuffer>;
  46242. }): void;
  46243. /** @hidden */
  46244. _releaseBuffer(buffer: DataBuffer): boolean;
  46245. createUniformBuffer(elements: FloatArray): DataBuffer;
  46246. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  46247. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  46248. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  46249. /**
  46250. * Create a new effect (used to store vertex/fragment shaders)
  46251. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  46252. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  46253. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  46254. * @param samplers defines an array of string used to represent textures
  46255. * @param defines defines the string containing the defines to use to compile the shaders
  46256. * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails
  46257. * @param onCompiled defines a function to call when the effect creation is successful
  46258. * @param onError defines a function to call when the effect creation has failed
  46259. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  46260. * @returns the new Effect
  46261. */
  46262. 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;
  46263. private _compileRawShaderToSpirV;
  46264. private _compileShaderToSpirV;
  46265. private _createPipelineStageDescriptor;
  46266. private _compileRawPipelineStageDescriptor;
  46267. private _compilePipelineStageDescriptor;
  46268. /** @hidden */
  46269. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  46270. /** @hidden */
  46271. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  46272. /**
  46273. * Creates a new pipeline context
  46274. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  46275. * @returns the new pipeline
  46276. */
  46277. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  46278. /** @hidden */
  46279. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  46280. /**
  46281. * Gets the list of active attributes for a given WebGPU program
  46282. * @param pipelineContext defines the pipeline context to use
  46283. * @param attributesNames defines the list of attribute names to get
  46284. * @returns an array of indices indicating the offset of each attribute
  46285. */
  46286. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46287. /**
  46288. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46289. * @param effect defines the effect to activate
  46290. */
  46291. enableEffect(effect: Nullable<Effect>): void;
  46292. /** @hidden */
  46293. _releaseEffect(effect: Effect): void;
  46294. /**
  46295. * 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
  46296. */
  46297. releaseEffects(): void;
  46298. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46299. /**
  46300. * Gets a boolean indicating that only power of 2 textures are supported
  46301. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  46302. */
  46303. get needPOTTextures(): boolean;
  46304. /** @hidden */
  46305. _createHardwareTexture(): HardwareTextureWrapper;
  46306. /** @hidden */
  46307. _releaseTexture(texture: InternalTexture): void;
  46308. /** @hidden */
  46309. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  46310. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  46311. /**
  46312. * Usually called from Texture.ts.
  46313. * Passed information to create a hardware texture
  46314. * @param url defines a value which contains one of the following:
  46315. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46316. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46317. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46318. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46319. * @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)
  46320. * @param scene needed for loading to the correct scene
  46321. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46322. * @param onLoad optional callback to be called upon successful completion
  46323. * @param onError optional callback to be called upon failure
  46324. * @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
  46325. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46326. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46327. * @param forcedExtension defines the extension to use to pick the right loader
  46328. * @param mimeType defines an optional mime type
  46329. * @param loaderOptions options to be passed to the loader
  46330. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46331. */
  46332. 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;
  46333. /** @hidden */
  46334. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  46335. /**
  46336. * Creates a cube texture
  46337. * @param rootUrl defines the url where the files to load is located
  46338. * @param scene defines the current scene
  46339. * @param files defines the list of files to load (1 per face)
  46340. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46341. * @param onLoad defines an optional callback raised when the texture is loaded
  46342. * @param onError defines an optional callback raised if there is an issue to load the texture
  46343. * @param format defines the format of the data
  46344. * @param forcedExtension defines the extension to use to pick the right loader
  46345. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46346. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46347. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46348. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46349. * @param loaderOptions options to be passed to the loader
  46350. * @returns the cube texture as an InternalTexture
  46351. */
  46352. 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;
  46353. /**
  46354. * Creates a raw texture
  46355. * @param data defines the data to store in the texture
  46356. * @param width defines the width of the texture
  46357. * @param height defines the height of the texture
  46358. * @param format defines the format of the data
  46359. * @param generateMipMaps defines if the engine should generate the mip levels
  46360. * @param invertY defines if data must be stored with Y axis inverted
  46361. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  46362. * @param compression defines the compression used (null by default)
  46363. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  46364. * @returns the raw texture inside an InternalTexture
  46365. */
  46366. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  46367. /**
  46368. * Creates a new raw cube texture
  46369. * @param data defines the array of data to use to create each face
  46370. * @param size defines the size of the textures
  46371. * @param format defines the format of the data
  46372. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  46373. * @param generateMipMaps defines if the engine should generate the mip levels
  46374. * @param invertY defines if data must be stored with Y axis inverted
  46375. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  46376. * @param compression defines the compression used (null by default)
  46377. * @returns the cube texture as an InternalTexture
  46378. */
  46379. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  46380. /**
  46381. * Creates a new raw cube texture from a specified url
  46382. * @param url defines the url where the data is located
  46383. * @param scene defines the current scene
  46384. * @param size defines the size of the textures
  46385. * @param format defines the format of the data
  46386. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  46387. * @param noMipmap defines if the engine should avoid generating the mip levels
  46388. * @param callback defines a callback used to extract texture data from loaded data
  46389. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  46390. * @param onLoad defines a callback called when texture is loaded
  46391. * @param onError defines a callback called if there is an error
  46392. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  46393. * @param invertY defines if data must be stored with Y axis inverted
  46394. * @returns the cube texture as an InternalTexture
  46395. */
  46396. 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;
  46397. /**
  46398. * Creates a new raw 2D array texture
  46399. * @param data defines the data used to create the texture
  46400. * @param width defines the width of the texture
  46401. * @param height defines the height of the texture
  46402. * @param depth defines the number of layers of the texture
  46403. * @param format defines the format of the texture
  46404. * @param generateMipMaps defines if the engine must generate mip levels
  46405. * @param invertY defines if data must be stored with Y axis inverted
  46406. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  46407. * @param compression defines the compressed used (can be null)
  46408. * @param textureType defines the compressed used (can be null)
  46409. * @returns a new raw 2D array texture (stored in an InternalTexture)
  46410. */
  46411. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  46412. /**
  46413. * Creates a new raw 3D texture
  46414. * @param data defines the data used to create the texture
  46415. * @param width defines the width of the texture
  46416. * @param height defines the height of the texture
  46417. * @param depth defines the depth of the texture
  46418. * @param format defines the format of the texture
  46419. * @param generateMipMaps defines if the engine must generate mip levels
  46420. * @param invertY defines if data must be stored with Y axis inverted
  46421. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  46422. * @param compression defines the compressed used (can be null)
  46423. * @param textureType defines the compressed used (can be null)
  46424. * @returns a new raw 3D texture (stored in an InternalTexture)
  46425. */
  46426. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  46427. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  46428. /**
  46429. * Update the sampling mode of a given texture
  46430. * @param samplingMode defines the required sampling mode
  46431. * @param texture defines the texture to update
  46432. * @param generateMipMaps defines whether to generate mipmaps for the texture
  46433. */
  46434. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  46435. /**
  46436. * Update the sampling mode of a given texture
  46437. * @param texture defines the texture to update
  46438. * @param wrapU defines the texture wrap mode of the u coordinates
  46439. * @param wrapV defines the texture wrap mode of the v coordinates
  46440. * @param wrapR defines the texture wrap mode of the r coordinates
  46441. */
  46442. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  46443. /**
  46444. * Update the dimensions of a texture
  46445. * @param texture texture to update
  46446. * @param width new width of the texture
  46447. * @param height new height of the texture
  46448. * @param depth new depth of the texture
  46449. */
  46450. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  46451. private _setInternalTexture;
  46452. /**
  46453. * Sets a texture to the according uniform.
  46454. * @param channel The texture channel
  46455. * @param unused unused parameter
  46456. * @param texture The texture to apply
  46457. * @param name The name of the uniform in the effect
  46458. */
  46459. setTexture(channel: number, unused: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>, name: string): void;
  46460. /**
  46461. * Sets an array of texture to the WebGPU context
  46462. * @param channel defines the channel where the texture array must be set
  46463. * @param unused unused parameter
  46464. * @param textures defines the array of textures to bind
  46465. * @param name name of the channel
  46466. */
  46467. setTextureArray(channel: number, unused: Nullable<WebGLUniformLocation>, textures: BaseTexture[], name: string): void;
  46468. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string, baseName?: string, textureIndex?: number): boolean;
  46469. /** @hidden */
  46470. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  46471. /** @hidden */
  46472. _bindTexture(channel: number, texture: InternalTexture, name: string): void;
  46473. private _generateMipmaps;
  46474. /**
  46475. * Update the content of a texture
  46476. * @param texture defines the texture to update
  46477. * @param canvas defines the source containing the data
  46478. * @param invertY defines if data must be stored with Y axis inverted
  46479. * @param premulAlpha defines if alpha is stored as premultiplied
  46480. * @param format defines the format of the data
  46481. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46482. */
  46483. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  46484. /**
  46485. * Update a portion of an internal texture
  46486. * @param texture defines the texture to update
  46487. * @param imageData defines the data to store into the texture
  46488. * @param xOffset defines the x coordinates of the update rectangle
  46489. * @param yOffset defines the y coordinates of the update rectangle
  46490. * @param width defines the width of the update rectangle
  46491. * @param height defines the height of the update rectangle
  46492. * @param faceIndex defines the face index if texture is a cube (0 by default)
  46493. * @param lod defines the lod level to update (0 by default)
  46494. */
  46495. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  46496. /**
  46497. * Update a video texture
  46498. * @param texture defines the texture to update
  46499. * @param video defines the video element to use
  46500. * @param invertY defines if data must be stored with Y axis inverted
  46501. */
  46502. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  46503. /** @hidden */
  46504. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46505. /** @hidden */
  46506. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  46507. /** @hidden */
  46508. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46509. /** @hidden */
  46510. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  46511. /**
  46512. * Update a raw texture
  46513. * @param texture defines the texture to update
  46514. * @param bufferView defines the data to store in the texture
  46515. * @param format defines the format of the data
  46516. * @param invertY defines if data must be stored with Y axis inverted
  46517. * @param compression defines the compression used (null by default)
  46518. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  46519. */
  46520. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  46521. /**
  46522. * Update a raw cube texture
  46523. * @param texture defines the texture to update
  46524. * @param bufferView defines the data to store
  46525. * @param format defines the data format
  46526. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  46527. * @param invertY defines if data must be stored with Y axis inverted
  46528. * @param compression defines the compression used (null by default)
  46529. * @param level defines which level of the texture to update
  46530. */
  46531. updateRawCubeTexture(texture: InternalTexture, bufferView: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  46532. /**
  46533. * Update a raw 2D array texture
  46534. * @param texture defines the texture to update
  46535. * @param bufferView defines the data to store
  46536. * @param format defines the data format
  46537. * @param invertY defines if data must be stored with Y axis inverted
  46538. * @param compression defines the used compression (can be null)
  46539. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  46540. */
  46541. updateRawTexture2DArray(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  46542. /**
  46543. * Update a raw 3D texture
  46544. * @param texture defines the texture to update
  46545. * @param bufferView defines the data to store
  46546. * @param format defines the data format
  46547. * @param invertY defines if data must be stored with Y axis inverted
  46548. * @param compression defines the used compression (can be null)
  46549. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  46550. */
  46551. updateRawTexture3D(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  46552. /**
  46553. * Reads pixels from the current frame buffer. Please note that this function can be slow
  46554. * @param x defines the x coordinate of the rectangle where pixels must be read
  46555. * @param y defines the y coordinate of the rectangle where pixels must be read
  46556. * @param width defines the width of the rectangle where pixels must be read
  46557. * @param height defines the height of the rectangle where pixels must be read
  46558. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  46559. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  46560. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  46561. */
  46562. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  46563. /** @hidden */
  46564. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  46565. /** @hidden */
  46566. _readTexturePixelsSync(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): ArrayBufferView;
  46567. /**
  46568. * Creates a new render target texture
  46569. * @param size defines the size of the texture
  46570. * @param options defines the options used to create the texture
  46571. * @returns a new render target texture stored in an InternalTexture
  46572. */
  46573. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46574. /**
  46575. * Create a multi render target texture
  46576. * @param size defines the size of the texture
  46577. * @param options defines the creation options
  46578. * @returns the cube texture as an InternalTexture
  46579. */
  46580. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46581. /**
  46582. * Creates a new render target cube texture
  46583. * @param size defines the size of the texture
  46584. * @param options defines the options used to create the texture
  46585. * @returns a new render target cube texture stored in an InternalTexture
  46586. */
  46587. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  46588. /** @hidden */
  46589. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  46590. width: number;
  46591. height: number;
  46592. layers?: number;
  46593. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  46594. /** @hidden */
  46595. _createDepthStencilTexture(size: number | {
  46596. width: number;
  46597. height: number;
  46598. layers?: number;
  46599. }, options: DepthTextureCreationOptions): InternalTexture;
  46600. /** @hidden */
  46601. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  46602. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  46603. /**
  46604. * Update the sample count for a given multiple render target texture
  46605. * @param textures defines the textures to update
  46606. * @param samples defines the sample count to set
  46607. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46608. */
  46609. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46610. /**
  46611. * Begin a new frame
  46612. */
  46613. beginFrame(): void;
  46614. /**
  46615. * End the current frame
  46616. */
  46617. endFrame(): void;
  46618. /**
  46619. * Force a WebGPU flush (ie. a flush of all waiting commands)
  46620. */
  46621. flushFramebuffer(): void;
  46622. private _startRenderTargetRenderPass;
  46623. private _endRenderTargetRenderPass;
  46624. private _getCurrentRenderPass;
  46625. private _startMainRenderPass;
  46626. private _endMainRenderPass;
  46627. /**
  46628. * Restores the WebGPU state to only draw on the main color attachment
  46629. */
  46630. restoreSingleAttachment(): void;
  46631. /**
  46632. * Creates a layout object to draw/clear on specific textures in a MRT
  46633. * @param textureStatus textureStatus[i] indicates if the i-th is active
  46634. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  46635. */
  46636. buildTextureLayout(textureStatus: boolean[]): number[];
  46637. /**
  46638. * Select a subsets of attachments to draw to.
  46639. * @param attachments index of attachments
  46640. */
  46641. bindAttachments(attachments: number[]): void;
  46642. /**
  46643. * Binds the frame buffer to the specified texture.
  46644. * @param texture The texture to render to or null for the default canvas
  46645. * @param faceIndex The face of the texture to render to in case of cube texture
  46646. * @param requiredWidth The width of the target to render to
  46647. * @param requiredHeight The height of the target to render to
  46648. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46649. * @param lodLevel defines the lod level to bind to the frame buffer
  46650. * @param layer defines the 2d array index to bind to frame buffer to
  46651. */
  46652. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  46653. /**
  46654. * Unbind the current render target texture from the WebGPU context
  46655. * @param texture defines the render target texture 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. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46660. /**
  46661. * Unbind a list of render target textures from the WebGPU context
  46662. * @param textures defines the render target textures to unbind
  46663. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46664. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46665. */
  46666. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46667. /**
  46668. * Unbind the current render target and bind the default framebuffer
  46669. */
  46670. restoreDefaultFramebuffer(): void;
  46671. private _setColorFormat;
  46672. private _setDepthTextureFormat;
  46673. setDitheringState(value: boolean): void;
  46674. setRasterizerState(value: boolean): void;
  46675. /**
  46676. * Set various states to the context
  46677. * @param culling defines backface culling state
  46678. * @param zOffset defines the value to apply to zOffset (0 by default)
  46679. * @param force defines if states must be applied even if cache is up to date
  46680. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46681. */
  46682. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46683. /**
  46684. * Sets the current alpha mode
  46685. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46686. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46687. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46688. */
  46689. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46690. /**
  46691. * Sets the current alpha equation
  46692. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  46693. */
  46694. setAlphaEquation(equation: number): void;
  46695. private _getBindGroupsToRender;
  46696. private _bindVertexInputs;
  46697. private _setRenderBindGroups;
  46698. private _setRenderPipeline;
  46699. /**
  46700. * Draw a list of indexed primitives
  46701. * @param fillMode defines the primitive to use
  46702. * @param indexStart defines the starting index
  46703. * @param indexCount defines the number of index to draw
  46704. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  46705. */
  46706. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46707. /**
  46708. * Draw a list of unindexed primitives
  46709. * @param fillMode defines the primitive to use
  46710. * @param verticesStart defines the index of first vertex to draw
  46711. * @param verticesCount defines the count of vertices to draw
  46712. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  46713. */
  46714. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46715. private _bundleEncoder;
  46716. /**
  46717. * Start recording all the gpu calls into a bundle.
  46718. */
  46719. startRecordBundle(): void;
  46720. /**
  46721. * Stops recording the bundle.
  46722. * @returns the recorded bundle
  46723. */
  46724. stopRecordBundle(): GPURenderBundle;
  46725. /**
  46726. * Execute the previously recorded bundle.
  46727. * @param bundles defines the bundle to replay
  46728. */
  46729. executeBundles(bundles: GPURenderBundle[]): void;
  46730. /**
  46731. * Dispose and release all associated resources
  46732. */
  46733. dispose(): void;
  46734. /**
  46735. * Gets the current render width
  46736. * @param useScreen defines if screen size must be used (or the current render target if any)
  46737. * @returns a number defining the current render width
  46738. */
  46739. getRenderWidth(useScreen?: boolean): number;
  46740. /**
  46741. * Gets the current render height
  46742. * @param useScreen defines if screen size must be used (or the current render target if any)
  46743. * @returns a number defining the current render height
  46744. */
  46745. getRenderHeight(useScreen?: boolean): number;
  46746. /**
  46747. * Gets the HTML canvas attached with the current WebGPU context
  46748. * @returns a HTML canvas
  46749. */
  46750. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  46751. /** @hidden */
  46752. _debugPushGroup(groupName: string, targetObject?: number): void;
  46753. /** @hidden */
  46754. _debugPopGroup(targetObject?: number): void;
  46755. /** @hidden */
  46756. _debugInsertMarker(text: string, targetObject?: number): void;
  46757. private _debugFlushPendingCommands;
  46758. /**
  46759. * Get the current error code of the WebGPU context
  46760. * @returns the error code
  46761. */
  46762. getError(): number;
  46763. /** @hidden */
  46764. bindSamplers(effect: Effect): void;
  46765. /** @hidden */
  46766. _bindTextureDirectly(target: number, texture: InternalTexture, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  46767. /** @hidden */
  46768. _releaseFramebufferObjects(texture: InternalTexture): void;
  46769. /** @hidden */
  46770. applyStates(): void;
  46771. /**
  46772. * Gets a boolean indicating if all created effects are ready
  46773. * @returns always true - No parallel shader compilation
  46774. */
  46775. areAllEffectsReady(): boolean;
  46776. /** @hidden */
  46777. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46778. /** @hidden */
  46779. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46780. /** @hidden */
  46781. _getUnpackAlignement(): number;
  46782. /** @hidden */
  46783. _unpackFlipY(value: boolean): void;
  46784. /** @hidden */
  46785. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  46786. min: number;
  46787. mag: number;
  46788. };
  46789. /** @hidden */
  46790. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46791. /** @hidden */
  46792. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46793. /** @hidden */
  46794. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  46795. /** @hidden */
  46796. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  46797. /** @hidden */
  46798. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  46799. /** @hidden */
  46800. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  46801. /** @hidden */
  46802. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  46803. /** @hidden */
  46804. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  46805. /** @hidden */
  46806. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  46807. /** @hidden */
  46808. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  46809. /** @hidden */
  46810. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  46811. /** @hidden */
  46812. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  46813. /** @hidden */
  46814. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  46815. /** @hidden */
  46816. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  46817. /** @hidden */
  46818. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  46819. /** @hidden */
  46820. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  46821. /** @hidden */
  46822. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  46823. }
  46824. }
  46825. declare module BABYLON {
  46826. /**
  46827. * Define an interface for all classes that will hold resources
  46828. */
  46829. export interface IDisposable {
  46830. /**
  46831. * Releases all held resources
  46832. */
  46833. dispose(): void;
  46834. }
  46835. /** Interface defining initialization parameters for Scene class */
  46836. export interface SceneOptions {
  46837. /**
  46838. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  46839. * It will improve performance when the number of geometries becomes important.
  46840. */
  46841. useGeometryUniqueIdsMap?: boolean;
  46842. /**
  46843. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  46844. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  46845. */
  46846. useMaterialMeshMap?: boolean;
  46847. /**
  46848. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  46849. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  46850. */
  46851. useClonedMeshMap?: boolean;
  46852. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  46853. virtual?: boolean;
  46854. }
  46855. /**
  46856. * Represents a scene to be rendered by the engine.
  46857. * @see https://doc.babylonjs.com/features/scene
  46858. */
  46859. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  46860. /** The fog is deactivated */
  46861. static readonly FOGMODE_NONE: number;
  46862. /** The fog density is following an exponential function */
  46863. static readonly FOGMODE_EXP: number;
  46864. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  46865. static readonly FOGMODE_EXP2: number;
  46866. /** The fog density is following a linear function. */
  46867. static readonly FOGMODE_LINEAR: number;
  46868. /**
  46869. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  46870. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46871. */
  46872. static MinDeltaTime: number;
  46873. /**
  46874. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  46875. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46876. */
  46877. static MaxDeltaTime: number;
  46878. /**
  46879. * Factory used to create the default material.
  46880. * @param name The name of the material to create
  46881. * @param scene The scene to create the material for
  46882. * @returns The default material
  46883. */
  46884. static DefaultMaterialFactory(scene: Scene): Material;
  46885. /**
  46886. * Factory used to create the a collision coordinator.
  46887. * @returns The collision coordinator
  46888. */
  46889. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  46890. /** @hidden */
  46891. _inputManager: InputManager;
  46892. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  46893. cameraToUseForPointers: Nullable<Camera>;
  46894. /** @hidden */
  46895. readonly _isScene: boolean;
  46896. /** @hidden */
  46897. _blockEntityCollection: boolean;
  46898. /**
  46899. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  46900. */
  46901. autoClear: boolean;
  46902. /**
  46903. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  46904. */
  46905. autoClearDepthAndStencil: boolean;
  46906. /**
  46907. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  46908. */
  46909. clearColor: Color4;
  46910. /**
  46911. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  46912. */
  46913. ambientColor: Color3;
  46914. /**
  46915. * This is use to store the default BRDF lookup for PBR materials in your scene.
  46916. * It should only be one of the following (if not the default embedded one):
  46917. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46918. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  46919. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46920. * The material properties need to be setup according to the type of texture in use.
  46921. */
  46922. environmentBRDFTexture: BaseTexture;
  46923. /**
  46924. * Texture used in all pbr material as the reflection texture.
  46925. * As in the majority of the scene they are the same (exception for multi room and so on),
  46926. * this is easier to reference from here than from all the materials.
  46927. */
  46928. get environmentTexture(): Nullable<BaseTexture>;
  46929. /**
  46930. * Texture used in all pbr material as the reflection texture.
  46931. * As in the majority of the scene they are the same (exception for multi room and so on),
  46932. * this is easier to set here than in all the materials.
  46933. */
  46934. set environmentTexture(value: Nullable<BaseTexture>);
  46935. /** @hidden */
  46936. protected _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 reference from here than from all the materials.
  46942. */
  46943. get environmentIntensity(): number;
  46944. /**
  46945. * Intensity of the environment in all pbr material.
  46946. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  46947. * As in the majority of the scene they are the same (exception for multi room and so on),
  46948. * this is easier to set here than in all the materials.
  46949. */
  46950. set environmentIntensity(value: number);
  46951. /** @hidden */
  46952. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46953. /**
  46954. * Default image processing configuration used either in the rendering
  46955. * Forward main pass or through the imageProcessingPostProcess if present.
  46956. * As in the majority of the scene they are the same (exception for multi camera),
  46957. * this is easier to reference from here than from all the materials and post process.
  46958. *
  46959. * No setter as we it is a shared configuration, you can set the values instead.
  46960. */
  46961. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  46962. private _forceWireframe;
  46963. /**
  46964. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  46965. */
  46966. set forceWireframe(value: boolean);
  46967. get forceWireframe(): boolean;
  46968. private _skipFrustumClipping;
  46969. /**
  46970. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  46971. */
  46972. set skipFrustumClipping(value: boolean);
  46973. get skipFrustumClipping(): boolean;
  46974. private _forcePointsCloud;
  46975. /**
  46976. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  46977. */
  46978. set forcePointsCloud(value: boolean);
  46979. get forcePointsCloud(): boolean;
  46980. /**
  46981. * Gets or sets the active clipplane 1
  46982. */
  46983. clipPlane: Nullable<Plane>;
  46984. /**
  46985. * Gets or sets the active clipplane 2
  46986. */
  46987. clipPlane2: Nullable<Plane>;
  46988. /**
  46989. * Gets or sets the active clipplane 3
  46990. */
  46991. clipPlane3: Nullable<Plane>;
  46992. /**
  46993. * Gets or sets the active clipplane 4
  46994. */
  46995. clipPlane4: Nullable<Plane>;
  46996. /**
  46997. * Gets or sets the active clipplane 5
  46998. */
  46999. clipPlane5: Nullable<Plane>;
  47000. /**
  47001. * Gets or sets the active clipplane 6
  47002. */
  47003. clipPlane6: Nullable<Plane>;
  47004. /**
  47005. * Gets or sets a boolean indicating if animations are enabled
  47006. */
  47007. animationsEnabled: boolean;
  47008. private _animationPropertiesOverride;
  47009. /**
  47010. * Gets or sets the animation properties override
  47011. */
  47012. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  47013. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  47014. /**
  47015. * Gets or sets a boolean indicating if a constant deltatime has to be used
  47016. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  47017. */
  47018. useConstantAnimationDeltaTime: boolean;
  47019. /**
  47020. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  47021. * Please note that it requires to run a ray cast through the scene on every frame
  47022. */
  47023. constantlyUpdateMeshUnderPointer: boolean;
  47024. /**
  47025. * Defines the HTML cursor to use when hovering over interactive elements
  47026. */
  47027. hoverCursor: string;
  47028. /**
  47029. * Defines the HTML default cursor to use (empty by default)
  47030. */
  47031. defaultCursor: string;
  47032. /**
  47033. * Defines whether cursors are handled by the scene.
  47034. */
  47035. doNotHandleCursors: boolean;
  47036. /**
  47037. * This is used to call preventDefault() on pointer down
  47038. * in order to block unwanted artifacts like system double clicks
  47039. */
  47040. preventDefaultOnPointerDown: boolean;
  47041. /**
  47042. * This is used to call preventDefault() on pointer up
  47043. * in order to block unwanted artifacts like system double clicks
  47044. */
  47045. preventDefaultOnPointerUp: boolean;
  47046. /**
  47047. * Gets or sets user defined metadata
  47048. */
  47049. metadata: any;
  47050. /**
  47051. * For internal use only. Please do not use.
  47052. */
  47053. reservedDataStore: any;
  47054. /**
  47055. * Gets the name of the plugin used to load this scene (null by default)
  47056. */
  47057. loadingPluginName: string;
  47058. /**
  47059. * Use this array to add regular expressions used to disable offline support for specific urls
  47060. */
  47061. disableOfflineSupportExceptionRules: RegExp[];
  47062. /**
  47063. * An event triggered when the scene is disposed.
  47064. */
  47065. onDisposeObservable: Observable<Scene>;
  47066. private _onDisposeObserver;
  47067. /** Sets a function to be executed when this scene is disposed. */
  47068. set onDispose(callback: () => void);
  47069. /**
  47070. * An event triggered before rendering the scene (right after animations and physics)
  47071. */
  47072. onBeforeRenderObservable: Observable<Scene>;
  47073. private _onBeforeRenderObserver;
  47074. /** Sets a function to be executed before rendering this scene */
  47075. set beforeRender(callback: Nullable<() => void>);
  47076. /**
  47077. * An event triggered after rendering the scene
  47078. */
  47079. onAfterRenderObservable: Observable<Scene>;
  47080. /**
  47081. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  47082. */
  47083. onAfterRenderCameraObservable: Observable<Camera>;
  47084. private _onAfterRenderObserver;
  47085. /** Sets a function to be executed after rendering this scene */
  47086. set afterRender(callback: Nullable<() => void>);
  47087. /**
  47088. * An event triggered before animating the scene
  47089. */
  47090. onBeforeAnimationsObservable: Observable<Scene>;
  47091. /**
  47092. * An event triggered after animations processing
  47093. */
  47094. onAfterAnimationsObservable: Observable<Scene>;
  47095. /**
  47096. * An event triggered before draw calls are ready to be sent
  47097. */
  47098. onBeforeDrawPhaseObservable: Observable<Scene>;
  47099. /**
  47100. * An event triggered after draw calls have been sent
  47101. */
  47102. onAfterDrawPhaseObservable: Observable<Scene>;
  47103. /**
  47104. * An event triggered when the scene is ready
  47105. */
  47106. onReadyObservable: Observable<Scene>;
  47107. /**
  47108. * An event triggered before rendering a camera
  47109. */
  47110. onBeforeCameraRenderObservable: Observable<Camera>;
  47111. private _onBeforeCameraRenderObserver;
  47112. /** Sets a function to be executed before rendering a camera*/
  47113. set beforeCameraRender(callback: () => void);
  47114. /**
  47115. * An event triggered after rendering a camera
  47116. */
  47117. onAfterCameraRenderObservable: Observable<Camera>;
  47118. private _onAfterCameraRenderObserver;
  47119. /** Sets a function to be executed after rendering a camera*/
  47120. set afterCameraRender(callback: () => void);
  47121. /**
  47122. * An event triggered when active meshes evaluation is about to start
  47123. */
  47124. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  47125. /**
  47126. * An event triggered when active meshes evaluation is done
  47127. */
  47128. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  47129. /**
  47130. * An event triggered when particles rendering is about to start
  47131. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  47132. */
  47133. onBeforeParticlesRenderingObservable: Observable<Scene>;
  47134. /**
  47135. * An event triggered when particles rendering is done
  47136. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  47137. */
  47138. onAfterParticlesRenderingObservable: Observable<Scene>;
  47139. /**
  47140. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  47141. */
  47142. onDataLoadedObservable: Observable<Scene>;
  47143. /**
  47144. * An event triggered when a camera is created
  47145. */
  47146. onNewCameraAddedObservable: Observable<Camera>;
  47147. /**
  47148. * An event triggered when a camera is removed
  47149. */
  47150. onCameraRemovedObservable: Observable<Camera>;
  47151. /**
  47152. * An event triggered when a light is created
  47153. */
  47154. onNewLightAddedObservable: Observable<Light>;
  47155. /**
  47156. * An event triggered when a light is removed
  47157. */
  47158. onLightRemovedObservable: Observable<Light>;
  47159. /**
  47160. * An event triggered when a geometry is created
  47161. */
  47162. onNewGeometryAddedObservable: Observable<Geometry>;
  47163. /**
  47164. * An event triggered when a geometry is removed
  47165. */
  47166. onGeometryRemovedObservable: Observable<Geometry>;
  47167. /**
  47168. * An event triggered when a transform node is created
  47169. */
  47170. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  47171. /**
  47172. * An event triggered when a transform node is removed
  47173. */
  47174. onTransformNodeRemovedObservable: Observable<TransformNode>;
  47175. /**
  47176. * An event triggered when a mesh is created
  47177. */
  47178. onNewMeshAddedObservable: Observable<AbstractMesh>;
  47179. /**
  47180. * An event triggered when a mesh is removed
  47181. */
  47182. onMeshRemovedObservable: Observable<AbstractMesh>;
  47183. /**
  47184. * An event triggered when a skeleton is created
  47185. */
  47186. onNewSkeletonAddedObservable: Observable<Skeleton>;
  47187. /**
  47188. * An event triggered when a skeleton is removed
  47189. */
  47190. onSkeletonRemovedObservable: Observable<Skeleton>;
  47191. /**
  47192. * An event triggered when a material is created
  47193. */
  47194. onNewMaterialAddedObservable: Observable<Material>;
  47195. /**
  47196. * An event triggered when a multi material is created
  47197. */
  47198. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  47199. /**
  47200. * An event triggered when a material is removed
  47201. */
  47202. onMaterialRemovedObservable: Observable<Material>;
  47203. /**
  47204. * An event triggered when a multi material is removed
  47205. */
  47206. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  47207. /**
  47208. * An event triggered when a texture is created
  47209. */
  47210. onNewTextureAddedObservable: Observable<BaseTexture>;
  47211. /**
  47212. * An event triggered when a texture is removed
  47213. */
  47214. onTextureRemovedObservable: Observable<BaseTexture>;
  47215. /**
  47216. * An event triggered when render targets are about to be rendered
  47217. * Can happen multiple times per frame.
  47218. */
  47219. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  47220. /**
  47221. * An event triggered when render targets were rendered.
  47222. * Can happen multiple times per frame.
  47223. */
  47224. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  47225. /**
  47226. * An event triggered before calculating deterministic simulation step
  47227. */
  47228. onBeforeStepObservable: Observable<Scene>;
  47229. /**
  47230. * An event triggered after calculating deterministic simulation step
  47231. */
  47232. onAfterStepObservable: Observable<Scene>;
  47233. /**
  47234. * An event triggered when the activeCamera property is updated
  47235. */
  47236. onActiveCameraChanged: Observable<Scene>;
  47237. /**
  47238. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  47239. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  47240. * 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)
  47241. */
  47242. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  47243. /**
  47244. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  47245. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  47246. * 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)
  47247. */
  47248. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  47249. /**
  47250. * This Observable will when a mesh has been imported into the scene.
  47251. */
  47252. onMeshImportedObservable: Observable<AbstractMesh>;
  47253. /**
  47254. * This Observable will when an animation file has been imported into the scene.
  47255. */
  47256. onAnimationFileImportedObservable: Observable<Scene>;
  47257. /**
  47258. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  47259. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  47260. */
  47261. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  47262. /** @hidden */
  47263. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  47264. /**
  47265. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  47266. */
  47267. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  47268. /**
  47269. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  47270. */
  47271. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  47272. /**
  47273. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  47274. */
  47275. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  47276. /** Callback called when a pointer move is detected */
  47277. onPointerMove: (evt: IPointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  47278. /** Callback called when a pointer down is detected */
  47279. onPointerDown: (evt: IPointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  47280. /** Callback called when a pointer up is detected */
  47281. onPointerUp: (evt: IPointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  47282. /** Callback called when a pointer pick is detected */
  47283. onPointerPick: (evt: IPointerEvent, pickInfo: PickingInfo) => void;
  47284. /**
  47285. * 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).
  47286. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  47287. */
  47288. onPrePointerObservable: Observable<PointerInfoPre>;
  47289. /**
  47290. * Observable event triggered each time an input event is received from the rendering canvas
  47291. */
  47292. onPointerObservable: Observable<PointerInfo>;
  47293. /**
  47294. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  47295. */
  47296. get unTranslatedPointer(): Vector2;
  47297. /**
  47298. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  47299. */
  47300. static get DragMovementThreshold(): number;
  47301. static set DragMovementThreshold(value: number);
  47302. /**
  47303. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  47304. */
  47305. static get LongPressDelay(): number;
  47306. static set LongPressDelay(value: number);
  47307. /**
  47308. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  47309. */
  47310. static get DoubleClickDelay(): number;
  47311. static set DoubleClickDelay(value: number);
  47312. /** If you need to check double click without raising a single click at first click, enable this flag */
  47313. static get ExclusiveDoubleClickMode(): boolean;
  47314. static set ExclusiveDoubleClickMode(value: boolean);
  47315. /** @hidden */
  47316. _mirroredCameraPosition: Nullable<Vector3>;
  47317. /**
  47318. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  47319. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  47320. */
  47321. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  47322. /**
  47323. * Observable event triggered each time an keyboard event is received from the hosting window
  47324. */
  47325. onKeyboardObservable: Observable<KeyboardInfo>;
  47326. private _useRightHandedSystem;
  47327. /**
  47328. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  47329. */
  47330. set useRightHandedSystem(value: boolean);
  47331. get useRightHandedSystem(): boolean;
  47332. private _timeAccumulator;
  47333. private _currentStepId;
  47334. private _currentInternalStep;
  47335. /**
  47336. * Sets the step Id used by deterministic lock step
  47337. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47338. * @param newStepId defines the step Id
  47339. */
  47340. setStepId(newStepId: number): void;
  47341. /**
  47342. * Gets the step Id used by deterministic lock step
  47343. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47344. * @returns the step Id
  47345. */
  47346. getStepId(): number;
  47347. /**
  47348. * Gets the internal step used by deterministic lock step
  47349. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47350. * @returns the internal step
  47351. */
  47352. getInternalStep(): number;
  47353. private _fogEnabled;
  47354. /**
  47355. * Gets or sets a boolean indicating if fog is enabled on this scene
  47356. * @see https://doc.babylonjs.com/babylon101/environment#fog
  47357. * (Default is true)
  47358. */
  47359. set fogEnabled(value: boolean);
  47360. get fogEnabled(): boolean;
  47361. private _fogMode;
  47362. /**
  47363. * Gets or sets the fog mode to use
  47364. * @see https://doc.babylonjs.com/babylon101/environment#fog
  47365. * | mode | value |
  47366. * | --- | --- |
  47367. * | FOGMODE_NONE | 0 |
  47368. * | FOGMODE_EXP | 1 |
  47369. * | FOGMODE_EXP2 | 2 |
  47370. * | FOGMODE_LINEAR | 3 |
  47371. */
  47372. set fogMode(value: number);
  47373. get fogMode(): number;
  47374. /**
  47375. * Gets or sets the fog color to use
  47376. * @see https://doc.babylonjs.com/babylon101/environment#fog
  47377. * (Default is Color3(0.2, 0.2, 0.3))
  47378. */
  47379. fogColor: Color3;
  47380. /**
  47381. * Gets or sets the fog density to use
  47382. * @see https://doc.babylonjs.com/babylon101/environment#fog
  47383. * (Default is 0.1)
  47384. */
  47385. fogDensity: number;
  47386. /**
  47387. * Gets or sets the fog start distance to use
  47388. * @see https://doc.babylonjs.com/babylon101/environment#fog
  47389. * (Default is 0)
  47390. */
  47391. fogStart: number;
  47392. /**
  47393. * Gets or sets the fog end distance to use
  47394. * @see https://doc.babylonjs.com/babylon101/environment#fog
  47395. * (Default is 1000)
  47396. */
  47397. fogEnd: number;
  47398. /**
  47399. * Flag indicating that the frame buffer binding is handled by another component
  47400. */
  47401. get prePass(): boolean;
  47402. private _shadowsEnabled;
  47403. /**
  47404. * Gets or sets a boolean indicating if shadows are enabled on this scene
  47405. */
  47406. set shadowsEnabled(value: boolean);
  47407. get shadowsEnabled(): boolean;
  47408. private _lightsEnabled;
  47409. /**
  47410. * Gets or sets a boolean indicating if lights are enabled on this scene
  47411. */
  47412. set lightsEnabled(value: boolean);
  47413. get lightsEnabled(): boolean;
  47414. /** All of the active cameras added to this scene. */
  47415. activeCameras: Nullable<Camera[]>;
  47416. /** @hidden */
  47417. _activeCamera: Nullable<Camera>;
  47418. /** Gets or sets the current active camera */
  47419. get activeCamera(): Nullable<Camera>;
  47420. set activeCamera(value: Nullable<Camera>);
  47421. private _defaultMaterial;
  47422. /** The default material used on meshes when no material is affected */
  47423. get defaultMaterial(): Material;
  47424. /** The default material used on meshes when no material is affected */
  47425. set defaultMaterial(value: Material);
  47426. private _texturesEnabled;
  47427. /**
  47428. * Gets or sets a boolean indicating if textures are enabled on this scene
  47429. */
  47430. set texturesEnabled(value: boolean);
  47431. get texturesEnabled(): boolean;
  47432. /**
  47433. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  47434. */
  47435. physicsEnabled: boolean;
  47436. /**
  47437. * Gets or sets a boolean indicating if particles are enabled on this scene
  47438. */
  47439. particlesEnabled: boolean;
  47440. /**
  47441. * Gets or sets a boolean indicating if sprites are enabled on this scene
  47442. */
  47443. spritesEnabled: boolean;
  47444. private _skeletonsEnabled;
  47445. /**
  47446. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  47447. */
  47448. set skeletonsEnabled(value: boolean);
  47449. get skeletonsEnabled(): boolean;
  47450. /**
  47451. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  47452. */
  47453. lensFlaresEnabled: boolean;
  47454. /**
  47455. * Gets or sets a boolean indicating if collisions are enabled on this scene
  47456. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  47457. */
  47458. collisionsEnabled: boolean;
  47459. private _collisionCoordinator;
  47460. /** @hidden */
  47461. get collisionCoordinator(): ICollisionCoordinator;
  47462. /**
  47463. * Defines the gravity applied to this scene (used only for collisions)
  47464. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  47465. */
  47466. gravity: Vector3;
  47467. /**
  47468. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  47469. */
  47470. postProcessesEnabled: boolean;
  47471. /**
  47472. * Gets the current postprocess manager
  47473. */
  47474. postProcessManager: PostProcessManager;
  47475. /**
  47476. * Gets or sets a boolean indicating if render targets are enabled on this scene
  47477. */
  47478. renderTargetsEnabled: boolean;
  47479. /**
  47480. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  47481. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  47482. */
  47483. dumpNextRenderTargets: boolean;
  47484. /**
  47485. * The list of user defined render targets added to the scene
  47486. */
  47487. customRenderTargets: RenderTargetTexture[];
  47488. /**
  47489. * Defines if texture loading must be delayed
  47490. * If true, textures will only be loaded when they need to be rendered
  47491. */
  47492. useDelayedTextureLoading: boolean;
  47493. /**
  47494. * Gets the list of meshes imported to the scene through SceneLoader
  47495. */
  47496. importedMeshesFiles: String[];
  47497. /**
  47498. * Gets or sets a boolean indicating if probes are enabled on this scene
  47499. */
  47500. probesEnabled: boolean;
  47501. /**
  47502. * Gets or sets the current offline provider to use to store scene data
  47503. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  47504. */
  47505. offlineProvider: IOfflineProvider;
  47506. /**
  47507. * Gets or sets the action manager associated with the scene
  47508. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  47509. */
  47510. actionManager: AbstractActionManager;
  47511. private _meshesForIntersections;
  47512. /**
  47513. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  47514. */
  47515. proceduralTexturesEnabled: boolean;
  47516. private _engine;
  47517. private _totalVertices;
  47518. /** @hidden */
  47519. _activeIndices: PerfCounter;
  47520. /** @hidden */
  47521. _activeParticles: PerfCounter;
  47522. /** @hidden */
  47523. _activeBones: PerfCounter;
  47524. private _animationRatio;
  47525. /** @hidden */
  47526. _animationTimeLast: number;
  47527. /** @hidden */
  47528. _animationTime: number;
  47529. /**
  47530. * Gets or sets a general scale for animation speed
  47531. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  47532. */
  47533. animationTimeScale: number;
  47534. /** @hidden */
  47535. _cachedMaterial: Nullable<Material>;
  47536. /** @hidden */
  47537. _cachedEffect: Nullable<Effect>;
  47538. /** @hidden */
  47539. _cachedVisibility: Nullable<number>;
  47540. private _renderId;
  47541. private _frameId;
  47542. private _executeWhenReadyTimeoutId;
  47543. private _intermediateRendering;
  47544. private _viewUpdateFlag;
  47545. private _projectionUpdateFlag;
  47546. /** @hidden */
  47547. _toBeDisposed: Nullable<IDisposable>[];
  47548. private _activeRequests;
  47549. /** @hidden */
  47550. _pendingData: any[];
  47551. private _isDisposed;
  47552. /**
  47553. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  47554. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  47555. */
  47556. dispatchAllSubMeshesOfActiveMeshes: boolean;
  47557. private _activeMeshes;
  47558. private _processedMaterials;
  47559. private _renderTargets;
  47560. /** @hidden */
  47561. _activeParticleSystems: SmartArray<IParticleSystem>;
  47562. private _activeSkeletons;
  47563. private _softwareSkinnedMeshes;
  47564. private _renderingManager;
  47565. /** @hidden */
  47566. _activeAnimatables: Animatable[];
  47567. private _transformMatrix;
  47568. private _sceneUbo;
  47569. /** @hidden */
  47570. _viewMatrix: Matrix;
  47571. /** @hidden */
  47572. _projectionMatrix: Matrix;
  47573. /** @hidden */
  47574. _forcedViewPosition: Nullable<Vector3>;
  47575. /** @hidden */
  47576. _frustumPlanes: Plane[];
  47577. /**
  47578. * Gets the list of frustum planes (built from the active camera)
  47579. */
  47580. get frustumPlanes(): Plane[];
  47581. /**
  47582. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  47583. * This is useful if there are more lights that the maximum simulteanous authorized
  47584. */
  47585. requireLightSorting: boolean;
  47586. /** @hidden */
  47587. readonly useMaterialMeshMap: boolean;
  47588. /** @hidden */
  47589. readonly useClonedMeshMap: boolean;
  47590. private _externalData;
  47591. private _uid;
  47592. /**
  47593. * @hidden
  47594. * Backing store of defined scene components.
  47595. */
  47596. _components: ISceneComponent[];
  47597. /**
  47598. * @hidden
  47599. * Backing store of defined scene components.
  47600. */
  47601. _serializableComponents: ISceneSerializableComponent[];
  47602. /**
  47603. * List of components to register on the next registration step.
  47604. */
  47605. private _transientComponents;
  47606. /**
  47607. * Registers the transient components if needed.
  47608. */
  47609. private _registerTransientComponents;
  47610. /**
  47611. * @hidden
  47612. * Add a component to the scene.
  47613. * Note that the ccomponent could be registered on th next frame if this is called after
  47614. * the register component stage.
  47615. * @param component Defines the component to add to the scene
  47616. */
  47617. _addComponent(component: ISceneComponent): void;
  47618. /**
  47619. * @hidden
  47620. * Gets a component from the scene.
  47621. * @param name defines the name of the component to retrieve
  47622. * @returns the component or null if not present
  47623. */
  47624. _getComponent(name: string): Nullable<ISceneComponent>;
  47625. /**
  47626. * @hidden
  47627. * Defines the actions happening before camera updates.
  47628. */
  47629. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  47630. /**
  47631. * @hidden
  47632. * Defines the actions happening before clear the canvas.
  47633. */
  47634. _beforeClearStage: Stage<SimpleStageAction>;
  47635. /**
  47636. * @hidden
  47637. * Defines the actions happening before clear the canvas.
  47638. */
  47639. _beforeRenderTargetClearStage: Stage<RenderTargetStageAction>;
  47640. /**
  47641. * @hidden
  47642. * Defines the actions when collecting render targets for the frame.
  47643. */
  47644. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  47645. /**
  47646. * @hidden
  47647. * Defines the actions happening for one camera in the frame.
  47648. */
  47649. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  47650. /**
  47651. * @hidden
  47652. * Defines the actions happening during the per mesh ready checks.
  47653. */
  47654. _isReadyForMeshStage: Stage<MeshStageAction>;
  47655. /**
  47656. * @hidden
  47657. * Defines the actions happening before evaluate active mesh checks.
  47658. */
  47659. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  47660. /**
  47661. * @hidden
  47662. * Defines the actions happening during the evaluate sub mesh checks.
  47663. */
  47664. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  47665. /**
  47666. * @hidden
  47667. * Defines the actions happening during the active mesh stage.
  47668. */
  47669. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  47670. /**
  47671. * @hidden
  47672. * Defines the actions happening during the per camera render target step.
  47673. */
  47674. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  47675. /**
  47676. * @hidden
  47677. * Defines the actions happening just before the active camera is drawing.
  47678. */
  47679. _beforeCameraDrawStage: Stage<CameraStageAction>;
  47680. /**
  47681. * @hidden
  47682. * Defines the actions happening just before a render target is drawing.
  47683. */
  47684. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  47685. /**
  47686. * @hidden
  47687. * Defines the actions happening just before a rendering group is drawing.
  47688. */
  47689. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  47690. /**
  47691. * @hidden
  47692. * Defines the actions happening just before a mesh is drawing.
  47693. */
  47694. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  47695. /**
  47696. * @hidden
  47697. * Defines the actions happening just after a mesh has been drawn.
  47698. */
  47699. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  47700. /**
  47701. * @hidden
  47702. * Defines the actions happening just after a rendering group has been drawn.
  47703. */
  47704. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  47705. /**
  47706. * @hidden
  47707. * Defines the actions happening just after the active camera has been drawn.
  47708. */
  47709. _afterCameraDrawStage: Stage<CameraStageAction>;
  47710. /**
  47711. * @hidden
  47712. * Defines the actions happening just after a render target has been drawn.
  47713. */
  47714. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  47715. /**
  47716. * @hidden
  47717. * Defines the actions happening just after rendering all cameras and computing intersections.
  47718. */
  47719. _afterRenderStage: Stage<SimpleStageAction>;
  47720. /**
  47721. * @hidden
  47722. * Defines the actions happening when a pointer move event happens.
  47723. */
  47724. _pointerMoveStage: Stage<PointerMoveStageAction>;
  47725. /**
  47726. * @hidden
  47727. * Defines the actions happening when a pointer down event happens.
  47728. */
  47729. _pointerDownStage: Stage<PointerUpDownStageAction>;
  47730. /**
  47731. * @hidden
  47732. * Defines the actions happening when a pointer up event happens.
  47733. */
  47734. _pointerUpStage: Stage<PointerUpDownStageAction>;
  47735. /**
  47736. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  47737. */
  47738. private geometriesByUniqueId;
  47739. private _renderBundles;
  47740. /**
  47741. * Creates a new Scene
  47742. * @param engine defines the engine to use to render this scene
  47743. * @param options defines the scene options
  47744. */
  47745. constructor(engine: Engine, options?: SceneOptions);
  47746. /**
  47747. * Gets a string identifying the name of the class
  47748. * @returns "Scene" string
  47749. */
  47750. getClassName(): string;
  47751. private _defaultMeshCandidates;
  47752. /**
  47753. * @hidden
  47754. */
  47755. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47756. private _defaultSubMeshCandidates;
  47757. /**
  47758. * @hidden
  47759. */
  47760. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47761. /**
  47762. * Sets the default candidate providers for the scene.
  47763. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  47764. * and getCollidingSubMeshCandidates to their default function
  47765. */
  47766. setDefaultCandidateProviders(): void;
  47767. /**
  47768. * Gets the mesh that is currently under the pointer
  47769. */
  47770. get meshUnderPointer(): Nullable<AbstractMesh>;
  47771. /**
  47772. * Gets or sets the current on-screen X position of the pointer
  47773. */
  47774. get pointerX(): number;
  47775. set pointerX(value: number);
  47776. /**
  47777. * Gets or sets the current on-screen Y position of the pointer
  47778. */
  47779. get pointerY(): number;
  47780. set pointerY(value: number);
  47781. /**
  47782. * Gets the cached material (ie. the latest rendered one)
  47783. * @returns the cached material
  47784. */
  47785. getCachedMaterial(): Nullable<Material>;
  47786. /**
  47787. * Gets the cached effect (ie. the latest rendered one)
  47788. * @returns the cached effect
  47789. */
  47790. getCachedEffect(): Nullable<Effect>;
  47791. /**
  47792. * Gets the cached visibility state (ie. the latest rendered one)
  47793. * @returns the cached visibility state
  47794. */
  47795. getCachedVisibility(): Nullable<number>;
  47796. /**
  47797. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  47798. * @param material defines the current material
  47799. * @param effect defines the current effect
  47800. * @param visibility defines the current visibility state
  47801. * @returns true if one parameter is not cached
  47802. */
  47803. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  47804. /**
  47805. * Gets the engine associated with the scene
  47806. * @returns an Engine
  47807. */
  47808. getEngine(): Engine;
  47809. /**
  47810. * Gets the total number of vertices rendered per frame
  47811. * @returns the total number of vertices rendered per frame
  47812. */
  47813. getTotalVertices(): number;
  47814. /**
  47815. * Gets the performance counter for total vertices
  47816. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  47817. */
  47818. get totalVerticesPerfCounter(): PerfCounter;
  47819. /**
  47820. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  47821. * @returns the total number of active indices rendered per frame
  47822. */
  47823. getActiveIndices(): number;
  47824. /**
  47825. * Gets the performance counter for active indices
  47826. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  47827. */
  47828. get totalActiveIndicesPerfCounter(): PerfCounter;
  47829. /**
  47830. * Gets the total number of active particles rendered per frame
  47831. * @returns the total number of active particles rendered per frame
  47832. */
  47833. getActiveParticles(): number;
  47834. /**
  47835. * Gets the performance counter for active particles
  47836. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  47837. */
  47838. get activeParticlesPerfCounter(): PerfCounter;
  47839. /**
  47840. * Gets the total number of active bones rendered per frame
  47841. * @returns the total number of active bones rendered per frame
  47842. */
  47843. getActiveBones(): number;
  47844. /**
  47845. * Gets the performance counter for active bones
  47846. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  47847. */
  47848. get activeBonesPerfCounter(): PerfCounter;
  47849. /**
  47850. * Gets the array of active meshes
  47851. * @returns an array of AbstractMesh
  47852. */
  47853. getActiveMeshes(): SmartArray<AbstractMesh>;
  47854. /**
  47855. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  47856. * @returns a number
  47857. */
  47858. getAnimationRatio(): number;
  47859. /**
  47860. * Gets an unique Id for the current render phase
  47861. * @returns a number
  47862. */
  47863. getRenderId(): number;
  47864. /**
  47865. * Gets an unique Id for the current frame
  47866. * @returns a number
  47867. */
  47868. getFrameId(): number;
  47869. /** Call this function if you want to manually increment the render Id*/
  47870. incrementRenderId(): void;
  47871. private _createUbo;
  47872. /**
  47873. * Use this method to simulate a pointer move on a mesh
  47874. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  47875. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  47876. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  47877. * @returns the current scene
  47878. */
  47879. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  47880. /**
  47881. * Use this method to simulate a pointer down on a mesh
  47882. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  47883. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  47884. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  47885. * @returns the current scene
  47886. */
  47887. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  47888. /**
  47889. * Use this method to simulate a pointer up on a mesh
  47890. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  47891. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  47892. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  47893. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  47894. * @returns the current scene
  47895. */
  47896. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  47897. /**
  47898. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  47899. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  47900. * @returns true if the pointer was captured
  47901. */
  47902. isPointerCaptured(pointerId?: number): boolean;
  47903. /**
  47904. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  47905. * @param attachUp defines if you want to attach events to pointerup
  47906. * @param attachDown defines if you want to attach events to pointerdown
  47907. * @param attachMove defines if you want to attach events to pointermove
  47908. */
  47909. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  47910. /** Detaches all event handlers*/
  47911. detachControl(): void;
  47912. /**
  47913. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  47914. * Delay loaded resources are not taking in account
  47915. * @return true if all required resources are ready
  47916. */
  47917. isReady(): boolean;
  47918. /** Resets all cached information relative to material (including effect and visibility) */
  47919. resetCachedMaterial(): void;
  47920. /**
  47921. * Registers a function to be called before every frame render
  47922. * @param func defines the function to register
  47923. */
  47924. registerBeforeRender(func: () => void): void;
  47925. /**
  47926. * Unregisters a function called before every frame render
  47927. * @param func defines the function to unregister
  47928. */
  47929. unregisterBeforeRender(func: () => void): void;
  47930. /**
  47931. * Registers a function to be called after every frame render
  47932. * @param func defines the function to register
  47933. */
  47934. registerAfterRender(func: () => void): void;
  47935. /**
  47936. * Unregisters a function called after every frame render
  47937. * @param func defines the function to unregister
  47938. */
  47939. unregisterAfterRender(func: () => void): void;
  47940. private _executeOnceBeforeRender;
  47941. /**
  47942. * The provided function will run before render once and will be disposed afterwards.
  47943. * A timeout delay can be provided so that the function will be executed in N ms.
  47944. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  47945. * @param func The function to be executed.
  47946. * @param timeout optional delay in ms
  47947. */
  47948. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  47949. /** @hidden */
  47950. _addPendingData(data: any): void;
  47951. /** @hidden */
  47952. _removePendingData(data: any): void;
  47953. /**
  47954. * Returns the number of items waiting to be loaded
  47955. * @returns the number of items waiting to be loaded
  47956. */
  47957. getWaitingItemsCount(): number;
  47958. /**
  47959. * Returns a boolean indicating if the scene is still loading data
  47960. */
  47961. get isLoading(): boolean;
  47962. /**
  47963. * Registers a function to be executed when the scene is ready
  47964. * @param {Function} func - the function to be executed
  47965. */
  47966. executeWhenReady(func: () => void): void;
  47967. /**
  47968. * Returns a promise that resolves when the scene is ready
  47969. * @returns A promise that resolves when the scene is ready
  47970. */
  47971. whenReadyAsync(): Promise<void>;
  47972. /** @hidden */
  47973. _checkIsReady(): void;
  47974. /**
  47975. * Gets all animatable attached to the scene
  47976. */
  47977. get animatables(): Animatable[];
  47978. /**
  47979. * Resets the last animation time frame.
  47980. * Useful to override when animations start running when loading a scene for the first time.
  47981. */
  47982. resetLastAnimationTimeFrame(): void;
  47983. /**
  47984. * Gets the current view matrix
  47985. * @returns a Matrix
  47986. */
  47987. getViewMatrix(): Matrix;
  47988. /**
  47989. * Gets the current projection matrix
  47990. * @returns a Matrix
  47991. */
  47992. getProjectionMatrix(): Matrix;
  47993. /**
  47994. * Gets the current transform matrix
  47995. * @returns a Matrix made of View * Projection
  47996. */
  47997. getTransformMatrix(): Matrix;
  47998. /**
  47999. * Sets the current transform matrix
  48000. * @param viewL defines the View matrix to use
  48001. * @param projectionL defines the Projection matrix to use
  48002. * @param viewR defines the right View matrix to use (if provided)
  48003. * @param projectionR defines the right Projection matrix to use (if provided)
  48004. */
  48005. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  48006. /**
  48007. * Gets the uniform buffer used to store scene data
  48008. * @returns a UniformBuffer
  48009. */
  48010. getSceneUniformBuffer(): UniformBuffer;
  48011. /**
  48012. * Gets an unique (relatively to the current scene) Id
  48013. * @returns an unique number for the scene
  48014. */
  48015. getUniqueId(): number;
  48016. /**
  48017. * Add a mesh to the list of scene's meshes
  48018. * @param newMesh defines the mesh to add
  48019. * @param recursive if all child meshes should also be added to the scene
  48020. */
  48021. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  48022. /**
  48023. * Remove a mesh for the list of scene's meshes
  48024. * @param toRemove defines the mesh to remove
  48025. * @param recursive if all child meshes should also be removed from the scene
  48026. * @returns the index where the mesh was in the mesh list
  48027. */
  48028. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  48029. /**
  48030. * Add a transform node to the list of scene's transform nodes
  48031. * @param newTransformNode defines the transform node to add
  48032. */
  48033. addTransformNode(newTransformNode: TransformNode): void;
  48034. /**
  48035. * Remove a transform node for the list of scene's transform nodes
  48036. * @param toRemove defines the transform node to remove
  48037. * @returns the index where the transform node was in the transform node list
  48038. */
  48039. removeTransformNode(toRemove: TransformNode): number;
  48040. /**
  48041. * Remove a skeleton for the list of scene's skeletons
  48042. * @param toRemove defines the skeleton to remove
  48043. * @returns the index where the skeleton was in the skeleton list
  48044. */
  48045. removeSkeleton(toRemove: Skeleton): number;
  48046. /**
  48047. * Remove a morph target for the list of scene's morph targets
  48048. * @param toRemove defines the morph target to remove
  48049. * @returns the index where the morph target was in the morph target list
  48050. */
  48051. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  48052. /**
  48053. * Remove a light for the list of scene's lights
  48054. * @param toRemove defines the light to remove
  48055. * @returns the index where the light was in the light list
  48056. */
  48057. removeLight(toRemove: Light): number;
  48058. /**
  48059. * Remove a camera for the list of scene's cameras
  48060. * @param toRemove defines the camera to remove
  48061. * @returns the index where the camera was in the camera list
  48062. */
  48063. removeCamera(toRemove: Camera): number;
  48064. /**
  48065. * Remove a particle system for the list of scene's particle systems
  48066. * @param toRemove defines the particle system to remove
  48067. * @returns the index where the particle system was in the particle system list
  48068. */
  48069. removeParticleSystem(toRemove: IParticleSystem): number;
  48070. /**
  48071. * Remove a animation for the list of scene's animations
  48072. * @param toRemove defines the animation to remove
  48073. * @returns the index where the animation was in the animation list
  48074. */
  48075. removeAnimation(toRemove: Animation): number;
  48076. /**
  48077. * Will stop the animation of the given target
  48078. * @param target - the target
  48079. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  48080. * @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)
  48081. */
  48082. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  48083. /**
  48084. * Removes the given animation group from this scene.
  48085. * @param toRemove The animation group to remove
  48086. * @returns The index of the removed animation group
  48087. */
  48088. removeAnimationGroup(toRemove: AnimationGroup): number;
  48089. /**
  48090. * Removes the given multi-material from this scene.
  48091. * @param toRemove The multi-material to remove
  48092. * @returns The index of the removed multi-material
  48093. */
  48094. removeMultiMaterial(toRemove: MultiMaterial): number;
  48095. /**
  48096. * Removes the given material from this scene.
  48097. * @param toRemove The material to remove
  48098. * @returns The index of the removed material
  48099. */
  48100. removeMaterial(toRemove: Material): number;
  48101. /**
  48102. * Removes the given action manager from this scene.
  48103. * @param toRemove The action manager to remove
  48104. * @returns The index of the removed action manager
  48105. */
  48106. removeActionManager(toRemove: AbstractActionManager): number;
  48107. /**
  48108. * Removes the given texture from this scene.
  48109. * @param toRemove The texture to remove
  48110. * @returns The index of the removed texture
  48111. */
  48112. removeTexture(toRemove: BaseTexture): number;
  48113. /**
  48114. * Adds the given light to this scene
  48115. * @param newLight The light to add
  48116. */
  48117. addLight(newLight: Light): void;
  48118. /**
  48119. * Sorts the list list based on light priorities
  48120. */
  48121. sortLightsByPriority(): void;
  48122. /**
  48123. * Adds the given camera to this scene
  48124. * @param newCamera The camera to add
  48125. */
  48126. addCamera(newCamera: Camera): void;
  48127. /**
  48128. * Adds the given skeleton to this scene
  48129. * @param newSkeleton The skeleton to add
  48130. */
  48131. addSkeleton(newSkeleton: Skeleton): void;
  48132. /**
  48133. * Adds the given particle system to this scene
  48134. * @param newParticleSystem The particle system to add
  48135. */
  48136. addParticleSystem(newParticleSystem: IParticleSystem): void;
  48137. /**
  48138. * Adds the given animation to this scene
  48139. * @param newAnimation The animation to add
  48140. */
  48141. addAnimation(newAnimation: Animation): void;
  48142. /**
  48143. * Adds the given animation group to this scene.
  48144. * @param newAnimationGroup The animation group to add
  48145. */
  48146. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  48147. /**
  48148. * Adds the given multi-material to this scene
  48149. * @param newMultiMaterial The multi-material to add
  48150. */
  48151. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  48152. /**
  48153. * Adds the given material to this scene
  48154. * @param newMaterial The material to add
  48155. */
  48156. addMaterial(newMaterial: Material): void;
  48157. /**
  48158. * Adds the given morph target to this scene
  48159. * @param newMorphTargetManager The morph target to add
  48160. */
  48161. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  48162. /**
  48163. * Adds the given geometry to this scene
  48164. * @param newGeometry The geometry to add
  48165. */
  48166. addGeometry(newGeometry: Geometry): void;
  48167. /**
  48168. * Adds the given action manager to this scene
  48169. * @param newActionManager The action manager to add
  48170. */
  48171. addActionManager(newActionManager: AbstractActionManager): void;
  48172. /**
  48173. * Adds the given texture to this scene.
  48174. * @param newTexture The texture to add
  48175. */
  48176. addTexture(newTexture: BaseTexture): void;
  48177. /**
  48178. * Switch active camera
  48179. * @param newCamera defines the new active camera
  48180. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  48181. */
  48182. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  48183. /**
  48184. * sets the active camera of the scene using its ID
  48185. * @param id defines the camera's ID
  48186. * @return the new active camera or null if none found.
  48187. */
  48188. setActiveCameraByID(id: string): Nullable<Camera>;
  48189. /**
  48190. * sets the active camera of the scene using its name
  48191. * @param name defines the camera's name
  48192. * @returns the new active camera or null if none found.
  48193. */
  48194. setActiveCameraByName(name: string): Nullable<Camera>;
  48195. /**
  48196. * get an animation group using its name
  48197. * @param name defines the material's name
  48198. * @return the animation group or null if none found.
  48199. */
  48200. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  48201. /**
  48202. * Get a material using its unique id
  48203. * @param uniqueId defines the material's unique id
  48204. * @return the material or null if none found.
  48205. */
  48206. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  48207. /**
  48208. * get a material using its id
  48209. * @param id defines the material's ID
  48210. * @return the material or null if none found.
  48211. */
  48212. getMaterialByID(id: string): Nullable<Material>;
  48213. /**
  48214. * Gets a the last added material using a given id
  48215. * @param id defines the material's ID
  48216. * @return the last material with the given id or null if none found.
  48217. */
  48218. getLastMaterialByID(id: string): Nullable<Material>;
  48219. /**
  48220. * Gets a material using its name
  48221. * @param name defines the material's name
  48222. * @return the material or null if none found.
  48223. */
  48224. getMaterialByName(name: string): Nullable<Material>;
  48225. /**
  48226. * Get a texture using its unique id
  48227. * @param uniqueId defines the texture's unique id
  48228. * @return the texture or null if none found.
  48229. */
  48230. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  48231. /**
  48232. * Gets a camera using its id
  48233. * @param id defines the id to look for
  48234. * @returns the camera or null if not found
  48235. */
  48236. getCameraByID(id: string): Nullable<Camera>;
  48237. /**
  48238. * Gets a camera using its unique id
  48239. * @param uniqueId defines the unique id to look for
  48240. * @returns the camera or null if not found
  48241. */
  48242. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  48243. /**
  48244. * Gets a camera using its name
  48245. * @param name defines the camera's name
  48246. * @return the camera or null if none found.
  48247. */
  48248. getCameraByName(name: string): Nullable<Camera>;
  48249. /**
  48250. * Gets a bone using its id
  48251. * @param id defines the bone's id
  48252. * @return the bone or null if not found
  48253. */
  48254. getBoneByID(id: string): Nullable<Bone>;
  48255. /**
  48256. * Gets a bone using its id
  48257. * @param name defines the bone's name
  48258. * @return the bone or null if not found
  48259. */
  48260. getBoneByName(name: string): Nullable<Bone>;
  48261. /**
  48262. * Gets a light node using its name
  48263. * @param name defines the the light's name
  48264. * @return the light or null if none found.
  48265. */
  48266. getLightByName(name: string): Nullable<Light>;
  48267. /**
  48268. * Gets a light node using its id
  48269. * @param id defines the light's id
  48270. * @return the light or null if none found.
  48271. */
  48272. getLightByID(id: string): Nullable<Light>;
  48273. /**
  48274. * Gets a light node using its scene-generated unique ID
  48275. * @param uniqueId defines the light's unique id
  48276. * @return the light or null if none found.
  48277. */
  48278. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  48279. /**
  48280. * Gets a particle system by id
  48281. * @param id defines the particle system id
  48282. * @return the corresponding system or null if none found
  48283. */
  48284. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  48285. /**
  48286. * Gets a geometry using its ID
  48287. * @param id defines the geometry's id
  48288. * @return the geometry or null if none found.
  48289. */
  48290. getGeometryByID(id: string): Nullable<Geometry>;
  48291. private _getGeometryByUniqueID;
  48292. /**
  48293. * Add a new geometry to this scene
  48294. * @param geometry defines the geometry to be added to the scene.
  48295. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  48296. * @return a boolean defining if the geometry was added or not
  48297. */
  48298. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  48299. /**
  48300. * Removes an existing geometry
  48301. * @param geometry defines the geometry to be removed from the scene
  48302. * @return a boolean defining if the geometry was removed or not
  48303. */
  48304. removeGeometry(geometry: Geometry): boolean;
  48305. /**
  48306. * Gets the list of geometries attached to the scene
  48307. * @returns an array of Geometry
  48308. */
  48309. getGeometries(): Geometry[];
  48310. /**
  48311. * Gets the first added mesh found of a given ID
  48312. * @param id defines the id to search for
  48313. * @return the mesh found or null if not found at all
  48314. */
  48315. getMeshByID(id: string): Nullable<AbstractMesh>;
  48316. /**
  48317. * Gets a list of meshes using their id
  48318. * @param id defines the id to search for
  48319. * @returns a list of meshes
  48320. */
  48321. getMeshesByID(id: string): Array<AbstractMesh>;
  48322. /**
  48323. * Gets the first added transform node found of a given ID
  48324. * @param id defines the id to search for
  48325. * @return the found transform node or null if not found at all.
  48326. */
  48327. getTransformNodeByID(id: string): Nullable<TransformNode>;
  48328. /**
  48329. * Gets a transform node with its auto-generated unique id
  48330. * @param uniqueId efines the unique id to search for
  48331. * @return the found transform node or null if not found at all.
  48332. */
  48333. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  48334. /**
  48335. * Gets a list of transform nodes using their id
  48336. * @param id defines the id to search for
  48337. * @returns a list of transform nodes
  48338. */
  48339. getTransformNodesByID(id: string): Array<TransformNode>;
  48340. /**
  48341. * Gets a mesh with its auto-generated unique id
  48342. * @param uniqueId defines the unique id to search for
  48343. * @return the found mesh or null if not found at all.
  48344. */
  48345. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  48346. /**
  48347. * Gets a the last added mesh using a given id
  48348. * @param id defines the id to search for
  48349. * @return the found mesh or null if not found at all.
  48350. */
  48351. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  48352. /**
  48353. * Gets a the last added node (Mesh, Camera, Light) using a given id
  48354. * @param id defines the id to search for
  48355. * @return the found node or null if not found at all
  48356. */
  48357. getLastEntryByID(id: string): Nullable<Node>;
  48358. /**
  48359. * Gets a node (Mesh, Camera, Light) using a given id
  48360. * @param id defines the id to search for
  48361. * @return the found node or null if not found at all
  48362. */
  48363. getNodeByID(id: string): Nullable<Node>;
  48364. /**
  48365. * Gets a node (Mesh, Camera, Light) using a given name
  48366. * @param name defines the name to search for
  48367. * @return the found node or null if not found at all.
  48368. */
  48369. getNodeByName(name: string): Nullable<Node>;
  48370. /**
  48371. * Gets a mesh using a given name
  48372. * @param name defines the name to search for
  48373. * @return the found mesh or null if not found at all.
  48374. */
  48375. getMeshByName(name: string): Nullable<AbstractMesh>;
  48376. /**
  48377. * Gets a transform node using a given name
  48378. * @param name defines the name to search for
  48379. * @return the found transform node or null if not found at all.
  48380. */
  48381. getTransformNodeByName(name: string): Nullable<TransformNode>;
  48382. /**
  48383. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  48384. * @param id defines the id to search for
  48385. * @return the found skeleton or null if not found at all.
  48386. */
  48387. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  48388. /**
  48389. * Gets a skeleton using a given auto generated unique id
  48390. * @param uniqueId defines the unique id to search for
  48391. * @return the found skeleton or null if not found at all.
  48392. */
  48393. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  48394. /**
  48395. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  48396. * @param id defines the id to search for
  48397. * @return the found skeleton or null if not found at all.
  48398. */
  48399. getSkeletonById(id: string): Nullable<Skeleton>;
  48400. /**
  48401. * Gets a skeleton using a given name
  48402. * @param name defines the name to search for
  48403. * @return the found skeleton or null if not found at all.
  48404. */
  48405. getSkeletonByName(name: string): Nullable<Skeleton>;
  48406. /**
  48407. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  48408. * @param id defines the id to search for
  48409. * @return the found morph target manager or null if not found at all.
  48410. */
  48411. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  48412. /**
  48413. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  48414. * @param id defines the id to search for
  48415. * @return the found morph target or null if not found at all.
  48416. */
  48417. getMorphTargetById(id: string): Nullable<MorphTarget>;
  48418. /**
  48419. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  48420. * @param name defines the name to search for
  48421. * @return the found morph target or null if not found at all.
  48422. */
  48423. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  48424. /**
  48425. * Gets a post process using a given name (if many are found, this function will pick the first one)
  48426. * @param name defines the name to search for
  48427. * @return the found post process or null if not found at all.
  48428. */
  48429. getPostProcessByName(name: string): Nullable<PostProcess>;
  48430. /**
  48431. * Gets a boolean indicating if the given mesh is active
  48432. * @param mesh defines the mesh to look for
  48433. * @returns true if the mesh is in the active list
  48434. */
  48435. isActiveMesh(mesh: AbstractMesh): boolean;
  48436. /**
  48437. * Return a unique id as a string which can serve as an identifier for the scene
  48438. */
  48439. get uid(): string;
  48440. /**
  48441. * Add an externaly attached data from its key.
  48442. * This method call will fail and return false, if such key already exists.
  48443. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  48444. * @param key the unique key that identifies the data
  48445. * @param data the data object to associate to the key for this Engine instance
  48446. * @return true if no such key were already present and the data was added successfully, false otherwise
  48447. */
  48448. addExternalData<T>(key: string, data: T): boolean;
  48449. /**
  48450. * Get an externaly attached data from its key
  48451. * @param key the unique key that identifies the data
  48452. * @return the associated data, if present (can be null), or undefined if not present
  48453. */
  48454. getExternalData<T>(key: string): Nullable<T>;
  48455. /**
  48456. * Get an externaly attached data from its key, create it using a factory if it's not already present
  48457. * @param key the unique key that identifies the data
  48458. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  48459. * @return the associated data, can be null if the factory returned null.
  48460. */
  48461. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  48462. /**
  48463. * Remove an externaly attached data from the Engine instance
  48464. * @param key the unique key that identifies the data
  48465. * @return true if the data was successfully removed, false if it doesn't exist
  48466. */
  48467. removeExternalData(key: string): boolean;
  48468. private _evaluateSubMesh;
  48469. /**
  48470. * Clear the processed materials smart array preventing retention point in material dispose.
  48471. */
  48472. freeProcessedMaterials(): void;
  48473. private _preventFreeActiveMeshesAndRenderingGroups;
  48474. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  48475. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  48476. * when disposing several meshes in a row or a hierarchy of meshes.
  48477. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  48478. */
  48479. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  48480. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  48481. /**
  48482. * Clear the active meshes smart array preventing retention point in mesh dispose.
  48483. */
  48484. freeActiveMeshes(): void;
  48485. /**
  48486. * Clear the info related to rendering groups preventing retention points during dispose.
  48487. */
  48488. freeRenderingGroups(): void;
  48489. /** @hidden */
  48490. _isInIntermediateRendering(): boolean;
  48491. /**
  48492. * Lambda returning the list of potentially active meshes.
  48493. */
  48494. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  48495. /**
  48496. * Lambda returning the list of potentially active sub meshes.
  48497. */
  48498. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  48499. /**
  48500. * Lambda returning the list of potentially intersecting sub meshes.
  48501. */
  48502. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  48503. /**
  48504. * Lambda returning the list of potentially colliding sub meshes.
  48505. */
  48506. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  48507. /** @hidden */
  48508. _activeMeshesFrozen: boolean;
  48509. private _skipEvaluateActiveMeshesCompletely;
  48510. /**
  48511. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  48512. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  48513. * @param onSuccess optional success callback
  48514. * @param onError optional error callback
  48515. * @returns the current scene
  48516. */
  48517. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  48518. /**
  48519. * Use this function to restart evaluating active meshes on every frame
  48520. * @returns the current scene
  48521. */
  48522. unfreezeActiveMeshes(): Scene;
  48523. private _evaluateActiveMeshes;
  48524. private _activeMesh;
  48525. /**
  48526. * Update the transform matrix to update from the current active camera
  48527. * @param force defines a boolean used to force the update even if cache is up to date
  48528. */
  48529. updateTransformMatrix(force?: boolean): void;
  48530. private _bindFrameBuffer;
  48531. /** @hidden */
  48532. _allowPostProcessClearColor: boolean;
  48533. /** @hidden */
  48534. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  48535. private _processSubCameras;
  48536. private _checkIntersections;
  48537. /** @hidden */
  48538. _advancePhysicsEngineStep(step: number): void;
  48539. /**
  48540. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  48541. */
  48542. getDeterministicFrameTime: () => number;
  48543. /** @hidden */
  48544. _animate(): void;
  48545. /** Execute all animations (for a frame) */
  48546. animate(): void;
  48547. /**
  48548. * Render the scene
  48549. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  48550. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  48551. */
  48552. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  48553. /**
  48554. * Freeze all materials
  48555. * A frozen material will not be updatable but should be faster to render
  48556. */
  48557. freezeMaterials(): void;
  48558. /**
  48559. * Unfreeze all materials
  48560. * A frozen material will not be updatable but should be faster to render
  48561. */
  48562. unfreezeMaterials(): void;
  48563. /**
  48564. * Releases all held ressources
  48565. */
  48566. dispose(): void;
  48567. /**
  48568. * Gets if the scene is already disposed
  48569. */
  48570. get isDisposed(): boolean;
  48571. /**
  48572. * Call this function to reduce memory footprint of the scene.
  48573. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  48574. */
  48575. clearCachedVertexData(): void;
  48576. /**
  48577. * This function will remove the local cached buffer data from texture.
  48578. * It will save memory but will prevent the texture from being rebuilt
  48579. */
  48580. cleanCachedTextureBuffer(): void;
  48581. /**
  48582. * Get the world extend vectors with an optional filter
  48583. *
  48584. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  48585. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  48586. */
  48587. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  48588. min: Vector3;
  48589. max: Vector3;
  48590. };
  48591. /**
  48592. * Creates a ray that can be used to pick in the scene
  48593. * @param x defines the x coordinate of the origin (on-screen)
  48594. * @param y defines the y coordinate of the origin (on-screen)
  48595. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  48596. * @param camera defines the camera to use for the picking
  48597. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  48598. * @returns a Ray
  48599. */
  48600. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  48601. /**
  48602. * Creates a ray that can be used to pick in the scene
  48603. * @param x defines the x coordinate of the origin (on-screen)
  48604. * @param y defines the y coordinate of the origin (on-screen)
  48605. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  48606. * @param result defines the ray where to store the picking ray
  48607. * @param camera defines the camera to use for the picking
  48608. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  48609. * @returns the current scene
  48610. */
  48611. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  48612. /**
  48613. * Creates a ray that can be used to pick in the scene
  48614. * @param x defines the x coordinate of the origin (on-screen)
  48615. * @param y defines the y coordinate of the origin (on-screen)
  48616. * @param camera defines the camera to use for the picking
  48617. * @returns a Ray
  48618. */
  48619. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  48620. /**
  48621. * Creates a ray that can be used to pick in the scene
  48622. * @param x defines the x coordinate of the origin (on-screen)
  48623. * @param y defines the y coordinate of the origin (on-screen)
  48624. * @param result defines the ray where to store the picking ray
  48625. * @param camera defines the camera to use for the picking
  48626. * @returns the current scene
  48627. */
  48628. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  48629. /** Launch a ray to try to pick a mesh in the scene
  48630. * @param x position on screen
  48631. * @param y position on screen
  48632. * @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
  48633. * @param fastCheck defines if the first intersection will be used (and not the closest)
  48634. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  48635. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  48636. * @returns a PickingInfo
  48637. */
  48638. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  48639. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  48640. * @param x position on screen
  48641. * @param y position on screen
  48642. * @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
  48643. * @param fastCheck defines if the first intersection will be used (and not the closest)
  48644. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  48645. * @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)
  48646. */
  48647. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  48648. /** Use the given ray to pick a mesh in the scene
  48649. * @param ray The ray to use to pick meshes
  48650. * @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
  48651. * @param fastCheck defines if the first intersection will be used (and not the closest)
  48652. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  48653. * @returns a PickingInfo
  48654. */
  48655. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  48656. /**
  48657. * Launch a ray to try to pick a mesh in the scene
  48658. * @param x X position on screen
  48659. * @param y Y position on screen
  48660. * @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
  48661. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  48662. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  48663. * @returns an array of PickingInfo
  48664. */
  48665. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  48666. /**
  48667. * Launch a ray to try to pick a mesh in the scene
  48668. * @param ray Ray to use
  48669. * @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
  48670. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  48671. * @returns an array of PickingInfo
  48672. */
  48673. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  48674. /**
  48675. * Force the value of meshUnderPointer
  48676. * @param mesh defines the mesh to use
  48677. * @param pointerId optional pointer id when using more than one pointer
  48678. */
  48679. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  48680. /**
  48681. * Gets the mesh under the pointer
  48682. * @returns a Mesh or null if no mesh is under the pointer
  48683. */
  48684. getPointerOverMesh(): Nullable<AbstractMesh>;
  48685. /** @hidden */
  48686. _rebuildGeometries(): void;
  48687. /** @hidden */
  48688. _rebuildTextures(): void;
  48689. private _getByTags;
  48690. /**
  48691. * Get a list of meshes 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 Mesh
  48695. */
  48696. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  48697. /**
  48698. * Get a list of cameras 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 Camera
  48702. */
  48703. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  48704. /**
  48705. * Get a list of lights 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 Light
  48709. */
  48710. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  48711. /**
  48712. * Get a list of materials 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 Material
  48716. */
  48717. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  48718. /**
  48719. * Get a list of transform nodes by tags
  48720. * @param tagsQuery defines the tags query to use
  48721. * @param forEach defines a predicate used to filter results
  48722. * @returns an array of TransformNode
  48723. */
  48724. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  48725. /**
  48726. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  48727. * This allowed control for front to back rendering or reversly depending of the special needs.
  48728. *
  48729. * @param renderingGroupId The rendering group id corresponding to its index
  48730. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  48731. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  48732. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  48733. */
  48734. 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;
  48735. /**
  48736. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  48737. *
  48738. * @param renderingGroupId The rendering group id corresponding to its index
  48739. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48740. * @param depth Automatically clears depth between groups if true and autoClear is true.
  48741. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  48742. */
  48743. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  48744. /**
  48745. * Gets the current auto clear configuration for one rendering group of the rendering
  48746. * manager.
  48747. * @param index the rendering group index to get the information for
  48748. * @returns The auto clear setup for the requested rendering group
  48749. */
  48750. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  48751. private _blockMaterialDirtyMechanism;
  48752. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  48753. get blockMaterialDirtyMechanism(): boolean;
  48754. set blockMaterialDirtyMechanism(value: boolean);
  48755. /**
  48756. * Will flag all materials as dirty to trigger new shader compilation
  48757. * @param flag defines the flag used to specify which material part must be marked as dirty
  48758. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  48759. */
  48760. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  48761. /** @hidden */
  48762. _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;
  48763. /** @hidden */
  48764. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  48765. /** @hidden */
  48766. _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;
  48767. /** @hidden */
  48768. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  48769. /** @hidden */
  48770. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  48771. /** @hidden */
  48772. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  48773. }
  48774. }
  48775. declare module BABYLON {
  48776. /**
  48777. * Set of assets to keep when moving a scene into an asset container.
  48778. */
  48779. export class KeepAssets extends AbstractScene {
  48780. }
  48781. /**
  48782. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  48783. */
  48784. export class InstantiatedEntries {
  48785. /**
  48786. * List of new root nodes (eg. nodes with no parent)
  48787. */
  48788. rootNodes: TransformNode[];
  48789. /**
  48790. * List of new skeletons
  48791. */
  48792. skeletons: Skeleton[];
  48793. /**
  48794. * List of new animation groups
  48795. */
  48796. animationGroups: AnimationGroup[];
  48797. }
  48798. /**
  48799. * Container with a set of assets that can be added or removed from a scene.
  48800. */
  48801. export class AssetContainer extends AbstractScene {
  48802. private _wasAddedToScene;
  48803. /**
  48804. * The scene the AssetContainer belongs to.
  48805. */
  48806. scene: Scene;
  48807. /**
  48808. * Instantiates an AssetContainer.
  48809. * @param scene The scene the AssetContainer belongs to.
  48810. */
  48811. constructor(scene: Scene);
  48812. /**
  48813. * Instantiate or clone all meshes and add the new ones to the scene.
  48814. * Skeletons and animation groups will all be cloned
  48815. * @param nameFunction defines an optional function used to get new names for clones
  48816. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  48817. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  48818. */
  48819. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  48820. /**
  48821. * Adds all the assets from the container to the scene.
  48822. */
  48823. addAllToScene(): void;
  48824. /**
  48825. * Removes all the assets in the container from the scene
  48826. */
  48827. removeAllFromScene(): void;
  48828. /**
  48829. * Disposes all the assets in the container
  48830. */
  48831. dispose(): void;
  48832. private _moveAssets;
  48833. /**
  48834. * Removes all the assets contained in the scene and adds them to the container.
  48835. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  48836. */
  48837. moveAllFromScene(keepAssets?: KeepAssets): void;
  48838. /**
  48839. * 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.
  48840. * @returns the root mesh
  48841. */
  48842. createRootMesh(): Mesh;
  48843. /**
  48844. * Merge animations (direct and animation groups) from this asset container into a scene
  48845. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48846. * @param animatables set of animatables to retarget to a node from the scene
  48847. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  48848. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  48849. */
  48850. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  48851. }
  48852. }
  48853. declare module BABYLON {
  48854. /**
  48855. * Defines how the parser contract is defined.
  48856. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  48857. */
  48858. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  48859. /**
  48860. * Defines how the individual parser contract is defined.
  48861. * These parser can parse an individual asset
  48862. */
  48863. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  48864. /**
  48865. * Base class of the scene acting as a container for the different elements composing a scene.
  48866. * This class is dynamically extended by the different components of the scene increasing
  48867. * flexibility and reducing coupling
  48868. */
  48869. export abstract class AbstractScene {
  48870. /**
  48871. * Stores the list of available parsers in the application.
  48872. */
  48873. private static _BabylonFileParsers;
  48874. /**
  48875. * Stores the list of available individual parsers in the application.
  48876. */
  48877. private static _IndividualBabylonFileParsers;
  48878. /**
  48879. * Adds a parser in the list of available ones
  48880. * @param name Defines the name of the parser
  48881. * @param parser Defines the parser to add
  48882. */
  48883. static AddParser(name: string, parser: BabylonFileParser): void;
  48884. /**
  48885. * Gets a general parser from the list of avaialble ones
  48886. * @param name Defines the name of the parser
  48887. * @returns the requested parser or null
  48888. */
  48889. static GetParser(name: string): Nullable<BabylonFileParser>;
  48890. /**
  48891. * Adds n individual parser in the list of available ones
  48892. * @param name Defines the name of the parser
  48893. * @param parser Defines the parser to add
  48894. */
  48895. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  48896. /**
  48897. * Gets an individual parser from the list of avaialble ones
  48898. * @param name Defines the name of the parser
  48899. * @returns the requested parser or null
  48900. */
  48901. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  48902. /**
  48903. * Parser json data and populate both a scene and its associated container object
  48904. * @param jsonData Defines the data to parse
  48905. * @param scene Defines the scene to parse the data for
  48906. * @param container Defines the container attached to the parsing sequence
  48907. * @param rootUrl Defines the root url of the data
  48908. */
  48909. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  48910. /**
  48911. * Gets the list of root nodes (ie. nodes with no parent)
  48912. */
  48913. rootNodes: Node[];
  48914. /** All of the cameras added to this scene
  48915. * @see https://doc.babylonjs.com/babylon101/cameras
  48916. */
  48917. cameras: Camera[];
  48918. /**
  48919. * All of the lights added to this scene
  48920. * @see https://doc.babylonjs.com/babylon101/lights
  48921. */
  48922. lights: Light[];
  48923. /**
  48924. * All of the (abstract) meshes added to this scene
  48925. */
  48926. meshes: AbstractMesh[];
  48927. /**
  48928. * The list of skeletons added to the scene
  48929. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  48930. */
  48931. skeletons: Skeleton[];
  48932. /**
  48933. * All of the particle systems added to this scene
  48934. * @see https://doc.babylonjs.com/babylon101/particles
  48935. */
  48936. particleSystems: IParticleSystem[];
  48937. /**
  48938. * Gets a list of Animations associated with the scene
  48939. */
  48940. animations: Animation[];
  48941. /**
  48942. * All of the animation groups added to this scene
  48943. * @see https://doc.babylonjs.com/how_to/group
  48944. */
  48945. animationGroups: AnimationGroup[];
  48946. /**
  48947. * All of the multi-materials added to this scene
  48948. * @see https://doc.babylonjs.com/how_to/multi_materials
  48949. */
  48950. multiMaterials: MultiMaterial[];
  48951. /**
  48952. * All of the materials added to this scene
  48953. * In the context of a Scene, it is not supposed to be modified manually.
  48954. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  48955. * Note also that the order of the Material within the array is not significant and might change.
  48956. * @see https://doc.babylonjs.com/babylon101/materials
  48957. */
  48958. materials: Material[];
  48959. /**
  48960. * The list of morph target managers added to the scene
  48961. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  48962. */
  48963. morphTargetManagers: MorphTargetManager[];
  48964. /**
  48965. * The list of geometries used in the scene.
  48966. */
  48967. geometries: Geometry[];
  48968. /**
  48969. * All of the tranform nodes added to this scene
  48970. * In the context of a Scene, it is not supposed to be modified manually.
  48971. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  48972. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  48973. * @see https://doc.babylonjs.com/how_to/transformnode
  48974. */
  48975. transformNodes: TransformNode[];
  48976. /**
  48977. * ActionManagers available on the scene.
  48978. */
  48979. actionManagers: AbstractActionManager[];
  48980. /**
  48981. * Textures to keep.
  48982. */
  48983. textures: BaseTexture[];
  48984. /** @hidden */
  48985. protected _environmentTexture: Nullable<BaseTexture>;
  48986. /**
  48987. * Texture used in all pbr material as the reflection texture.
  48988. * As in the majority of the scene they are the same (exception for multi room and so on),
  48989. * this is easier to reference from here than from all the materials.
  48990. */
  48991. get environmentTexture(): Nullable<BaseTexture>;
  48992. set environmentTexture(value: Nullable<BaseTexture>);
  48993. /**
  48994. * The list of postprocesses added to the scene
  48995. */
  48996. postProcesses: PostProcess[];
  48997. /**
  48998. * @returns all meshes, lights, cameras, transformNodes and bones
  48999. */
  49000. getNodes(): Array<Node>;
  49001. }
  49002. }
  49003. declare module BABYLON {
  49004. /**
  49005. * Interface used to define options for Sound class
  49006. */
  49007. export interface ISoundOptions {
  49008. /**
  49009. * Does the sound autoplay once loaded.
  49010. */
  49011. autoplay?: boolean;
  49012. /**
  49013. * Does the sound loop after it finishes playing once.
  49014. */
  49015. loop?: boolean;
  49016. /**
  49017. * Sound's volume
  49018. */
  49019. volume?: number;
  49020. /**
  49021. * Is it a spatial sound?
  49022. */
  49023. spatialSound?: boolean;
  49024. /**
  49025. * Maximum distance to hear that sound
  49026. */
  49027. maxDistance?: number;
  49028. /**
  49029. * Uses user defined attenuation function
  49030. */
  49031. useCustomAttenuation?: boolean;
  49032. /**
  49033. * Define the roll off factor of spatial sounds.
  49034. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49035. */
  49036. rolloffFactor?: number;
  49037. /**
  49038. * Define the reference distance the sound should be heard perfectly.
  49039. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49040. */
  49041. refDistance?: number;
  49042. /**
  49043. * Define the distance attenuation model the sound will follow.
  49044. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49045. */
  49046. distanceModel?: string;
  49047. /**
  49048. * Defines the playback speed (1 by default)
  49049. */
  49050. playbackRate?: number;
  49051. /**
  49052. * Defines if the sound is from a streaming source
  49053. */
  49054. streaming?: boolean;
  49055. /**
  49056. * Defines an optional length (in seconds) inside the sound file
  49057. */
  49058. length?: number;
  49059. /**
  49060. * Defines an optional offset (in seconds) inside the sound file
  49061. */
  49062. offset?: number;
  49063. /**
  49064. * If true, URLs will not be required to state the audio file codec to use.
  49065. */
  49066. skipCodecCheck?: boolean;
  49067. }
  49068. }
  49069. declare module BABYLON {
  49070. /**
  49071. * Defines a sound that can be played in the application.
  49072. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  49073. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49074. */
  49075. export class Sound {
  49076. /**
  49077. * The name of the sound in the scene.
  49078. */
  49079. name: string;
  49080. /**
  49081. * Does the sound autoplay once loaded.
  49082. */
  49083. autoplay: boolean;
  49084. private _loop;
  49085. /**
  49086. * Does the sound loop after it finishes playing once.
  49087. */
  49088. get loop(): boolean;
  49089. set loop(value: boolean);
  49090. /**
  49091. * Does the sound use a custom attenuation curve to simulate the falloff
  49092. * happening when the source gets further away from the camera.
  49093. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  49094. */
  49095. useCustomAttenuation: boolean;
  49096. /**
  49097. * The sound track id this sound belongs to.
  49098. */
  49099. soundTrackId: number;
  49100. /**
  49101. * Is this sound currently played.
  49102. */
  49103. isPlaying: boolean;
  49104. /**
  49105. * Is this sound currently paused.
  49106. */
  49107. isPaused: boolean;
  49108. /**
  49109. * Does this sound enables spatial sound.
  49110. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49111. */
  49112. spatialSound: boolean;
  49113. /**
  49114. * Define the reference distance the sound should be heard perfectly.
  49115. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49116. */
  49117. refDistance: number;
  49118. /**
  49119. * Define the roll off factor of spatial sounds.
  49120. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49121. */
  49122. rolloffFactor: number;
  49123. /**
  49124. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  49125. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49126. */
  49127. maxDistance: number;
  49128. /**
  49129. * Define the distance attenuation model the sound will follow.
  49130. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49131. */
  49132. distanceModel: string;
  49133. /**
  49134. * @hidden
  49135. * Back Compat
  49136. **/
  49137. onended: () => any;
  49138. /**
  49139. * Gets or sets an object used to store user defined information for the sound.
  49140. */
  49141. metadata: any;
  49142. /**
  49143. * Observable event when the current playing sound finishes.
  49144. */
  49145. onEndedObservable: Observable<Sound>;
  49146. /**
  49147. * Gets the current time for the sound.
  49148. */
  49149. get currentTime(): number;
  49150. private _panningModel;
  49151. private _playbackRate;
  49152. private _streaming;
  49153. private _startTime;
  49154. private _startOffset;
  49155. private _position;
  49156. /** @hidden */
  49157. _positionInEmitterSpace: boolean;
  49158. private _localDirection;
  49159. private _volume;
  49160. private _isReadyToPlay;
  49161. private _isDirectional;
  49162. private _readyToPlayCallback;
  49163. private _audioBuffer;
  49164. private _soundSource;
  49165. private _streamingSource;
  49166. private _soundPanner;
  49167. private _soundGain;
  49168. private _inputAudioNode;
  49169. private _outputAudioNode;
  49170. private _coneInnerAngle;
  49171. private _coneOuterAngle;
  49172. private _coneOuterGain;
  49173. private _scene;
  49174. private _connectedTransformNode;
  49175. private _customAttenuationFunction;
  49176. private _registerFunc;
  49177. private _isOutputConnected;
  49178. private _htmlAudioElement;
  49179. private _urlType;
  49180. private _length?;
  49181. private _offset?;
  49182. /** @hidden */
  49183. static _SceneComponentInitialization: (scene: Scene) => void;
  49184. /**
  49185. * Create a sound and attach it to a scene
  49186. * @param name Name of your sound
  49187. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  49188. * @param scene defines the scene the sound belongs to
  49189. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  49190. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  49191. */
  49192. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  49193. /**
  49194. * Release the sound and its associated resources
  49195. */
  49196. dispose(): void;
  49197. /**
  49198. * Gets if the sounds is ready to be played or not.
  49199. * @returns true if ready, otherwise false
  49200. */
  49201. isReady(): boolean;
  49202. /**
  49203. * Get the current class name.
  49204. * @returns current class name
  49205. */
  49206. getClassName(): string;
  49207. private _soundLoaded;
  49208. /**
  49209. * Sets the data of the sound from an audiobuffer
  49210. * @param audioBuffer The audioBuffer containing the data
  49211. */
  49212. setAudioBuffer(audioBuffer: AudioBuffer): void;
  49213. /**
  49214. * Updates the current sounds options such as maxdistance, loop...
  49215. * @param options A JSON object containing values named as the object properties
  49216. */
  49217. updateOptions(options: ISoundOptions): void;
  49218. private _createSpatialParameters;
  49219. private _updateSpatialParameters;
  49220. /**
  49221. * Switch the panning model to HRTF:
  49222. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  49223. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49224. */
  49225. switchPanningModelToHRTF(): void;
  49226. /**
  49227. * Switch the panning model to Equal Power:
  49228. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  49229. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49230. */
  49231. switchPanningModelToEqualPower(): void;
  49232. private _switchPanningModel;
  49233. /**
  49234. * Connect this sound to a sound track audio node like gain...
  49235. * @param soundTrackAudioNode the sound track audio node to connect to
  49236. */
  49237. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  49238. /**
  49239. * Transform this sound into a directional source
  49240. * @param coneInnerAngle Size of the inner cone in degree
  49241. * @param coneOuterAngle Size of the outer cone in degree
  49242. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  49243. */
  49244. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  49245. /**
  49246. * Gets or sets the inner angle for the directional cone.
  49247. */
  49248. get directionalConeInnerAngle(): number;
  49249. /**
  49250. * Gets or sets the inner angle for the directional cone.
  49251. */
  49252. set directionalConeInnerAngle(value: number);
  49253. /**
  49254. * Gets or sets the outer angle for the directional cone.
  49255. */
  49256. get directionalConeOuterAngle(): number;
  49257. /**
  49258. * Gets or sets the outer angle for the directional cone.
  49259. */
  49260. set directionalConeOuterAngle(value: number);
  49261. /**
  49262. * Sets the position of the emitter if spatial sound is enabled
  49263. * @param newPosition Defines the new position
  49264. */
  49265. setPosition(newPosition: Vector3): void;
  49266. /**
  49267. * Sets the local direction of the emitter if spatial sound is enabled
  49268. * @param newLocalDirection Defines the new local direction
  49269. */
  49270. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  49271. private _updateDirection;
  49272. /** @hidden */
  49273. updateDistanceFromListener(): void;
  49274. /**
  49275. * Sets a new custom attenuation function for the sound.
  49276. * @param callback Defines the function used for the attenuation
  49277. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  49278. */
  49279. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  49280. /**
  49281. * Play the sound
  49282. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  49283. * @param offset (optional) Start the sound at a specific time in seconds
  49284. * @param length (optional) Sound duration (in seconds)
  49285. */
  49286. play(time?: number, offset?: number, length?: number): void;
  49287. private _onended;
  49288. /**
  49289. * Stop the sound
  49290. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  49291. */
  49292. stop(time?: number): void;
  49293. /**
  49294. * Put the sound in pause
  49295. */
  49296. pause(): void;
  49297. /**
  49298. * Sets a dedicated volume for this sounds
  49299. * @param newVolume Define the new volume of the sound
  49300. * @param time Define time for gradual change to new volume
  49301. */
  49302. setVolume(newVolume: number, time?: number): void;
  49303. /**
  49304. * Set the sound play back rate
  49305. * @param newPlaybackRate Define the playback rate the sound should be played at
  49306. */
  49307. setPlaybackRate(newPlaybackRate: number): void;
  49308. /**
  49309. * Gets the volume of the sound.
  49310. * @returns the volume of the sound
  49311. */
  49312. getVolume(): number;
  49313. /**
  49314. * Attach the sound to a dedicated mesh
  49315. * @param transformNode The transform node to connect the sound with
  49316. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  49317. */
  49318. attachToMesh(transformNode: TransformNode): void;
  49319. /**
  49320. * Detach the sound from the previously attached mesh
  49321. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  49322. */
  49323. detachFromMesh(): void;
  49324. private _onRegisterAfterWorldMatrixUpdate;
  49325. /**
  49326. * Clone the current sound in the scene.
  49327. * @returns the new sound clone
  49328. */
  49329. clone(): Nullable<Sound>;
  49330. /**
  49331. * Gets the current underlying audio buffer containing the data
  49332. * @returns the audio buffer
  49333. */
  49334. getAudioBuffer(): Nullable<AudioBuffer>;
  49335. /**
  49336. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  49337. * @returns the source node
  49338. */
  49339. getSoundSource(): Nullable<AudioBufferSourceNode>;
  49340. /**
  49341. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  49342. * @returns the gain node
  49343. */
  49344. getSoundGain(): Nullable<GainNode>;
  49345. /**
  49346. * Serializes the Sound in a JSON representation
  49347. * @returns the JSON representation of the sound
  49348. */
  49349. serialize(): any;
  49350. /**
  49351. * Parse a JSON representation of a sound to instantiate in a given scene
  49352. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  49353. * @param scene Define the scene the new parsed sound should be created in
  49354. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  49355. * @param sourceSound Define a sound place holder if do not need to instantiate a new one
  49356. * @returns the newly parsed sound
  49357. */
  49358. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  49359. }
  49360. }
  49361. declare module BABYLON {
  49362. /**
  49363. * This defines an action helpful to play a defined sound on a triggered action.
  49364. */
  49365. export class PlaySoundAction extends Action {
  49366. private _sound;
  49367. /**
  49368. * Instantiate the action
  49369. * @param triggerOptions defines the trigger options
  49370. * @param sound defines the sound to play
  49371. * @param condition defines the trigger related conditions
  49372. */
  49373. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  49374. /** @hidden */
  49375. _prepare(): void;
  49376. /**
  49377. * Execute the action and play the sound.
  49378. */
  49379. execute(): void;
  49380. /**
  49381. * Serializes the actions and its related information.
  49382. * @param parent defines the object to serialize in
  49383. * @returns the serialized object
  49384. */
  49385. serialize(parent: any): any;
  49386. }
  49387. /**
  49388. * This defines an action helpful to stop a defined sound on a triggered action.
  49389. */
  49390. export class StopSoundAction extends Action {
  49391. private _sound;
  49392. /**
  49393. * Instantiate the action
  49394. * @param triggerOptions defines the trigger options
  49395. * @param sound defines the sound to stop
  49396. * @param condition defines the trigger related conditions
  49397. */
  49398. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  49399. /** @hidden */
  49400. _prepare(): void;
  49401. /**
  49402. * Execute the action and stop the sound.
  49403. */
  49404. execute(): void;
  49405. /**
  49406. * Serializes the actions and its related information.
  49407. * @param parent defines the object to serialize in
  49408. * @returns the serialized object
  49409. */
  49410. serialize(parent: any): any;
  49411. }
  49412. }
  49413. declare module BABYLON {
  49414. /**
  49415. * This defines an action responsible to change the value of a property
  49416. * by interpolating between its current value and the newly set one once triggered.
  49417. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  49418. */
  49419. export class InterpolateValueAction extends Action {
  49420. /**
  49421. * Defines the path of the property where the value should be interpolated
  49422. */
  49423. propertyPath: string;
  49424. /**
  49425. * Defines the target value at the end of the interpolation.
  49426. */
  49427. value: any;
  49428. /**
  49429. * Defines the time it will take for the property to interpolate to the value.
  49430. */
  49431. duration: number;
  49432. /**
  49433. * Defines if the other scene animations should be stopped when the action has been triggered
  49434. */
  49435. stopOtherAnimations?: boolean;
  49436. /**
  49437. * Defines a callback raised once the interpolation animation has been done.
  49438. */
  49439. onInterpolationDone?: () => void;
  49440. /**
  49441. * Observable triggered once the interpolation animation has been done.
  49442. */
  49443. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  49444. private _target;
  49445. private _effectiveTarget;
  49446. private _property;
  49447. /**
  49448. * Instantiate the action
  49449. * @param triggerOptions defines the trigger options
  49450. * @param target defines the object containing the value to interpolate
  49451. * @param propertyPath defines the path to the property in the target object
  49452. * @param value defines the target value at the end of the interpolation
  49453. * @param duration defines the time it will take for the property to interpolate to the value.
  49454. * @param condition defines the trigger related conditions
  49455. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  49456. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  49457. */
  49458. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  49459. /** @hidden */
  49460. _prepare(): void;
  49461. /**
  49462. * Execute the action starts the value interpolation.
  49463. */
  49464. execute(): void;
  49465. /**
  49466. * Serializes the actions and its related information.
  49467. * @param parent defines the object to serialize in
  49468. * @returns the serialized object
  49469. */
  49470. serialize(parent: any): any;
  49471. }
  49472. }
  49473. declare module BABYLON {
  49474. /**
  49475. * A cursor which tracks a point on a path
  49476. */
  49477. export class PathCursor {
  49478. private path;
  49479. /**
  49480. * Stores path cursor callbacks for when an onchange event is triggered
  49481. */
  49482. private _onchange;
  49483. /**
  49484. * The value of the path cursor
  49485. */
  49486. value: number;
  49487. /**
  49488. * The animation array of the path cursor
  49489. */
  49490. animations: Animation[];
  49491. /**
  49492. * Initializes the path cursor
  49493. * @param path The path to track
  49494. */
  49495. constructor(path: Path2);
  49496. /**
  49497. * Gets the cursor point on the path
  49498. * @returns A point on the path cursor at the cursor location
  49499. */
  49500. getPoint(): Vector3;
  49501. /**
  49502. * Moves the cursor ahead by the step amount
  49503. * @param step The amount to move the cursor forward
  49504. * @returns This path cursor
  49505. */
  49506. moveAhead(step?: number): PathCursor;
  49507. /**
  49508. * Moves the cursor behind by the step amount
  49509. * @param step The amount to move the cursor back
  49510. * @returns This path cursor
  49511. */
  49512. moveBack(step?: number): PathCursor;
  49513. /**
  49514. * Moves the cursor by the step amount
  49515. * If the step amount is greater than one, an exception is thrown
  49516. * @param step The amount to move the cursor
  49517. * @returns This path cursor
  49518. */
  49519. move(step: number): PathCursor;
  49520. /**
  49521. * Ensures that the value is limited between zero and one
  49522. * @returns This path cursor
  49523. */
  49524. private ensureLimits;
  49525. /**
  49526. * Runs onchange callbacks on change (used by the animation engine)
  49527. * @returns This path cursor
  49528. */
  49529. private raiseOnChange;
  49530. /**
  49531. * Executes a function on change
  49532. * @param f A path cursor onchange callback
  49533. * @returns This path cursor
  49534. */
  49535. onchange(f: (cursor: PathCursor) => void): PathCursor;
  49536. }
  49537. }
  49538. declare module BABYLON {
  49539. /**
  49540. * This represents the default audio engine used in babylon.
  49541. * It is responsible to play, synchronize and analyse sounds throughout the application.
  49542. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49543. */
  49544. export class AudioEngine implements IAudioEngine {
  49545. private _audioContext;
  49546. private _audioContextInitialized;
  49547. private _muteButton;
  49548. private _hostElement;
  49549. /**
  49550. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  49551. */
  49552. canUseWebAudio: boolean;
  49553. /**
  49554. * The master gain node defines the global audio volume of your audio engine.
  49555. */
  49556. masterGain: GainNode;
  49557. /**
  49558. * Defines if Babylon should emit a warning if WebAudio is not supported.
  49559. * @ignoreNaming
  49560. */
  49561. WarnedWebAudioUnsupported: boolean;
  49562. /**
  49563. * Gets whether or not mp3 are supported by your browser.
  49564. */
  49565. isMP3supported: boolean;
  49566. /**
  49567. * Gets whether or not ogg are supported by your browser.
  49568. */
  49569. isOGGsupported: boolean;
  49570. /**
  49571. * Gets whether audio has been unlocked on the device.
  49572. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  49573. * a user interaction has happened.
  49574. */
  49575. unlocked: boolean;
  49576. /**
  49577. * Defines if the audio engine relies on a custom unlocked button.
  49578. * In this case, the embedded button will not be displayed.
  49579. */
  49580. useCustomUnlockedButton: boolean;
  49581. /**
  49582. * Event raised when audio has been unlocked on the browser.
  49583. */
  49584. onAudioUnlockedObservable: Observable<IAudioEngine>;
  49585. /**
  49586. * Event raised when audio has been locked on the browser.
  49587. */
  49588. onAudioLockedObservable: Observable<IAudioEngine>;
  49589. /**
  49590. * Gets the current AudioContext if available.
  49591. */
  49592. get audioContext(): Nullable<AudioContext>;
  49593. private _connectedAnalyser;
  49594. /**
  49595. * Instantiates a new audio engine.
  49596. *
  49597. * There should be only one per page as some browsers restrict the number
  49598. * of audio contexts you can create.
  49599. * @param hostElement defines the host element where to display the mute icon if necessary
  49600. */
  49601. constructor(hostElement?: Nullable<HTMLElement>);
  49602. /**
  49603. * Flags the audio engine in Locked state.
  49604. * This happens due to new browser policies preventing audio to autoplay.
  49605. */
  49606. lock(): void;
  49607. /**
  49608. * Unlocks the audio engine once a user action has been done on the dom.
  49609. * This is helpful to resume play once browser policies have been satisfied.
  49610. */
  49611. unlock(): void;
  49612. private _resumeAudioContext;
  49613. private _initializeAudioContext;
  49614. private _tryToRun;
  49615. private _triggerRunningState;
  49616. private _triggerSuspendedState;
  49617. private _displayMuteButton;
  49618. private _moveButtonToTopLeft;
  49619. private _onResize;
  49620. private _hideMuteButton;
  49621. /**
  49622. * Destroy and release the resources associated with the audio context.
  49623. */
  49624. dispose(): void;
  49625. /**
  49626. * Gets the global volume sets on the master gain.
  49627. * @returns the global volume if set or -1 otherwise
  49628. */
  49629. getGlobalVolume(): number;
  49630. /**
  49631. * Sets the global volume of your experience (sets on the master gain).
  49632. * @param newVolume Defines the new global volume of the application
  49633. */
  49634. setGlobalVolume(newVolume: number): void;
  49635. /**
  49636. * Connect the audio engine to an audio analyser allowing some amazing
  49637. * synchronization between the sounds/music and your visualization (VuMeter for instance).
  49638. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  49639. * @param analyser The analyser to connect to the engine
  49640. */
  49641. connectToAnalyser(analyser: Analyser): void;
  49642. }
  49643. }
  49644. declare module BABYLON {
  49645. /**
  49646. * Options allowed during the creation of a sound track.
  49647. */
  49648. export interface ISoundTrackOptions {
  49649. /**
  49650. * The volume the sound track should take during creation
  49651. */
  49652. volume?: number;
  49653. /**
  49654. * Define if the sound track is the main sound track of the scene
  49655. */
  49656. mainTrack?: boolean;
  49657. }
  49658. /**
  49659. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  49660. * It will be also used in a future release to apply effects on a specific track.
  49661. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  49662. */
  49663. export class SoundTrack {
  49664. /**
  49665. * The unique identifier of the sound track in the scene.
  49666. */
  49667. id: number;
  49668. /**
  49669. * The list of sounds included in the sound track.
  49670. */
  49671. soundCollection: Array<Sound>;
  49672. private _outputAudioNode;
  49673. private _scene;
  49674. private _connectedAnalyser;
  49675. private _options;
  49676. private _isInitialized;
  49677. /**
  49678. * Creates a new sound track.
  49679. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  49680. * @param scene Define the scene the sound track belongs to
  49681. * @param options
  49682. */
  49683. constructor(scene: Scene, options?: ISoundTrackOptions);
  49684. private _initializeSoundTrackAudioGraph;
  49685. /**
  49686. * Release the sound track and its associated resources
  49687. */
  49688. dispose(): void;
  49689. /**
  49690. * Adds a sound to this sound track
  49691. * @param sound define the sound to add
  49692. * @ignoreNaming
  49693. */
  49694. addSound(sound: Sound): void;
  49695. /**
  49696. * Removes a sound to this sound track
  49697. * @param sound define the sound to remove
  49698. * @ignoreNaming
  49699. */
  49700. removeSound(sound: Sound): void;
  49701. /**
  49702. * Set a global volume for the full sound track.
  49703. * @param newVolume Define the new volume of the sound track
  49704. */
  49705. setVolume(newVolume: number): void;
  49706. /**
  49707. * Switch the panning model to HRTF:
  49708. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  49709. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49710. */
  49711. switchPanningModelToHRTF(): void;
  49712. /**
  49713. * Switch the panning model to Equal Power:
  49714. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  49715. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49716. */
  49717. switchPanningModelToEqualPower(): void;
  49718. /**
  49719. * Connect the sound track to an audio analyser allowing some amazing
  49720. * synchronization between the sounds/music and your visualization (VuMeter for instance).
  49721. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  49722. * @param analyser The analyser to connect to the engine
  49723. */
  49724. connectToAnalyser(analyser: Analyser): void;
  49725. }
  49726. }
  49727. declare module BABYLON {
  49728. interface AbstractScene {
  49729. /**
  49730. * The list of sounds used in the scene.
  49731. */
  49732. sounds: Nullable<Array<Sound>>;
  49733. }
  49734. interface Scene {
  49735. /**
  49736. * @hidden
  49737. * Backing field
  49738. */
  49739. _mainSoundTrack: SoundTrack;
  49740. /**
  49741. * The main sound track played by the scene.
  49742. * It contains your primary collection of sounds.
  49743. */
  49744. mainSoundTrack: SoundTrack;
  49745. /**
  49746. * The list of sound tracks added to the scene
  49747. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49748. */
  49749. soundTracks: Nullable<Array<SoundTrack>>;
  49750. /**
  49751. * Gets a sound using a given name
  49752. * @param name defines the name to search for
  49753. * @return the found sound or null if not found at all.
  49754. */
  49755. getSoundByName(name: string): Nullable<Sound>;
  49756. /**
  49757. * Gets or sets if audio support is enabled
  49758. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49759. */
  49760. audioEnabled: boolean;
  49761. /**
  49762. * Gets or sets if audio will be output to headphones
  49763. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49764. */
  49765. headphone: boolean;
  49766. /**
  49767. * Gets or sets custom audio listener position provider
  49768. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49769. */
  49770. audioListenerPositionProvider: Nullable<() => Vector3>;
  49771. /**
  49772. * Gets or sets a refresh rate when using 3D audio positioning
  49773. */
  49774. audioPositioningRefreshRate: number;
  49775. }
  49776. /**
  49777. * Defines the sound scene component responsible to manage any sounds
  49778. * in a given scene.
  49779. */
  49780. export class AudioSceneComponent implements ISceneSerializableComponent {
  49781. private static _CameraDirectionLH;
  49782. private static _CameraDirectionRH;
  49783. /**
  49784. * The component name helpful to identify the component in the list of scene components.
  49785. */
  49786. readonly name: string;
  49787. /**
  49788. * The scene the component belongs to.
  49789. */
  49790. scene: Scene;
  49791. private _audioEnabled;
  49792. /**
  49793. * Gets whether audio is enabled or not.
  49794. * Please use related enable/disable method to switch state.
  49795. */
  49796. get audioEnabled(): boolean;
  49797. private _headphone;
  49798. /**
  49799. * Gets whether audio is outputting to headphone or not.
  49800. * Please use the according Switch methods to change output.
  49801. */
  49802. get headphone(): boolean;
  49803. /**
  49804. * Gets or sets a refresh rate when using 3D audio positioning
  49805. */
  49806. audioPositioningRefreshRate: number;
  49807. private _audioListenerPositionProvider;
  49808. /**
  49809. * Gets the current audio listener position provider
  49810. */
  49811. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  49812. /**
  49813. * Sets a custom listener position for all sounds in the scene
  49814. * By default, this is the position of the first active camera
  49815. */
  49816. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  49817. /**
  49818. * Creates a new instance of the component for the given scene
  49819. * @param scene Defines the scene to register the component in
  49820. */
  49821. constructor(scene: Scene);
  49822. /**
  49823. * Registers the component in a given scene
  49824. */
  49825. register(): void;
  49826. /**
  49827. * Rebuilds the elements related to this component in case of
  49828. * context lost for instance.
  49829. */
  49830. rebuild(): void;
  49831. /**
  49832. * Serializes the component data to the specified json object
  49833. * @param serializationObject The object to serialize to
  49834. */
  49835. serialize(serializationObject: any): void;
  49836. /**
  49837. * Adds all the elements from the container to the scene
  49838. * @param container the container holding the elements
  49839. */
  49840. addFromContainer(container: AbstractScene): void;
  49841. /**
  49842. * Removes all the elements in the container from the scene
  49843. * @param container contains the elements to remove
  49844. * @param dispose if the removed element should be disposed (default: false)
  49845. */
  49846. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49847. /**
  49848. * Disposes the component and the associated resources.
  49849. */
  49850. dispose(): void;
  49851. /**
  49852. * Disables audio in the associated scene.
  49853. */
  49854. disableAudio(): void;
  49855. /**
  49856. * Enables audio in the associated scene.
  49857. */
  49858. enableAudio(): void;
  49859. /**
  49860. * Switch audio to headphone output.
  49861. */
  49862. switchAudioModeForHeadphones(): void;
  49863. /**
  49864. * Switch audio to normal speakers.
  49865. */
  49866. switchAudioModeForNormalSpeakers(): void;
  49867. private _cachedCameraDirection;
  49868. private _cachedCameraPosition;
  49869. private _lastCheck;
  49870. private _afterRender;
  49871. }
  49872. }
  49873. declare module BABYLON {
  49874. /**
  49875. * Wraps one or more Sound objects and selects one with random weight for playback.
  49876. */
  49877. export class WeightedSound {
  49878. /** When true a Sound will be selected and played when the current playing Sound completes. */
  49879. loop: boolean;
  49880. private _coneInnerAngle;
  49881. private _coneOuterAngle;
  49882. private _volume;
  49883. /** A Sound is currently playing. */
  49884. isPlaying: boolean;
  49885. /** A Sound is currently paused. */
  49886. isPaused: boolean;
  49887. private _sounds;
  49888. private _weights;
  49889. private _currentIndex?;
  49890. /**
  49891. * Creates a new WeightedSound from the list of sounds given.
  49892. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  49893. * @param sounds Array of Sounds that will be selected from.
  49894. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  49895. */
  49896. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  49897. /**
  49898. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  49899. */
  49900. get directionalConeInnerAngle(): number;
  49901. /**
  49902. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  49903. */
  49904. set directionalConeInnerAngle(value: number);
  49905. /**
  49906. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  49907. * Listener angles between innerAngle and outerAngle will falloff linearly.
  49908. */
  49909. get directionalConeOuterAngle(): number;
  49910. /**
  49911. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  49912. * Listener angles between innerAngle and outerAngle will falloff linearly.
  49913. */
  49914. set directionalConeOuterAngle(value: number);
  49915. /**
  49916. * Playback volume.
  49917. */
  49918. get volume(): number;
  49919. /**
  49920. * Playback volume.
  49921. */
  49922. set volume(value: number);
  49923. private _onended;
  49924. /**
  49925. * Suspend playback
  49926. */
  49927. pause(): void;
  49928. /**
  49929. * Stop playback
  49930. */
  49931. stop(): void;
  49932. /**
  49933. * Start playback.
  49934. * @param startOffset Position the clip head at a specific time in seconds.
  49935. */
  49936. play(startOffset?: number): void;
  49937. }
  49938. }
  49939. declare module BABYLON {
  49940. /**
  49941. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  49942. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  49943. */
  49944. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  49945. /**
  49946. * Gets the name of the behavior.
  49947. */
  49948. get name(): string;
  49949. /**
  49950. * The easing function used by animations
  49951. */
  49952. static EasingFunction: BackEase;
  49953. /**
  49954. * The easing mode used by animations
  49955. */
  49956. static EasingMode: number;
  49957. /**
  49958. * The duration of the animation, in milliseconds
  49959. */
  49960. transitionDuration: number;
  49961. /**
  49962. * Length of the distance animated by the transition when lower radius is reached
  49963. */
  49964. lowerRadiusTransitionRange: number;
  49965. /**
  49966. * Length of the distance animated by the transition when upper radius is reached
  49967. */
  49968. upperRadiusTransitionRange: number;
  49969. private _autoTransitionRange;
  49970. /**
  49971. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  49972. */
  49973. get autoTransitionRange(): boolean;
  49974. /**
  49975. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  49976. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  49977. */
  49978. set autoTransitionRange(value: boolean);
  49979. private _attachedCamera;
  49980. private _onAfterCheckInputsObserver;
  49981. private _onMeshTargetChangedObserver;
  49982. /**
  49983. * Initializes the behavior.
  49984. */
  49985. init(): void;
  49986. /**
  49987. * Attaches the behavior to its arc rotate camera.
  49988. * @param camera Defines the camera to attach the behavior to
  49989. */
  49990. attach(camera: ArcRotateCamera): void;
  49991. /**
  49992. * Detaches the behavior from its current arc rotate camera.
  49993. */
  49994. detach(): void;
  49995. private _radiusIsAnimating;
  49996. private _radiusBounceTransition;
  49997. private _animatables;
  49998. private _cachedWheelPrecision;
  49999. /**
  50000. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  50001. * @param radiusLimit The limit to check against.
  50002. * @return Bool to indicate if at limit.
  50003. */
  50004. private _isRadiusAtLimit;
  50005. /**
  50006. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  50007. * @param radiusDelta The delta by which to animate to. Can be negative.
  50008. */
  50009. private _applyBoundRadiusAnimation;
  50010. /**
  50011. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  50012. */
  50013. protected _clearAnimationLocks(): void;
  50014. /**
  50015. * Stops and removes all animations that have been applied to the camera
  50016. */
  50017. stopAllAnimations(): void;
  50018. }
  50019. }
  50020. declare module BABYLON {
  50021. /**
  50022. * 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.
  50023. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  50024. */
  50025. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  50026. /**
  50027. * Gets the name of the behavior.
  50028. */
  50029. get name(): string;
  50030. private _mode;
  50031. private _radiusScale;
  50032. private _positionScale;
  50033. private _defaultElevation;
  50034. private _elevationReturnTime;
  50035. private _elevationReturnWaitTime;
  50036. private _zoomStopsAnimation;
  50037. private _framingTime;
  50038. /**
  50039. * The easing function used by animations
  50040. */
  50041. static EasingFunction: ExponentialEase;
  50042. /**
  50043. * The easing mode used by animations
  50044. */
  50045. static EasingMode: number;
  50046. /**
  50047. * Sets the current mode used by the behavior
  50048. */
  50049. set mode(mode: number);
  50050. /**
  50051. * Gets current mode used by the behavior.
  50052. */
  50053. get mode(): number;
  50054. /**
  50055. * Sets the scale applied to the radius (1 by default)
  50056. */
  50057. set radiusScale(radius: number);
  50058. /**
  50059. * Gets the scale applied to the radius
  50060. */
  50061. get radiusScale(): number;
  50062. /**
  50063. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  50064. */
  50065. set positionScale(scale: number);
  50066. /**
  50067. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  50068. */
  50069. get positionScale(): number;
  50070. /**
  50071. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  50072. * behaviour is triggered, in radians.
  50073. */
  50074. set defaultElevation(elevation: number);
  50075. /**
  50076. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  50077. * behaviour is triggered, in radians.
  50078. */
  50079. get defaultElevation(): number;
  50080. /**
  50081. * Sets the time (in milliseconds) taken to return to the default beta position.
  50082. * Negative value indicates camera should not return to default.
  50083. */
  50084. set elevationReturnTime(speed: number);
  50085. /**
  50086. * Gets the time (in milliseconds) taken to return to the default beta position.
  50087. * Negative value indicates camera should not return to default.
  50088. */
  50089. get elevationReturnTime(): number;
  50090. /**
  50091. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  50092. */
  50093. set elevationReturnWaitTime(time: number);
  50094. /**
  50095. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  50096. */
  50097. get elevationReturnWaitTime(): number;
  50098. /**
  50099. * Sets the flag that indicates if user zooming should stop animation.
  50100. */
  50101. set zoomStopsAnimation(flag: boolean);
  50102. /**
  50103. * Gets the flag that indicates if user zooming should stop animation.
  50104. */
  50105. get zoomStopsAnimation(): boolean;
  50106. /**
  50107. * Sets the transition time when framing the mesh, in milliseconds
  50108. */
  50109. set framingTime(time: number);
  50110. /**
  50111. * Gets the transition time when framing the mesh, in milliseconds
  50112. */
  50113. get framingTime(): number;
  50114. /**
  50115. * Define if the behavior should automatically change the configured
  50116. * camera limits and sensibilities.
  50117. */
  50118. autoCorrectCameraLimitsAndSensibility: boolean;
  50119. private _onPrePointerObservableObserver;
  50120. private _onAfterCheckInputsObserver;
  50121. private _onMeshTargetChangedObserver;
  50122. private _attachedCamera;
  50123. private _isPointerDown;
  50124. private _lastInteractionTime;
  50125. /**
  50126. * Initializes the behavior.
  50127. */
  50128. init(): void;
  50129. /**
  50130. * Attaches the behavior to its arc rotate camera.
  50131. * @param camera Defines the camera to attach the behavior to
  50132. */
  50133. attach(camera: ArcRotateCamera): void;
  50134. /**
  50135. * Detaches the behavior from its current arc rotate camera.
  50136. */
  50137. detach(): void;
  50138. private _animatables;
  50139. private _betaIsAnimating;
  50140. private _betaTransition;
  50141. private _radiusTransition;
  50142. private _vectorTransition;
  50143. /**
  50144. * Targets the given mesh 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. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  50150. /**
  50151. * Targets the given mesh with its children and updates zoom level accordingly.
  50152. * @param mesh 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. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  50157. /**
  50158. * Targets the given meshes with their children and updates zoom level accordingly.
  50159. * @param meshes The mesh to target.
  50160. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  50161. * @param onAnimationEnd Callback triggered at the end of the framing animation
  50162. */
  50163. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  50164. /**
  50165. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  50166. * @param minimumWorld Determines the smaller position of the bounding box extend
  50167. * @param maximumWorld Determines the bigger position of the bounding box extend
  50168. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  50169. * @param onAnimationEnd Callback triggered at the end of the framing animation
  50170. */
  50171. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  50172. /**
  50173. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  50174. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  50175. * frustum width.
  50176. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  50177. * to fully enclose the mesh in the viewing frustum.
  50178. */
  50179. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  50180. /**
  50181. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  50182. * is automatically returned to its default position (expected to be above ground plane).
  50183. */
  50184. private _maintainCameraAboveGround;
  50185. /**
  50186. * Returns the frustum slope based on the canvas ratio and camera FOV
  50187. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  50188. */
  50189. private _getFrustumSlope;
  50190. /**
  50191. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  50192. */
  50193. private _clearAnimationLocks;
  50194. /**
  50195. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  50196. */
  50197. private _applyUserInteraction;
  50198. /**
  50199. * Stops and removes all animations that have been applied to the camera
  50200. */
  50201. stopAllAnimations(): void;
  50202. /**
  50203. * Gets a value indicating if the user is moving the camera
  50204. */
  50205. get isUserIsMoving(): boolean;
  50206. /**
  50207. * The camera can move all the way towards the mesh.
  50208. */
  50209. static IgnoreBoundsSizeMode: number;
  50210. /**
  50211. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  50212. */
  50213. static FitFrustumSidesMode: number;
  50214. }
  50215. }
  50216. declare module BABYLON {
  50217. /**
  50218. * Base class for Camera Pointer Inputs.
  50219. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  50220. * for example usage.
  50221. */
  50222. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  50223. /**
  50224. * Defines the camera the input is attached to.
  50225. */
  50226. abstract camera: Camera;
  50227. /**
  50228. * Whether keyboard modifier keys are pressed at time of last mouse event.
  50229. */
  50230. protected _altKey: boolean;
  50231. protected _ctrlKey: boolean;
  50232. protected _metaKey: boolean;
  50233. protected _shiftKey: boolean;
  50234. /**
  50235. * Which mouse buttons were pressed at time of last mouse event.
  50236. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  50237. */
  50238. protected _buttonsPressed: number;
  50239. /**
  50240. * Defines the buttons associated with the input to handle camera move.
  50241. */
  50242. buttons: number[];
  50243. /**
  50244. * Attach the input controls to a specific dom element to get the input from.
  50245. * @param element Defines the element the controls should be listened from
  50246. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50247. */
  50248. attachControl(noPreventDefault?: boolean): void;
  50249. /**
  50250. * Detach the current controls from the specified dom element.
  50251. */
  50252. detachControl(): void;
  50253. /**
  50254. * Gets the class name of the current input.
  50255. * @returns the class name
  50256. */
  50257. getClassName(): string;
  50258. /**
  50259. * Get the friendly name associated with the input class.
  50260. * @returns the input friendly name
  50261. */
  50262. getSimpleName(): string;
  50263. /**
  50264. * Called on pointer POINTERDOUBLETAP event.
  50265. * Override this method to provide functionality on POINTERDOUBLETAP event.
  50266. */
  50267. protected onDoubleTap(type: string): void;
  50268. /**
  50269. * Called on pointer POINTERMOVE event if only a single touch is active.
  50270. * Override this method to provide functionality.
  50271. */
  50272. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  50273. /**
  50274. * Called on pointer POINTERMOVE event if multiple touches are active.
  50275. * Override this method to provide functionality.
  50276. */
  50277. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  50278. /**
  50279. * Called on JS contextmenu event.
  50280. * Override this method to provide functionality.
  50281. */
  50282. protected onContextMenu(evt: PointerEvent): void;
  50283. /**
  50284. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  50285. * press.
  50286. * Override this method to provide functionality.
  50287. */
  50288. protected onButtonDown(evt: IPointerEvent): void;
  50289. /**
  50290. * Called each time a new POINTERUP event occurs. Ie, for each button
  50291. * release.
  50292. * Override this method to provide functionality.
  50293. */
  50294. protected onButtonUp(evt: IPointerEvent): void;
  50295. /**
  50296. * Called when window becomes inactive.
  50297. * Override this method to provide functionality.
  50298. */
  50299. protected onLostFocus(): void;
  50300. private _pointerInput;
  50301. private _observer;
  50302. private _onLostFocus;
  50303. private pointA;
  50304. private pointB;
  50305. }
  50306. }
  50307. declare module BABYLON {
  50308. /**
  50309. * Manage the pointers inputs to control an arc rotate camera.
  50310. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50311. */
  50312. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  50313. /**
  50314. * Defines the camera the input is attached to.
  50315. */
  50316. camera: ArcRotateCamera;
  50317. /**
  50318. * Gets the class name of the current input.
  50319. * @returns the class name
  50320. */
  50321. getClassName(): string;
  50322. /**
  50323. * Defines the buttons associated with the input to handle camera move.
  50324. */
  50325. buttons: number[];
  50326. /**
  50327. * Defines the pointer angular sensibility along the X axis or how fast is
  50328. * the camera rotating.
  50329. */
  50330. angularSensibilityX: number;
  50331. /**
  50332. * Defines the pointer angular sensibility along the Y axis or how fast is
  50333. * the camera rotating.
  50334. */
  50335. angularSensibilityY: number;
  50336. /**
  50337. * Defines the pointer pinch precision or how fast is the camera zooming.
  50338. */
  50339. pinchPrecision: number;
  50340. /**
  50341. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  50342. * from 0.
  50343. * It defines the percentage of current camera.radius to use as delta when
  50344. * pinch zoom is used.
  50345. */
  50346. pinchDeltaPercentage: number;
  50347. /**
  50348. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  50349. * that any object in the plane at the camera's target point will scale
  50350. * perfectly with finger motion.
  50351. * Overrides pinchDeltaPercentage and pinchPrecision.
  50352. */
  50353. useNaturalPinchZoom: boolean;
  50354. /**
  50355. * Defines whether zoom (2 fingers pinch) is enabled through multitouch
  50356. */
  50357. pinchZoom: boolean;
  50358. /**
  50359. * Defines the pointer panning sensibility or how fast is the camera moving.
  50360. */
  50361. panningSensibility: number;
  50362. /**
  50363. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  50364. */
  50365. multiTouchPanning: boolean;
  50366. /**
  50367. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  50368. * zoom (pinch) through multitouch.
  50369. */
  50370. multiTouchPanAndZoom: boolean;
  50371. /**
  50372. * Revers pinch action direction.
  50373. */
  50374. pinchInwards: boolean;
  50375. private _isPanClick;
  50376. private _twoFingerActivityCount;
  50377. private _isPinching;
  50378. /**
  50379. * Move camera from multi touch panning positions.
  50380. */
  50381. private _computeMultiTouchPanning;
  50382. /**
  50383. * Move camera from pinch zoom distances.
  50384. */
  50385. private _computePinchZoom;
  50386. /**
  50387. * Called on pointer POINTERMOVE event if only a single touch is active.
  50388. */
  50389. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  50390. /**
  50391. * Called on pointer POINTERDOUBLETAP event.
  50392. */
  50393. protected onDoubleTap(type: string): void;
  50394. /**
  50395. * Called on pointer POINTERMOVE event if multiple touches are active.
  50396. */
  50397. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  50398. /**
  50399. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  50400. * press.
  50401. */
  50402. protected onButtonDown(evt: IPointerEvent): void;
  50403. /**
  50404. * Called each time a new POINTERUP event occurs. Ie, for each button
  50405. * release.
  50406. */
  50407. protected onButtonUp(evt: IPointerEvent): void;
  50408. /**
  50409. * Called when window becomes inactive.
  50410. */
  50411. protected onLostFocus(): void;
  50412. }
  50413. }
  50414. declare module BABYLON {
  50415. /**
  50416. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  50417. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50418. */
  50419. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  50420. /**
  50421. * Defines the camera the input is attached to.
  50422. */
  50423. camera: ArcRotateCamera;
  50424. /**
  50425. * Defines the list of key codes associated with the up action (increase alpha)
  50426. */
  50427. keysUp: number[];
  50428. /**
  50429. * Defines the list of key codes associated with the down action (decrease alpha)
  50430. */
  50431. keysDown: number[];
  50432. /**
  50433. * Defines the list of key codes associated with the left action (increase beta)
  50434. */
  50435. keysLeft: number[];
  50436. /**
  50437. * Defines the list of key codes associated with the right action (decrease beta)
  50438. */
  50439. keysRight: number[];
  50440. /**
  50441. * Defines the list of key codes associated with the reset action.
  50442. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  50443. */
  50444. keysReset: number[];
  50445. /**
  50446. * Defines the panning sensibility of the inputs.
  50447. * (How fast is the camera panning)
  50448. */
  50449. panningSensibility: number;
  50450. /**
  50451. * Defines the zooming sensibility of the inputs.
  50452. * (How fast is the camera zooming)
  50453. */
  50454. zoomingSensibility: number;
  50455. /**
  50456. * Defines whether maintaining the alt key down switch the movement mode from
  50457. * orientation to zoom.
  50458. */
  50459. useAltToZoom: boolean;
  50460. /**
  50461. * Rotation speed of the camera
  50462. */
  50463. angularSpeed: number;
  50464. private _keys;
  50465. private _ctrlPressed;
  50466. private _altPressed;
  50467. private _onCanvasBlurObserver;
  50468. private _onKeyboardObserver;
  50469. private _engine;
  50470. private _scene;
  50471. /**
  50472. * Attach the input controls to a specific dom element to get the input from.
  50473. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50474. */
  50475. attachControl(noPreventDefault?: boolean): void;
  50476. /**
  50477. * Detach the current controls from the specified dom element.
  50478. */
  50479. detachControl(): void;
  50480. /**
  50481. * Update the current camera state depending on the inputs that have been used this frame.
  50482. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50483. */
  50484. checkInputs(): void;
  50485. /**
  50486. * Gets the class name of the current input.
  50487. * @returns the class name
  50488. */
  50489. getClassName(): string;
  50490. /**
  50491. * Get the friendly name associated with the input class.
  50492. * @returns the input friendly name
  50493. */
  50494. getSimpleName(): string;
  50495. }
  50496. }
  50497. declare module BABYLON {
  50498. /**
  50499. * Manage the mouse wheel inputs to control an arc rotate camera.
  50500. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50501. */
  50502. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  50503. /**
  50504. * Defines the camera the input is attached to.
  50505. */
  50506. camera: ArcRotateCamera;
  50507. /**
  50508. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  50509. */
  50510. wheelPrecision: number;
  50511. /**
  50512. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  50513. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  50514. */
  50515. wheelDeltaPercentage: number;
  50516. private _wheel;
  50517. private _observer;
  50518. /**
  50519. * Attach the input controls to a specific dom element to get the input from.
  50520. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50521. */
  50522. attachControl(noPreventDefault?: boolean): void;
  50523. /**
  50524. * Detach the current controls from the specified dom element.
  50525. */
  50526. detachControl(): void;
  50527. /**
  50528. * Gets the class name of the current input.
  50529. * @returns the class name
  50530. */
  50531. getClassName(): string;
  50532. /**
  50533. * Get the friendly name associated with the input class.
  50534. * @returns the input friendly name
  50535. */
  50536. getSimpleName(): string;
  50537. }
  50538. }
  50539. declare module BABYLON {
  50540. /**
  50541. * Default Inputs manager for the ArcRotateCamera.
  50542. * It groups all the default supported inputs for ease of use.
  50543. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50544. */
  50545. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  50546. /**
  50547. * Instantiates a new ArcRotateCameraInputsManager.
  50548. * @param camera Defines the camera the inputs belong to
  50549. */
  50550. constructor(camera: ArcRotateCamera);
  50551. /**
  50552. * Add mouse wheel input support to the input manager.
  50553. * @returns the current input manager
  50554. */
  50555. addMouseWheel(): ArcRotateCameraInputsManager;
  50556. /**
  50557. * Add pointers input support to the input manager.
  50558. * @returns the current input manager
  50559. */
  50560. addPointers(): ArcRotateCameraInputsManager;
  50561. /**
  50562. * Add keyboard input support to the input manager.
  50563. * @returns the current input manager
  50564. */
  50565. addKeyboard(): ArcRotateCameraInputsManager;
  50566. }
  50567. }
  50568. declare module BABYLON {
  50569. /**
  50570. * This represents an orbital type of camera.
  50571. *
  50572. * 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.
  50573. * 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.
  50574. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  50575. */
  50576. export class ArcRotateCamera extends TargetCamera {
  50577. /**
  50578. * Defines the rotation angle of the camera along the longitudinal axis.
  50579. */
  50580. alpha: number;
  50581. /**
  50582. * Defines the rotation angle of the camera along the latitudinal axis.
  50583. */
  50584. beta: number;
  50585. /**
  50586. * Defines the radius of the camera from it s target point.
  50587. */
  50588. radius: number;
  50589. protected _target: Vector3;
  50590. protected _targetHost: Nullable<AbstractMesh>;
  50591. /**
  50592. * Defines the target point of the camera.
  50593. * The camera looks towards it form the radius distance.
  50594. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  50595. */
  50596. get target(): Vector3;
  50597. set target(value: Vector3);
  50598. /**
  50599. * Define the current local position of the camera in the scene
  50600. */
  50601. get position(): Vector3;
  50602. set position(newPosition: Vector3);
  50603. protected _upToYMatrix: Matrix;
  50604. protected _YToUpMatrix: Matrix;
  50605. /**
  50606. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  50607. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  50608. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  50609. */
  50610. set upVector(vec: Vector3);
  50611. get upVector(): Vector3;
  50612. /**
  50613. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  50614. */
  50615. setMatUp(): void;
  50616. /**
  50617. * Current inertia value on the longitudinal axis.
  50618. * The bigger this number the longer it will take for the camera to stop.
  50619. */
  50620. inertialAlphaOffset: number;
  50621. /**
  50622. * Current inertia value on the latitudinal axis.
  50623. * The bigger this number the longer it will take for the camera to stop.
  50624. */
  50625. inertialBetaOffset: number;
  50626. /**
  50627. * Current inertia value on the radius axis.
  50628. * The bigger this number the longer it will take for the camera to stop.
  50629. */
  50630. inertialRadiusOffset: number;
  50631. /**
  50632. * Minimum allowed angle on the longitudinal axis.
  50633. * This can help limiting how the Camera is able to move in the scene.
  50634. */
  50635. lowerAlphaLimit: Nullable<number>;
  50636. /**
  50637. * Maximum allowed angle on the longitudinal axis.
  50638. * This can help limiting how the Camera is able to move in the scene.
  50639. */
  50640. upperAlphaLimit: Nullable<number>;
  50641. /**
  50642. * Minimum allowed angle on the latitudinal axis.
  50643. * This can help limiting how the Camera is able to move in the scene.
  50644. */
  50645. lowerBetaLimit: number;
  50646. /**
  50647. * Maximum allowed angle on the latitudinal axis.
  50648. * This can help limiting how the Camera is able to move in the scene.
  50649. */
  50650. upperBetaLimit: number;
  50651. /**
  50652. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  50653. * This can help limiting how the Camera is able to move in the scene.
  50654. */
  50655. lowerRadiusLimit: Nullable<number>;
  50656. /**
  50657. * Maximum allowed distance of the camera to the target (The camera can not get further).
  50658. * This can help limiting how the Camera is able to move in the scene.
  50659. */
  50660. upperRadiusLimit: Nullable<number>;
  50661. /**
  50662. * Defines the current inertia value used during panning of the camera along the X axis.
  50663. */
  50664. inertialPanningX: number;
  50665. /**
  50666. * Defines the current inertia value used during panning of the camera along the Y axis.
  50667. */
  50668. inertialPanningY: number;
  50669. /**
  50670. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  50671. * Basically if your fingers moves away from more than this distance you will be considered
  50672. * in pinch mode.
  50673. */
  50674. pinchToPanMaxDistance: number;
  50675. /**
  50676. * Defines the maximum distance the camera can pan.
  50677. * This could help keeping the camera always in your scene.
  50678. */
  50679. panningDistanceLimit: Nullable<number>;
  50680. /**
  50681. * Defines the target of the camera before panning.
  50682. */
  50683. panningOriginTarget: Vector3;
  50684. /**
  50685. * Defines the value of the inertia used during panning.
  50686. * 0 would mean stop inertia and one would mean no decelleration at all.
  50687. */
  50688. panningInertia: number;
  50689. /**
  50690. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  50691. */
  50692. get angularSensibilityX(): number;
  50693. set angularSensibilityX(value: number);
  50694. /**
  50695. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  50696. */
  50697. get angularSensibilityY(): number;
  50698. set angularSensibilityY(value: number);
  50699. /**
  50700. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  50701. */
  50702. get pinchPrecision(): number;
  50703. set pinchPrecision(value: number);
  50704. /**
  50705. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  50706. * It will be used instead of pinchDeltaPrecision if different from 0.
  50707. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  50708. */
  50709. get pinchDeltaPercentage(): number;
  50710. set pinchDeltaPercentage(value: number);
  50711. /**
  50712. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  50713. * and pinch delta percentage.
  50714. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  50715. * that any object in the plane at the camera's target point will scale
  50716. * perfectly with finger motion.
  50717. */
  50718. get useNaturalPinchZoom(): boolean;
  50719. set useNaturalPinchZoom(value: boolean);
  50720. /**
  50721. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  50722. */
  50723. get panningSensibility(): number;
  50724. set panningSensibility(value: number);
  50725. /**
  50726. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  50727. */
  50728. get keysUp(): number[];
  50729. set keysUp(value: number[]);
  50730. /**
  50731. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  50732. */
  50733. get keysDown(): number[];
  50734. set keysDown(value: number[]);
  50735. /**
  50736. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  50737. */
  50738. get keysLeft(): number[];
  50739. set keysLeft(value: number[]);
  50740. /**
  50741. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  50742. */
  50743. get keysRight(): number[];
  50744. set keysRight(value: number[]);
  50745. /**
  50746. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  50747. */
  50748. get wheelPrecision(): number;
  50749. set wheelPrecision(value: number);
  50750. /**
  50751. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  50752. * It will be used instead of pinchDeltaPrecision if different from 0.
  50753. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  50754. */
  50755. get wheelDeltaPercentage(): number;
  50756. set wheelDeltaPercentage(value: number);
  50757. /**
  50758. * Defines how much the radius should be scaled while zooming on a particular mesh (through the zoomOn function)
  50759. */
  50760. zoomOnFactor: number;
  50761. /**
  50762. * Defines a screen offset for the camera position.
  50763. */
  50764. targetScreenOffset: Vector2;
  50765. /**
  50766. * Allows the camera to be completely reversed.
  50767. * If false the camera can not arrive upside down.
  50768. */
  50769. allowUpsideDown: boolean;
  50770. /**
  50771. * Define if double tap/click is used to restore the previously saved state of the camera.
  50772. */
  50773. useInputToRestoreState: boolean;
  50774. /** @hidden */
  50775. _viewMatrix: Matrix;
  50776. /** @hidden */
  50777. _useCtrlForPanning: boolean;
  50778. /** @hidden */
  50779. _panningMouseButton: number;
  50780. /**
  50781. * Defines the input associated to the camera.
  50782. */
  50783. inputs: ArcRotateCameraInputsManager;
  50784. /** @hidden */
  50785. _reset: () => void;
  50786. /**
  50787. * Defines the allowed panning axis.
  50788. */
  50789. panningAxis: Vector3;
  50790. protected _transformedDirection: Vector3;
  50791. private _bouncingBehavior;
  50792. /**
  50793. * Gets the bouncing behavior of the camera if it has been enabled.
  50794. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  50795. */
  50796. get bouncingBehavior(): Nullable<BouncingBehavior>;
  50797. /**
  50798. * Defines if the bouncing behavior of the camera is enabled on the camera.
  50799. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  50800. */
  50801. get useBouncingBehavior(): boolean;
  50802. set useBouncingBehavior(value: boolean);
  50803. private _framingBehavior;
  50804. /**
  50805. * Gets the framing behavior of the camera if it has been enabled.
  50806. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  50807. */
  50808. get framingBehavior(): Nullable<FramingBehavior>;
  50809. /**
  50810. * Defines if the framing behavior of the camera is enabled on the camera.
  50811. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  50812. */
  50813. get useFramingBehavior(): boolean;
  50814. set useFramingBehavior(value: boolean);
  50815. private _autoRotationBehavior;
  50816. /**
  50817. * Gets the auto rotation behavior of the camera if it has been enabled.
  50818. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  50819. */
  50820. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  50821. /**
  50822. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  50823. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  50824. */
  50825. get useAutoRotationBehavior(): boolean;
  50826. set useAutoRotationBehavior(value: boolean);
  50827. /**
  50828. * Observable triggered when the mesh target has been changed on the camera.
  50829. */
  50830. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  50831. /**
  50832. * Event raised when the camera is colliding with a mesh.
  50833. */
  50834. onCollide: (collidedMesh: AbstractMesh) => void;
  50835. /**
  50836. * Defines whether the camera should check collision with the objects oh the scene.
  50837. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  50838. */
  50839. checkCollisions: boolean;
  50840. /**
  50841. * Defines the collision radius of the camera.
  50842. * This simulates a sphere around the camera.
  50843. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  50844. */
  50845. collisionRadius: Vector3;
  50846. protected _collider: Collider;
  50847. protected _previousPosition: Vector3;
  50848. protected _collisionVelocity: Vector3;
  50849. protected _newPosition: Vector3;
  50850. protected _previousAlpha: number;
  50851. protected _previousBeta: number;
  50852. protected _previousRadius: number;
  50853. protected _collisionTriggered: boolean;
  50854. protected _targetBoundingCenter: Nullable<Vector3>;
  50855. private _computationVector;
  50856. /**
  50857. * Instantiates a new ArcRotateCamera in a given scene
  50858. * @param name Defines the name of the camera
  50859. * @param alpha Defines the camera rotation along the longitudinal axis
  50860. * @param beta Defines the camera rotation along the latitudinal axis
  50861. * @param radius Defines the camera distance from its target
  50862. * @param target Defines the camera target
  50863. * @param scene Defines the scene the camera belongs to
  50864. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active if not other active cameras have been defined
  50865. */
  50866. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  50867. /** @hidden */
  50868. _initCache(): void;
  50869. /** @hidden */
  50870. _updateCache(ignoreParentClass?: boolean): void;
  50871. protected _getTargetPosition(): Vector3;
  50872. private _storedAlpha;
  50873. private _storedBeta;
  50874. private _storedRadius;
  50875. private _storedTarget;
  50876. private _storedTargetScreenOffset;
  50877. /**
  50878. * Stores the current state of the camera (alpha, beta, radius and target)
  50879. * @returns the camera itself
  50880. */
  50881. storeState(): Camera;
  50882. /**
  50883. * @hidden
  50884. * Restored camera state. You must call storeState() first
  50885. */
  50886. _restoreStateValues(): boolean;
  50887. /** @hidden */
  50888. _isSynchronizedViewMatrix(): boolean;
  50889. /**
  50890. * Attach the input controls to a specific dom element to get the input from.
  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(noPreventDefault?: boolean): void;
  50894. /**
  50895. * Attach the input controls to a specific dom element to get the input from.
  50896. * @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
  50897. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50898. */
  50899. attachControl(ignored: any, noPreventDefault?: boolean): void;
  50900. /**
  50901. * Attached controls to the current camera.
  50902. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50903. * @param useCtrlForPanning Defines whether ctrl is used for panning within the controls
  50904. */
  50905. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  50906. /**
  50907. * Attached controls to the current camera.
  50908. * @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
  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. */
  50912. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  50913. /**
  50914. * Attached controls to the current camera.
  50915. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50916. * @param useCtrlForPanning Defines whether ctrl is used for panning within the controls
  50917. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  50918. */
  50919. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  50920. /**
  50921. * Detach the current controls from the specified dom element.
  50922. */
  50923. detachControl(): void;
  50924. /**
  50925. * Detach the current controls from the specified dom element.
  50926. * @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
  50927. */
  50928. detachControl(ignored: any): void;
  50929. /** @hidden */
  50930. _checkInputs(): void;
  50931. protected _checkLimits(): void;
  50932. /**
  50933. * Rebuilds angles (alpha, beta) and radius from the give position and target
  50934. */
  50935. rebuildAnglesAndRadius(): void;
  50936. /**
  50937. * Use a position to define the current camera related information like alpha, beta and radius
  50938. * @param position Defines the position to set the camera at
  50939. */
  50940. setPosition(position: Vector3): void;
  50941. /**
  50942. * Defines the target the camera should look at.
  50943. * This will automatically adapt alpha beta and radius to fit within the new target.
  50944. * @param target Defines the new target as a Vector or a mesh
  50945. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  50946. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  50947. */
  50948. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  50949. /** @hidden */
  50950. _getViewMatrix(): Matrix;
  50951. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  50952. /**
  50953. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  50954. * @param meshes Defines the mesh to zoom on
  50955. * @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)
  50956. */
  50957. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  50958. /**
  50959. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  50960. * The target will be changed but the radius
  50961. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  50962. * @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)
  50963. */
  50964. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  50965. min: Vector3;
  50966. max: Vector3;
  50967. distance: number;
  50968. }, doNotUpdateMaxZ?: boolean): void;
  50969. /**
  50970. * @override
  50971. * Override Camera.createRigCamera
  50972. */
  50973. createRigCamera(name: string, cameraIndex: number): Camera;
  50974. /**
  50975. * @hidden
  50976. * @override
  50977. * Override Camera._updateRigCameras
  50978. */
  50979. _updateRigCameras(): void;
  50980. /**
  50981. * Destroy the camera and release the current resources hold by it.
  50982. */
  50983. dispose(): void;
  50984. /**
  50985. * Gets the current object class name.
  50986. * @return the class name
  50987. */
  50988. getClassName(): string;
  50989. }
  50990. }
  50991. declare module BABYLON {
  50992. /**
  50993. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  50994. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  50995. */
  50996. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  50997. /**
  50998. * Gets the name of the behavior.
  50999. */
  51000. get name(): string;
  51001. private _zoomStopsAnimation;
  51002. private _idleRotationSpeed;
  51003. private _idleRotationWaitTime;
  51004. private _idleRotationSpinupTime;
  51005. /**
  51006. * Sets the flag that indicates if user zooming should stop animation.
  51007. */
  51008. set zoomStopsAnimation(flag: boolean);
  51009. /**
  51010. * Gets the flag that indicates if user zooming should stop animation.
  51011. */
  51012. get zoomStopsAnimation(): boolean;
  51013. /**
  51014. * Sets the default speed at which the camera rotates around the model.
  51015. */
  51016. set idleRotationSpeed(speed: number);
  51017. /**
  51018. * Gets the default speed at which the camera rotates around the model.
  51019. */
  51020. get idleRotationSpeed(): number;
  51021. /**
  51022. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  51023. */
  51024. set idleRotationWaitTime(time: number);
  51025. /**
  51026. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  51027. */
  51028. get idleRotationWaitTime(): number;
  51029. /**
  51030. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  51031. */
  51032. set idleRotationSpinupTime(time: number);
  51033. /**
  51034. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  51035. */
  51036. get idleRotationSpinupTime(): number;
  51037. /**
  51038. * Gets a value indicating if the camera is currently rotating because of this behavior
  51039. */
  51040. get rotationInProgress(): boolean;
  51041. private _onPrePointerObservableObserver;
  51042. private _onAfterCheckInputsObserver;
  51043. private _attachedCamera;
  51044. private _isPointerDown;
  51045. private _lastFrameTime;
  51046. private _lastInteractionTime;
  51047. private _cameraRotationSpeed;
  51048. /**
  51049. * Initializes the behavior.
  51050. */
  51051. init(): void;
  51052. /**
  51053. * Attaches the behavior to its arc rotate camera.
  51054. * @param camera Defines the camera to attach the behavior to
  51055. */
  51056. attach(camera: ArcRotateCamera): void;
  51057. /**
  51058. * Detaches the behavior from its current arc rotate camera.
  51059. */
  51060. detach(): void;
  51061. /**
  51062. * Returns true if user is scrolling.
  51063. * @return true if user is scrolling.
  51064. */
  51065. private _userIsZooming;
  51066. private _lastFrameRadius;
  51067. private _shouldAnimationStopForInteraction;
  51068. /**
  51069. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  51070. */
  51071. private _applyUserInteraction;
  51072. private _userIsMoving;
  51073. }
  51074. }
  51075. declare module BABYLON {
  51076. /**
  51077. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  51078. */
  51079. export class AttachToBoxBehavior implements Behavior<Mesh> {
  51080. private ui;
  51081. /**
  51082. * The name of the behavior
  51083. */
  51084. name: string;
  51085. /**
  51086. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  51087. */
  51088. distanceAwayFromFace: number;
  51089. /**
  51090. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  51091. */
  51092. distanceAwayFromBottomOfFace: number;
  51093. private _faceVectors;
  51094. private _target;
  51095. private _scene;
  51096. private _onRenderObserver;
  51097. private _tmpMatrix;
  51098. private _tmpVector;
  51099. /**
  51100. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  51101. * @param ui The transform node that should be attached to the mesh
  51102. */
  51103. constructor(ui: TransformNode);
  51104. /**
  51105. * Initializes the behavior
  51106. */
  51107. init(): void;
  51108. private _closestFace;
  51109. private _zeroVector;
  51110. private _lookAtTmpMatrix;
  51111. private _lookAtToRef;
  51112. /**
  51113. * Attaches the AttachToBoxBehavior to the passed in mesh
  51114. * @param target The mesh that the specified node will be attached to
  51115. */
  51116. attach(target: Mesh): void;
  51117. /**
  51118. * Detaches the behavior from the mesh
  51119. */
  51120. detach(): void;
  51121. }
  51122. }
  51123. declare module BABYLON {
  51124. /**
  51125. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  51126. */
  51127. export class FadeInOutBehavior implements Behavior<Mesh> {
  51128. /**
  51129. * Time in milliseconds to delay before fading in (Default: 0)
  51130. */
  51131. delay: number;
  51132. /**
  51133. * Time in milliseconds for the mesh to fade in (Default: 300)
  51134. */
  51135. fadeInTime: number;
  51136. private _millisecondsPerFrame;
  51137. private _hovered;
  51138. private _hoverValue;
  51139. private _ownerNode;
  51140. /**
  51141. * Instantiates the FadeInOutBehavior
  51142. */
  51143. constructor();
  51144. /**
  51145. * The name of the behavior
  51146. */
  51147. get name(): string;
  51148. /**
  51149. * Initializes the behavior
  51150. */
  51151. init(): void;
  51152. /**
  51153. * Attaches the fade behavior on the passed in mesh
  51154. * @param ownerNode The mesh that will be faded in/out once attached
  51155. */
  51156. attach(ownerNode: Mesh): void;
  51157. /**
  51158. * Detaches the behavior from the mesh
  51159. */
  51160. detach(): void;
  51161. /**
  51162. * Triggers the mesh to begin fading in or out
  51163. * @param value if the object should fade in or out (true to fade in)
  51164. */
  51165. fadeIn(value: boolean): void;
  51166. private _update;
  51167. private _setAllVisibility;
  51168. }
  51169. }
  51170. declare module BABYLON {
  51171. /**
  51172. * Class containing a set of static utilities functions for managing Pivots
  51173. * @hidden
  51174. */
  51175. export class PivotTools {
  51176. private static _PivotCached;
  51177. private static _OldPivotPoint;
  51178. private static _PivotTranslation;
  51179. private static _PivotTmpVector;
  51180. private static _PivotPostMultiplyPivotMatrix;
  51181. /** @hidden */
  51182. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  51183. /** @hidden */
  51184. static _RestorePivotPoint(mesh: AbstractMesh): void;
  51185. }
  51186. }
  51187. declare module BABYLON {
  51188. /**
  51189. * Class containing static functions to help procedurally build meshes
  51190. */
  51191. export class PlaneBuilder {
  51192. /**
  51193. * Creates a plane mesh
  51194. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  51195. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  51196. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  51197. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51198. * * 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
  51199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51200. * @param name defines the name of the mesh
  51201. * @param options defines the options used to create the mesh
  51202. * @param scene defines the hosting scene
  51203. * @returns the plane mesh
  51204. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  51205. */
  51206. static CreatePlane(name: string, options: {
  51207. size?: number;
  51208. width?: number;
  51209. height?: number;
  51210. sideOrientation?: number;
  51211. frontUVs?: Vector4;
  51212. backUVs?: Vector4;
  51213. updatable?: boolean;
  51214. sourcePlane?: Plane;
  51215. }, scene?: Nullable<Scene>): Mesh;
  51216. }
  51217. }
  51218. declare module BABYLON {
  51219. /**
  51220. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  51221. */
  51222. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  51223. private static _AnyMouseID;
  51224. /**
  51225. * Abstract mesh the behavior is set on
  51226. */
  51227. attachedNode: AbstractMesh;
  51228. private _dragPlane;
  51229. private _scene;
  51230. private _pointerObserver;
  51231. private _beforeRenderObserver;
  51232. private static _planeScene;
  51233. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  51234. /**
  51235. * 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)
  51236. */
  51237. maxDragAngle: number;
  51238. /**
  51239. * @hidden
  51240. */
  51241. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  51242. /**
  51243. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  51244. */
  51245. currentDraggingPointerID: number;
  51246. /**
  51247. * The last position where the pointer hit the drag plane in world space
  51248. */
  51249. lastDragPosition: Vector3;
  51250. /**
  51251. * If the behavior is currently in a dragging state
  51252. */
  51253. dragging: boolean;
  51254. /**
  51255. * 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)
  51256. */
  51257. dragDeltaRatio: number;
  51258. /**
  51259. * If the drag plane orientation should be updated during the dragging (Default: true)
  51260. */
  51261. updateDragPlane: boolean;
  51262. private _debugMode;
  51263. private _moving;
  51264. /**
  51265. * Fires each time the attached mesh is dragged with the pointer
  51266. * * delta between last drag position and current drag position in world space
  51267. * * dragDistance along the drag axis
  51268. * * dragPlaneNormal normal of the current drag plane used during the drag
  51269. * * dragPlanePoint in world space where the drag intersects the drag plane
  51270. */
  51271. onDragObservable: Observable<{
  51272. delta: Vector3;
  51273. dragPlanePoint: Vector3;
  51274. dragPlaneNormal: Vector3;
  51275. dragDistance: number;
  51276. pointerId: number;
  51277. }>;
  51278. /**
  51279. * Fires each time a drag begins (eg. mouse down on mesh)
  51280. */
  51281. onDragStartObservable: Observable<{
  51282. dragPlanePoint: Vector3;
  51283. pointerId: number;
  51284. }>;
  51285. /**
  51286. * Fires each time a drag ends (eg. mouse release after drag)
  51287. */
  51288. onDragEndObservable: Observable<{
  51289. dragPlanePoint: Vector3;
  51290. pointerId: number;
  51291. }>;
  51292. /**
  51293. * If the attached mesh should be moved when dragged
  51294. */
  51295. moveAttached: boolean;
  51296. /**
  51297. * If the drag behavior will react to drag events (Default: true)
  51298. */
  51299. enabled: boolean;
  51300. /**
  51301. * If pointer events should start and release the drag (Default: true)
  51302. */
  51303. startAndReleaseDragOnPointerEvents: boolean;
  51304. /**
  51305. * If camera controls should be detached during the drag
  51306. */
  51307. detachCameraControls: boolean;
  51308. /**
  51309. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  51310. */
  51311. useObjectOrientationForDragging: boolean;
  51312. private _options;
  51313. /**
  51314. * Gets the options used by the behavior
  51315. */
  51316. get options(): {
  51317. dragAxis?: Vector3;
  51318. dragPlaneNormal?: Vector3;
  51319. };
  51320. /**
  51321. * Sets the options used by the behavior
  51322. */
  51323. set options(options: {
  51324. dragAxis?: Vector3;
  51325. dragPlaneNormal?: Vector3;
  51326. });
  51327. /**
  51328. * Creates a pointer drag behavior that can be attached to a mesh
  51329. * @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)
  51330. */
  51331. constructor(options?: {
  51332. dragAxis?: Vector3;
  51333. dragPlaneNormal?: Vector3;
  51334. });
  51335. /**
  51336. * Predicate to determine if it is valid to move the object to a new position when it is moved
  51337. */
  51338. validateDrag: (targetPosition: Vector3) => boolean;
  51339. /**
  51340. * The name of the behavior
  51341. */
  51342. get name(): string;
  51343. /**
  51344. * Initializes the behavior
  51345. */
  51346. init(): void;
  51347. private _tmpVector;
  51348. private _alternatePickedPoint;
  51349. private _worldDragAxis;
  51350. private _targetPosition;
  51351. private _attachedToElement;
  51352. /**
  51353. * Attaches the drag behavior the passed in mesh
  51354. * @param ownerNode The mesh that will be dragged around once attached
  51355. * @param predicate Predicate to use for pick filtering
  51356. */
  51357. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  51358. /**
  51359. * Force release the drag action by code.
  51360. */
  51361. releaseDrag(): void;
  51362. private _startDragRay;
  51363. private _lastPointerRay;
  51364. /**
  51365. * Simulates the start of a pointer drag event on the behavior
  51366. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  51367. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  51368. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  51369. */
  51370. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  51371. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  51372. private _dragDelta;
  51373. protected _moveDrag(ray: Ray): void;
  51374. private _pickWithRayOnDragPlane;
  51375. private _pointA;
  51376. private _pointC;
  51377. private _localAxis;
  51378. private _lookAt;
  51379. private _updateDragPlanePosition;
  51380. /**
  51381. * Detaches the behavior from the mesh
  51382. */
  51383. detach(): void;
  51384. }
  51385. }
  51386. declare module BABYLON {
  51387. /**
  51388. * A behavior that when attached to a mesh will allow the mesh to be scaled
  51389. */
  51390. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  51391. private _dragBehaviorA;
  51392. private _dragBehaviorB;
  51393. private _startDistance;
  51394. private _initialScale;
  51395. private _targetScale;
  51396. private _ownerNode;
  51397. private _sceneRenderObserver;
  51398. /**
  51399. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  51400. */
  51401. constructor();
  51402. /**
  51403. * The name of the behavior
  51404. */
  51405. get name(): string;
  51406. /**
  51407. * Initializes the behavior
  51408. */
  51409. init(): void;
  51410. private _getCurrentDistance;
  51411. /**
  51412. * Attaches the scale behavior the passed in mesh
  51413. * @param ownerNode The mesh that will be scaled around once attached
  51414. */
  51415. attach(ownerNode: Mesh): void;
  51416. /**
  51417. * Detaches the behavior from the mesh
  51418. */
  51419. detach(): void;
  51420. }
  51421. }
  51422. declare module BABYLON {
  51423. /**
  51424. * 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
  51425. */
  51426. export class SixDofDragBehavior implements Behavior<Mesh> {
  51427. private static _virtualScene;
  51428. private _ownerNode;
  51429. private _sceneRenderObserver;
  51430. private _scene;
  51431. private _targetPosition;
  51432. private _virtualOriginMesh;
  51433. private _virtualDragMesh;
  51434. private _pointerObserver;
  51435. private _moving;
  51436. private _startingOrientation;
  51437. private _attachedToElement;
  51438. /**
  51439. * 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)
  51440. */
  51441. private zDragFactor;
  51442. /**
  51443. * If the object should rotate to face the drag origin
  51444. */
  51445. rotateDraggedObject: boolean;
  51446. /**
  51447. * If the behavior is currently in a dragging state
  51448. */
  51449. dragging: boolean;
  51450. /**
  51451. * 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)
  51452. */
  51453. dragDeltaRatio: number;
  51454. /**
  51455. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  51456. */
  51457. currentDraggingPointerID: number;
  51458. /**
  51459. * If camera controls should be detached during the drag
  51460. */
  51461. detachCameraControls: boolean;
  51462. /**
  51463. * Fires each time a drag starts
  51464. */
  51465. onDragStartObservable: Observable<{}>;
  51466. /**
  51467. * Fires each time a drag happens
  51468. */
  51469. onDragObservable: Observable<void>;
  51470. /**
  51471. * Fires each time a drag ends (eg. mouse release after drag)
  51472. */
  51473. onDragEndObservable: Observable<{}>;
  51474. /**
  51475. * 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
  51476. */
  51477. constructor();
  51478. /**
  51479. * The name of the behavior
  51480. */
  51481. get name(): string;
  51482. /**
  51483. * Initializes the behavior
  51484. */
  51485. init(): void;
  51486. /**
  51487. * In the case of multiple active cameras, the cameraToUseForPointers should be used if set instead of active camera
  51488. */
  51489. private get _pointerCamera();
  51490. /**
  51491. * Attaches the scale behavior the passed in mesh
  51492. * @param ownerNode The mesh that will be scaled around once attached
  51493. */
  51494. attach(ownerNode: Mesh): void;
  51495. /**
  51496. * Detaches the behavior from the mesh
  51497. */
  51498. detach(): void;
  51499. }
  51500. }
  51501. declare module BABYLON {
  51502. /**
  51503. * Class used to apply inverse kinematics to bones
  51504. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  51505. */
  51506. export class BoneIKController {
  51507. private static _tmpVecs;
  51508. private static _tmpQuat;
  51509. private static _tmpMats;
  51510. /**
  51511. * Gets or sets the target mesh
  51512. */
  51513. targetMesh: AbstractMesh;
  51514. /** Gets or sets the mesh used as pole */
  51515. poleTargetMesh: AbstractMesh;
  51516. /**
  51517. * Gets or sets the bone used as pole
  51518. */
  51519. poleTargetBone: Nullable<Bone>;
  51520. /**
  51521. * Gets or sets the target position
  51522. */
  51523. targetPosition: Vector3;
  51524. /**
  51525. * Gets or sets the pole target position
  51526. */
  51527. poleTargetPosition: Vector3;
  51528. /**
  51529. * Gets or sets the pole target local offset
  51530. */
  51531. poleTargetLocalOffset: Vector3;
  51532. /**
  51533. * Gets or sets the pole angle
  51534. */
  51535. poleAngle: number;
  51536. /**
  51537. * Gets or sets the mesh associated with the controller
  51538. */
  51539. mesh: AbstractMesh;
  51540. /**
  51541. * 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)
  51542. */
  51543. slerpAmount: number;
  51544. private _bone1Quat;
  51545. private _bone1Mat;
  51546. private _bone2Ang;
  51547. private _bone1;
  51548. private _bone2;
  51549. private _bone1Length;
  51550. private _bone2Length;
  51551. private _maxAngle;
  51552. private _maxReach;
  51553. private _rightHandedSystem;
  51554. private _bendAxis;
  51555. private _slerping;
  51556. private _adjustRoll;
  51557. /**
  51558. * Gets or sets maximum allowed angle
  51559. */
  51560. get maxAngle(): number;
  51561. set maxAngle(value: number);
  51562. /**
  51563. * Creates a new BoneIKController
  51564. * @param mesh defines the mesh to control
  51565. * @param bone defines the bone to control
  51566. * @param options defines options to set up the controller
  51567. */
  51568. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  51569. targetMesh?: AbstractMesh;
  51570. poleTargetMesh?: AbstractMesh;
  51571. poleTargetBone?: Bone;
  51572. poleTargetLocalOffset?: Vector3;
  51573. poleAngle?: number;
  51574. bendAxis?: Vector3;
  51575. maxAngle?: number;
  51576. slerpAmount?: number;
  51577. });
  51578. private _setMaxAngle;
  51579. /**
  51580. * Force the controller to update the bones
  51581. */
  51582. update(): void;
  51583. }
  51584. }
  51585. declare module BABYLON {
  51586. /**
  51587. * Class used to make a bone look toward a point in space
  51588. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  51589. */
  51590. export class BoneLookController {
  51591. private static _tmpVecs;
  51592. private static _tmpQuat;
  51593. private static _tmpMats;
  51594. /**
  51595. * The target Vector3 that the bone will look at
  51596. */
  51597. target: Vector3;
  51598. /**
  51599. * The mesh that the bone is attached to
  51600. */
  51601. mesh: AbstractMesh;
  51602. /**
  51603. * The bone that will be looking to the target
  51604. */
  51605. bone: Bone;
  51606. /**
  51607. * The up axis of the coordinate system that is used when the bone is rotated
  51608. */
  51609. upAxis: Vector3;
  51610. /**
  51611. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  51612. */
  51613. upAxisSpace: Space;
  51614. /**
  51615. * Used to make an adjustment to the yaw of the bone
  51616. */
  51617. adjustYaw: number;
  51618. /**
  51619. * Used to make an adjustment to the pitch of the bone
  51620. */
  51621. adjustPitch: number;
  51622. /**
  51623. * Used to make an adjustment to the roll of the bone
  51624. */
  51625. adjustRoll: number;
  51626. /**
  51627. * 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)
  51628. */
  51629. slerpAmount: number;
  51630. private _minYaw;
  51631. private _maxYaw;
  51632. private _minPitch;
  51633. private _maxPitch;
  51634. private _minYawSin;
  51635. private _minYawCos;
  51636. private _maxYawSin;
  51637. private _maxYawCos;
  51638. private _midYawConstraint;
  51639. private _minPitchTan;
  51640. private _maxPitchTan;
  51641. private _boneQuat;
  51642. private _slerping;
  51643. private _transformYawPitch;
  51644. private _transformYawPitchInv;
  51645. private _firstFrameSkipped;
  51646. private _yawRange;
  51647. private _fowardAxis;
  51648. /**
  51649. * Gets or sets the minimum yaw angle that the bone can look to
  51650. */
  51651. get minYaw(): number;
  51652. set minYaw(value: number);
  51653. /**
  51654. * Gets or sets the maximum yaw angle that the bone can look to
  51655. */
  51656. get maxYaw(): number;
  51657. set maxYaw(value: number);
  51658. /**
  51659. * Gets or sets the minimum pitch angle that the bone can look to
  51660. */
  51661. get minPitch(): number;
  51662. set minPitch(value: number);
  51663. /**
  51664. * Gets or sets the maximum pitch angle that the bone can look to
  51665. */
  51666. get maxPitch(): number;
  51667. set maxPitch(value: number);
  51668. /**
  51669. * Create a BoneLookController
  51670. * @param mesh the mesh that the bone belongs to
  51671. * @param bone the bone that will be looking to the target
  51672. * @param target the target Vector3 to look at
  51673. * @param options optional settings:
  51674. * * maxYaw: the maximum angle the bone will yaw to
  51675. * * minYaw: the minimum angle the bone will yaw to
  51676. * * maxPitch: the maximum angle the bone will pitch to
  51677. * * minPitch: the minimum angle the bone will yaw to
  51678. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  51679. * * upAxis: the up axis of the coordinate system
  51680. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  51681. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  51682. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  51683. * * adjustYaw: used to make an adjustment to the yaw of the bone
  51684. * * adjustPitch: used to make an adjustment to the pitch of the bone
  51685. * * adjustRoll: used to make an adjustment to the roll of the bone
  51686. **/
  51687. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  51688. maxYaw?: number;
  51689. minYaw?: number;
  51690. maxPitch?: number;
  51691. minPitch?: number;
  51692. slerpAmount?: number;
  51693. upAxis?: Vector3;
  51694. upAxisSpace?: Space;
  51695. yawAxis?: Vector3;
  51696. pitchAxis?: Vector3;
  51697. adjustYaw?: number;
  51698. adjustPitch?: number;
  51699. adjustRoll?: number;
  51700. });
  51701. /**
  51702. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  51703. */
  51704. update(): void;
  51705. private _getAngleDiff;
  51706. private _getAngleBetween;
  51707. private _isAngleBetween;
  51708. }
  51709. }
  51710. declare module BABYLON {
  51711. /**
  51712. * Manage the gamepad inputs to control an arc rotate camera.
  51713. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51714. */
  51715. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  51716. /**
  51717. * Defines the camera the input is attached to.
  51718. */
  51719. camera: ArcRotateCamera;
  51720. /**
  51721. * Defines the gamepad the input is gathering event from.
  51722. */
  51723. gamepad: Nullable<Gamepad>;
  51724. /**
  51725. * Defines the gamepad rotation sensiblity.
  51726. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  51727. */
  51728. gamepadRotationSensibility: number;
  51729. /**
  51730. * Defines the gamepad move sensiblity.
  51731. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  51732. */
  51733. gamepadMoveSensibility: number;
  51734. private _yAxisScale;
  51735. /**
  51736. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  51737. */
  51738. get invertYAxis(): boolean;
  51739. set invertYAxis(value: boolean);
  51740. private _onGamepadConnectedObserver;
  51741. private _onGamepadDisconnectedObserver;
  51742. /**
  51743. * Attach the input controls to a specific dom element to get the input from.
  51744. */
  51745. attachControl(): void;
  51746. /**
  51747. * Detach the current controls from the specified dom element.
  51748. */
  51749. detachControl(): void;
  51750. /**
  51751. * Update the current camera state depending on the inputs that have been used this frame.
  51752. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51753. */
  51754. checkInputs(): void;
  51755. /**
  51756. * Gets the class name of the current intput.
  51757. * @returns the class name
  51758. */
  51759. getClassName(): string;
  51760. /**
  51761. * Get the friendly name associated with the input class.
  51762. * @returns the input friendly name
  51763. */
  51764. getSimpleName(): string;
  51765. }
  51766. }
  51767. declare module BABYLON {
  51768. interface ArcRotateCameraInputsManager {
  51769. /**
  51770. * Add orientation input support to the input manager.
  51771. * @returns the current input manager
  51772. */
  51773. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  51774. }
  51775. /**
  51776. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  51777. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51778. */
  51779. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  51780. /**
  51781. * Defines the camera the input is attached to.
  51782. */
  51783. camera: ArcRotateCamera;
  51784. /**
  51785. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  51786. */
  51787. alphaCorrection: number;
  51788. /**
  51789. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  51790. */
  51791. gammaCorrection: number;
  51792. private _alpha;
  51793. private _gamma;
  51794. private _dirty;
  51795. private _deviceOrientationHandler;
  51796. /**
  51797. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  51798. */
  51799. constructor();
  51800. /**
  51801. * Attach the input controls to a specific dom element to get the input from.
  51802. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51803. */
  51804. attachControl(noPreventDefault?: boolean): void;
  51805. /** @hidden */
  51806. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  51807. /**
  51808. * Update the current camera state depending on the inputs that have been used this frame.
  51809. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51810. */
  51811. checkInputs(): void;
  51812. /**
  51813. * Detach the current controls from the specified dom element.
  51814. */
  51815. detachControl(): void;
  51816. /**
  51817. * Gets the class name of the current input.
  51818. * @returns the class name
  51819. */
  51820. getClassName(): string;
  51821. /**
  51822. * Get the friendly name associated with the input class.
  51823. * @returns the input friendly name
  51824. */
  51825. getSimpleName(): string;
  51826. }
  51827. }
  51828. declare module BABYLON {
  51829. /**
  51830. * Listen to mouse events to control the camera.
  51831. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51832. */
  51833. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  51834. /**
  51835. * Defines the camera the input is attached to.
  51836. */
  51837. camera: FlyCamera;
  51838. /**
  51839. * Defines if touch is enabled. (Default is true.)
  51840. */
  51841. touchEnabled: boolean;
  51842. /**
  51843. * Defines the buttons associated with the input to handle camera rotation.
  51844. */
  51845. buttons: number[];
  51846. /**
  51847. * Assign buttons for Yaw control.
  51848. */
  51849. buttonsYaw: number[];
  51850. /**
  51851. * Assign buttons for Pitch control.
  51852. */
  51853. buttonsPitch: number[];
  51854. /**
  51855. * Assign buttons for Roll control.
  51856. */
  51857. buttonsRoll: number[];
  51858. /**
  51859. * Detect if any button is being pressed while mouse is moved.
  51860. * -1 = Mouse locked.
  51861. * 0 = Left button.
  51862. * 1 = Middle Button.
  51863. * 2 = Right Button.
  51864. */
  51865. activeButton: number;
  51866. /**
  51867. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  51868. * Higher values reduce its sensitivity.
  51869. */
  51870. angularSensibility: number;
  51871. private _observer;
  51872. private _rollObserver;
  51873. private previousPosition;
  51874. private noPreventDefault;
  51875. private element;
  51876. /**
  51877. * Listen to mouse events to control the camera.
  51878. * @param touchEnabled Define if touch is enabled. (Default is true.)
  51879. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51880. */
  51881. constructor(touchEnabled?: boolean);
  51882. /**
  51883. * Attach the mouse control to the HTML DOM element.
  51884. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  51885. */
  51886. attachControl(noPreventDefault?: boolean): void;
  51887. /**
  51888. * Detach the current controls from the specified dom element.
  51889. */
  51890. detachControl(): void;
  51891. /**
  51892. * Gets the class name of the current input.
  51893. * @returns the class name.
  51894. */
  51895. getClassName(): string;
  51896. /**
  51897. * Get the friendly name associated with the input class.
  51898. * @returns the input's friendly name.
  51899. */
  51900. getSimpleName(): string;
  51901. private _pointerInput;
  51902. private _onMouseMove;
  51903. /**
  51904. * Rotate camera by mouse offset.
  51905. */
  51906. private rotateCamera;
  51907. }
  51908. }
  51909. declare module BABYLON {
  51910. /**
  51911. * Default Inputs manager for the FlyCamera.
  51912. * It groups all the default supported inputs for ease of use.
  51913. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51914. */
  51915. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  51916. /**
  51917. * Instantiates a new FlyCameraInputsManager.
  51918. * @param camera Defines the camera the inputs belong to.
  51919. */
  51920. constructor(camera: FlyCamera);
  51921. /**
  51922. * Add keyboard input support to the input manager.
  51923. * @returns the new FlyCameraKeyboardMoveInput().
  51924. */
  51925. addKeyboard(): FlyCameraInputsManager;
  51926. /**
  51927. * Add mouse input support to the input manager.
  51928. * @param touchEnabled Enable touch screen support.
  51929. * @returns the new FlyCameraMouseInput().
  51930. */
  51931. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  51932. }
  51933. }
  51934. declare module BABYLON {
  51935. /**
  51936. * This is a flying camera, designed for 3D movement and rotation in all directions,
  51937. * such as in a 3D Space Shooter or a Flight Simulator.
  51938. */
  51939. export class FlyCamera extends TargetCamera {
  51940. /**
  51941. * Define the collision ellipsoid of the camera.
  51942. * This is helpful for simulating a camera body, like a player's body.
  51943. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  51944. */
  51945. ellipsoid: Vector3;
  51946. /**
  51947. * Define an offset for the position of the ellipsoid around the camera.
  51948. * This can be helpful if the camera is attached away from the player's body center,
  51949. * such as at its head.
  51950. */
  51951. ellipsoidOffset: Vector3;
  51952. /**
  51953. * Enable or disable collisions of the camera with the rest of the scene objects.
  51954. */
  51955. checkCollisions: boolean;
  51956. /**
  51957. * Enable or disable gravity on the camera.
  51958. */
  51959. applyGravity: boolean;
  51960. /**
  51961. * Define the current direction the camera is moving to.
  51962. */
  51963. cameraDirection: Vector3;
  51964. /**
  51965. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  51966. * This overrides and empties cameraRotation.
  51967. */
  51968. rotationQuaternion: Quaternion;
  51969. /**
  51970. * Track Roll to maintain the wanted Rolling when looking around.
  51971. */
  51972. _trackRoll: number;
  51973. /**
  51974. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  51975. */
  51976. rollCorrect: number;
  51977. /**
  51978. * Mimic a banked turn, Rolling the camera when Yawing.
  51979. * It's recommended to use rollCorrect = 10 for faster banking correction.
  51980. */
  51981. bankedTurn: boolean;
  51982. /**
  51983. * Limit in radians for how much Roll banking will add. (Default: 90°)
  51984. */
  51985. bankedTurnLimit: number;
  51986. /**
  51987. * Value of 0 disables the banked Roll.
  51988. * Value of 1 is equal to the Yaw angle in radians.
  51989. */
  51990. bankedTurnMultiplier: number;
  51991. /**
  51992. * The inputs manager loads all the input sources, such as keyboard and mouse.
  51993. */
  51994. inputs: FlyCameraInputsManager;
  51995. /**
  51996. * Gets the input sensibility for mouse input.
  51997. * Higher values reduce sensitivity.
  51998. */
  51999. get angularSensibility(): number;
  52000. /**
  52001. * Sets the input sensibility for a mouse input.
  52002. * Higher values reduce sensitivity.
  52003. */
  52004. set angularSensibility(value: number);
  52005. /**
  52006. * Get the keys for camera movement forward.
  52007. */
  52008. get keysForward(): number[];
  52009. /**
  52010. * Set the keys for camera movement forward.
  52011. */
  52012. set keysForward(value: number[]);
  52013. /**
  52014. * Get the keys for camera movement backward.
  52015. */
  52016. get keysBackward(): number[];
  52017. set keysBackward(value: number[]);
  52018. /**
  52019. * Get the keys for camera movement up.
  52020. */
  52021. get keysUp(): number[];
  52022. /**
  52023. * Set the keys for camera movement up.
  52024. */
  52025. set keysUp(value: number[]);
  52026. /**
  52027. * Get the keys for camera movement down.
  52028. */
  52029. get keysDown(): number[];
  52030. /**
  52031. * Set the keys for camera movement down.
  52032. */
  52033. set keysDown(value: number[]);
  52034. /**
  52035. * Get the keys for camera movement left.
  52036. */
  52037. get keysLeft(): number[];
  52038. /**
  52039. * Set the keys for camera movement left.
  52040. */
  52041. set keysLeft(value: number[]);
  52042. /**
  52043. * Set the keys for camera movement right.
  52044. */
  52045. get keysRight(): number[];
  52046. /**
  52047. * Set the keys for camera movement right.
  52048. */
  52049. set keysRight(value: number[]);
  52050. /**
  52051. * Event raised when the camera collides with a mesh in the scene.
  52052. */
  52053. onCollide: (collidedMesh: AbstractMesh) => void;
  52054. private _collider;
  52055. private _needMoveForGravity;
  52056. private _oldPosition;
  52057. private _diffPosition;
  52058. private _newPosition;
  52059. /** @hidden */
  52060. _localDirection: Vector3;
  52061. /** @hidden */
  52062. _transformedDirection: Vector3;
  52063. /**
  52064. * Instantiates a FlyCamera.
  52065. * This is a flying camera, designed for 3D movement and rotation in all directions,
  52066. * such as in a 3D Space Shooter or a Flight Simulator.
  52067. * @param name Define the name of the camera in the scene.
  52068. * @param position Define the starting position of the camera in the scene.
  52069. * @param scene Define the scene the camera belongs to.
  52070. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active, if no other camera has been defined as active.
  52071. */
  52072. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  52073. /**
  52074. * Attach the input controls to a specific dom element to get the input from.
  52075. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  52076. */
  52077. attachControl(noPreventDefault?: boolean): void;
  52078. /**
  52079. * Detach a control from the HTML DOM element.
  52080. * The camera will stop reacting to that input.
  52081. */
  52082. detachControl(): void;
  52083. private _collisionMask;
  52084. /**
  52085. * Get the mask that the camera ignores in collision events.
  52086. */
  52087. get collisionMask(): number;
  52088. /**
  52089. * Set the mask that the camera ignores in collision events.
  52090. */
  52091. set collisionMask(mask: number);
  52092. /** @hidden */
  52093. _collideWithWorld(displacement: Vector3): void;
  52094. /** @hidden */
  52095. private _onCollisionPositionChange;
  52096. /** @hidden */
  52097. _checkInputs(): void;
  52098. /** @hidden */
  52099. _decideIfNeedsToMove(): boolean;
  52100. /** @hidden */
  52101. _updatePosition(): void;
  52102. /**
  52103. * Restore the Roll to its target value at the rate specified.
  52104. * @param rate - Higher means slower restoring.
  52105. * @hidden
  52106. */
  52107. restoreRoll(rate: number): void;
  52108. /**
  52109. * Destroy the camera and release the current resources held by it.
  52110. */
  52111. dispose(): void;
  52112. /**
  52113. * Get the current object class name.
  52114. * @returns the class name.
  52115. */
  52116. getClassName(): string;
  52117. }
  52118. }
  52119. declare module BABYLON {
  52120. /**
  52121. * Listen to keyboard events to control the camera.
  52122. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52123. */
  52124. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  52125. /**
  52126. * Defines the camera the input is attached to.
  52127. */
  52128. camera: FlyCamera;
  52129. /**
  52130. * The list of keyboard keys used to control the forward move of the camera.
  52131. */
  52132. keysForward: number[];
  52133. /**
  52134. * The list of keyboard keys used to control the backward move of the camera.
  52135. */
  52136. keysBackward: number[];
  52137. /**
  52138. * The list of keyboard keys used to control the forward move of the camera.
  52139. */
  52140. keysUp: number[];
  52141. /**
  52142. * The list of keyboard keys used to control the backward move of the camera.
  52143. */
  52144. keysDown: number[];
  52145. /**
  52146. * The list of keyboard keys used to control the right strafe move of the camera.
  52147. */
  52148. keysRight: number[];
  52149. /**
  52150. * The list of keyboard keys used to control the left strafe move of the camera.
  52151. */
  52152. keysLeft: number[];
  52153. private _keys;
  52154. private _onCanvasBlurObserver;
  52155. private _onKeyboardObserver;
  52156. private _engine;
  52157. private _scene;
  52158. /**
  52159. * Attach the input controls to a specific dom element to get the input from.
  52160. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  52161. */
  52162. attachControl(noPreventDefault?: boolean): void;
  52163. /**
  52164. * Detach the current controls from the specified dom element.
  52165. */
  52166. detachControl(): void;
  52167. /**
  52168. * Gets the class name of the current intput.
  52169. * @returns the class name
  52170. */
  52171. getClassName(): string;
  52172. /** @hidden */
  52173. _onLostFocus(e: FocusEvent): void;
  52174. /**
  52175. * Get the friendly name associated with the input class.
  52176. * @returns the input friendly name
  52177. */
  52178. getSimpleName(): string;
  52179. /**
  52180. * Update the current camera state depending on the inputs that have been used this frame.
  52181. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52182. */
  52183. checkInputs(): void;
  52184. }
  52185. }
  52186. declare module BABYLON {
  52187. /**
  52188. * Manage the mouse wheel inputs to control a follow camera.
  52189. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52190. */
  52191. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  52192. /**
  52193. * Defines the camera the input is attached to.
  52194. */
  52195. camera: FollowCamera;
  52196. /**
  52197. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  52198. */
  52199. axisControlRadius: boolean;
  52200. /**
  52201. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  52202. */
  52203. axisControlHeight: boolean;
  52204. /**
  52205. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  52206. */
  52207. axisControlRotation: boolean;
  52208. /**
  52209. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  52210. * relation to mouseWheel events.
  52211. */
  52212. wheelPrecision: number;
  52213. /**
  52214. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  52215. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  52216. */
  52217. wheelDeltaPercentage: number;
  52218. private _wheel;
  52219. private _observer;
  52220. /**
  52221. * Attach the input controls to a specific dom element to get the input from.
  52222. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  52223. */
  52224. attachControl(noPreventDefault?: boolean): void;
  52225. /**
  52226. * Detach the current controls from the specified dom element.
  52227. */
  52228. detachControl(): void;
  52229. /**
  52230. * Gets the class name of the current input.
  52231. * @returns the class name
  52232. */
  52233. getClassName(): string;
  52234. /**
  52235. * Get the friendly name associated with the input class.
  52236. * @returns the input friendly name
  52237. */
  52238. getSimpleName(): string;
  52239. }
  52240. }
  52241. declare module BABYLON {
  52242. /**
  52243. * Manage the pointers inputs to control an follow camera.
  52244. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52245. */
  52246. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  52247. /**
  52248. * Defines the camera the input is attached to.
  52249. */
  52250. camera: FollowCamera;
  52251. /**
  52252. * Gets the class name of the current input.
  52253. * @returns the class name
  52254. */
  52255. getClassName(): string;
  52256. /**
  52257. * Defines the pointer angular sensibility along the X axis or how fast is
  52258. * the camera rotating.
  52259. * A negative number will reverse the axis direction.
  52260. */
  52261. angularSensibilityX: number;
  52262. /**
  52263. * Defines the pointer angular sensibility along the Y axis or how fast is
  52264. * the camera rotating.
  52265. * A negative number will reverse the axis direction.
  52266. */
  52267. angularSensibilityY: number;
  52268. /**
  52269. * Defines the pointer pinch precision or how fast is the camera zooming.
  52270. * A negative number will reverse the axis direction.
  52271. */
  52272. pinchPrecision: number;
  52273. /**
  52274. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  52275. * from 0.
  52276. * It defines the percentage of current camera.radius to use as delta when
  52277. * pinch zoom is used.
  52278. */
  52279. pinchDeltaPercentage: number;
  52280. /**
  52281. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  52282. */
  52283. axisXControlRadius: boolean;
  52284. /**
  52285. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  52286. */
  52287. axisXControlHeight: boolean;
  52288. /**
  52289. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  52290. */
  52291. axisXControlRotation: boolean;
  52292. /**
  52293. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  52294. */
  52295. axisYControlRadius: boolean;
  52296. /**
  52297. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  52298. */
  52299. axisYControlHeight: boolean;
  52300. /**
  52301. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  52302. */
  52303. axisYControlRotation: boolean;
  52304. /**
  52305. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  52306. */
  52307. axisPinchControlRadius: boolean;
  52308. /**
  52309. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  52310. */
  52311. axisPinchControlHeight: boolean;
  52312. /**
  52313. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  52314. */
  52315. axisPinchControlRotation: boolean;
  52316. /**
  52317. * Log error messages if basic misconfiguration has occurred.
  52318. */
  52319. warningEnable: boolean;
  52320. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  52321. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  52322. private _warningCounter;
  52323. private _warning;
  52324. }
  52325. }
  52326. declare module BABYLON {
  52327. /**
  52328. * Default Inputs manager for the FollowCamera.
  52329. * It groups all the default supported inputs for ease of use.
  52330. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52331. */
  52332. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  52333. /**
  52334. * Instantiates a new FollowCameraInputsManager.
  52335. * @param camera Defines the camera the inputs belong to
  52336. */
  52337. constructor(camera: FollowCamera);
  52338. /**
  52339. * Add keyboard input support to the input manager.
  52340. * @returns the current input manager
  52341. */
  52342. addKeyboard(): FollowCameraInputsManager;
  52343. /**
  52344. * Add mouse wheel input support to the input manager.
  52345. * @returns the current input manager
  52346. */
  52347. addMouseWheel(): FollowCameraInputsManager;
  52348. /**
  52349. * Add pointers input support to the input manager.
  52350. * @returns the current input manager
  52351. */
  52352. addPointers(): FollowCameraInputsManager;
  52353. /**
  52354. * Add orientation input support to the input manager.
  52355. * @returns the current input manager
  52356. */
  52357. addVRDeviceOrientation(): FollowCameraInputsManager;
  52358. }
  52359. }
  52360. declare module BABYLON {
  52361. /**
  52362. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  52363. * an arc rotate version arcFollowCamera are available.
  52364. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  52365. */
  52366. export class FollowCamera extends TargetCamera {
  52367. /**
  52368. * Distance the follow camera should follow an object at
  52369. */
  52370. radius: number;
  52371. /**
  52372. * Minimum allowed distance of the camera to the axis of rotation
  52373. * (The camera can not get closer).
  52374. * This can help limiting how the Camera is able to move in the scene.
  52375. */
  52376. lowerRadiusLimit: Nullable<number>;
  52377. /**
  52378. * Maximum allowed distance of the camera to the axis of rotation
  52379. * (The camera can not get further).
  52380. * This can help limiting how the Camera is able to move in the scene.
  52381. */
  52382. upperRadiusLimit: Nullable<number>;
  52383. /**
  52384. * Define a rotation offset between the camera and the object it follows
  52385. */
  52386. rotationOffset: number;
  52387. /**
  52388. * Minimum allowed angle to camera position relative to target object.
  52389. * This can help limiting how the Camera is able to move in the scene.
  52390. */
  52391. lowerRotationOffsetLimit: Nullable<number>;
  52392. /**
  52393. * Maximum allowed angle to camera position relative to target object.
  52394. * This can help limiting how the Camera is able to move in the scene.
  52395. */
  52396. upperRotationOffsetLimit: Nullable<number>;
  52397. /**
  52398. * Define a height offset between the camera and the object it follows.
  52399. * It can help following an object from the top (like a car chasing a plane)
  52400. */
  52401. heightOffset: number;
  52402. /**
  52403. * Minimum allowed height of camera position relative to target object.
  52404. * This can help limiting how the Camera is able to move in the scene.
  52405. */
  52406. lowerHeightOffsetLimit: Nullable<number>;
  52407. /**
  52408. * Maximum allowed height of camera position relative to target object.
  52409. * This can help limiting how the Camera is able to move in the scene.
  52410. */
  52411. upperHeightOffsetLimit: Nullable<number>;
  52412. /**
  52413. * Define how fast the camera can accelerate to follow it s target.
  52414. */
  52415. cameraAcceleration: number;
  52416. /**
  52417. * Define the speed limit of the camera following an object.
  52418. */
  52419. maxCameraSpeed: number;
  52420. /**
  52421. * Define the target of the camera.
  52422. */
  52423. lockedTarget: Nullable<AbstractMesh>;
  52424. /**
  52425. * Defines the input associated with the camera.
  52426. */
  52427. inputs: FollowCameraInputsManager;
  52428. /**
  52429. * Instantiates the follow camera.
  52430. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  52431. * @param name Define the name of the camera in the scene
  52432. * @param position Define the position of the camera
  52433. * @param scene Define the scene the camera belong to
  52434. * @param lockedTarget Define the target of the camera
  52435. */
  52436. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  52437. private _follow;
  52438. /**
  52439. * Attach the input controls to a specific dom element to get the input from.
  52440. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  52441. */
  52442. attachControl(noPreventDefault?: boolean): void;
  52443. /**
  52444. * Detach the current controls from the specified dom element.
  52445. */
  52446. detachControl(): void;
  52447. /** @hidden */
  52448. _checkInputs(): void;
  52449. private _checkLimits;
  52450. /**
  52451. * Gets the camera class name.
  52452. * @returns the class name
  52453. */
  52454. getClassName(): string;
  52455. }
  52456. /**
  52457. * Arc Rotate version of the follow camera.
  52458. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  52459. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  52460. */
  52461. export class ArcFollowCamera extends TargetCamera {
  52462. /** The longitudinal angle of the camera */
  52463. alpha: number;
  52464. /** The latitudinal angle of the camera */
  52465. beta: number;
  52466. /** The radius of the camera from its target */
  52467. radius: number;
  52468. private _cartesianCoordinates;
  52469. /** Define the camera target (the mesh it should follow) */
  52470. private _meshTarget;
  52471. /**
  52472. * Instantiates a new ArcFollowCamera
  52473. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  52474. * @param name Define the name of the camera
  52475. * @param alpha Define the rotation angle of the camera around the longitudinal axis
  52476. * @param beta Define the rotation angle of the camera around the elevation axis
  52477. * @param radius Define the radius of the camera from its target point
  52478. * @param target Define the target of the camera
  52479. * @param scene Define the scene the camera belongs to
  52480. */
  52481. constructor(name: string,
  52482. /** The longitudinal angle of the camera */
  52483. alpha: number,
  52484. /** The latitudinal angle of the camera */
  52485. beta: number,
  52486. /** The radius of the camera from its target */
  52487. radius: number,
  52488. /** Define the camera target (the mesh it should follow) */
  52489. target: Nullable<AbstractMesh>, scene: Scene);
  52490. private _follow;
  52491. /** @hidden */
  52492. _checkInputs(): void;
  52493. /**
  52494. * Returns the class name of the object.
  52495. * It is mostly used internally for serialization purposes.
  52496. */
  52497. getClassName(): string;
  52498. }
  52499. }
  52500. declare module BABYLON {
  52501. /**
  52502. * Manage the keyboard inputs to control the movement of a follow camera.
  52503. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52504. */
  52505. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  52506. /**
  52507. * Defines the camera the input is attached to.
  52508. */
  52509. camera: FollowCamera;
  52510. /**
  52511. * Defines the list of key codes associated with the up action (increase heightOffset)
  52512. */
  52513. keysHeightOffsetIncr: number[];
  52514. /**
  52515. * Defines the list of key codes associated with the down action (decrease heightOffset)
  52516. */
  52517. keysHeightOffsetDecr: number[];
  52518. /**
  52519. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  52520. */
  52521. keysHeightOffsetModifierAlt: boolean;
  52522. /**
  52523. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  52524. */
  52525. keysHeightOffsetModifierCtrl: boolean;
  52526. /**
  52527. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  52528. */
  52529. keysHeightOffsetModifierShift: boolean;
  52530. /**
  52531. * Defines the list of key codes associated with the left action (increase rotationOffset)
  52532. */
  52533. keysRotationOffsetIncr: number[];
  52534. /**
  52535. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  52536. */
  52537. keysRotationOffsetDecr: number[];
  52538. /**
  52539. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  52540. */
  52541. keysRotationOffsetModifierAlt: boolean;
  52542. /**
  52543. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  52544. */
  52545. keysRotationOffsetModifierCtrl: boolean;
  52546. /**
  52547. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  52548. */
  52549. keysRotationOffsetModifierShift: boolean;
  52550. /**
  52551. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  52552. */
  52553. keysRadiusIncr: number[];
  52554. /**
  52555. * Defines the list of key codes associated with the zoom-out action (increase radius)
  52556. */
  52557. keysRadiusDecr: number[];
  52558. /**
  52559. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  52560. */
  52561. keysRadiusModifierAlt: boolean;
  52562. /**
  52563. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  52564. */
  52565. keysRadiusModifierCtrl: boolean;
  52566. /**
  52567. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  52568. */
  52569. keysRadiusModifierShift: boolean;
  52570. /**
  52571. * Defines the rate of change of heightOffset.
  52572. */
  52573. heightSensibility: number;
  52574. /**
  52575. * Defines the rate of change of rotationOffset.
  52576. */
  52577. rotationSensibility: number;
  52578. /**
  52579. * Defines the rate of change of radius.
  52580. */
  52581. radiusSensibility: number;
  52582. private _keys;
  52583. private _ctrlPressed;
  52584. private _altPressed;
  52585. private _shiftPressed;
  52586. private _onCanvasBlurObserver;
  52587. private _onKeyboardObserver;
  52588. private _engine;
  52589. private _scene;
  52590. /**
  52591. * Attach the input controls to a specific dom element to get the input from.
  52592. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  52593. */
  52594. attachControl(noPreventDefault?: boolean): void;
  52595. /**
  52596. * Detach the current controls from the specified dom element.
  52597. */
  52598. detachControl(): void;
  52599. /**
  52600. * Update the current camera state depending on the inputs that have been used this frame.
  52601. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52602. */
  52603. checkInputs(): void;
  52604. /**
  52605. * Gets the class name of the current input.
  52606. * @returns the class name
  52607. */
  52608. getClassName(): string;
  52609. /**
  52610. * Get the friendly name associated with the input class.
  52611. * @returns the input friendly name
  52612. */
  52613. getSimpleName(): string;
  52614. /**
  52615. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  52616. * allow modification of the heightOffset value.
  52617. */
  52618. private _modifierHeightOffset;
  52619. /**
  52620. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  52621. * allow modification of the rotationOffset value.
  52622. */
  52623. private _modifierRotationOffset;
  52624. /**
  52625. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  52626. * allow modification of the radius value.
  52627. */
  52628. private _modifierRadius;
  52629. }
  52630. }
  52631. declare module BABYLON {
  52632. interface FreeCameraInputsManager {
  52633. /**
  52634. * @hidden
  52635. */
  52636. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  52637. /**
  52638. * Add orientation input support to the input manager.
  52639. * @returns the current input manager
  52640. */
  52641. addDeviceOrientation(): FreeCameraInputsManager;
  52642. }
  52643. /**
  52644. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  52645. * Screen rotation is taken into account.
  52646. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52647. */
  52648. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  52649. private _camera;
  52650. private _screenOrientationAngle;
  52651. private _constantTranform;
  52652. private _screenQuaternion;
  52653. private _alpha;
  52654. private _beta;
  52655. private _gamma;
  52656. /**
  52657. * Can be used to detect if a device orientation sensor is available on a device
  52658. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  52659. * @returns a promise that will resolve on orientation change
  52660. */
  52661. static WaitForOrientationChangeAsync(timeout?: number): Promise<void>;
  52662. /**
  52663. * @hidden
  52664. */
  52665. _onDeviceOrientationChangedObservable: Observable<void>;
  52666. /**
  52667. * Instantiates a new input
  52668. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52669. */
  52670. constructor();
  52671. /**
  52672. * Define the camera controlled by the input.
  52673. */
  52674. get camera(): FreeCamera;
  52675. set camera(camera: FreeCamera);
  52676. /**
  52677. * Attach the input controls to a specific dom element to get the input from.
  52678. */
  52679. attachControl(): void;
  52680. private _orientationChanged;
  52681. private _deviceOrientation;
  52682. /**
  52683. * Detach the current controls from the specified dom element.
  52684. */
  52685. detachControl(): void;
  52686. /**
  52687. * Update the current camera state depending on the inputs that have been used this frame.
  52688. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52689. */
  52690. checkInputs(): void;
  52691. /**
  52692. * Gets the class name of the current input.
  52693. * @returns the class name
  52694. */
  52695. getClassName(): string;
  52696. /**
  52697. * Get the friendly name associated with the input class.
  52698. * @returns the input friendly name
  52699. */
  52700. getSimpleName(): string;
  52701. }
  52702. }
  52703. declare module BABYLON {
  52704. /**
  52705. * Manage the gamepad inputs to control a free camera.
  52706. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52707. */
  52708. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  52709. /**
  52710. * Define the camera the input is attached to.
  52711. */
  52712. camera: FreeCamera;
  52713. /**
  52714. * Define the Gamepad controlling the input
  52715. */
  52716. gamepad: Nullable<Gamepad>;
  52717. /**
  52718. * Defines the gamepad rotation sensiblity.
  52719. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  52720. */
  52721. gamepadAngularSensibility: number;
  52722. /**
  52723. * Defines the gamepad move sensiblity.
  52724. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  52725. */
  52726. gamepadMoveSensibility: number;
  52727. private _yAxisScale;
  52728. /**
  52729. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  52730. */
  52731. get invertYAxis(): boolean;
  52732. set invertYAxis(value: boolean);
  52733. private _onGamepadConnectedObserver;
  52734. private _onGamepadDisconnectedObserver;
  52735. private _cameraTransform;
  52736. private _deltaTransform;
  52737. private _vector3;
  52738. private _vector2;
  52739. /**
  52740. * Attach the input controls to a specific dom element to get the input from.
  52741. */
  52742. attachControl(): void;
  52743. /**
  52744. * Detach the current controls from the specified dom element.
  52745. */
  52746. detachControl(): void;
  52747. /**
  52748. * Update the current camera state depending on the inputs that have been used this frame.
  52749. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52750. */
  52751. checkInputs(): void;
  52752. /**
  52753. * Gets the class name of the current input.
  52754. * @returns the class name
  52755. */
  52756. getClassName(): string;
  52757. /**
  52758. * Get the friendly name associated with the input class.
  52759. * @returns the input friendly name
  52760. */
  52761. getSimpleName(): string;
  52762. }
  52763. }
  52764. declare module BABYLON {
  52765. /**
  52766. * Defines the potential axis of a Joystick
  52767. */
  52768. export enum JoystickAxis {
  52769. /** X axis */
  52770. X = 0,
  52771. /** Y axis */
  52772. Y = 1,
  52773. /** Z axis */
  52774. Z = 2
  52775. }
  52776. /**
  52777. * Represents the different customization options available
  52778. * for VirtualJoystick
  52779. */
  52780. interface VirtualJoystickCustomizations {
  52781. /**
  52782. * Size of the joystick's puck
  52783. */
  52784. puckSize: number;
  52785. /**
  52786. * Size of the joystick's container
  52787. */
  52788. containerSize: number;
  52789. /**
  52790. * Color of the joystick && puck
  52791. */
  52792. color: string;
  52793. /**
  52794. * Image URL for the joystick's puck
  52795. */
  52796. puckImage?: string;
  52797. /**
  52798. * Image URL for the joystick's container
  52799. */
  52800. containerImage?: string;
  52801. /**
  52802. * Defines the unmoving position of the joystick container
  52803. */
  52804. position?: {
  52805. x: number;
  52806. y: number;
  52807. };
  52808. /**
  52809. * Defines whether or not the joystick container is always visible
  52810. */
  52811. alwaysVisible: boolean;
  52812. /**
  52813. * Defines whether or not to limit the movement of the puck to the joystick's container
  52814. */
  52815. limitToContainer: boolean;
  52816. }
  52817. /**
  52818. * Class used to define virtual joystick (used in touch mode)
  52819. */
  52820. export class VirtualJoystick {
  52821. /**
  52822. * Gets or sets a boolean indicating that left and right values must be inverted
  52823. */
  52824. reverseLeftRight: boolean;
  52825. /**
  52826. * Gets or sets a boolean indicating that up and down values must be inverted
  52827. */
  52828. reverseUpDown: boolean;
  52829. /**
  52830. * Gets the offset value for the position (ie. the change of the position value)
  52831. */
  52832. deltaPosition: Vector3;
  52833. /**
  52834. * Gets a boolean indicating if the virtual joystick was pressed
  52835. */
  52836. pressed: boolean;
  52837. /**
  52838. * Canvas the virtual joystick will render onto, default z-index of this is 5
  52839. */
  52840. static Canvas: Nullable<HTMLCanvasElement>;
  52841. /**
  52842. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  52843. */
  52844. limitToContainer: boolean;
  52845. private static _globalJoystickIndex;
  52846. private static _alwaysVisibleSticks;
  52847. private static vjCanvasContext;
  52848. private static vjCanvasWidth;
  52849. private static vjCanvasHeight;
  52850. private static halfWidth;
  52851. private static _GetDefaultOptions;
  52852. private _action;
  52853. private _axisTargetedByLeftAndRight;
  52854. private _axisTargetedByUpAndDown;
  52855. private _joystickSensibility;
  52856. private _inversedSensibility;
  52857. private _joystickPointerID;
  52858. private _joystickColor;
  52859. private _joystickPointerPos;
  52860. private _joystickPreviousPointerPos;
  52861. private _joystickPointerStartPos;
  52862. private _deltaJoystickVector;
  52863. private _leftJoystick;
  52864. private _touches;
  52865. private _joystickPosition;
  52866. private _alwaysVisible;
  52867. private _puckImage;
  52868. private _containerImage;
  52869. private _joystickPuckSize;
  52870. private _joystickContainerSize;
  52871. private _clearPuckSize;
  52872. private _clearContainerSize;
  52873. private _clearPuckSizeOffset;
  52874. private _clearContainerSizeOffset;
  52875. private _onPointerDownHandlerRef;
  52876. private _onPointerMoveHandlerRef;
  52877. private _onPointerUpHandlerRef;
  52878. private _onResize;
  52879. /**
  52880. * Creates a new virtual joystick
  52881. * @param leftJoystick defines that the joystick is for left hand (false by default)
  52882. * @param customizations Defines the options we want to customize the VirtualJoystick
  52883. */
  52884. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  52885. /**
  52886. * Defines joystick sensibility (ie. the ratio between a physical move and virtual joystick position change)
  52887. * @param newJoystickSensibility defines the new sensibility
  52888. */
  52889. setJoystickSensibility(newJoystickSensibility: number): void;
  52890. private _onPointerDown;
  52891. private _onPointerMove;
  52892. private _onPointerUp;
  52893. /**
  52894. * Change the color of the virtual joystick
  52895. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  52896. */
  52897. setJoystickColor(newColor: string): void;
  52898. /**
  52899. * Size of the joystick's container
  52900. */
  52901. set containerSize(newSize: number);
  52902. get containerSize(): number;
  52903. /**
  52904. * Size of the joystick's puck
  52905. */
  52906. set puckSize(newSize: number);
  52907. get puckSize(): number;
  52908. /**
  52909. * Clears the set position of the joystick
  52910. */
  52911. clearPosition(): void;
  52912. /**
  52913. * Defines whether or not the joystick container is always visible
  52914. */
  52915. set alwaysVisible(value: boolean);
  52916. get alwaysVisible(): boolean;
  52917. /**
  52918. * Sets the constant position of the Joystick container
  52919. * @param x X axis coordinate
  52920. * @param y Y axis coordinate
  52921. */
  52922. setPosition(x: number, y: number): void;
  52923. /**
  52924. * Defines a callback to call when the joystick is touched
  52925. * @param action defines the callback
  52926. */
  52927. setActionOnTouch(action: () => any): void;
  52928. /**
  52929. * Defines which axis you'd like to control for left & right
  52930. * @param axis defines the axis to use
  52931. */
  52932. setAxisForLeftRight(axis: JoystickAxis): void;
  52933. /**
  52934. * Defines which axis you'd like to control for up & down
  52935. * @param axis defines the axis to use
  52936. */
  52937. setAxisForUpDown(axis: JoystickAxis): void;
  52938. /**
  52939. * Clears the canvas from the previous puck / container draw
  52940. */
  52941. private _clearPreviousDraw;
  52942. /**
  52943. * Loads `urlPath` to be used for the container's image
  52944. * @param urlPath defines the urlPath of an image to use
  52945. */
  52946. setContainerImage(urlPath: string): void;
  52947. /**
  52948. * Loads `urlPath` to be used for the puck's image
  52949. * @param urlPath defines the urlPath of an image to use
  52950. */
  52951. setPuckImage(urlPath: string): void;
  52952. /**
  52953. * Draws the Virtual Joystick's container
  52954. */
  52955. private _drawContainer;
  52956. /**
  52957. * Draws the Virtual Joystick's puck
  52958. */
  52959. private _drawPuck;
  52960. private _drawVirtualJoystick;
  52961. /**
  52962. * Release internal HTML canvas
  52963. */
  52964. releaseCanvas(): void;
  52965. }
  52966. }
  52967. declare module BABYLON {
  52968. interface FreeCameraInputsManager {
  52969. /**
  52970. * Add virtual joystick input support to the input manager.
  52971. * @returns the current input manager
  52972. */
  52973. addVirtualJoystick(): FreeCameraInputsManager;
  52974. }
  52975. /**
  52976. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  52977. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52978. */
  52979. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  52980. /**
  52981. * Defines the camera the input is attached to.
  52982. */
  52983. camera: FreeCamera;
  52984. private _leftjoystick;
  52985. private _rightjoystick;
  52986. /**
  52987. * Gets the left stick of the virtual joystick.
  52988. * @returns The virtual Joystick
  52989. */
  52990. getLeftJoystick(): VirtualJoystick;
  52991. /**
  52992. * Gets the right stick of the virtual joystick.
  52993. * @returns The virtual Joystick
  52994. */
  52995. getRightJoystick(): VirtualJoystick;
  52996. /**
  52997. * Update the current camera state depending on the inputs that have been used this frame.
  52998. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52999. */
  53000. checkInputs(): void;
  53001. /**
  53002. * Attach the input controls to a specific dom element to get the input from.
  53003. */
  53004. attachControl(): void;
  53005. /**
  53006. * Detach the current controls from the specified dom element.
  53007. */
  53008. detachControl(): void;
  53009. /**
  53010. * Gets the class name of the current input.
  53011. * @returns the class name
  53012. */
  53013. getClassName(): string;
  53014. /**
  53015. * Get the friendly name associated with the input class.
  53016. * @returns the input friendly name
  53017. */
  53018. getSimpleName(): string;
  53019. }
  53020. }
  53021. declare module BABYLON {
  53022. /**
  53023. * This represents a FPS type of camera controlled by touch.
  53024. * This is like a universal camera minus the Gamepad controls.
  53025. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53026. */
  53027. export class TouchCamera extends FreeCamera {
  53028. /**
  53029. * Defines the touch sensibility for rotation.
  53030. * The higher the faster.
  53031. */
  53032. get touchAngularSensibility(): number;
  53033. set touchAngularSensibility(value: number);
  53034. /**
  53035. * Defines the touch sensibility for move.
  53036. * The higher the faster.
  53037. */
  53038. get touchMoveSensibility(): number;
  53039. set touchMoveSensibility(value: number);
  53040. /**
  53041. * Instantiates a new touch camera.
  53042. * This represents a FPS type of camera controlled by touch.
  53043. * This is like a universal camera minus the Gamepad controls.
  53044. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53045. * @param name Define the name of the camera in the scene
  53046. * @param position Define the start position of the camera in the scene
  53047. * @param scene Define the scene the camera belongs to
  53048. */
  53049. constructor(name: string, position: Vector3, scene: Scene);
  53050. /**
  53051. * Gets the current object class name.
  53052. * @return the class name
  53053. */
  53054. getClassName(): string;
  53055. /** @hidden */
  53056. _setupInputs(): void;
  53057. }
  53058. }
  53059. declare module BABYLON {
  53060. /**
  53061. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  53062. * being tilted forward or back and left or right.
  53063. */
  53064. export class DeviceOrientationCamera extends FreeCamera {
  53065. private _initialQuaternion;
  53066. private _quaternionCache;
  53067. private _tmpDragQuaternion;
  53068. private _disablePointerInputWhenUsingDeviceOrientation;
  53069. /**
  53070. * Creates a new device orientation camera
  53071. * @param name The name of the camera
  53072. * @param position The start position camera
  53073. * @param scene The scene the camera belongs to
  53074. */
  53075. constructor(name: string, position: Vector3, scene: Scene);
  53076. /**
  53077. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  53078. */
  53079. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  53080. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  53081. private _dragFactor;
  53082. /**
  53083. * Enabled turning on the y axis when the orientation sensor is active
  53084. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  53085. */
  53086. enableHorizontalDragging(dragFactor?: number): void;
  53087. /**
  53088. * Gets the current instance class name ("DeviceOrientationCamera").
  53089. * This helps avoiding instanceof at run time.
  53090. * @returns the class name
  53091. */
  53092. getClassName(): string;
  53093. /**
  53094. * @hidden
  53095. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  53096. */
  53097. _checkInputs(): void;
  53098. /**
  53099. * Reset the camera to its default orientation on the specified axis only.
  53100. * @param axis The axis to reset
  53101. */
  53102. resetToCurrentRotation(axis?: Axis): void;
  53103. }
  53104. }
  53105. declare module BABYLON {
  53106. /**
  53107. * Defines supported buttons for XBox360 compatible gamepads
  53108. */
  53109. export enum Xbox360Button {
  53110. /** A */
  53111. A = 0,
  53112. /** B */
  53113. B = 1,
  53114. /** X */
  53115. X = 2,
  53116. /** Y */
  53117. Y = 3,
  53118. /** Left button */
  53119. LB = 4,
  53120. /** Right button */
  53121. RB = 5,
  53122. /** Back */
  53123. Back = 8,
  53124. /** Start */
  53125. Start = 9,
  53126. /** Left stick */
  53127. LeftStick = 10,
  53128. /** Right stick */
  53129. RightStick = 11
  53130. }
  53131. /** Defines values for XBox360 DPad */
  53132. export enum Xbox360Dpad {
  53133. /** Up */
  53134. Up = 12,
  53135. /** Down */
  53136. Down = 13,
  53137. /** Left */
  53138. Left = 14,
  53139. /** Right */
  53140. Right = 15
  53141. }
  53142. /**
  53143. * Defines a XBox360 gamepad
  53144. */
  53145. export class Xbox360Pad extends Gamepad {
  53146. private _leftTrigger;
  53147. private _rightTrigger;
  53148. private _onlefttriggerchanged;
  53149. private _onrighttriggerchanged;
  53150. private _onbuttondown;
  53151. private _onbuttonup;
  53152. private _ondpaddown;
  53153. private _ondpadup;
  53154. /** Observable raised when a button is pressed */
  53155. onButtonDownObservable: Observable<Xbox360Button>;
  53156. /** Observable raised when a button is released */
  53157. onButtonUpObservable: Observable<Xbox360Button>;
  53158. /** Observable raised when a pad is pressed */
  53159. onPadDownObservable: Observable<Xbox360Dpad>;
  53160. /** Observable raised when a pad is released */
  53161. onPadUpObservable: Observable<Xbox360Dpad>;
  53162. private _buttonA;
  53163. private _buttonB;
  53164. private _buttonX;
  53165. private _buttonY;
  53166. private _buttonBack;
  53167. private _buttonStart;
  53168. private _buttonLB;
  53169. private _buttonRB;
  53170. private _buttonLeftStick;
  53171. private _buttonRightStick;
  53172. private _dPadUp;
  53173. private _dPadDown;
  53174. private _dPadLeft;
  53175. private _dPadRight;
  53176. private _isXboxOnePad;
  53177. /**
  53178. * Creates a new XBox360 gamepad object
  53179. * @param id defines the id of this gamepad
  53180. * @param index defines its index
  53181. * @param gamepad defines the internal HTML gamepad object
  53182. * @param xboxOne defines if it is a XBox One gamepad
  53183. */
  53184. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  53185. /**
  53186. * Defines the callback to call when left trigger is pressed
  53187. * @param callback defines the callback to use
  53188. */
  53189. onlefttriggerchanged(callback: (value: number) => void): void;
  53190. /**
  53191. * Defines the callback to call when right trigger is pressed
  53192. * @param callback defines the callback to use
  53193. */
  53194. onrighttriggerchanged(callback: (value: number) => void): void;
  53195. /**
  53196. * Gets the left trigger value
  53197. */
  53198. get leftTrigger(): number;
  53199. /**
  53200. * Sets the left trigger value
  53201. */
  53202. set leftTrigger(newValue: number);
  53203. /**
  53204. * Gets the right trigger value
  53205. */
  53206. get rightTrigger(): number;
  53207. /**
  53208. * Sets the right trigger value
  53209. */
  53210. set rightTrigger(newValue: number);
  53211. /**
  53212. * Defines the callback to call when a button is pressed
  53213. * @param callback defines the callback to use
  53214. */
  53215. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  53216. /**
  53217. * Defines the callback to call when a button is released
  53218. * @param callback defines the callback to use
  53219. */
  53220. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  53221. /**
  53222. * Defines the callback to call when a pad is pressed
  53223. * @param callback defines the callback to use
  53224. */
  53225. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  53226. /**
  53227. * Defines the callback to call when a pad is released
  53228. * @param callback defines the callback to use
  53229. */
  53230. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  53231. private _setButtonValue;
  53232. private _setDPadValue;
  53233. /**
  53234. * Gets the value of the `A` button
  53235. */
  53236. get buttonA(): number;
  53237. /**
  53238. * Sets the value of the `A` button
  53239. */
  53240. set buttonA(value: number);
  53241. /**
  53242. * Gets the value of the `B` button
  53243. */
  53244. get buttonB(): number;
  53245. /**
  53246. * Sets the value of the `B` button
  53247. */
  53248. set buttonB(value: number);
  53249. /**
  53250. * Gets the value of the `X` button
  53251. */
  53252. get buttonX(): number;
  53253. /**
  53254. * Sets the value of the `X` button
  53255. */
  53256. set buttonX(value: number);
  53257. /**
  53258. * Gets the value of the `Y` button
  53259. */
  53260. get buttonY(): number;
  53261. /**
  53262. * Sets the value of the `Y` button
  53263. */
  53264. set buttonY(value: number);
  53265. /**
  53266. * Gets the value of the `Start` button
  53267. */
  53268. get buttonStart(): number;
  53269. /**
  53270. * Sets the value of the `Start` button
  53271. */
  53272. set buttonStart(value: number);
  53273. /**
  53274. * Gets the value of the `Back` button
  53275. */
  53276. get buttonBack(): number;
  53277. /**
  53278. * Sets the value of the `Back` button
  53279. */
  53280. set buttonBack(value: number);
  53281. /**
  53282. * Gets the value of the `Left` button
  53283. */
  53284. get buttonLB(): number;
  53285. /**
  53286. * Sets the value of the `Left` button
  53287. */
  53288. set buttonLB(value: number);
  53289. /**
  53290. * Gets the value of the `Right` button
  53291. */
  53292. get buttonRB(): number;
  53293. /**
  53294. * Sets the value of the `Right` button
  53295. */
  53296. set buttonRB(value: number);
  53297. /**
  53298. * Gets the value of the Left joystick
  53299. */
  53300. get buttonLeftStick(): number;
  53301. /**
  53302. * Sets the value of the Left joystick
  53303. */
  53304. set buttonLeftStick(value: number);
  53305. /**
  53306. * Gets the value of the Right joystick
  53307. */
  53308. get buttonRightStick(): number;
  53309. /**
  53310. * Sets the value of the Right joystick
  53311. */
  53312. set buttonRightStick(value: number);
  53313. /**
  53314. * Gets the value of D-pad up
  53315. */
  53316. get dPadUp(): number;
  53317. /**
  53318. * Sets the value of D-pad up
  53319. */
  53320. set dPadUp(value: number);
  53321. /**
  53322. * Gets the value of D-pad down
  53323. */
  53324. get dPadDown(): number;
  53325. /**
  53326. * Sets the value of D-pad down
  53327. */
  53328. set dPadDown(value: number);
  53329. /**
  53330. * Gets the value of D-pad left
  53331. */
  53332. get dPadLeft(): number;
  53333. /**
  53334. * Sets the value of D-pad left
  53335. */
  53336. set dPadLeft(value: number);
  53337. /**
  53338. * Gets the value of D-pad right
  53339. */
  53340. get dPadRight(): number;
  53341. /**
  53342. * Sets the value of D-pad right
  53343. */
  53344. set dPadRight(value: number);
  53345. /**
  53346. * Force the gamepad to synchronize with device values
  53347. */
  53348. update(): void;
  53349. /**
  53350. * Disposes the gamepad
  53351. */
  53352. dispose(): void;
  53353. }
  53354. }
  53355. declare module BABYLON {
  53356. /**
  53357. * Defines supported buttons for DualShock compatible gamepads
  53358. */
  53359. export enum DualShockButton {
  53360. /** Cross */
  53361. Cross = 0,
  53362. /** Circle */
  53363. Circle = 1,
  53364. /** Square */
  53365. Square = 2,
  53366. /** Triangle */
  53367. Triangle = 3,
  53368. /** L1 */
  53369. L1 = 4,
  53370. /** R1 */
  53371. R1 = 5,
  53372. /** Share */
  53373. Share = 8,
  53374. /** Options */
  53375. Options = 9,
  53376. /** Left stick */
  53377. LeftStick = 10,
  53378. /** Right stick */
  53379. RightStick = 11
  53380. }
  53381. /** Defines values for DualShock DPad */
  53382. export enum DualShockDpad {
  53383. /** Up */
  53384. Up = 12,
  53385. /** Down */
  53386. Down = 13,
  53387. /** Left */
  53388. Left = 14,
  53389. /** Right */
  53390. Right = 15
  53391. }
  53392. /**
  53393. * Defines a DualShock gamepad
  53394. */
  53395. export class DualShockPad extends Gamepad {
  53396. private _leftTrigger;
  53397. private _rightTrigger;
  53398. private _onlefttriggerchanged;
  53399. private _onrighttriggerchanged;
  53400. private _onbuttondown;
  53401. private _onbuttonup;
  53402. private _ondpaddown;
  53403. private _ondpadup;
  53404. /** Observable raised when a button is pressed */
  53405. onButtonDownObservable: Observable<DualShockButton>;
  53406. /** Observable raised when a button is released */
  53407. onButtonUpObservable: Observable<DualShockButton>;
  53408. /** Observable raised when a pad is pressed */
  53409. onPadDownObservable: Observable<DualShockDpad>;
  53410. /** Observable raised when a pad is released */
  53411. onPadUpObservable: Observable<DualShockDpad>;
  53412. private _buttonCross;
  53413. private _buttonCircle;
  53414. private _buttonSquare;
  53415. private _buttonTriangle;
  53416. private _buttonShare;
  53417. private _buttonOptions;
  53418. private _buttonL1;
  53419. private _buttonR1;
  53420. private _buttonLeftStick;
  53421. private _buttonRightStick;
  53422. private _dPadUp;
  53423. private _dPadDown;
  53424. private _dPadLeft;
  53425. private _dPadRight;
  53426. /**
  53427. * Creates a new DualShock gamepad object
  53428. * @param id defines the id of this gamepad
  53429. * @param index defines its index
  53430. * @param gamepad defines the internal HTML gamepad object
  53431. */
  53432. constructor(id: string, index: number, gamepad: any);
  53433. /**
  53434. * Defines the callback to call when left trigger is pressed
  53435. * @param callback defines the callback to use
  53436. */
  53437. onlefttriggerchanged(callback: (value: number) => void): void;
  53438. /**
  53439. * Defines the callback to call when right trigger is pressed
  53440. * @param callback defines the callback to use
  53441. */
  53442. onrighttriggerchanged(callback: (value: number) => void): void;
  53443. /**
  53444. * Gets the left trigger value
  53445. */
  53446. get leftTrigger(): number;
  53447. /**
  53448. * Sets the left trigger value
  53449. */
  53450. set leftTrigger(newValue: number);
  53451. /**
  53452. * Gets the right trigger value
  53453. */
  53454. get rightTrigger(): number;
  53455. /**
  53456. * Sets the right trigger value
  53457. */
  53458. set rightTrigger(newValue: number);
  53459. /**
  53460. * Defines the callback to call when a button is pressed
  53461. * @param callback defines the callback to use
  53462. */
  53463. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  53464. /**
  53465. * Defines the callback to call when a button is released
  53466. * @param callback defines the callback to use
  53467. */
  53468. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  53469. /**
  53470. * Defines the callback to call when a pad is pressed
  53471. * @param callback defines the callback to use
  53472. */
  53473. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  53474. /**
  53475. * Defines the callback to call when a pad is released
  53476. * @param callback defines the callback to use
  53477. */
  53478. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  53479. private _setButtonValue;
  53480. private _setDPadValue;
  53481. /**
  53482. * Gets the value of the `Cross` button
  53483. */
  53484. get buttonCross(): number;
  53485. /**
  53486. * Sets the value of the `Cross` button
  53487. */
  53488. set buttonCross(value: number);
  53489. /**
  53490. * Gets the value of the `Circle` button
  53491. */
  53492. get buttonCircle(): number;
  53493. /**
  53494. * Sets the value of the `Circle` button
  53495. */
  53496. set buttonCircle(value: number);
  53497. /**
  53498. * Gets the value of the `Square` button
  53499. */
  53500. get buttonSquare(): number;
  53501. /**
  53502. * Sets the value of the `Square` button
  53503. */
  53504. set buttonSquare(value: number);
  53505. /**
  53506. * Gets the value of the `Triangle` button
  53507. */
  53508. get buttonTriangle(): number;
  53509. /**
  53510. * Sets the value of the `Triangle` button
  53511. */
  53512. set buttonTriangle(value: number);
  53513. /**
  53514. * Gets the value of the `Options` button
  53515. */
  53516. get buttonOptions(): number;
  53517. /**
  53518. * Sets the value of the `Options` button
  53519. */
  53520. set buttonOptions(value: number);
  53521. /**
  53522. * Gets the value of the `Share` button
  53523. */
  53524. get buttonShare(): number;
  53525. /**
  53526. * Sets the value of the `Share` button
  53527. */
  53528. set buttonShare(value: number);
  53529. /**
  53530. * Gets the value of the `L1` button
  53531. */
  53532. get buttonL1(): number;
  53533. /**
  53534. * Sets the value of the `L1` button
  53535. */
  53536. set buttonL1(value: number);
  53537. /**
  53538. * Gets the value of the `R1` button
  53539. */
  53540. get buttonR1(): number;
  53541. /**
  53542. * Sets the value of the `R1` button
  53543. */
  53544. set buttonR1(value: number);
  53545. /**
  53546. * Gets the value of the Left joystick
  53547. */
  53548. get buttonLeftStick(): number;
  53549. /**
  53550. * Sets the value of the Left joystick
  53551. */
  53552. set buttonLeftStick(value: number);
  53553. /**
  53554. * Gets the value of the Right joystick
  53555. */
  53556. get buttonRightStick(): number;
  53557. /**
  53558. * Sets the value of the Right joystick
  53559. */
  53560. set buttonRightStick(value: number);
  53561. /**
  53562. * Gets the value of D-pad up
  53563. */
  53564. get dPadUp(): number;
  53565. /**
  53566. * Sets the value of D-pad up
  53567. */
  53568. set dPadUp(value: number);
  53569. /**
  53570. * Gets the value of D-pad down
  53571. */
  53572. get dPadDown(): number;
  53573. /**
  53574. * Sets the value of D-pad down
  53575. */
  53576. set dPadDown(value: number);
  53577. /**
  53578. * Gets the value of D-pad left
  53579. */
  53580. get dPadLeft(): number;
  53581. /**
  53582. * Sets the value of D-pad left
  53583. */
  53584. set dPadLeft(value: number);
  53585. /**
  53586. * Gets the value of D-pad right
  53587. */
  53588. get dPadRight(): number;
  53589. /**
  53590. * Sets the value of D-pad right
  53591. */
  53592. set dPadRight(value: number);
  53593. /**
  53594. * Force the gamepad to synchronize with device values
  53595. */
  53596. update(): void;
  53597. /**
  53598. * Disposes the gamepad
  53599. */
  53600. dispose(): void;
  53601. }
  53602. }
  53603. declare module BABYLON {
  53604. /**
  53605. * Manager for handling gamepads
  53606. */
  53607. export class GamepadManager {
  53608. private _scene?;
  53609. private _babylonGamepads;
  53610. private _oneGamepadConnected;
  53611. /** @hidden */
  53612. _isMonitoring: boolean;
  53613. private _gamepadEventSupported;
  53614. private _gamepadSupport?;
  53615. /**
  53616. * observable to be triggered when the gamepad controller has been connected
  53617. */
  53618. onGamepadConnectedObservable: Observable<Gamepad>;
  53619. /**
  53620. * observable to be triggered when the gamepad controller has been disconnected
  53621. */
  53622. onGamepadDisconnectedObservable: Observable<Gamepad>;
  53623. private _onGamepadConnectedEvent;
  53624. private _onGamepadDisconnectedEvent;
  53625. /**
  53626. * Initializes the gamepad manager
  53627. * @param _scene BabylonJS scene
  53628. */
  53629. constructor(_scene?: Scene | undefined);
  53630. /**
  53631. * The gamepads in the game pad manager
  53632. */
  53633. get gamepads(): Gamepad[];
  53634. /**
  53635. * Get the gamepad controllers based on type
  53636. * @param type The type of gamepad controller
  53637. * @returns Nullable gamepad
  53638. */
  53639. getGamepadByType(type?: number): Nullable<Gamepad>;
  53640. /**
  53641. * Disposes the gamepad manager
  53642. */
  53643. dispose(): void;
  53644. private _addNewGamepad;
  53645. private _startMonitoringGamepads;
  53646. private _stopMonitoringGamepads;
  53647. /** @hidden */
  53648. _checkGamepadsStatus(): void;
  53649. private _updateGamepadObjects;
  53650. }
  53651. }
  53652. declare module BABYLON {
  53653. interface Scene {
  53654. /** @hidden */
  53655. _gamepadManager: Nullable<GamepadManager>;
  53656. /**
  53657. * Gets the gamepad manager associated with the scene
  53658. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  53659. */
  53660. gamepadManager: GamepadManager;
  53661. }
  53662. /**
  53663. * Interface representing a free camera inputs manager
  53664. */
  53665. interface FreeCameraInputsManager {
  53666. /**
  53667. * Adds gamepad input support to the FreeCameraInputsManager.
  53668. * @returns the FreeCameraInputsManager
  53669. */
  53670. addGamepad(): FreeCameraInputsManager;
  53671. }
  53672. /**
  53673. * Interface representing an arc rotate camera inputs manager
  53674. */
  53675. interface ArcRotateCameraInputsManager {
  53676. /**
  53677. * Adds gamepad input support to the ArcRotateCamera InputManager.
  53678. * @returns the camera inputs manager
  53679. */
  53680. addGamepad(): ArcRotateCameraInputsManager;
  53681. }
  53682. /**
  53683. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  53684. */
  53685. export class GamepadSystemSceneComponent implements ISceneComponent {
  53686. /**
  53687. * The component name helpfull to identify the component in the list of scene components.
  53688. */
  53689. readonly name: string;
  53690. /**
  53691. * The scene the component belongs to.
  53692. */
  53693. scene: Scene;
  53694. /**
  53695. * Creates a new instance of the component for the given scene
  53696. * @param scene Defines the scene to register the component in
  53697. */
  53698. constructor(scene: Scene);
  53699. /**
  53700. * Registers the component in a given scene
  53701. */
  53702. register(): void;
  53703. /**
  53704. * Rebuilds the elements related to this component in case of
  53705. * context lost for instance.
  53706. */
  53707. rebuild(): void;
  53708. /**
  53709. * Disposes the component and the associated ressources
  53710. */
  53711. dispose(): void;
  53712. private _beforeCameraUpdate;
  53713. }
  53714. }
  53715. declare module BABYLON {
  53716. /**
  53717. * 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,
  53718. * which still works and will still be found in many Playgrounds.
  53719. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53720. */
  53721. export class UniversalCamera extends TouchCamera {
  53722. /**
  53723. * Defines the gamepad rotation sensiblity.
  53724. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  53725. */
  53726. get gamepadAngularSensibility(): number;
  53727. set gamepadAngularSensibility(value: number);
  53728. /**
  53729. * Defines the gamepad move sensiblity.
  53730. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  53731. */
  53732. get gamepadMoveSensibility(): number;
  53733. set gamepadMoveSensibility(value: number);
  53734. /**
  53735. * 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,
  53736. * which still works and will still be found in many Playgrounds.
  53737. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53738. * @param name Define the name of the camera in the scene
  53739. * @param position Define the start position of the camera in the scene
  53740. * @param scene Define the scene the camera belongs to
  53741. */
  53742. constructor(name: string, position: Vector3, scene: Scene);
  53743. /**
  53744. * Gets the current object class name.
  53745. * @return the class name
  53746. */
  53747. getClassName(): string;
  53748. }
  53749. }
  53750. declare module BABYLON {
  53751. /**
  53752. * This represents a FPS type of camera. This is only here for back compat purpose.
  53753. * Please use the UniversalCamera instead as both are identical.
  53754. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53755. */
  53756. export class GamepadCamera extends UniversalCamera {
  53757. /**
  53758. * Instantiates a new Gamepad Camera
  53759. * This represents a FPS type of camera. This is only here for back compat purpose.
  53760. * Please use the UniversalCamera instead as both are identical.
  53761. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53762. * @param name Define the name of the camera in the scene
  53763. * @param position Define the start position of the camera in the scene
  53764. * @param scene Define the scene the camera belongs to
  53765. */
  53766. constructor(name: string, position: Vector3, scene: Scene);
  53767. /**
  53768. * Gets the current object class name.
  53769. * @return the class name
  53770. */
  53771. getClassName(): string;
  53772. }
  53773. }
  53774. declare module BABYLON {
  53775. /** @hidden */
  53776. export var anaglyphPixelShader: {
  53777. name: string;
  53778. shader: string;
  53779. };
  53780. }
  53781. declare module BABYLON {
  53782. /**
  53783. * Postprocess used to generate anaglyphic rendering
  53784. */
  53785. export class AnaglyphPostProcess extends PostProcess {
  53786. private _passedProcess;
  53787. /**
  53788. * Gets a string identifying the name of the class
  53789. * @returns "AnaglyphPostProcess" string
  53790. */
  53791. getClassName(): string;
  53792. /**
  53793. * Creates a new AnaglyphPostProcess
  53794. * @param name defines postprocess name
  53795. * @param options defines creation options or target ratio scale
  53796. * @param rigCameras defines cameras using this postprocess
  53797. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  53798. * @param engine defines hosting engine
  53799. * @param reusable defines if the postprocess will be reused multiple times per frame
  53800. */
  53801. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  53802. }
  53803. }
  53804. declare module BABYLON {
  53805. /**
  53806. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  53807. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  53808. */
  53809. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  53810. /**
  53811. * Creates a new AnaglyphArcRotateCamera
  53812. * @param name defines camera name
  53813. * @param alpha defines alpha angle (in radians)
  53814. * @param beta defines beta angle (in radians)
  53815. * @param radius defines radius
  53816. * @param target defines camera target
  53817. * @param interaxialDistance defines distance between each color axis
  53818. * @param scene defines the hosting scene
  53819. */
  53820. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  53821. /**
  53822. * Gets camera class name
  53823. * @returns AnaglyphArcRotateCamera
  53824. */
  53825. getClassName(): string;
  53826. }
  53827. }
  53828. declare module BABYLON {
  53829. /**
  53830. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  53831. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  53832. */
  53833. export class AnaglyphFreeCamera extends FreeCamera {
  53834. /**
  53835. * Creates a new AnaglyphFreeCamera
  53836. * @param name defines camera name
  53837. * @param position defines initial position
  53838. * @param interaxialDistance defines distance between each color axis
  53839. * @param scene defines the hosting scene
  53840. */
  53841. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  53842. /**
  53843. * Gets camera class name
  53844. * @returns AnaglyphFreeCamera
  53845. */
  53846. getClassName(): string;
  53847. }
  53848. }
  53849. declare module BABYLON {
  53850. /**
  53851. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  53852. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  53853. */
  53854. export class AnaglyphGamepadCamera extends GamepadCamera {
  53855. /**
  53856. * Creates a new AnaglyphGamepadCamera
  53857. * @param name defines camera name
  53858. * @param position defines initial position
  53859. * @param interaxialDistance defines distance between each color axis
  53860. * @param scene defines the hosting scene
  53861. */
  53862. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  53863. /**
  53864. * Gets camera class name
  53865. * @returns AnaglyphGamepadCamera
  53866. */
  53867. getClassName(): string;
  53868. }
  53869. }
  53870. declare module BABYLON {
  53871. /**
  53872. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  53873. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  53874. */
  53875. export class AnaglyphUniversalCamera extends UniversalCamera {
  53876. /**
  53877. * Creates a new AnaglyphUniversalCamera
  53878. * @param name defines camera name
  53879. * @param position defines initial position
  53880. * @param interaxialDistance defines distance between each color axis
  53881. * @param scene defines the hosting scene
  53882. */
  53883. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  53884. /**
  53885. * Gets camera class name
  53886. * @returns AnaglyphUniversalCamera
  53887. */
  53888. getClassName(): string;
  53889. }
  53890. }
  53891. declare module BABYLON {
  53892. /** @hidden */
  53893. export var stereoscopicInterlacePixelShader: {
  53894. name: string;
  53895. shader: string;
  53896. };
  53897. }
  53898. declare module BABYLON {
  53899. /**
  53900. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  53901. */
  53902. export class StereoscopicInterlacePostProcessI extends PostProcess {
  53903. private _stepSize;
  53904. private _passedProcess;
  53905. /**
  53906. * Gets a string identifying the name of the class
  53907. * @returns "StereoscopicInterlacePostProcessI" string
  53908. */
  53909. getClassName(): string;
  53910. /**
  53911. * Initializes a StereoscopicInterlacePostProcessI
  53912. * @param name The name of the effect.
  53913. * @param rigCameras The rig cameras to be applied to the post process
  53914. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  53915. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  53916. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53917. * @param engine The engine which the post process will be applied. (default: current engine)
  53918. * @param reusable If the post process can be reused on the same frame. (default: false)
  53919. */
  53920. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53921. }
  53922. /**
  53923. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  53924. */
  53925. export class StereoscopicInterlacePostProcess extends PostProcess {
  53926. private _stepSize;
  53927. private _passedProcess;
  53928. /**
  53929. * Gets a string identifying the name of the class
  53930. * @returns "StereoscopicInterlacePostProcess" string
  53931. */
  53932. getClassName(): string;
  53933. /**
  53934. * Initializes a StereoscopicInterlacePostProcess
  53935. * @param name The name of the effect.
  53936. * @param rigCameras The rig cameras to be applied to the post process
  53937. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  53938. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53939. * @param engine The engine which the post process will be applied. (default: current engine)
  53940. * @param reusable If the post process can be reused on the same frame. (default: false)
  53941. */
  53942. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53943. }
  53944. }
  53945. declare module BABYLON {
  53946. /**
  53947. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  53948. * @see https://doc.babylonjs.com/features/cameras
  53949. */
  53950. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  53951. /**
  53952. * Creates a new StereoscopicArcRotateCamera
  53953. * @param name defines camera name
  53954. * @param alpha defines alpha angle (in radians)
  53955. * @param beta defines beta angle (in radians)
  53956. * @param radius defines radius
  53957. * @param target defines camera target
  53958. * @param interaxialDistance defines distance between each color axis
  53959. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  53960. * @param scene defines the hosting scene
  53961. */
  53962. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  53963. /**
  53964. * Gets camera class name
  53965. * @returns StereoscopicArcRotateCamera
  53966. */
  53967. getClassName(): string;
  53968. }
  53969. }
  53970. declare module BABYLON {
  53971. /**
  53972. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  53973. * @see https://doc.babylonjs.com/features/cameras
  53974. */
  53975. export class StereoscopicFreeCamera extends FreeCamera {
  53976. /**
  53977. * Creates a new StereoscopicFreeCamera
  53978. * @param name defines camera name
  53979. * @param position defines initial position
  53980. * @param interaxialDistance defines distance between each color axis
  53981. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  53982. * @param scene defines the hosting scene
  53983. */
  53984. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  53985. /**
  53986. * Gets camera class name
  53987. * @returns StereoscopicFreeCamera
  53988. */
  53989. getClassName(): string;
  53990. }
  53991. }
  53992. declare module BABYLON {
  53993. /**
  53994. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  53995. * @see https://doc.babylonjs.com/features/cameras
  53996. */
  53997. export class StereoscopicGamepadCamera extends GamepadCamera {
  53998. /**
  53999. * Creates a new StereoscopicGamepadCamera
  54000. * @param name defines camera name
  54001. * @param position defines initial position
  54002. * @param interaxialDistance defines distance between each color axis
  54003. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  54004. * @param scene defines the hosting scene
  54005. */
  54006. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  54007. /**
  54008. * Gets camera class name
  54009. * @returns StereoscopicGamepadCamera
  54010. */
  54011. getClassName(): string;
  54012. }
  54013. }
  54014. declare module BABYLON {
  54015. /**
  54016. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  54017. * @see https://doc.babylonjs.com/features/cameras
  54018. */
  54019. export class StereoscopicUniversalCamera extends UniversalCamera {
  54020. /**
  54021. * Creates a new StereoscopicUniversalCamera
  54022. * @param name defines camera name
  54023. * @param position defines initial position
  54024. * @param interaxialDistance defines distance between each color axis
  54025. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  54026. * @param scene defines the hosting scene
  54027. */
  54028. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  54029. /**
  54030. * Gets camera class name
  54031. * @returns StereoscopicUniversalCamera
  54032. */
  54033. getClassName(): string;
  54034. }
  54035. }
  54036. declare module BABYLON {
  54037. /**
  54038. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  54039. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  54040. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  54041. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  54042. */
  54043. export class VirtualJoysticksCamera extends FreeCamera {
  54044. /**
  54045. * Instantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  54046. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  54047. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  54048. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  54049. * @param name Define the name of the camera in the scene
  54050. * @param position Define the start position of the camera in the scene
  54051. * @param scene Define the scene the camera belongs to
  54052. */
  54053. constructor(name: string, position: Vector3, scene: Scene);
  54054. /**
  54055. * Gets the current object class name.
  54056. * @return the class name
  54057. */
  54058. getClassName(): string;
  54059. }
  54060. }
  54061. declare module BABYLON {
  54062. /**
  54063. * This represents all the required metrics to create a VR camera.
  54064. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  54065. */
  54066. export class VRCameraMetrics {
  54067. /**
  54068. * Define the horizontal resolution off the screen.
  54069. */
  54070. hResolution: number;
  54071. /**
  54072. * Define the vertical resolution off the screen.
  54073. */
  54074. vResolution: number;
  54075. /**
  54076. * Define the horizontal screen size.
  54077. */
  54078. hScreenSize: number;
  54079. /**
  54080. * Define the vertical screen size.
  54081. */
  54082. vScreenSize: number;
  54083. /**
  54084. * Define the vertical screen center position.
  54085. */
  54086. vScreenCenter: number;
  54087. /**
  54088. * Define the distance of the eyes to the screen.
  54089. */
  54090. eyeToScreenDistance: number;
  54091. /**
  54092. * Define the distance between both lenses
  54093. */
  54094. lensSeparationDistance: number;
  54095. /**
  54096. * Define the distance between both viewer's eyes.
  54097. */
  54098. interpupillaryDistance: number;
  54099. /**
  54100. * Define the distortion factor of the VR postprocess.
  54101. * Please, touch with care.
  54102. */
  54103. distortionK: number[];
  54104. /**
  54105. * Define the chromatic aberration correction factors for the VR post process.
  54106. */
  54107. chromaAbCorrection: number[];
  54108. /**
  54109. * Define the scale factor of the post process.
  54110. * The smaller the better but the slower.
  54111. */
  54112. postProcessScaleFactor: number;
  54113. /**
  54114. * Define an offset for the lens center.
  54115. */
  54116. lensCenterOffset: number;
  54117. /**
  54118. * Define if the current vr camera should compensate the distortion of the lens or not.
  54119. */
  54120. compensateDistortion: boolean;
  54121. /**
  54122. * Defines if multiview should be enabled when rendering (Default: false)
  54123. */
  54124. multiviewEnabled: boolean;
  54125. /**
  54126. * Gets the rendering aspect ratio based on the provided resolutions.
  54127. */
  54128. get aspectRatio(): number;
  54129. /**
  54130. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  54131. */
  54132. get aspectRatioFov(): number;
  54133. /**
  54134. * @hidden
  54135. */
  54136. get leftHMatrix(): Matrix;
  54137. /**
  54138. * @hidden
  54139. */
  54140. get rightHMatrix(): Matrix;
  54141. /**
  54142. * @hidden
  54143. */
  54144. get leftPreViewMatrix(): Matrix;
  54145. /**
  54146. * @hidden
  54147. */
  54148. get rightPreViewMatrix(): Matrix;
  54149. /**
  54150. * Get the default VRMetrics based on the most generic setup.
  54151. * @returns the default vr metrics
  54152. */
  54153. static GetDefault(): VRCameraMetrics;
  54154. }
  54155. }
  54156. declare module BABYLON {
  54157. /** @hidden */
  54158. export var vrDistortionCorrectionPixelShader: {
  54159. name: string;
  54160. shader: string;
  54161. };
  54162. }
  54163. declare module BABYLON {
  54164. /**
  54165. * VRDistortionCorrectionPostProcess used for mobile VR
  54166. */
  54167. export class VRDistortionCorrectionPostProcess extends PostProcess {
  54168. private _isRightEye;
  54169. private _distortionFactors;
  54170. private _postProcessScaleFactor;
  54171. private _lensCenterOffset;
  54172. private _scaleIn;
  54173. private _scaleFactor;
  54174. private _lensCenter;
  54175. /**
  54176. * Gets a string identifying the name of the class
  54177. * @returns "VRDistortionCorrectionPostProcess" string
  54178. */
  54179. getClassName(): string;
  54180. /**
  54181. * Initializes the VRDistortionCorrectionPostProcess
  54182. * @param name The name of the effect.
  54183. * @param camera The camera to apply the render pass to.
  54184. * @param isRightEye If this is for the right eye distortion
  54185. * @param vrMetrics All the required metrics for the VR camera
  54186. */
  54187. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  54188. }
  54189. }
  54190. declare module BABYLON {
  54191. /**
  54192. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  54193. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  54194. */
  54195. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  54196. /**
  54197. * Creates a new VRDeviceOrientationArcRotateCamera
  54198. * @param name defines camera name
  54199. * @param alpha defines the camera rotation along the longitudinal axis
  54200. * @param beta defines the camera rotation along the latitudinal axis
  54201. * @param radius defines the camera distance from its target
  54202. * @param target defines the camera target
  54203. * @param scene defines the scene the camera belongs to
  54204. * @param compensateDistortion defines if the camera needs to compensate the lens distortion
  54205. * @param vrCameraMetrics defines the vr metrics associated to the camera
  54206. */
  54207. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  54208. /**
  54209. * Gets camera class name
  54210. * @returns VRDeviceOrientationArcRotateCamera
  54211. */
  54212. getClassName(): string;
  54213. }
  54214. }
  54215. declare module BABYLON {
  54216. /**
  54217. * Camera used to simulate VR rendering (based on FreeCamera)
  54218. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  54219. */
  54220. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  54221. /**
  54222. * Creates a new VRDeviceOrientationFreeCamera
  54223. * @param name defines camera name
  54224. * @param position defines the start position of the camera
  54225. * @param scene defines the scene the camera belongs to
  54226. * @param compensateDistortion defines if the camera needs to compensate the lens distortion
  54227. * @param vrCameraMetrics defines the vr metrics associated to the camera
  54228. */
  54229. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  54230. /**
  54231. * Gets camera class name
  54232. * @returns VRDeviceOrientationFreeCamera
  54233. */
  54234. getClassName(): string;
  54235. }
  54236. }
  54237. declare module BABYLON {
  54238. /**
  54239. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  54240. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  54241. */
  54242. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  54243. /**
  54244. * Creates a new VRDeviceOrientationGamepadCamera
  54245. * @param name defines camera name
  54246. * @param position defines the start position of the camera
  54247. * @param scene defines the scene the camera belongs to
  54248. * @param compensateDistortion defines if the camera needs to compensate the lens distortion
  54249. * @param vrCameraMetrics defines the vr metrics associated to the camera
  54250. */
  54251. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  54252. /**
  54253. * Gets camera class name
  54254. * @returns VRDeviceOrientationGamepadCamera
  54255. */
  54256. getClassName(): string;
  54257. }
  54258. }
  54259. declare module BABYLON {
  54260. /**
  54261. * A class extending Texture allowing drawing on a texture
  54262. * @see https://doc.babylonjs.com/how_to/dynamictexture
  54263. */
  54264. export class DynamicTexture extends Texture {
  54265. private _generateMipMaps;
  54266. private _canvas;
  54267. private _context;
  54268. /**
  54269. * Creates a DynamicTexture
  54270. * @param name defines the name of the texture
  54271. * @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
  54272. * @param scene defines the scene where you want the texture
  54273. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  54274. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54275. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  54276. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  54277. */
  54278. constructor(name: string, options: any, scene?: Nullable<Scene>, generateMipMaps?: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  54279. /**
  54280. * Get the current class name of the texture useful for serialization or dynamic coding.
  54281. * @returns "DynamicTexture"
  54282. */
  54283. getClassName(): string;
  54284. /**
  54285. * Gets the current state of canRescale
  54286. */
  54287. get canRescale(): boolean;
  54288. private _recreate;
  54289. /**
  54290. * Scales the texture
  54291. * @param ratio the scale factor to apply to both width and height
  54292. */
  54293. scale(ratio: number): void;
  54294. /**
  54295. * Resizes the texture
  54296. * @param width the new width
  54297. * @param height the new height
  54298. */
  54299. scaleTo(width: number, height: number): void;
  54300. /**
  54301. * Gets the context of the canvas used by the texture
  54302. * @returns the canvas context of the dynamic texture
  54303. */
  54304. getContext(): CanvasRenderingContext2D;
  54305. /**
  54306. * Clears the texture
  54307. */
  54308. clear(): void;
  54309. /**
  54310. * Updates the texture
  54311. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  54312. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  54313. */
  54314. update(invertY?: boolean, premulAlpha?: boolean): void;
  54315. /**
  54316. * Draws text onto the texture
  54317. * @param text defines the text to be drawn
  54318. * @param x defines the placement of the text from the left
  54319. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  54320. * @param font defines the font to be used with font-style, font-size, font-name
  54321. * @param color defines the color used for the text
  54322. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  54323. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  54324. * @param update defines whether texture is immediately update (default is true)
  54325. */
  54326. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  54327. /**
  54328. * Clones the texture
  54329. * @returns the clone of the texture.
  54330. */
  54331. clone(): DynamicTexture;
  54332. /**
  54333. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  54334. * @returns a serialized dynamic texture object
  54335. */
  54336. serialize(): any;
  54337. private _IsCanvasElement;
  54338. /** @hidden */
  54339. _rebuild(): void;
  54340. }
  54341. }
  54342. declare module BABYLON {
  54343. /**
  54344. * Class containing static functions to help procedurally build meshes
  54345. */
  54346. export class GroundBuilder {
  54347. /**
  54348. * Creates a ground mesh
  54349. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  54350. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  54351. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54352. * @param name defines the name of the mesh
  54353. * @param options defines the options used to create the mesh
  54354. * @param scene defines the hosting scene
  54355. * @returns the ground mesh
  54356. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  54357. */
  54358. static CreateGround(name: string, options: {
  54359. width?: number;
  54360. height?: number;
  54361. subdivisions?: number;
  54362. subdivisionsX?: number;
  54363. subdivisionsY?: number;
  54364. updatable?: boolean;
  54365. }, scene: any): Mesh;
  54366. /**
  54367. * Creates a tiled ground mesh
  54368. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  54369. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  54370. * * 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
  54371. * * 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
  54372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54373. * @param name defines the name of the mesh
  54374. * @param options defines the options used to create the mesh
  54375. * @param scene defines the hosting scene
  54376. * @returns the tiled ground mesh
  54377. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  54378. */
  54379. static CreateTiledGround(name: string, options: {
  54380. xmin: number;
  54381. zmin: number;
  54382. xmax: number;
  54383. zmax: number;
  54384. subdivisions?: {
  54385. w: number;
  54386. h: number;
  54387. };
  54388. precision?: {
  54389. w: number;
  54390. h: number;
  54391. };
  54392. updatable?: boolean;
  54393. }, scene?: Nullable<Scene>): Mesh;
  54394. /**
  54395. * Creates a ground mesh from a height map
  54396. * * The parameter `url` sets the URL of the height map image resource.
  54397. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  54398. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  54399. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  54400. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  54401. * * 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.
  54402. * * 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).
  54403. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  54404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54405. * @param name defines the name of the mesh
  54406. * @param url defines the url to the height map
  54407. * @param options defines the options used to create the mesh
  54408. * @param scene defines the hosting scene
  54409. * @returns the ground mesh
  54410. * @see https://doc.babylonjs.com/babylon101/height_map
  54411. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  54412. */
  54413. static CreateGroundFromHeightMap(name: string, url: string, options: {
  54414. width?: number;
  54415. height?: number;
  54416. subdivisions?: number;
  54417. minHeight?: number;
  54418. maxHeight?: number;
  54419. colorFilter?: Color3;
  54420. alphaFilter?: number;
  54421. updatable?: boolean;
  54422. onReady?: (mesh: GroundMesh) => void;
  54423. }, scene?: Nullable<Scene>): GroundMesh;
  54424. }
  54425. }
  54426. declare module BABYLON {
  54427. /**
  54428. * Class containing static functions to help procedurally build meshes
  54429. */
  54430. export class TorusBuilder {
  54431. /**
  54432. * Creates a torus mesh
  54433. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  54434. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  54435. * * The parameter `tessellation` sets the number of torus sides (positive integer, default 16)
  54436. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54437. * * 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
  54438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54439. * @param name defines the name of the mesh
  54440. * @param options defines the options used to create the mesh
  54441. * @param scene defines the hosting scene
  54442. * @returns the torus mesh
  54443. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  54444. */
  54445. static CreateTorus(name: string, options: {
  54446. diameter?: number;
  54447. thickness?: number;
  54448. tessellation?: number;
  54449. updatable?: boolean;
  54450. sideOrientation?: number;
  54451. frontUVs?: Vector4;
  54452. backUVs?: Vector4;
  54453. }, scene: any): Mesh;
  54454. }
  54455. }
  54456. declare module BABYLON {
  54457. /**
  54458. * Class containing static functions to help procedurally build meshes
  54459. */
  54460. export class CylinderBuilder {
  54461. /**
  54462. * Creates a cylinder or a cone mesh
  54463. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  54464. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  54465. * * 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.
  54466. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  54467. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  54468. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  54469. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  54470. * * 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).
  54471. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  54472. * * 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).
  54473. * * 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
  54474. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  54475. * * 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
  54476. * * 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.
  54477. * * If `enclose` is false, a ring surface is one element.
  54478. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  54479. * * 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
  54480. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54481. * * 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
  54482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54483. * @param name defines the name of the mesh
  54484. * @param options defines the options used to create the mesh
  54485. * @param scene defines the hosting scene
  54486. * @returns the cylinder mesh
  54487. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  54488. */
  54489. static CreateCylinder(name: string, options: {
  54490. height?: number;
  54491. diameterTop?: number;
  54492. diameterBottom?: number;
  54493. diameter?: number;
  54494. tessellation?: number;
  54495. subdivisions?: number;
  54496. arc?: number;
  54497. faceColors?: Color4[];
  54498. faceUV?: Vector4[];
  54499. updatable?: boolean;
  54500. hasRings?: boolean;
  54501. enclose?: boolean;
  54502. cap?: number;
  54503. sideOrientation?: number;
  54504. frontUVs?: Vector4;
  54505. backUVs?: Vector4;
  54506. }, scene: any): Mesh;
  54507. }
  54508. }
  54509. declare module BABYLON {
  54510. /**
  54511. * States of the webXR experience
  54512. */
  54513. export enum WebXRState {
  54514. /**
  54515. * Transitioning to being in XR mode
  54516. */
  54517. ENTERING_XR = 0,
  54518. /**
  54519. * Transitioning to non XR mode
  54520. */
  54521. EXITING_XR = 1,
  54522. /**
  54523. * In XR mode and presenting
  54524. */
  54525. IN_XR = 2,
  54526. /**
  54527. * Not entered XR mode
  54528. */
  54529. NOT_IN_XR = 3
  54530. }
  54531. /**
  54532. * The state of the XR camera's tracking
  54533. */
  54534. export enum WebXRTrackingState {
  54535. /**
  54536. * No transformation received, device is not being tracked
  54537. */
  54538. NOT_TRACKING = 0,
  54539. /**
  54540. * Tracking lost - using emulated position
  54541. */
  54542. TRACKING_LOST = 1,
  54543. /**
  54544. * Transformation tracking works normally
  54545. */
  54546. TRACKING = 2
  54547. }
  54548. /**
  54549. * Abstraction of the XR render target
  54550. */
  54551. export interface WebXRRenderTarget extends IDisposable {
  54552. /**
  54553. * xrpresent context of the canvas which can be used to display/mirror xr content
  54554. */
  54555. canvasContext: WebGLRenderingContext;
  54556. /**
  54557. * xr layer for the canvas
  54558. */
  54559. xrLayer: Nullable<XRWebGLLayer>;
  54560. /**
  54561. * Initializes the xr layer for the session
  54562. * @param xrSession xr session
  54563. * @returns a promise that will resolve once the XR Layer has been created
  54564. */
  54565. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  54566. }
  54567. }
  54568. declare module BABYLON {
  54569. /**
  54570. * Configuration object for WebXR output canvas
  54571. */
  54572. export class WebXRManagedOutputCanvasOptions {
  54573. /**
  54574. * An optional canvas in case you wish to create it yourself and provide it here.
  54575. * If not provided, a new canvas will be created
  54576. */
  54577. canvasElement?: HTMLCanvasElement;
  54578. /**
  54579. * Options for this XR Layer output
  54580. */
  54581. canvasOptions?: XRWebGLLayerInit;
  54582. /**
  54583. * CSS styling for a newly created canvas (if not provided)
  54584. */
  54585. newCanvasCssStyle?: string;
  54586. /**
  54587. * Get the default values of the configuration object
  54588. * @param engine defines the engine to use (can be null)
  54589. * @returns default values of this configuration object
  54590. */
  54591. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  54592. }
  54593. /**
  54594. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  54595. */
  54596. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  54597. private _options;
  54598. private _canvas;
  54599. private _engine;
  54600. private _originalCanvasSize;
  54601. /**
  54602. * Rendering context of the canvas which can be used to display/mirror xr content
  54603. */
  54604. canvasContext: WebGLRenderingContext;
  54605. /**
  54606. * xr layer for the canvas
  54607. */
  54608. xrLayer: Nullable<XRWebGLLayer>;
  54609. /**
  54610. * Observers registered here will be triggered when the xr layer was initialized
  54611. */
  54612. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  54613. /**
  54614. * Initializes the canvas to be added/removed upon entering/exiting xr
  54615. * @param _xrSessionManager The XR Session manager
  54616. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  54617. */
  54618. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  54619. /**
  54620. * Disposes of the object
  54621. */
  54622. dispose(): void;
  54623. /**
  54624. * Initializes the xr layer for the session
  54625. * @param xrSession xr session
  54626. * @returns a promise that will resolve once the XR Layer has been created
  54627. */
  54628. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  54629. private _addCanvas;
  54630. private _removeCanvas;
  54631. private _setCanvasSize;
  54632. private _setManagedOutputCanvas;
  54633. }
  54634. }
  54635. declare module BABYLON {
  54636. /**
  54637. * Manages an XRSession to work with Babylon's engine
  54638. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  54639. */
  54640. export class WebXRSessionManager implements IDisposable {
  54641. /** The scene which the session should be created for */
  54642. scene: Scene;
  54643. private _referenceSpace;
  54644. private _rttProvider;
  54645. private _sessionEnded;
  54646. private _xrNavigator;
  54647. private baseLayer;
  54648. /**
  54649. * The base reference space from which the session started. good if you want to reset your
  54650. * reference space
  54651. */
  54652. baseReferenceSpace: XRReferenceSpace;
  54653. /**
  54654. * Current XR frame
  54655. */
  54656. currentFrame: Nullable<XRFrame>;
  54657. /** WebXR timestamp updated every frame */
  54658. currentTimestamp: number;
  54659. /**
  54660. * Used just in case of a failure to initialize an immersive session.
  54661. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  54662. */
  54663. defaultHeightCompensation: number;
  54664. /**
  54665. * Fires every time a new xrFrame arrives which can be used to update the camera
  54666. */
  54667. onXRFrameObservable: Observable<XRFrame>;
  54668. /**
  54669. * Fires when the reference space changed
  54670. */
  54671. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  54672. /**
  54673. * Fires when the xr session is ended either by the device or manually done
  54674. */
  54675. onXRSessionEnded: Observable<any>;
  54676. /**
  54677. * Fires when the xr session is ended either by the device or manually done
  54678. */
  54679. onXRSessionInit: Observable<XRSession>;
  54680. /**
  54681. * Underlying xr session
  54682. */
  54683. session: XRSession;
  54684. /**
  54685. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  54686. * or get the offset the player is currently at.
  54687. */
  54688. viewerReferenceSpace: XRReferenceSpace;
  54689. /**
  54690. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  54691. * @param scene The scene which the session should be created for
  54692. */
  54693. constructor(
  54694. /** The scene which the session should be created for */
  54695. scene: Scene);
  54696. /**
  54697. * The current reference space used in this session. This reference space can constantly change!
  54698. * It is mainly used to offset the camera's position.
  54699. */
  54700. get referenceSpace(): XRReferenceSpace;
  54701. /**
  54702. * Set a new reference space and triggers the observable
  54703. */
  54704. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  54705. /**
  54706. * Disposes of the session manager
  54707. */
  54708. dispose(): void;
  54709. /**
  54710. * Stops the xrSession and restores the render loop
  54711. * @returns Promise which resolves after it exits XR
  54712. */
  54713. exitXRAsync(): Promise<void>;
  54714. /**
  54715. * Gets the correct render target texture to be rendered this frame for this eye
  54716. * @param eye the eye for which to get the render target
  54717. * @returns the render target for the specified eye
  54718. */
  54719. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  54720. /**
  54721. * Creates a WebXRRenderTarget object for the XR session
  54722. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  54723. * @param options optional options to provide when creating a new render target
  54724. * @returns a WebXR render target to which the session can render
  54725. */
  54726. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  54727. /**
  54728. * Initializes the manager
  54729. * After initialization enterXR can be called to start an XR session
  54730. * @returns Promise which resolves after it is initialized
  54731. */
  54732. initializeAsync(): Promise<void>;
  54733. /**
  54734. * Initializes an xr session
  54735. * @param xrSessionMode mode to initialize
  54736. * @param xrSessionInit defines optional and required values to pass to the session builder
  54737. * @returns a promise which will resolve once the session has been initialized
  54738. */
  54739. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  54740. /**
  54741. * Checks if a session would be supported for the creation options specified
  54742. * @param sessionMode session mode to check if supported eg. immersive-vr
  54743. * @returns A Promise that resolves to true if supported and false if not
  54744. */
  54745. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  54746. /**
  54747. * Resets the reference space to the one started the session
  54748. */
  54749. resetReferenceSpace(): void;
  54750. /**
  54751. * Starts rendering to the xr layer
  54752. */
  54753. runXRRenderLoop(): void;
  54754. /**
  54755. * Sets the reference space on the xr session
  54756. * @param referenceSpaceType space to set
  54757. * @returns a promise that will resolve once the reference space has been set
  54758. */
  54759. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  54760. /**
  54761. * Updates the render state of the session
  54762. * @param state state to set
  54763. * @returns a promise that resolves once the render state has been updated
  54764. */
  54765. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  54766. /**
  54767. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  54768. * @param sessionMode defines the session to test
  54769. * @returns a promise with boolean as final value
  54770. */
  54771. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  54772. /**
  54773. * Returns true if Babylon.js is using the BabylonNative backend, otherwise false
  54774. */
  54775. get isNative(): boolean;
  54776. private _createRenderTargetTexture;
  54777. }
  54778. }
  54779. declare module BABYLON {
  54780. /**
  54781. * WebXR Camera which holds the views for the xrSession
  54782. * @see https://doc.babylonjs.com/how_to/webxr_camera
  54783. */
  54784. export class WebXRCamera extends FreeCamera {
  54785. private _xrSessionManager;
  54786. private _firstFrame;
  54787. private _referenceQuaternion;
  54788. private _referencedPosition;
  54789. private _xrInvPositionCache;
  54790. private _xrInvQuaternionCache;
  54791. private _trackingState;
  54792. /**
  54793. * Observable raised before camera teleportation
  54794. */
  54795. onBeforeCameraTeleport: Observable<Vector3>;
  54796. /**
  54797. * Observable raised after camera teleportation
  54798. */
  54799. onAfterCameraTeleport: Observable<Vector3>;
  54800. /**
  54801. * Notifies when the camera's tracking state has changed.
  54802. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  54803. */
  54804. onTrackingStateChanged: Observable<WebXRTrackingState>;
  54805. /**
  54806. * Should position compensation execute on first frame.
  54807. * This is used when copying the position from a native (non XR) camera
  54808. */
  54809. compensateOnFirstFrame: boolean;
  54810. /**
  54811. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  54812. * @param name the name of the camera
  54813. * @param scene the scene to add the camera to
  54814. * @param _xrSessionManager a constructed xr session manager
  54815. */
  54816. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  54817. /**
  54818. * Get the current XR tracking state of the camera
  54819. */
  54820. get trackingState(): WebXRTrackingState;
  54821. private _setTrackingState;
  54822. /**
  54823. * Return the user's height, unrelated to the current ground.
  54824. * This will be the y position of this camera, when ground level is 0.
  54825. */
  54826. get realWorldHeight(): number;
  54827. /** @hidden */
  54828. _updateForDualEyeDebugging(): void;
  54829. /**
  54830. * Sets this camera's transformation based on a non-vr camera
  54831. * @param otherCamera the non-vr camera to copy the transformation from
  54832. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  54833. */
  54834. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  54835. /**
  54836. * Gets the current instance class name ("WebXRCamera").
  54837. * @returns the class name
  54838. */
  54839. getClassName(): string;
  54840. private _rotate180;
  54841. private _updateFromXRSession;
  54842. private _updateNumberOfRigCameras;
  54843. private _updateReferenceSpace;
  54844. private _updateReferenceSpaceOffset;
  54845. }
  54846. }
  54847. declare module BABYLON {
  54848. /**
  54849. * Defining the interface required for a (webxr) feature
  54850. */
  54851. export interface IWebXRFeature extends IDisposable {
  54852. /**
  54853. * Is this feature attached
  54854. */
  54855. attached: boolean;
  54856. /**
  54857. * Should auto-attach be disabled?
  54858. */
  54859. disableAutoAttach: boolean;
  54860. /**
  54861. * Attach the feature to the session
  54862. * Will usually be called by the features manager
  54863. *
  54864. * @param force should attachment be forced (even when already attached)
  54865. * @returns true if successful.
  54866. */
  54867. attach(force?: boolean): boolean;
  54868. /**
  54869. * Detach the feature from the session
  54870. * Will usually be called by the features manager
  54871. *
  54872. * @returns true if successful.
  54873. */
  54874. detach(): boolean;
  54875. /**
  54876. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  54877. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  54878. *
  54879. * @returns whether or not the feature is compatible in this environment
  54880. */
  54881. isCompatible(): boolean;
  54882. /**
  54883. * Was this feature disposed;
  54884. */
  54885. isDisposed: boolean;
  54886. /**
  54887. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  54888. */
  54889. xrNativeFeatureName?: string;
  54890. /**
  54891. * A list of (Babylon WebXR) features this feature depends on
  54892. */
  54893. dependsOn?: string[];
  54894. /**
  54895. * If this feature requires to extend the XRSessionInit object, this function will return the partial XR session init object
  54896. */
  54897. getXRSessionInitExtension?: () => Promise<Partial<XRSessionInit>>;
  54898. }
  54899. /**
  54900. * A list of the currently available features without referencing them
  54901. */
  54902. export class WebXRFeatureName {
  54903. /**
  54904. * The name of the anchor system feature
  54905. */
  54906. static readonly ANCHOR_SYSTEM: string;
  54907. /**
  54908. * The name of the background remover feature
  54909. */
  54910. static readonly BACKGROUND_REMOVER: string;
  54911. /**
  54912. * The name of the hit test feature
  54913. */
  54914. static readonly HIT_TEST: string;
  54915. /**
  54916. * The name of the mesh detection feature
  54917. */
  54918. static readonly MESH_DETECTION: string;
  54919. /**
  54920. * physics impostors for xr controllers feature
  54921. */
  54922. static readonly PHYSICS_CONTROLLERS: string;
  54923. /**
  54924. * The name of the plane detection feature
  54925. */
  54926. static readonly PLANE_DETECTION: string;
  54927. /**
  54928. * The name of the pointer selection feature
  54929. */
  54930. static readonly POINTER_SELECTION: string;
  54931. /**
  54932. * The name of the teleportation feature
  54933. */
  54934. static readonly TELEPORTATION: string;
  54935. /**
  54936. * The name of the feature points feature.
  54937. */
  54938. static readonly FEATURE_POINTS: string;
  54939. /**
  54940. * The name of the hand tracking feature.
  54941. */
  54942. static readonly HAND_TRACKING: string;
  54943. /**
  54944. * The name of the image tracking feature
  54945. */
  54946. static readonly IMAGE_TRACKING: string;
  54947. }
  54948. /**
  54949. * Defining the constructor of a feature. Used to register the modules.
  54950. */
  54951. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  54952. /**
  54953. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  54954. * It is mainly used in AR sessions.
  54955. *
  54956. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  54957. */
  54958. export class WebXRFeaturesManager implements IDisposable {
  54959. private _xrSessionManager;
  54960. private static readonly _AvailableFeatures;
  54961. private _features;
  54962. /**
  54963. * constructs a new features manages.
  54964. *
  54965. * @param _xrSessionManager an instance of WebXRSessionManager
  54966. */
  54967. constructor(_xrSessionManager: WebXRSessionManager);
  54968. /**
  54969. * Used to register a module. After calling this function a developer can use this feature in the scene.
  54970. * Mainly used internally.
  54971. *
  54972. * @param featureName the name of the feature to register
  54973. * @param constructorFunction the function used to construct the module
  54974. * @param version the (babylon) version of the module
  54975. * @param stable is that a stable version of this module
  54976. */
  54977. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  54978. /**
  54979. * Returns a constructor of a specific feature.
  54980. *
  54981. * @param featureName the name of the feature to construct
  54982. * @param version the version of the feature to load
  54983. * @param xrSessionManager the xrSessionManager. Used to construct the module
  54984. * @param options optional options provided to the module.
  54985. * @returns a function that, when called, will return a new instance of this feature
  54986. */
  54987. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  54988. /**
  54989. * Can be used to return the list of features currently registered
  54990. *
  54991. * @returns an Array of available features
  54992. */
  54993. static GetAvailableFeatures(): string[];
  54994. /**
  54995. * Gets the versions available for a specific feature
  54996. * @param featureName the name of the feature
  54997. * @returns an array with the available versions
  54998. */
  54999. static GetAvailableVersions(featureName: string): string[];
  55000. /**
  55001. * Return the latest unstable 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 GetLatestVersionOfFeature(featureName: string): number;
  55006. /**
  55007. * Return the latest stable version of this feature
  55008. * @param featureName the name of the feature to search
  55009. * @returns the version number. if not found will return -1
  55010. */
  55011. static GetStableVersionOfFeature(featureName: string): number;
  55012. /**
  55013. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  55014. * Can be used during a session to start a feature
  55015. * @param featureName the name of feature to attach
  55016. */
  55017. attachFeature(featureName: string): void;
  55018. /**
  55019. * Can be used inside a session or when the session ends to detach a specific feature
  55020. * @param featureName the name of the feature to detach
  55021. */
  55022. detachFeature(featureName: string): void;
  55023. /**
  55024. * Used to disable an already-enabled feature
  55025. * The feature will be disposed and will be recreated once enabled.
  55026. * @param featureName the feature to disable
  55027. * @returns true if disable was successful
  55028. */
  55029. disableFeature(featureName: string | {
  55030. Name: string;
  55031. }): boolean;
  55032. /**
  55033. * dispose this features manager
  55034. */
  55035. dispose(): void;
  55036. /**
  55037. * 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.
  55038. * 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.
  55039. *
  55040. * @param featureName the name of the feature to load or the class of the feature
  55041. * @param version optional version to load. if not provided the latest version will be enabled
  55042. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  55043. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  55044. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  55045. * @returns a new constructed feature or throws an error if feature not found.
  55046. */
  55047. enableFeature(featureName: string | {
  55048. Name: string;
  55049. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  55050. /**
  55051. * get the implementation of an enabled feature.
  55052. * @param featureName the name of the feature to load
  55053. * @returns the feature class, if found
  55054. */
  55055. getEnabledFeature(featureName: string): IWebXRFeature;
  55056. /**
  55057. * Get the list of enabled features
  55058. * @returns an array of enabled features
  55059. */
  55060. getEnabledFeatures(): string[];
  55061. /**
  55062. * This function will extend the session creation configuration object with enabled features.
  55063. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  55064. * according to the defined "required" variable, provided during enableFeature call
  55065. * @param xrSessionInit the xr Session init object to extend
  55066. *
  55067. * @returns an extended XRSessionInit object
  55068. */
  55069. _extendXRSessionInitObject(xrSessionInit: XRSessionInit): Promise<XRSessionInit>;
  55070. }
  55071. }
  55072. declare module BABYLON {
  55073. /**
  55074. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  55075. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  55076. */
  55077. export class WebXRExperienceHelper implements IDisposable {
  55078. private scene;
  55079. private _nonVRCamera;
  55080. private _originalSceneAutoClear;
  55081. private _supported;
  55082. /**
  55083. * Camera used to render xr content
  55084. */
  55085. camera: WebXRCamera;
  55086. /** A features manager for this xr session */
  55087. featuresManager: WebXRFeaturesManager;
  55088. /**
  55089. * Observers registered here will be triggered after the camera's initial transformation is set
  55090. * This can be used to set a different ground level or an extra rotation.
  55091. *
  55092. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  55093. * to the position set after this observable is done executing.
  55094. */
  55095. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  55096. /**
  55097. * Fires when the state of the experience helper has changed
  55098. */
  55099. onStateChangedObservable: Observable<WebXRState>;
  55100. /** Session manager used to keep track of xr session */
  55101. sessionManager: WebXRSessionManager;
  55102. /**
  55103. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  55104. */
  55105. state: WebXRState;
  55106. /**
  55107. * Creates a WebXRExperienceHelper
  55108. * @param scene The scene the helper should be created in
  55109. */
  55110. private constructor();
  55111. /**
  55112. * Creates the experience helper
  55113. * @param scene the scene to attach the experience helper to
  55114. * @returns a promise for the experience helper
  55115. */
  55116. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  55117. /**
  55118. * Disposes of the experience helper
  55119. */
  55120. dispose(): void;
  55121. /**
  55122. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  55123. * @param sessionMode options for the XR session
  55124. * @param referenceSpaceType frame of reference of the XR session
  55125. * @param renderTarget the output canvas that will be used to enter XR mode
  55126. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  55127. * @returns promise that resolves after xr mode has entered
  55128. */
  55129. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  55130. /**
  55131. * Exits XR mode and returns the scene to its original state
  55132. * @returns promise that resolves after xr mode has exited
  55133. */
  55134. exitXRAsync(): Promise<void>;
  55135. private _nonXRToXRCamera;
  55136. private _setState;
  55137. }
  55138. }
  55139. declare module BABYLON {
  55140. /**
  55141. * X-Y values for axes in WebXR
  55142. */
  55143. export interface IWebXRMotionControllerAxesValue {
  55144. /**
  55145. * The value of the x axis
  55146. */
  55147. x: number;
  55148. /**
  55149. * The value of the y-axis
  55150. */
  55151. y: number;
  55152. }
  55153. /**
  55154. * changed / previous values for the values of this component
  55155. */
  55156. export interface IWebXRMotionControllerComponentChangesValues<T> {
  55157. /**
  55158. * current (this frame) value
  55159. */
  55160. current: T;
  55161. /**
  55162. * previous (last change) value
  55163. */
  55164. previous: T;
  55165. }
  55166. /**
  55167. * Represents changes in the component between current frame and last values recorded
  55168. */
  55169. export interface IWebXRMotionControllerComponentChanges {
  55170. /**
  55171. * will be populated with previous and current values if axes changed
  55172. */
  55173. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  55174. /**
  55175. * will be populated with previous and current values if pressed changed
  55176. */
  55177. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  55178. /**
  55179. * will be populated with previous and current values if touched changed
  55180. */
  55181. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  55182. /**
  55183. * will be populated with previous and current values if value changed
  55184. */
  55185. value?: IWebXRMotionControllerComponentChangesValues<number>;
  55186. }
  55187. /**
  55188. * This class represents a single component (for example button or thumbstick) of a motion controller
  55189. */
  55190. export class WebXRControllerComponent implements IDisposable {
  55191. /**
  55192. * the id of this component
  55193. */
  55194. id: string;
  55195. /**
  55196. * the type of the component
  55197. */
  55198. type: MotionControllerComponentType;
  55199. private _buttonIndex;
  55200. private _axesIndices;
  55201. private _axes;
  55202. private _changes;
  55203. private _currentValue;
  55204. private _hasChanges;
  55205. private _pressed;
  55206. private _touched;
  55207. /**
  55208. * button component type
  55209. */
  55210. static BUTTON_TYPE: MotionControllerComponentType;
  55211. /**
  55212. * squeeze component type
  55213. */
  55214. static SQUEEZE_TYPE: MotionControllerComponentType;
  55215. /**
  55216. * Thumbstick component type
  55217. */
  55218. static THUMBSTICK_TYPE: MotionControllerComponentType;
  55219. /**
  55220. * Touchpad component type
  55221. */
  55222. static TOUCHPAD_TYPE: MotionControllerComponentType;
  55223. /**
  55224. * trigger component type
  55225. */
  55226. static TRIGGER_TYPE: MotionControllerComponentType;
  55227. /**
  55228. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  55229. * the axes data changes
  55230. */
  55231. onAxisValueChangedObservable: Observable<{
  55232. x: number;
  55233. y: number;
  55234. }>;
  55235. /**
  55236. * Observers registered here will be triggered when the state of a button changes
  55237. * State change is either pressed / touched / value
  55238. */
  55239. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  55240. /**
  55241. * Creates a new component for a motion controller.
  55242. * It is created by the motion controller itself
  55243. *
  55244. * @param id the id of this component
  55245. * @param type the type of the component
  55246. * @param _buttonIndex index in the buttons array of the gamepad
  55247. * @param _axesIndices indices of the values in the axes array of the gamepad
  55248. */
  55249. constructor(
  55250. /**
  55251. * the id of this component
  55252. */
  55253. id: string,
  55254. /**
  55255. * the type of the component
  55256. */
  55257. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  55258. /**
  55259. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  55260. */
  55261. get axes(): IWebXRMotionControllerAxesValue;
  55262. /**
  55263. * Get the changes. Elements will be populated only if they changed with their previous and current value
  55264. */
  55265. get changes(): IWebXRMotionControllerComponentChanges;
  55266. /**
  55267. * Return whether or not the component changed the last frame
  55268. */
  55269. get hasChanges(): boolean;
  55270. /**
  55271. * is the button currently pressed
  55272. */
  55273. get pressed(): boolean;
  55274. /**
  55275. * is the button currently touched
  55276. */
  55277. get touched(): boolean;
  55278. /**
  55279. * Get the current value of this component
  55280. */
  55281. get value(): number;
  55282. /**
  55283. * Dispose this component
  55284. */
  55285. dispose(): void;
  55286. /**
  55287. * Are there axes correlating to this component
  55288. * @return true is axes data is available
  55289. */
  55290. isAxes(): boolean;
  55291. /**
  55292. * Is this component a button (hence - pressable)
  55293. * @returns true if can be pressed
  55294. */
  55295. isButton(): boolean;
  55296. /**
  55297. * update this component using the gamepad object it is in. Called on every frame
  55298. * @param nativeController the native gamepad controller object
  55299. */
  55300. update(nativeController: IMinimalMotionControllerObject): void;
  55301. }
  55302. }
  55303. declare module BABYLON {
  55304. /**
  55305. * Type used for the success callback of ImportMesh
  55306. */
  55307. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  55308. /**
  55309. * Interface used for the result of ImportMeshAsync
  55310. */
  55311. export interface ISceneLoaderAsyncResult {
  55312. /**
  55313. * The array of loaded meshes
  55314. */
  55315. readonly meshes: AbstractMesh[];
  55316. /**
  55317. * The array of loaded particle systems
  55318. */
  55319. readonly particleSystems: IParticleSystem[];
  55320. /**
  55321. * The array of loaded skeletons
  55322. */
  55323. readonly skeletons: Skeleton[];
  55324. /**
  55325. * The array of loaded animation groups
  55326. */
  55327. readonly animationGroups: AnimationGroup[];
  55328. /**
  55329. * The array of loaded transform nodes
  55330. */
  55331. readonly transformNodes: TransformNode[];
  55332. /**
  55333. * The array of loaded geometries
  55334. */
  55335. readonly geometries: Geometry[];
  55336. /**
  55337. * The array of loaded lights
  55338. */
  55339. readonly lights: Light[];
  55340. }
  55341. /**
  55342. * Interface used to represent data loading progression
  55343. */
  55344. export interface ISceneLoaderProgressEvent {
  55345. /**
  55346. * Defines if data length to load can be evaluated
  55347. */
  55348. readonly lengthComputable: boolean;
  55349. /**
  55350. * Defines the loaded data length
  55351. */
  55352. readonly loaded: number;
  55353. /**
  55354. * Defines the data length to load
  55355. */
  55356. readonly total: number;
  55357. }
  55358. /**
  55359. * Interface used by SceneLoader plugins to define supported file extensions
  55360. */
  55361. export interface ISceneLoaderPluginExtensions {
  55362. /**
  55363. * Defines the list of supported extensions
  55364. */
  55365. [extension: string]: {
  55366. isBinary: boolean;
  55367. };
  55368. }
  55369. /**
  55370. * Interface used by SceneLoader plugin factory
  55371. */
  55372. export interface ISceneLoaderPluginFactory {
  55373. /**
  55374. * Defines the name of the factory
  55375. */
  55376. name: string;
  55377. /**
  55378. * Function called to create a new plugin
  55379. * @return the new plugin
  55380. */
  55381. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  55382. /**
  55383. * The callback that returns true if the data can be directly loaded.
  55384. * @param data string containing the file data
  55385. * @returns if the data can be loaded directly
  55386. */
  55387. canDirectLoad?(data: string): boolean;
  55388. }
  55389. /**
  55390. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  55391. */
  55392. export interface ISceneLoaderPluginBase {
  55393. /**
  55394. * The friendly name of this plugin.
  55395. */
  55396. name: string;
  55397. /**
  55398. * The file extensions supported by this plugin.
  55399. */
  55400. extensions: string | ISceneLoaderPluginExtensions;
  55401. /**
  55402. * The callback called when loading from a url.
  55403. * @param scene scene loading this url
  55404. * @param url url to load
  55405. * @param onSuccess callback called when the file successfully loads
  55406. * @param onProgress callback called while file is loading (if the server supports this mode)
  55407. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  55408. * @param onError callback called when the file fails to load
  55409. * @returns a file request object
  55410. */
  55411. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  55412. /**
  55413. * The callback called when loading from a file object.
  55414. * @param scene scene loading this file
  55415. * @param file defines the file to load
  55416. * @param onSuccess defines the callback to call when data is loaded
  55417. * @param onProgress defines the callback to call during loading process
  55418. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  55419. * @param onError defines the callback to call when an error occurs
  55420. * @returns a file request object
  55421. */
  55422. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  55423. /**
  55424. * The callback that returns true if the data can be directly loaded.
  55425. * @param data string containing the file data
  55426. * @returns if the data can be loaded directly
  55427. */
  55428. canDirectLoad?(data: string): boolean;
  55429. /**
  55430. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  55431. * @param scene scene loading this data
  55432. * @param data string containing the data
  55433. * @returns data to pass to the plugin
  55434. */
  55435. directLoad?(scene: Scene, data: string): any;
  55436. /**
  55437. * The callback that allows custom handling of the root url based on the response url.
  55438. * @param rootUrl the original root url
  55439. * @param responseURL the response url if available
  55440. * @returns the new root url
  55441. */
  55442. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  55443. }
  55444. /**
  55445. * Interface used to define a SceneLoader plugin
  55446. */
  55447. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  55448. /**
  55449. * Import meshes into a scene.
  55450. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  55451. * @param scene The scene to import into
  55452. * @param data The data to import
  55453. * @param rootUrl The root url for scene and resources
  55454. * @param meshes The meshes array to import into
  55455. * @param particleSystems The particle systems array to import into
  55456. * @param skeletons The skeletons array to import into
  55457. * @param onError The callback when import fails
  55458. * @returns True if successful or false otherwise
  55459. */
  55460. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  55461. /**
  55462. * Load into a scene.
  55463. * @param scene The scene to load into
  55464. * @param data The data to import
  55465. * @param rootUrl The root url for scene and resources
  55466. * @param onError The callback when import fails
  55467. * @returns True if successful or false otherwise
  55468. */
  55469. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  55470. /**
  55471. * Load into an asset container.
  55472. * @param scene The scene to load into
  55473. * @param data The data to import
  55474. * @param rootUrl The root url for scene and resources
  55475. * @param onError The callback when import fails
  55476. * @returns The loaded asset container
  55477. */
  55478. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  55479. }
  55480. /**
  55481. * Interface used to define an async SceneLoader plugin
  55482. */
  55483. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  55484. /**
  55485. * Import meshes into a scene.
  55486. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  55487. * @param scene The scene to import into
  55488. * @param data The data to import
  55489. * @param rootUrl The root url for scene and resources
  55490. * @param onProgress The callback when the load progresses
  55491. * @param fileName Defines the name of the file to load
  55492. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  55493. */
  55494. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  55495. /**
  55496. * Load into a scene.
  55497. * @param scene The scene to load into
  55498. * @param data The data to import
  55499. * @param rootUrl The root url for scene and resources
  55500. * @param onProgress The callback when the load progresses
  55501. * @param fileName Defines the name of the file to load
  55502. * @returns Nothing
  55503. */
  55504. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  55505. /**
  55506. * Load into an asset container.
  55507. * @param scene The scene to load into
  55508. * @param data The data to import
  55509. * @param rootUrl The root url for scene and resources
  55510. * @param onProgress The callback when the load progresses
  55511. * @param fileName Defines the name of the file to load
  55512. * @returns The loaded asset container
  55513. */
  55514. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  55515. }
  55516. /**
  55517. * Mode that determines how to handle old animation groups before loading new ones.
  55518. */
  55519. export enum SceneLoaderAnimationGroupLoadingMode {
  55520. /**
  55521. * Reset all old animations to initial state then dispose them.
  55522. */
  55523. Clean = 0,
  55524. /**
  55525. * Stop all old animations.
  55526. */
  55527. Stop = 1,
  55528. /**
  55529. * Restart old animations from first frame.
  55530. */
  55531. Sync = 2,
  55532. /**
  55533. * Old animations remains untouched.
  55534. */
  55535. NoSync = 3
  55536. }
  55537. /**
  55538. * Defines a plugin registered by the SceneLoader
  55539. */
  55540. interface IRegisteredPlugin {
  55541. /**
  55542. * Defines the plugin to use
  55543. */
  55544. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  55545. /**
  55546. * Defines if the plugin supports binary data
  55547. */
  55548. isBinary: boolean;
  55549. }
  55550. /**
  55551. * Class used to load scene from various file formats using registered plugins
  55552. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  55553. */
  55554. export class SceneLoader {
  55555. /**
  55556. * No logging while loading
  55557. */
  55558. static readonly NO_LOGGING: number;
  55559. /**
  55560. * Minimal logging while loading
  55561. */
  55562. static readonly MINIMAL_LOGGING: number;
  55563. /**
  55564. * Summary logging while loading
  55565. */
  55566. static readonly SUMMARY_LOGGING: number;
  55567. /**
  55568. * Detailed logging while loading
  55569. */
  55570. static readonly DETAILED_LOGGING: number;
  55571. /**
  55572. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  55573. */
  55574. static get ForceFullSceneLoadingForIncremental(): boolean;
  55575. static set ForceFullSceneLoadingForIncremental(value: boolean);
  55576. /**
  55577. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  55578. */
  55579. static get ShowLoadingScreen(): boolean;
  55580. static set ShowLoadingScreen(value: boolean);
  55581. /**
  55582. * Defines the current logging level (while loading the scene)
  55583. * @ignorenaming
  55584. */
  55585. static get loggingLevel(): number;
  55586. static set loggingLevel(value: number);
  55587. /**
  55588. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  55589. */
  55590. static get CleanBoneMatrixWeights(): boolean;
  55591. static set CleanBoneMatrixWeights(value: boolean);
  55592. /**
  55593. * Event raised when a plugin is used to load a scene
  55594. */
  55595. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  55596. private static _registeredPlugins;
  55597. private static _showingLoadingScreen;
  55598. /**
  55599. * Gets the default plugin (used to load Babylon files)
  55600. * @returns the .babylon plugin
  55601. */
  55602. static GetDefaultPlugin(): IRegisteredPlugin;
  55603. private static _GetPluginForExtension;
  55604. private static _GetPluginForDirectLoad;
  55605. private static _GetPluginForFilename;
  55606. private static _GetDirectLoad;
  55607. private static _LoadData;
  55608. private static _GetFileInfo;
  55609. /**
  55610. * Gets a plugin that can load the given extension
  55611. * @param extension defines the extension to load
  55612. * @returns a plugin or null if none works
  55613. */
  55614. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  55615. /**
  55616. * Gets a boolean indicating that the given extension can be loaded
  55617. * @param extension defines the extension to load
  55618. * @returns true if the extension is supported
  55619. */
  55620. static IsPluginForExtensionAvailable(extension: string): boolean;
  55621. /**
  55622. * Adds a new plugin to the list of registered plugins
  55623. * @param plugin defines the plugin to add
  55624. */
  55625. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  55626. /**
  55627. * Import meshes into a scene
  55628. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  55629. * @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)
  55630. * @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)
  55631. * @param scene the instance of BABYLON.Scene to append to
  55632. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  55633. * @param onProgress a callback with a progress event for each file being loaded
  55634. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  55635. * @param pluginExtension the extension used to determine the plugin
  55636. * @returns The loaded plugin
  55637. */
  55638. 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>;
  55639. /**
  55640. * Import meshes into a scene
  55641. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  55642. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  55643. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  55644. * @param scene the instance of BABYLON.Scene to append to
  55645. * @param onProgress a callback with a progress event for each file being loaded
  55646. * @param pluginExtension the extension used to determine the plugin
  55647. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  55648. */
  55649. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  55650. /**
  55651. * Load a scene
  55652. * @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)
  55653. * @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)
  55654. * @param engine is the instance of BABYLON.Engine to use to create the scene
  55655. * @param onSuccess a callback with the scene when import succeeds
  55656. * @param onProgress a callback with a progress event for each file being loaded
  55657. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  55658. * @param pluginExtension the extension used to determine the plugin
  55659. * @returns The loaded plugin
  55660. */
  55661. 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>;
  55662. /**
  55663. * Load a scene
  55664. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  55665. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  55666. * @param engine is the instance of BABYLON.Engine to use to create the scene
  55667. * @param onProgress a callback with a progress event for each file being loaded
  55668. * @param pluginExtension the extension used to determine the plugin
  55669. * @returns The loaded scene
  55670. */
  55671. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  55672. /**
  55673. * Append a scene
  55674. * @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)
  55675. * @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)
  55676. * @param scene is the instance of BABYLON.Scene to append to
  55677. * @param onSuccess a callback with the scene when import succeeds
  55678. * @param onProgress a callback with a progress event for each file being loaded
  55679. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  55680. * @param pluginExtension the extension used to determine the plugin
  55681. * @returns The loaded plugin
  55682. */
  55683. 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>;
  55684. /**
  55685. * Append a scene
  55686. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  55687. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  55688. * @param scene is the instance of BABYLON.Scene to append to
  55689. * @param onProgress a callback with a progress event for each file being loaded
  55690. * @param pluginExtension the extension used to determine the plugin
  55691. * @returns The given scene
  55692. */
  55693. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  55694. /**
  55695. * Load a scene into an asset container
  55696. * @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)
  55697. * @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)
  55698. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  55699. * @param onSuccess a callback with the scene when import succeeds
  55700. * @param onProgress a callback with a progress event for each file being loaded
  55701. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  55702. * @param pluginExtension the extension used to determine the plugin
  55703. * @returns The loaded plugin
  55704. */
  55705. 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>;
  55706. /**
  55707. * Load a scene into an asset container
  55708. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  55709. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  55710. * @param scene is the instance of Scene to append to
  55711. * @param onProgress a callback with a progress event for each file being loaded
  55712. * @param pluginExtension the extension used to determine the plugin
  55713. * @returns The loaded asset container
  55714. */
  55715. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  55716. /**
  55717. * Import animations from a file into a scene
  55718. * @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)
  55719. * @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)
  55720. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  55721. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  55722. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  55723. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  55724. * @param onSuccess a callback with the scene when import succeeds
  55725. * @param onProgress a callback with a progress event for each file being loaded
  55726. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  55727. * @param pluginExtension the extension used to determine the plugin
  55728. */
  55729. 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;
  55730. /**
  55731. * Import animations from a file into a scene
  55732. * @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)
  55733. * @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)
  55734. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  55735. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  55736. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  55737. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  55738. * @param onSuccess a callback with the scene when import succeeds
  55739. * @param onProgress a callback with a progress event for each file being loaded
  55740. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  55741. * @param pluginExtension the extension used to determine the plugin
  55742. * @returns the updated scene with imported animations
  55743. */
  55744. 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>;
  55745. }
  55746. }
  55747. declare module BABYLON {
  55748. /**
  55749. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  55750. */
  55751. export type MotionControllerHandedness = "none" | "left" | "right";
  55752. /**
  55753. * The type of components available in motion controllers.
  55754. * This is not the name of the component.
  55755. */
  55756. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  55757. /**
  55758. * The state of a controller component
  55759. */
  55760. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  55761. /**
  55762. * The schema of motion controller layout.
  55763. * No object will be initialized using this interface
  55764. * This is used just to define the profile.
  55765. */
  55766. export interface IMotionControllerLayout {
  55767. /**
  55768. * Path to load the assets. Usually relative to the base path
  55769. */
  55770. assetPath: string;
  55771. /**
  55772. * Available components (unsorted)
  55773. */
  55774. components: {
  55775. /**
  55776. * A map of component Ids
  55777. */
  55778. [componentId: string]: {
  55779. /**
  55780. * The type of input the component outputs
  55781. */
  55782. type: MotionControllerComponentType;
  55783. /**
  55784. * The indices of this component in the gamepad object
  55785. */
  55786. gamepadIndices: {
  55787. /**
  55788. * Index of button
  55789. */
  55790. button?: number;
  55791. /**
  55792. * If available, index of x-axis
  55793. */
  55794. xAxis?: number;
  55795. /**
  55796. * If available, index of y-axis
  55797. */
  55798. yAxis?: number;
  55799. };
  55800. /**
  55801. * The mesh's root node name
  55802. */
  55803. rootNodeName: string;
  55804. /**
  55805. * Animation definitions for this model
  55806. */
  55807. visualResponses: {
  55808. [stateKey: string]: {
  55809. /**
  55810. * What property will be animated
  55811. */
  55812. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  55813. /**
  55814. * What states influence this visual response
  55815. */
  55816. states: MotionControllerComponentStateType[];
  55817. /**
  55818. * Type of animation - movement or visibility
  55819. */
  55820. valueNodeProperty: "transform" | "visibility";
  55821. /**
  55822. * Base node name to move. Its position will be calculated according to the min and max nodes
  55823. */
  55824. valueNodeName?: string;
  55825. /**
  55826. * Minimum movement node
  55827. */
  55828. minNodeName?: string;
  55829. /**
  55830. * Max movement node
  55831. */
  55832. maxNodeName?: string;
  55833. };
  55834. };
  55835. /**
  55836. * If touch enabled, what is the name of node to display user feedback
  55837. */
  55838. touchPointNodeName?: string;
  55839. };
  55840. };
  55841. /**
  55842. * Is it xr standard mapping or not
  55843. */
  55844. gamepadMapping: "" | "xr-standard";
  55845. /**
  55846. * Base root node of this entire model
  55847. */
  55848. rootNodeName: string;
  55849. /**
  55850. * Defines the main button component id
  55851. */
  55852. selectComponentId: string;
  55853. }
  55854. /**
  55855. * A definition for the layout map in the input profile
  55856. */
  55857. export interface IMotionControllerLayoutMap {
  55858. /**
  55859. * Layouts with handedness type as a key
  55860. */
  55861. [handedness: string]: IMotionControllerLayout;
  55862. }
  55863. /**
  55864. * The XR Input profile schema
  55865. * Profiles can be found here:
  55866. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  55867. */
  55868. export interface IMotionControllerProfile {
  55869. /**
  55870. * fallback profiles for this profileId
  55871. */
  55872. fallbackProfileIds: string[];
  55873. /**
  55874. * The layout map, with handedness as key
  55875. */
  55876. layouts: IMotionControllerLayoutMap;
  55877. /**
  55878. * The id of this profile
  55879. * correlates to the profile(s) in the xrInput.profiles array
  55880. */
  55881. profileId: string;
  55882. }
  55883. /**
  55884. * A helper-interface for the 3 meshes needed for controller button animation
  55885. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  55886. */
  55887. export interface IMotionControllerButtonMeshMap {
  55888. /**
  55889. * the mesh that defines the pressed value mesh position.
  55890. * This is used to find the max-position of this button
  55891. */
  55892. pressedMesh: AbstractMesh;
  55893. /**
  55894. * the mesh that defines the unpressed value mesh position.
  55895. * This is used to find the min (or initial) position of this button
  55896. */
  55897. unpressedMesh: AbstractMesh;
  55898. /**
  55899. * The mesh that will be changed when value changes
  55900. */
  55901. valueMesh: AbstractMesh;
  55902. }
  55903. /**
  55904. * A helper-interface for the 3 meshes needed for controller axis animation.
  55905. * This will be expanded when touchpad animations are fully supported
  55906. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  55907. */
  55908. export interface IMotionControllerMeshMap {
  55909. /**
  55910. * the mesh that defines the maximum value mesh position.
  55911. */
  55912. maxMesh?: AbstractMesh;
  55913. /**
  55914. * the mesh that defines the minimum value mesh position.
  55915. */
  55916. minMesh?: AbstractMesh;
  55917. /**
  55918. * The mesh that will be changed when axis value changes
  55919. */
  55920. valueMesh?: AbstractMesh;
  55921. }
  55922. /**
  55923. * The elements needed for change-detection of the gamepad objects in motion controllers
  55924. */
  55925. export interface IMinimalMotionControllerObject {
  55926. /**
  55927. * Available axes of this controller
  55928. */
  55929. axes: number[];
  55930. /**
  55931. * An array of available buttons
  55932. */
  55933. buttons: Array<{
  55934. /**
  55935. * Value of the button/trigger
  55936. */
  55937. value: number;
  55938. /**
  55939. * If the button/trigger is currently touched
  55940. */
  55941. touched: boolean;
  55942. /**
  55943. * If the button/trigger is currently pressed
  55944. */
  55945. pressed: boolean;
  55946. }>;
  55947. /**
  55948. * EXPERIMENTAL haptic support.
  55949. */
  55950. hapticActuators?: Array<{
  55951. pulse: (value: number, duration: number) => Promise<boolean>;
  55952. }>;
  55953. }
  55954. /**
  55955. * An Abstract Motion controller
  55956. * This class receives an xrInput and a profile layout and uses those to initialize the components
  55957. * Each component has an observable to check for changes in value and state
  55958. */
  55959. export abstract class WebXRAbstractMotionController implements IDisposable {
  55960. protected scene: Scene;
  55961. protected layout: IMotionControllerLayout;
  55962. /**
  55963. * The gamepad object correlating to this controller
  55964. */
  55965. gamepadObject: IMinimalMotionControllerObject;
  55966. /**
  55967. * handedness (left/right/none) of this controller
  55968. */
  55969. handedness: MotionControllerHandedness;
  55970. private _initComponent;
  55971. private _modelReady;
  55972. /**
  55973. * A map of components (WebXRControllerComponent) in this motion controller
  55974. * Components have a ComponentType and can also have both button and axis definitions
  55975. */
  55976. readonly components: {
  55977. [id: string]: WebXRControllerComponent;
  55978. };
  55979. /**
  55980. * Disable the model's animation. Can be set at any time.
  55981. */
  55982. disableAnimation: boolean;
  55983. /**
  55984. * Observers registered here will be triggered when the model of this controller is done loading
  55985. */
  55986. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  55987. /**
  55988. * The profile id of this motion controller
  55989. */
  55990. abstract profileId: string;
  55991. /**
  55992. * The root mesh of the model. It is null if the model was not yet initialized
  55993. */
  55994. rootMesh: Nullable<AbstractMesh>;
  55995. /**
  55996. * constructs a new abstract motion controller
  55997. * @param scene the scene to which the model of the controller will be added
  55998. * @param layout The profile layout to load
  55999. * @param gamepadObject The gamepad object correlating to this controller
  56000. * @param handedness handedness (left/right/none) of this controller
  56001. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  56002. */
  56003. constructor(scene: Scene, layout: IMotionControllerLayout,
  56004. /**
  56005. * The gamepad object correlating to this controller
  56006. */
  56007. gamepadObject: IMinimalMotionControllerObject,
  56008. /**
  56009. * handedness (left/right/none) of this controller
  56010. */
  56011. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  56012. /**
  56013. * Dispose this controller, the model mesh and all its components
  56014. */
  56015. dispose(): void;
  56016. /**
  56017. * Returns all components of specific type
  56018. * @param type the type to search for
  56019. * @return an array of components with this type
  56020. */
  56021. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  56022. /**
  56023. * get a component based an its component id as defined in layout.components
  56024. * @param id the id of the component
  56025. * @returns the component correlates to the id or undefined if not found
  56026. */
  56027. getComponent(id: string): WebXRControllerComponent;
  56028. /**
  56029. * Get the list of components available in this motion controller
  56030. * @returns an array of strings correlating to available components
  56031. */
  56032. getComponentIds(): string[];
  56033. /**
  56034. * Get the first component of specific type
  56035. * @param type type of component to find
  56036. * @return a controller component or null if not found
  56037. */
  56038. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  56039. /**
  56040. * Get the main (Select) component of this controller as defined in the layout
  56041. * @returns the main component of this controller
  56042. */
  56043. getMainComponent(): WebXRControllerComponent;
  56044. /**
  56045. * Loads the model correlating to this controller
  56046. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  56047. * @returns A promise fulfilled with the result of the model loading
  56048. */
  56049. loadModel(): Promise<boolean>;
  56050. /**
  56051. * Update this model using the current XRFrame
  56052. * @param xrFrame the current xr frame to use and update the model
  56053. */
  56054. updateFromXRFrame(xrFrame: XRFrame): void;
  56055. /**
  56056. * Backwards compatibility due to a deeply-integrated typo
  56057. */
  56058. get handness(): XREye;
  56059. /**
  56060. * Pulse (vibrate) this controller
  56061. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  56062. * Consecutive calls to this function will cancel the last pulse call
  56063. *
  56064. * @param value the strength of the pulse in 0.0...1.0 range
  56065. * @param duration Duration of the pulse in milliseconds
  56066. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  56067. * @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
  56068. */
  56069. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  56070. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  56071. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  56072. /**
  56073. * Moves the axis on the controller mesh based on its current state
  56074. * @param axis the index of the axis
  56075. * @param axisValue the value of the axis which determines the meshes new position
  56076. * @hidden
  56077. */
  56078. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  56079. /**
  56080. * Update the model itself with the current frame data
  56081. * @param xrFrame the frame to use for updating the model mesh
  56082. */
  56083. protected updateModel(xrFrame: XRFrame): void;
  56084. /**
  56085. * Get the filename and path for this controller's model
  56086. * @returns a map of filename and path
  56087. */
  56088. protected abstract _getFilenameAndPath(): {
  56089. filename: string;
  56090. path: string;
  56091. };
  56092. /**
  56093. * This function is called before the mesh is loaded. It checks for loading constraints.
  56094. * For example, this function can check if the GLB loader is available
  56095. * If this function returns false, the generic controller will be loaded instead
  56096. * @returns Is the client ready to load the mesh
  56097. */
  56098. protected abstract _getModelLoadingConstraints(): boolean;
  56099. /**
  56100. * This function will be called after the model was successfully loaded and can be used
  56101. * for mesh transformations before it is available for the user
  56102. * @param meshes the loaded meshes
  56103. */
  56104. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  56105. /**
  56106. * Set the root mesh for this controller. Important for the WebXR controller class
  56107. * @param meshes the loaded meshes
  56108. */
  56109. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  56110. /**
  56111. * A function executed each frame that updates the mesh (if needed)
  56112. * @param xrFrame the current xrFrame
  56113. */
  56114. protected abstract _updateModel(xrFrame: XRFrame): void;
  56115. private _getGenericFilenameAndPath;
  56116. private _getGenericParentMesh;
  56117. }
  56118. }
  56119. declare module BABYLON {
  56120. /**
  56121. * A generic trigger-only motion controller for WebXR
  56122. */
  56123. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  56124. /**
  56125. * Static version of the profile id of this controller
  56126. */
  56127. static ProfileId: string;
  56128. profileId: string;
  56129. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  56130. protected _getFilenameAndPath(): {
  56131. filename: string;
  56132. path: string;
  56133. };
  56134. protected _getModelLoadingConstraints(): boolean;
  56135. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  56136. protected _setRootMesh(meshes: AbstractMesh[]): void;
  56137. protected _updateModel(): void;
  56138. }
  56139. }
  56140. declare module BABYLON {
  56141. /**
  56142. * Class containing static functions to help procedurally build meshes
  56143. */
  56144. export class SphereBuilder {
  56145. /**
  56146. * Creates a sphere mesh
  56147. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  56148. * * 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`)
  56149. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  56150. * * 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
  56151. * * 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)
  56152. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56153. * * 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
  56154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56155. * @param name defines the name of the mesh
  56156. * @param options defines the options used to create the mesh
  56157. * @param scene defines the hosting scene
  56158. * @returns the sphere mesh
  56159. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  56160. */
  56161. static CreateSphere(name: string, options: {
  56162. segments?: number;
  56163. diameter?: number;
  56164. diameterX?: number;
  56165. diameterY?: number;
  56166. diameterZ?: number;
  56167. arc?: number;
  56168. slice?: number;
  56169. sideOrientation?: number;
  56170. frontUVs?: Vector4;
  56171. backUVs?: Vector4;
  56172. updatable?: boolean;
  56173. }, scene?: Nullable<Scene>): Mesh;
  56174. }
  56175. }
  56176. declare module BABYLON {
  56177. /**
  56178. * A profiled motion controller has its profile loaded from an online repository.
  56179. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  56180. */
  56181. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  56182. private _repositoryUrl;
  56183. private _buttonMeshMapping;
  56184. private _touchDots;
  56185. /**
  56186. * The profile ID of this controller. Will be populated when the controller initializes.
  56187. */
  56188. profileId: string;
  56189. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  56190. dispose(): void;
  56191. protected _getFilenameAndPath(): {
  56192. filename: string;
  56193. path: string;
  56194. };
  56195. protected _getModelLoadingConstraints(): boolean;
  56196. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  56197. protected _setRootMesh(meshes: AbstractMesh[]): void;
  56198. protected _updateModel(_xrFrame: XRFrame): void;
  56199. }
  56200. }
  56201. declare module BABYLON {
  56202. /**
  56203. * A construction function type to create a new controller based on an xrInput object
  56204. */
  56205. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  56206. /**
  56207. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  56208. *
  56209. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  56210. * it should be replaced with auto-loaded controllers.
  56211. *
  56212. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  56213. */
  56214. export class WebXRMotionControllerManager {
  56215. private static _AvailableControllers;
  56216. private static _Fallbacks;
  56217. private static _ProfileLoadingPromises;
  56218. private static _ProfilesList;
  56219. /**
  56220. * The base URL of the online controller repository. Can be changed at any time.
  56221. */
  56222. static BaseRepositoryUrl: string;
  56223. /**
  56224. * Which repository gets priority - local or online
  56225. */
  56226. static PrioritizeOnlineRepository: boolean;
  56227. /**
  56228. * Use the online repository, or use only locally-defined controllers
  56229. */
  56230. static UseOnlineRepository: boolean;
  56231. /**
  56232. * Clear the cache used for profile loading and reload when requested again
  56233. */
  56234. static ClearProfilesCache(): void;
  56235. /**
  56236. * Register the default fallbacks.
  56237. * This function is called automatically when this file is imported.
  56238. */
  56239. static DefaultFallbacks(): void;
  56240. /**
  56241. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  56242. * @param profileId the profile to which a fallback needs to be found
  56243. * @return an array with corresponding fallback profiles
  56244. */
  56245. static FindFallbackWithProfileId(profileId: string): string[];
  56246. /**
  56247. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  56248. * The order of search:
  56249. *
  56250. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  56251. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  56252. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  56253. * 4) return the generic trigger controller if none were found
  56254. *
  56255. * @param xrInput the xrInput to which a new controller is initialized
  56256. * @param scene the scene to which the model will be added
  56257. * @param forceProfile force a certain profile for this controller
  56258. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  56259. */
  56260. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  56261. /**
  56262. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  56263. *
  56264. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  56265. *
  56266. * @param type the profile type to register
  56267. * @param constructFunction the function to be called when loading this profile
  56268. */
  56269. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  56270. /**
  56271. * Register a fallback to a specific profile.
  56272. * @param profileId the profileId that will receive the fallbacks
  56273. * @param fallbacks A list of fallback profiles
  56274. */
  56275. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  56276. /**
  56277. * Will update the list of profiles available in the repository
  56278. * @return a promise that resolves to a map of profiles available online
  56279. */
  56280. static UpdateProfilesList(): Promise<{
  56281. [profile: string]: string;
  56282. }>;
  56283. private static _LoadProfileFromRepository;
  56284. private static _LoadProfilesFromAvailableControllers;
  56285. }
  56286. }
  56287. declare module BABYLON {
  56288. /**
  56289. * Configuration options for the WebXR controller creation
  56290. */
  56291. export interface IWebXRControllerOptions {
  56292. /**
  56293. * Should the controller mesh be animated when a user interacts with it
  56294. * The pressed buttons / thumbstick and touchpad animations will be disabled
  56295. */
  56296. disableMotionControllerAnimation?: boolean;
  56297. /**
  56298. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  56299. */
  56300. doNotLoadControllerMesh?: boolean;
  56301. /**
  56302. * Force a specific controller type for this controller.
  56303. * This can be used when creating your own profile or when testing different controllers
  56304. */
  56305. forceControllerProfile?: string;
  56306. /**
  56307. * Defines a rendering group ID for meshes that will be loaded.
  56308. * This is for the default controllers only.
  56309. */
  56310. renderingGroupId?: number;
  56311. }
  56312. /**
  56313. * Represents an XR controller
  56314. */
  56315. export class WebXRInputSource {
  56316. private _scene;
  56317. /** The underlying input source for the controller */
  56318. inputSource: XRInputSource;
  56319. private _options;
  56320. private _tmpVector;
  56321. private _uniqueId;
  56322. private _disposed;
  56323. /**
  56324. * 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
  56325. */
  56326. grip?: AbstractMesh;
  56327. /**
  56328. * If available, this is the gamepad object related to this controller.
  56329. * Using this object it is possible to get click events and trackpad changes of the
  56330. * webxr controller that is currently being used.
  56331. */
  56332. motionController?: WebXRAbstractMotionController;
  56333. /**
  56334. * Event that fires when the controller is removed/disposed.
  56335. * The object provided as event data is this controller, after associated assets were disposed.
  56336. * uniqueId is still available.
  56337. */
  56338. onDisposeObservable: Observable<WebXRInputSource>;
  56339. /**
  56340. * Will be triggered when the mesh associated with the motion controller is done loading.
  56341. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  56342. * A shortened version of controller -> motion controller -> on mesh loaded.
  56343. */
  56344. onMeshLoadedObservable: Observable<AbstractMesh>;
  56345. /**
  56346. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  56347. */
  56348. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  56349. /**
  56350. * Pointer which can be used to select objects or attach a visible laser to
  56351. */
  56352. pointer: AbstractMesh;
  56353. /**
  56354. * Creates the input source object
  56355. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  56356. * @param _scene the scene which the controller should be associated to
  56357. * @param inputSource the underlying input source for the controller
  56358. * @param _options options for this controller creation
  56359. */
  56360. constructor(_scene: Scene,
  56361. /** The underlying input source for the controller */
  56362. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  56363. /**
  56364. * Get this controllers unique id
  56365. */
  56366. get uniqueId(): string;
  56367. /**
  56368. * Disposes of the object
  56369. */
  56370. dispose(): void;
  56371. /**
  56372. * Gets a world space ray coming from the pointer or grip
  56373. * @param result the resulting ray
  56374. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  56375. */
  56376. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  56377. /**
  56378. * Updates the controller pose based on the given XRFrame
  56379. * @param xrFrame xr frame to update the pose with
  56380. * @param referenceSpace reference space to use
  56381. */
  56382. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  56383. }
  56384. }
  56385. declare module BABYLON {
  56386. /**
  56387. * The schema for initialization options of the XR Input class
  56388. */
  56389. export interface IWebXRInputOptions {
  56390. /**
  56391. * If set to true no model will be automatically loaded
  56392. */
  56393. doNotLoadControllerMeshes?: boolean;
  56394. /**
  56395. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  56396. * If not found, the xr input profile data will be used.
  56397. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  56398. */
  56399. forceInputProfile?: string;
  56400. /**
  56401. * Do not send a request to the controller repository to load the profile.
  56402. *
  56403. * Instead, use the controllers available in babylon itself.
  56404. */
  56405. disableOnlineControllerRepository?: boolean;
  56406. /**
  56407. * A custom URL for the controllers repository
  56408. */
  56409. customControllersRepositoryURL?: string;
  56410. /**
  56411. * Should the controller model's components not move according to the user input
  56412. */
  56413. disableControllerAnimation?: boolean;
  56414. /**
  56415. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  56416. */
  56417. controllerOptions?: IWebXRControllerOptions;
  56418. }
  56419. /**
  56420. * XR input used to track XR inputs such as controllers/rays
  56421. */
  56422. export class WebXRInput implements IDisposable {
  56423. /**
  56424. * the xr session manager for this session
  56425. */
  56426. xrSessionManager: WebXRSessionManager;
  56427. /**
  56428. * the WebXR camera for this session. Mainly used for teleportation
  56429. */
  56430. xrCamera: WebXRCamera;
  56431. private readonly options;
  56432. /**
  56433. * XR controllers being tracked
  56434. */
  56435. controllers: Array<WebXRInputSource>;
  56436. private _frameObserver;
  56437. private _sessionEndedObserver;
  56438. private _sessionInitObserver;
  56439. /**
  56440. * Event when a controller has been connected/added
  56441. */
  56442. onControllerAddedObservable: Observable<WebXRInputSource>;
  56443. /**
  56444. * Event when a controller has been removed/disconnected
  56445. */
  56446. onControllerRemovedObservable: Observable<WebXRInputSource>;
  56447. /**
  56448. * Initializes the WebXRInput
  56449. * @param xrSessionManager the xr session manager for this session
  56450. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  56451. * @param options = initialization options for this xr input
  56452. */
  56453. constructor(
  56454. /**
  56455. * the xr session manager for this session
  56456. */
  56457. xrSessionManager: WebXRSessionManager,
  56458. /**
  56459. * the WebXR camera for this session. Mainly used for teleportation
  56460. */
  56461. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  56462. private _onInputSourcesChange;
  56463. private _addAndRemoveControllers;
  56464. /**
  56465. * Disposes of the object
  56466. */
  56467. dispose(): void;
  56468. }
  56469. }
  56470. declare module BABYLON {
  56471. /**
  56472. * This is the base class for all WebXR features.
  56473. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  56474. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  56475. */
  56476. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  56477. protected _xrSessionManager: WebXRSessionManager;
  56478. private _attached;
  56479. private _removeOnDetach;
  56480. /**
  56481. * Is this feature disposed?
  56482. */
  56483. isDisposed: boolean;
  56484. /**
  56485. * Should auto-attach be disabled?
  56486. */
  56487. disableAutoAttach: boolean;
  56488. /**
  56489. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  56490. */
  56491. xrNativeFeatureName: string;
  56492. /**
  56493. * Construct a new (abstract) WebXR feature
  56494. * @param _xrSessionManager the xr session manager for this feature
  56495. */
  56496. constructor(_xrSessionManager: WebXRSessionManager);
  56497. /**
  56498. * Is this feature attached
  56499. */
  56500. get attached(): boolean;
  56501. /**
  56502. * attach this feature
  56503. *
  56504. * @param force should attachment be forced (even when already attached)
  56505. * @returns true if successful, false is failed or already attached
  56506. */
  56507. attach(force?: boolean): boolean;
  56508. /**
  56509. * detach this feature.
  56510. *
  56511. * @returns true if successful, false if failed or already detached
  56512. */
  56513. detach(): boolean;
  56514. /**
  56515. * Dispose this feature and all of the resources attached
  56516. */
  56517. dispose(): void;
  56518. /**
  56519. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  56520. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  56521. *
  56522. * @returns whether or not the feature is compatible in this environment
  56523. */
  56524. isCompatible(): boolean;
  56525. /**
  56526. * This is used to register callbacks that will automatically be removed when detach is called.
  56527. * @param observable the observable to which the observer will be attached
  56528. * @param callback the callback to register
  56529. */
  56530. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  56531. /**
  56532. * Code in this function will be executed on each xrFrame received from the browser.
  56533. * This function will not execute after the feature is detached.
  56534. * @param _xrFrame the current frame
  56535. */
  56536. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  56537. }
  56538. }
  56539. declare module BABYLON {
  56540. /**
  56541. * Renders a layer on top of an existing scene
  56542. */
  56543. export class UtilityLayerRenderer implements IDisposable {
  56544. /** the original scene that will be rendered on top of */
  56545. originalScene: Scene;
  56546. private _pointerCaptures;
  56547. private _lastPointerEvents;
  56548. private static _DefaultUtilityLayer;
  56549. private static _DefaultKeepDepthUtilityLayer;
  56550. private _sharedGizmoLight;
  56551. private _renderCamera;
  56552. /**
  56553. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  56554. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  56555. * @returns the camera that is used when rendering the utility layer
  56556. */
  56557. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  56558. /**
  56559. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  56560. * @param cam the camera that should be used when rendering the utility layer
  56561. */
  56562. setRenderCamera(cam: Nullable<Camera>): void;
  56563. /**
  56564. * @hidden
  56565. * Light which used by gizmos to get light shading
  56566. */
  56567. _getSharedGizmoLight(): HemisphericLight;
  56568. /**
  56569. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  56570. */
  56571. pickUtilitySceneFirst: boolean;
  56572. /**
  56573. * 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)
  56574. */
  56575. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  56576. /**
  56577. * 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)
  56578. */
  56579. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  56580. /**
  56581. * The scene that is rendered on top of the original scene
  56582. */
  56583. utilityLayerScene: Scene;
  56584. /**
  56585. * If the utility layer should automatically be rendered on top of existing scene
  56586. */
  56587. shouldRender: boolean;
  56588. /**
  56589. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  56590. */
  56591. onlyCheckPointerDownEvents: boolean;
  56592. /**
  56593. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  56594. */
  56595. processAllEvents: boolean;
  56596. /**
  56597. * Observable raised when the pointer move from the utility layer scene to the main scene
  56598. */
  56599. onPointerOutObservable: Observable<number>;
  56600. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  56601. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  56602. private _afterRenderObserver;
  56603. private _sceneDisposeObserver;
  56604. private _originalPointerObserver;
  56605. /**
  56606. * Instantiates a UtilityLayerRenderer
  56607. * @param originalScene the original scene that will be rendered on top of
  56608. * @param handleEvents boolean indicating if the utility layer should handle events
  56609. */
  56610. constructor(
  56611. /** the original scene that will be rendered on top of */
  56612. originalScene: Scene, handleEvents?: boolean);
  56613. private _notifyObservers;
  56614. /**
  56615. * Renders the utility layers scene on top of the original scene
  56616. */
  56617. render(): void;
  56618. /**
  56619. * Disposes of the renderer
  56620. */
  56621. dispose(): void;
  56622. private _updateCamera;
  56623. }
  56624. }
  56625. declare module BABYLON {
  56626. /**
  56627. * Options interface for the pointer selection module
  56628. */
  56629. export interface IWebXRControllerPointerSelectionOptions {
  56630. /**
  56631. * if provided, this scene will be used to render meshes.
  56632. */
  56633. customUtilityLayerScene?: Scene;
  56634. /**
  56635. * 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)
  56636. * If not disabled, the last picked point will be used to execute a pointer up event
  56637. * If disabled, pointer up event will be triggered right after the pointer down event.
  56638. * Used in screen and gaze target ray mode only
  56639. */
  56640. disablePointerUpOnTouchOut: boolean;
  56641. /**
  56642. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  56643. */
  56644. forceGazeMode: boolean;
  56645. /**
  56646. * 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
  56647. * to start a new countdown to the pointer down event.
  56648. * Defaults to 1.
  56649. */
  56650. gazeModePointerMovedFactor?: number;
  56651. /**
  56652. * Different button type to use instead of the main component
  56653. */
  56654. overrideButtonId?: string;
  56655. /**
  56656. * use this rendering group id for the meshes (optional)
  56657. */
  56658. renderingGroupId?: number;
  56659. /**
  56660. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  56661. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  56662. * 3000 means 3 seconds between pointing at something and selecting it
  56663. */
  56664. timeToSelect?: number;
  56665. /**
  56666. * Should meshes created here be added to a utility layer or the main scene
  56667. */
  56668. useUtilityLayer?: boolean;
  56669. /**
  56670. * Optional WebXR camera to be used for gaze selection
  56671. */
  56672. gazeCamera?: WebXRCamera;
  56673. /**
  56674. * the xr input to use with this pointer selection
  56675. */
  56676. xrInput: WebXRInput;
  56677. /**
  56678. * Should the scene pointerX and pointerY update be disabled
  56679. * This is required for fullscreen AR GUI, but might slow down other experiences.
  56680. * Disable in VR, if not needed.
  56681. * The first rig camera (left eye) will be used to calculate the projection
  56682. */
  56683. disableScenePointerVectorUpdate: boolean;
  56684. /**
  56685. * Enable pointer selection on all controllers instead of switching between them
  56686. */
  56687. enablePointerSelectionOnAllControllers?: boolean;
  56688. /**
  56689. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  56690. * If switch is enabled, it will still allow the user to switch between the different controllers
  56691. */
  56692. preferredHandedness?: XRHandedness;
  56693. /**
  56694. * Disable switching the pointer selection from one controller to the other.
  56695. * 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
  56696. */
  56697. disableSwitchOnClick?: boolean;
  56698. /**
  56699. * The maximum distance of the pointer selection feature. Defaults to 100.
  56700. */
  56701. maxPointerDistance?: number;
  56702. }
  56703. /**
  56704. * A module that will enable pointer selection for motion controllers of XR Input Sources
  56705. */
  56706. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  56707. private readonly _options;
  56708. private static _idCounter;
  56709. private _attachController;
  56710. private _controllers;
  56711. private _scene;
  56712. private _tmpVectorForPickCompare;
  56713. private _attachedController;
  56714. /**
  56715. * The module's name
  56716. */
  56717. static readonly Name: string;
  56718. /**
  56719. * The (Babylon) version of this module.
  56720. * This is an integer representing the implementation version.
  56721. * This number does not correspond to the WebXR specs version
  56722. */
  56723. static readonly Version: number;
  56724. /**
  56725. * Disable lighting on the laser pointer (so it will always be visible)
  56726. */
  56727. disablePointerLighting: boolean;
  56728. /**
  56729. * Disable lighting on the selection mesh (so it will always be visible)
  56730. */
  56731. disableSelectionMeshLighting: boolean;
  56732. /**
  56733. * Should the laser pointer be displayed
  56734. */
  56735. displayLaserPointer: boolean;
  56736. /**
  56737. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  56738. */
  56739. displaySelectionMesh: boolean;
  56740. /**
  56741. * This color will be set to the laser pointer when selection is triggered
  56742. */
  56743. laserPointerPickedColor: Color3;
  56744. /**
  56745. * Default color of the laser pointer
  56746. */
  56747. laserPointerDefaultColor: Color3;
  56748. /**
  56749. * default color of the selection ring
  56750. */
  56751. selectionMeshDefaultColor: Color3;
  56752. /**
  56753. * This color will be applied to the selection ring when selection is triggered
  56754. */
  56755. selectionMeshPickedColor: Color3;
  56756. /**
  56757. * Optional filter to be used for ray selection. This predicate shares behavior with
  56758. * scene.pointerMovePredicate which takes priority if it is also assigned.
  56759. */
  56760. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  56761. /**
  56762. * constructs a new background remover module
  56763. * @param _xrSessionManager the session manager for this module
  56764. * @param _options read-only options to be used in this module
  56765. */
  56766. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  56767. /**
  56768. * attach this feature
  56769. * Will usually be called by the features manager
  56770. *
  56771. * @returns true if successful.
  56772. */
  56773. attach(): boolean;
  56774. /**
  56775. * detach this feature.
  56776. * Will usually be called by the features manager
  56777. *
  56778. * @returns true if successful.
  56779. */
  56780. detach(): boolean;
  56781. /**
  56782. * Will get the mesh under a specific pointer.
  56783. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  56784. * @param controllerId the controllerId to check
  56785. * @returns The mesh under pointer or null if no mesh is under the pointer
  56786. */
  56787. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  56788. /**
  56789. * Get the xr controller that correlates to the pointer id in the pointer event
  56790. *
  56791. * @param id the pointer id to search for
  56792. * @returns the controller that correlates to this id or null if not found
  56793. */
  56794. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  56795. private _identityMatrix;
  56796. private _screenCoordinatesRef;
  56797. private _viewportRef;
  56798. protected _onXRFrame(_xrFrame: XRFrame): void;
  56799. private _attachGazeMode;
  56800. private _attachScreenRayMode;
  56801. private _attachTrackedPointerRayMode;
  56802. private _convertNormalToDirectionOfRay;
  56803. private _detachController;
  56804. private _generateNewMeshPair;
  56805. private _pickingMoved;
  56806. private _updatePointerDistance;
  56807. /** @hidden */
  56808. get lasterPointerDefaultColor(): Color3;
  56809. }
  56810. }
  56811. declare module BABYLON {
  56812. /**
  56813. * Button which can be used to enter a different mode of XR
  56814. */
  56815. export class WebXREnterExitUIButton {
  56816. /** button element */
  56817. element: HTMLElement;
  56818. /** XR initialization options for the button */
  56819. sessionMode: XRSessionMode;
  56820. /** Reference space type */
  56821. referenceSpaceType: XRReferenceSpaceType;
  56822. /**
  56823. * Creates a WebXREnterExitUIButton
  56824. * @param element button element
  56825. * @param sessionMode XR initialization session mode
  56826. * @param referenceSpaceType the type of reference space to be used
  56827. */
  56828. constructor(
  56829. /** button element */
  56830. element: HTMLElement,
  56831. /** XR initialization options for the button */
  56832. sessionMode: XRSessionMode,
  56833. /** Reference space type */
  56834. referenceSpaceType: XRReferenceSpaceType);
  56835. /**
  56836. * Extendable function which can be used to update the button's visuals when the state changes
  56837. * @param activeButton the current active button in the UI
  56838. */
  56839. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  56840. }
  56841. /**
  56842. * Options to create the webXR UI
  56843. */
  56844. export class WebXREnterExitUIOptions {
  56845. /**
  56846. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  56847. */
  56848. customButtons?: Array<WebXREnterExitUIButton>;
  56849. /**
  56850. * A reference space type to use when creating the default button.
  56851. * Default is local-floor
  56852. */
  56853. referenceSpaceType?: XRReferenceSpaceType;
  56854. /**
  56855. * Context to enter xr with
  56856. */
  56857. renderTarget?: Nullable<WebXRRenderTarget>;
  56858. /**
  56859. * A session mode to use when creating the default button.
  56860. * Default is immersive-vr
  56861. */
  56862. sessionMode?: XRSessionMode;
  56863. /**
  56864. * A list of optional features to init the session with
  56865. */
  56866. optionalFeatures?: string[];
  56867. /**
  56868. * A list of optional features to init the session with
  56869. */
  56870. requiredFeatures?: string[];
  56871. /**
  56872. * If defined, this function will be executed if the UI encounters an error when entering XR
  56873. */
  56874. onError?: (error: any) => void;
  56875. }
  56876. /**
  56877. * UI to allow the user to enter/exit XR mode
  56878. */
  56879. export class WebXREnterExitUI implements IDisposable {
  56880. private scene;
  56881. /** version of the options passed to this UI */
  56882. options: WebXREnterExitUIOptions;
  56883. private _activeButton;
  56884. private _buttons;
  56885. /**
  56886. * The HTML Div Element to which buttons are added.
  56887. */
  56888. readonly overlay: HTMLDivElement;
  56889. /**
  56890. * Fired every time the active button is changed.
  56891. *
  56892. * When xr is entered via a button that launches xr that button will be the callback parameter
  56893. *
  56894. * When exiting xr the callback parameter will be null)
  56895. */
  56896. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  56897. /**
  56898. *
  56899. * @param scene babylon scene object to use
  56900. * @param options (read-only) version of the options passed to this UI
  56901. */
  56902. private constructor();
  56903. /**
  56904. * Creates UI to allow the user to enter/exit XR mode
  56905. * @param scene the scene to add the ui to
  56906. * @param helper the xr experience helper to enter/exit xr with
  56907. * @param options options to configure the UI
  56908. * @returns the created ui
  56909. */
  56910. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  56911. /**
  56912. * Disposes of the XR UI component
  56913. */
  56914. dispose(): void;
  56915. private _updateButtons;
  56916. }
  56917. }
  56918. declare module BABYLON {
  56919. /**
  56920. * Class containing static functions to help procedurally build meshes
  56921. */
  56922. export class LinesBuilder {
  56923. /**
  56924. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  56925. * * 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
  56926. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  56927. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  56928. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  56929. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  56930. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56931. * * 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
  56932. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  56933. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56934. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  56935. * @param name defines the name of the new line system
  56936. * @param options defines the options used to create the line system
  56937. * @param scene defines the hosting scene
  56938. * @returns a new line system mesh
  56939. */
  56940. static CreateLineSystem(name: string, options: {
  56941. lines: Vector3[][];
  56942. updatable?: boolean;
  56943. instance?: Nullable<LinesMesh>;
  56944. colors?: Nullable<Color4[][]>;
  56945. useVertexAlpha?: boolean;
  56946. }, scene: Nullable<Scene>): LinesMesh;
  56947. /**
  56948. * Creates a line mesh
  56949. * 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
  56950. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56951. * * The parameter `points` is an array successive Vector3
  56952. * * 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
  56953. * * The optional parameter `colors` is an array of successive Color4, one per line point
  56954. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  56955. * * When updating an instance, remember that only point positions can change, not the number of points
  56956. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56957. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  56958. * @param name defines the name of the new line system
  56959. * @param options defines the options used to create the line system
  56960. * @param scene defines the hosting scene
  56961. * @returns a new line mesh
  56962. */
  56963. static CreateLines(name: string, options: {
  56964. points: Vector3[];
  56965. updatable?: boolean;
  56966. instance?: Nullable<LinesMesh>;
  56967. colors?: Color4[];
  56968. useVertexAlpha?: boolean;
  56969. }, scene?: Nullable<Scene>): LinesMesh;
  56970. /**
  56971. * Creates a dashed line mesh
  56972. * * 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
  56973. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56974. * * The parameter `points` is an array successive Vector3
  56975. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  56976. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  56977. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  56978. * * 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
  56979. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56980. * * When updating an instance, remember that only point positions can change, not the number of points
  56981. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56982. * @param name defines the name of the mesh
  56983. * @param options defines the options used to create the mesh
  56984. * @param scene defines the hosting scene
  56985. * @returns the dashed line mesh
  56986. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  56987. */
  56988. static CreateDashedLines(name: string, options: {
  56989. points: Vector3[];
  56990. dashSize?: number;
  56991. gapSize?: number;
  56992. dashNb?: number;
  56993. updatable?: boolean;
  56994. instance?: LinesMesh;
  56995. useVertexAlpha?: boolean;
  56996. }, scene?: Nullable<Scene>): LinesMesh;
  56997. }
  56998. }
  56999. declare module BABYLON {
  57000. /**
  57001. * Construction options for a timer
  57002. */
  57003. export interface ITimerOptions<T> {
  57004. /**
  57005. * Time-to-end
  57006. */
  57007. timeout: number;
  57008. /**
  57009. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  57010. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  57011. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  57012. */
  57013. contextObservable: Observable<T>;
  57014. /**
  57015. * Optional parameters when adding an observer to the observable
  57016. */
  57017. observableParameters?: {
  57018. mask?: number;
  57019. insertFirst?: boolean;
  57020. scope?: any;
  57021. };
  57022. /**
  57023. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  57024. */
  57025. breakCondition?: (data?: ITimerData<T>) => boolean;
  57026. /**
  57027. * Will be triggered when the time condition has met
  57028. */
  57029. onEnded?: (data: ITimerData<any>) => void;
  57030. /**
  57031. * Will be triggered when the break condition has met (prematurely ended)
  57032. */
  57033. onAborted?: (data: ITimerData<any>) => void;
  57034. /**
  57035. * Optional function to execute on each tick (or count)
  57036. */
  57037. onTick?: (data: ITimerData<any>) => void;
  57038. }
  57039. /**
  57040. * An interface defining the data sent by the timer
  57041. */
  57042. export interface ITimerData<T> {
  57043. /**
  57044. * When did it start
  57045. */
  57046. startTime: number;
  57047. /**
  57048. * Time now
  57049. */
  57050. currentTime: number;
  57051. /**
  57052. * Time passed since started
  57053. */
  57054. deltaTime: number;
  57055. /**
  57056. * How much is completed, in [0.0...1.0].
  57057. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  57058. */
  57059. completeRate: number;
  57060. /**
  57061. * What the registered observable sent in the last count
  57062. */
  57063. payload: T;
  57064. }
  57065. /**
  57066. * The current state of the timer
  57067. */
  57068. export enum TimerState {
  57069. /**
  57070. * Timer initialized, not yet started
  57071. */
  57072. INIT = 0,
  57073. /**
  57074. * Timer started and counting
  57075. */
  57076. STARTED = 1,
  57077. /**
  57078. * Timer ended (whether aborted or time reached)
  57079. */
  57080. ENDED = 2
  57081. }
  57082. /**
  57083. * A simple version of the timer. Will take options and start the timer immediately after calling it
  57084. *
  57085. * @param options options with which to initialize this timer
  57086. */
  57087. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  57088. /**
  57089. * An advanced implementation of a timer class
  57090. */
  57091. export class AdvancedTimer<T = any> implements IDisposable {
  57092. /**
  57093. * Will notify each time the timer calculates the remaining time
  57094. */
  57095. onEachCountObservable: Observable<ITimerData<T>>;
  57096. /**
  57097. * Will trigger when the timer was aborted due to the break condition
  57098. */
  57099. onTimerAbortedObservable: Observable<ITimerData<T>>;
  57100. /**
  57101. * Will trigger when the timer ended successfully
  57102. */
  57103. onTimerEndedObservable: Observable<ITimerData<T>>;
  57104. /**
  57105. * Will trigger when the timer state has changed
  57106. */
  57107. onStateChangedObservable: Observable<TimerState>;
  57108. private _observer;
  57109. private _contextObservable;
  57110. private _observableParameters;
  57111. private _startTime;
  57112. private _timer;
  57113. private _state;
  57114. private _breakCondition;
  57115. private _timeToEnd;
  57116. private _breakOnNextTick;
  57117. /**
  57118. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  57119. * @param options construction options for this advanced timer
  57120. */
  57121. constructor(options: ITimerOptions<T>);
  57122. /**
  57123. * set a breaking condition for this timer. Default is to never break during count
  57124. * @param predicate the new break condition. Returns true to break, false otherwise
  57125. */
  57126. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  57127. /**
  57128. * Reset ALL associated observables in this advanced timer
  57129. */
  57130. clearObservables(): void;
  57131. /**
  57132. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  57133. *
  57134. * @param timeToEnd how much time to measure until timer ended
  57135. */
  57136. start(timeToEnd?: number): void;
  57137. /**
  57138. * Will force a stop on the next tick.
  57139. */
  57140. stop(): void;
  57141. /**
  57142. * Dispose this timer, clearing all resources
  57143. */
  57144. dispose(): void;
  57145. private _setState;
  57146. private _tick;
  57147. private _stop;
  57148. }
  57149. }
  57150. declare module BABYLON {
  57151. /**
  57152. * The options container for the teleportation module
  57153. */
  57154. export interface IWebXRTeleportationOptions {
  57155. /**
  57156. * if provided, this scene will be used to render meshes.
  57157. */
  57158. customUtilityLayerScene?: Scene;
  57159. /**
  57160. * Values to configure the default target mesh
  57161. */
  57162. defaultTargetMeshOptions?: {
  57163. /**
  57164. * Fill color of the teleportation area
  57165. */
  57166. teleportationFillColor?: string;
  57167. /**
  57168. * Border color for the teleportation area
  57169. */
  57170. teleportationBorderColor?: string;
  57171. /**
  57172. * Disable the mesh's animation sequence
  57173. */
  57174. disableAnimation?: boolean;
  57175. /**
  57176. * Disable lighting on the material or the ring and arrow
  57177. */
  57178. disableLighting?: boolean;
  57179. /**
  57180. * Override the default material of the torus and arrow
  57181. */
  57182. torusArrowMaterial?: Material;
  57183. };
  57184. /**
  57185. * A list of meshes to use as floor meshes.
  57186. * Meshes can be added and removed after initializing the feature using the
  57187. * addFloorMesh and removeFloorMesh functions
  57188. * If empty, rotation will still work
  57189. */
  57190. floorMeshes?: AbstractMesh[];
  57191. /**
  57192. * use this rendering group id for the meshes (optional)
  57193. */
  57194. renderingGroupId?: number;
  57195. /**
  57196. * Should teleportation move only to snap points
  57197. */
  57198. snapPointsOnly?: boolean;
  57199. /**
  57200. * An array of points to which the teleportation will snap to.
  57201. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  57202. */
  57203. snapPositions?: Vector3[];
  57204. /**
  57205. * How close should the teleportation ray be in order to snap to position.
  57206. * Default to 0.8 units (meters)
  57207. */
  57208. snapToPositionRadius?: number;
  57209. /**
  57210. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  57211. * If you want to support rotation, make sure your mesh has a direction indicator.
  57212. *
  57213. * When left untouched, the default mesh will be initialized.
  57214. */
  57215. teleportationTargetMesh?: AbstractMesh;
  57216. /**
  57217. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  57218. */
  57219. timeToTeleport?: number;
  57220. /**
  57221. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  57222. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  57223. */
  57224. useMainComponentOnly?: boolean;
  57225. /**
  57226. * Should meshes created here be added to a utility layer or the main scene
  57227. */
  57228. useUtilityLayer?: boolean;
  57229. /**
  57230. * Babylon XR Input class for controller
  57231. */
  57232. xrInput: WebXRInput;
  57233. /**
  57234. * Meshes that the teleportation ray cannot go through
  57235. */
  57236. pickBlockerMeshes?: AbstractMesh[];
  57237. /**
  57238. * Should teleport work only on a specific hand?
  57239. */
  57240. forceHandedness?: XRHandedness;
  57241. /**
  57242. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  57243. */
  57244. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  57245. }
  57246. /**
  57247. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  57248. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  57249. * the input of the attached controllers.
  57250. */
  57251. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  57252. private _options;
  57253. private _controllers;
  57254. private _currentTeleportationControllerId;
  57255. private _floorMeshes;
  57256. private _quadraticBezierCurve;
  57257. private _selectionFeature;
  57258. private _snapToPositions;
  57259. private _snappedToPoint;
  57260. private _teleportationRingMaterial?;
  57261. private _tmpRay;
  57262. private _tmpVector;
  57263. private _tmpQuaternion;
  57264. /**
  57265. * The module's name
  57266. */
  57267. static readonly Name: string;
  57268. /**
  57269. * The (Babylon) version of this module.
  57270. * This is an integer representing the implementation version.
  57271. * This number does not correspond to the webxr specs version
  57272. */
  57273. static readonly Version: number;
  57274. /**
  57275. * Is movement backwards enabled
  57276. */
  57277. backwardsMovementEnabled: boolean;
  57278. /**
  57279. * Distance to travel when moving backwards
  57280. */
  57281. backwardsTeleportationDistance: number;
  57282. /**
  57283. * The distance from the user to the inspection point in the direction of the controller
  57284. * A higher number will allow the user to move further
  57285. * defaults to 5 (meters, in xr units)
  57286. */
  57287. parabolicCheckRadius: number;
  57288. /**
  57289. * Should the module support parabolic ray on top of direct ray
  57290. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  57291. * Very helpful when moving between floors / different heights
  57292. */
  57293. parabolicRayEnabled: boolean;
  57294. /**
  57295. * The second type of ray - straight line.
  57296. * Should it be enabled or should the parabolic line be the only one.
  57297. */
  57298. straightRayEnabled: boolean;
  57299. /**
  57300. * How much rotation should be applied when rotating right and left
  57301. */
  57302. rotationAngle: number;
  57303. private _rotationEnabled;
  57304. /**
  57305. * Is rotation enabled when moving forward?
  57306. * Disabling this feature will prevent the user from deciding the direction when teleporting
  57307. */
  57308. get rotationEnabled(): boolean;
  57309. /**
  57310. * Sets whether rotation is enabled or not
  57311. * @param enabled is rotation enabled when teleportation is shown
  57312. */
  57313. set rotationEnabled(enabled: boolean);
  57314. /**
  57315. * Exposes the currently set teleportation target mesh.
  57316. */
  57317. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  57318. /**
  57319. * constructs a new anchor system
  57320. * @param _xrSessionManager an instance of WebXRSessionManager
  57321. * @param _options configuration object for this feature
  57322. */
  57323. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  57324. /**
  57325. * Get the snapPointsOnly flag
  57326. */
  57327. get snapPointsOnly(): boolean;
  57328. /**
  57329. * Sets the snapPointsOnly flag
  57330. * @param snapToPoints should teleportation be exclusively to snap points
  57331. */
  57332. set snapPointsOnly(snapToPoints: boolean);
  57333. /**
  57334. * Add a new mesh to the floor meshes array
  57335. * @param mesh the mesh to use as floor mesh
  57336. */
  57337. addFloorMesh(mesh: AbstractMesh): void;
  57338. /**
  57339. * Add a new snap-to point to fix teleportation to this position
  57340. * @param newSnapPoint The new Snap-To point
  57341. */
  57342. addSnapPoint(newSnapPoint: Vector3): void;
  57343. attach(): boolean;
  57344. detach(): boolean;
  57345. dispose(): void;
  57346. /**
  57347. * Remove a mesh from the floor meshes array
  57348. * @param mesh the mesh to remove
  57349. */
  57350. removeFloorMesh(mesh: AbstractMesh): void;
  57351. /**
  57352. * Remove a mesh from the floor meshes array using its name
  57353. * @param name the mesh name to remove
  57354. */
  57355. removeFloorMeshByName(name: string): void;
  57356. /**
  57357. * 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
  57358. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  57359. * @returns was the point found and removed or not
  57360. */
  57361. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  57362. /**
  57363. * This function sets a selection feature that will be disabled when
  57364. * the forward ray is shown and will be reattached when hidden.
  57365. * This is used to remove the selection rays when moving.
  57366. * @param selectionFeature the feature to disable when forward movement is enabled
  57367. */
  57368. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  57369. protected _onXRFrame(_xrFrame: XRFrame): void;
  57370. private _attachController;
  57371. private _createDefaultTargetMesh;
  57372. private _detachController;
  57373. private _findClosestSnapPointWithRadius;
  57374. private _setTargetMeshPosition;
  57375. private _setTargetMeshVisibility;
  57376. private _showParabolicPath;
  57377. private _teleportForward;
  57378. }
  57379. }
  57380. declare module BABYLON {
  57381. /**
  57382. * Options for the default xr helper
  57383. */
  57384. export class WebXRDefaultExperienceOptions {
  57385. /**
  57386. * Enable or disable default UI to enter XR
  57387. */
  57388. disableDefaultUI?: boolean;
  57389. /**
  57390. * Should pointer selection not initialize.
  57391. * Note that disabling pointer selection also disables teleportation.
  57392. * Defaults to false.
  57393. */
  57394. disablePointerSelection?: boolean;
  57395. /**
  57396. * Should teleportation not initialize. Defaults to false.
  57397. */
  57398. disableTeleportation?: boolean;
  57399. /**
  57400. * Floor meshes that will be used for teleport
  57401. */
  57402. floorMeshes?: Array<AbstractMesh>;
  57403. /**
  57404. * If set to true, the first frame will not be used to reset position
  57405. * The first frame is mainly used when copying transformation from the old camera
  57406. * Mainly used in AR
  57407. */
  57408. ignoreNativeCameraTransformation?: boolean;
  57409. /**
  57410. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  57411. */
  57412. inputOptions?: IWebXRInputOptions;
  57413. /**
  57414. * optional configuration for the output canvas
  57415. */
  57416. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  57417. /**
  57418. * optional UI options. This can be used among other to change session mode and reference space type
  57419. */
  57420. uiOptions?: WebXREnterExitUIOptions;
  57421. /**
  57422. * When loading teleportation and pointer select, use stable versions instead of latest.
  57423. */
  57424. useStablePlugins?: boolean;
  57425. /**
  57426. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  57427. */
  57428. renderingGroupId?: number;
  57429. /**
  57430. * A list of optional features to init the session with
  57431. * If set to true, all features we support will be added
  57432. */
  57433. optionalFeatures?: boolean | string[];
  57434. }
  57435. /**
  57436. * Default experience which provides a similar setup to the previous webVRExperience
  57437. */
  57438. export class WebXRDefaultExperience {
  57439. /**
  57440. * Base experience
  57441. */
  57442. baseExperience: WebXRExperienceHelper;
  57443. /**
  57444. * Enables ui for entering/exiting xr
  57445. */
  57446. enterExitUI: WebXREnterExitUI;
  57447. /**
  57448. * Input experience extension
  57449. */
  57450. input: WebXRInput;
  57451. /**
  57452. * Enables laser pointer and selection
  57453. */
  57454. pointerSelection: WebXRControllerPointerSelection;
  57455. /**
  57456. * Default target xr should render to
  57457. */
  57458. renderTarget: WebXRRenderTarget;
  57459. /**
  57460. * Enables teleportation
  57461. */
  57462. teleportation: WebXRMotionControllerTeleportation;
  57463. private constructor();
  57464. /**
  57465. * Creates the default xr experience
  57466. * @param scene scene
  57467. * @param options options for basic configuration
  57468. * @returns resulting WebXRDefaultExperience
  57469. */
  57470. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  57471. /**
  57472. * Disposes of the experience helper
  57473. */
  57474. dispose(): void;
  57475. }
  57476. }
  57477. declare module BABYLON {
  57478. /**
  57479. * Options to modify the vr teleportation behavior.
  57480. */
  57481. export interface VRTeleportationOptions {
  57482. /**
  57483. * The name of the mesh which should be used as the teleportation floor. (default: null)
  57484. */
  57485. floorMeshName?: string;
  57486. /**
  57487. * A list of meshes to be used as the teleportation floor. (default: empty)
  57488. */
  57489. floorMeshes?: Mesh[];
  57490. /**
  57491. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  57492. */
  57493. teleportationMode?: number;
  57494. /**
  57495. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  57496. */
  57497. teleportationTime?: number;
  57498. /**
  57499. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  57500. */
  57501. teleportationSpeed?: number;
  57502. /**
  57503. * The easing function used in the animation or null for Linear. (default CircleEase)
  57504. */
  57505. easingFunction?: EasingFunction;
  57506. }
  57507. /**
  57508. * Options to modify the vr experience helper's behavior.
  57509. */
  57510. export interface VRExperienceHelperOptions extends WebVROptions {
  57511. /**
  57512. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  57513. */
  57514. createDeviceOrientationCamera?: boolean;
  57515. /**
  57516. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  57517. */
  57518. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  57519. /**
  57520. * Uses the main button on the controller to toggle the laser casted. (default: true)
  57521. */
  57522. laserToggle?: boolean;
  57523. /**
  57524. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  57525. */
  57526. floorMeshes?: Mesh[];
  57527. /**
  57528. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  57529. */
  57530. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  57531. /**
  57532. * Defines if WebXR should be used instead of WebVR (if available)
  57533. */
  57534. useXR?: boolean;
  57535. }
  57536. /**
  57537. * Event containing information after VR has been entered
  57538. */
  57539. export class OnAfterEnteringVRObservableEvent {
  57540. /**
  57541. * If entering vr was successful
  57542. */
  57543. success: boolean;
  57544. }
  57545. /**
  57546. * Helps to quickly add VR support to an existing scene.
  57547. * See https://doc.babylonjs.com/how_to/webvr_helper
  57548. */
  57549. export class VRExperienceHelper {
  57550. /** Options to modify the vr experience helper's behavior. */
  57551. webVROptions: VRExperienceHelperOptions;
  57552. private _scene;
  57553. private _position;
  57554. private _btnVR;
  57555. private _btnVRDisplayed;
  57556. private _webVRsupported;
  57557. private _webVRready;
  57558. private _webVRrequesting;
  57559. private _webVRpresenting;
  57560. private _hasEnteredVR;
  57561. private _fullscreenVRpresenting;
  57562. private _inputElement;
  57563. private _webVRCamera;
  57564. private _vrDeviceOrientationCamera;
  57565. private _deviceOrientationCamera;
  57566. private _existingCamera;
  57567. private _onKeyDown;
  57568. private _onVrDisplayPresentChange;
  57569. private _onVRDisplayChanged;
  57570. private _onVRRequestPresentStart;
  57571. private _onVRRequestPresentComplete;
  57572. /**
  57573. * 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)
  57574. */
  57575. enableGazeEvenWhenNoPointerLock: boolean;
  57576. /**
  57577. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  57578. */
  57579. exitVROnDoubleTap: boolean;
  57580. /**
  57581. * Observable raised right before entering VR.
  57582. */
  57583. onEnteringVRObservable: Observable<VRExperienceHelper>;
  57584. /**
  57585. * Observable raised when entering VR has completed.
  57586. */
  57587. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  57588. /**
  57589. * Observable raised when exiting VR.
  57590. */
  57591. onExitingVRObservable: Observable<VRExperienceHelper>;
  57592. /**
  57593. * Observable raised when controller mesh is loaded.
  57594. */
  57595. onControllerMeshLoadedObservable: Observable<WebVRController>;
  57596. /** Return this.onEnteringVRObservable
  57597. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  57598. */
  57599. get onEnteringVR(): Observable<VRExperienceHelper>;
  57600. /** Return this.onExitingVRObservable
  57601. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  57602. */
  57603. get onExitingVR(): Observable<VRExperienceHelper>;
  57604. /** Return this.onControllerMeshLoadedObservable
  57605. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  57606. */
  57607. get onControllerMeshLoaded(): Observable<WebVRController>;
  57608. private _rayLength;
  57609. private _useCustomVRButton;
  57610. private _teleportationRequested;
  57611. private _teleportActive;
  57612. private _floorMeshName;
  57613. private _floorMeshesCollection;
  57614. private _teleportationMode;
  57615. private _teleportationTime;
  57616. private _teleportationSpeed;
  57617. private _teleportationEasing;
  57618. private _rotationAllowed;
  57619. private _teleportBackwardsVector;
  57620. private _teleportationTarget;
  57621. private _isDefaultTeleportationTarget;
  57622. private _postProcessMove;
  57623. private _teleportationFillColor;
  57624. private _teleportationBorderColor;
  57625. private _rotationAngle;
  57626. private _haloCenter;
  57627. private _cameraGazer;
  57628. private _padSensibilityUp;
  57629. private _padSensibilityDown;
  57630. private _leftController;
  57631. private _rightController;
  57632. private _gazeColor;
  57633. private _laserColor;
  57634. private _pickedLaserColor;
  57635. private _pickedGazeColor;
  57636. /**
  57637. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  57638. */
  57639. onNewMeshSelected: Observable<AbstractMesh>;
  57640. /**
  57641. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  57642. * This observable will provide the mesh and the controller used to select the mesh
  57643. */
  57644. onMeshSelectedWithController: Observable<{
  57645. mesh: AbstractMesh;
  57646. controller: WebVRController;
  57647. }>;
  57648. /**
  57649. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  57650. */
  57651. onNewMeshPicked: Observable<PickingInfo>;
  57652. private _circleEase;
  57653. /**
  57654. * Observable raised before camera teleportation
  57655. */
  57656. onBeforeCameraTeleport: Observable<Vector3>;
  57657. /**
  57658. * Observable raised after camera teleportation
  57659. */
  57660. onAfterCameraTeleport: Observable<Vector3>;
  57661. /**
  57662. * Observable raised when current selected mesh gets unselected
  57663. */
  57664. onSelectedMeshUnselected: Observable<AbstractMesh>;
  57665. private _raySelectionPredicate;
  57666. /**
  57667. * To be optionally changed by user to define custom ray selection
  57668. */
  57669. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  57670. /**
  57671. * To be optionally changed by user to define custom selection logic (after ray selection)
  57672. */
  57673. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  57674. /**
  57675. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  57676. */
  57677. teleportationEnabled: boolean;
  57678. private _defaultHeight;
  57679. private _teleportationInitialized;
  57680. private _interactionsEnabled;
  57681. private _interactionsRequested;
  57682. private _displayGaze;
  57683. private _displayLaserPointer;
  57684. /**
  57685. * The mesh used to display where the user is going to teleport.
  57686. */
  57687. get teleportationTarget(): Mesh;
  57688. /**
  57689. * Sets the mesh to be used to display where the user is going to teleport.
  57690. */
  57691. set teleportationTarget(value: Mesh);
  57692. /**
  57693. * 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
  57694. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  57695. * See https://doc.babylonjs.com/resources/baking_transformations
  57696. */
  57697. get gazeTrackerMesh(): Mesh;
  57698. set gazeTrackerMesh(value: Mesh);
  57699. /**
  57700. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  57701. */
  57702. updateGazeTrackerScale: boolean;
  57703. /**
  57704. * If the gaze trackers color should be updated when selecting meshes
  57705. */
  57706. updateGazeTrackerColor: boolean;
  57707. /**
  57708. * If the controller laser color should be updated when selecting meshes
  57709. */
  57710. updateControllerLaserColor: boolean;
  57711. /**
  57712. * The gaze tracking mesh corresponding to the left controller
  57713. */
  57714. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  57715. /**
  57716. * The gaze tracking mesh corresponding to the right controller
  57717. */
  57718. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  57719. /**
  57720. * If the ray of the gaze should be displayed.
  57721. */
  57722. get displayGaze(): boolean;
  57723. /**
  57724. * Sets if the ray of the gaze should be displayed.
  57725. */
  57726. set displayGaze(value: boolean);
  57727. /**
  57728. * If the ray of the LaserPointer should be displayed.
  57729. */
  57730. get displayLaserPointer(): boolean;
  57731. /**
  57732. * Sets if the ray of the LaserPointer should be displayed.
  57733. */
  57734. set displayLaserPointer(value: boolean);
  57735. /**
  57736. * The deviceOrientationCamera used as the camera when not in VR.
  57737. */
  57738. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  57739. /**
  57740. * Based on the current WebVR support, returns the current VR camera used.
  57741. */
  57742. get currentVRCamera(): Nullable<Camera>;
  57743. /**
  57744. * The webVRCamera which is used when in VR.
  57745. */
  57746. get webVRCamera(): WebVRFreeCamera;
  57747. /**
  57748. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  57749. */
  57750. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  57751. /**
  57752. * The html button that is used to trigger entering into VR.
  57753. */
  57754. get vrButton(): Nullable<HTMLButtonElement>;
  57755. private get _teleportationRequestInitiated();
  57756. /**
  57757. * Defines whether or not Pointer lock should be requested when switching to
  57758. * full screen.
  57759. */
  57760. requestPointerLockOnFullScreen: boolean;
  57761. /**
  57762. * If asking to force XR, this will be populated with the default xr experience
  57763. */
  57764. xr: WebXRDefaultExperience;
  57765. /**
  57766. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  57767. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  57768. */
  57769. xrTestDone: boolean;
  57770. /**
  57771. * Instantiates a VRExperienceHelper.
  57772. * Helps to quickly add VR support to an existing scene.
  57773. * @param scene The scene the VRExperienceHelper belongs to.
  57774. * @param webVROptions Options to modify the vr experience helper's behavior.
  57775. */
  57776. constructor(scene: Scene,
  57777. /** Options to modify the vr experience helper's behavior. */
  57778. webVROptions?: VRExperienceHelperOptions);
  57779. private completeVRInit;
  57780. private _onDefaultMeshLoaded;
  57781. private _onResize;
  57782. private _onFullscreenChange;
  57783. /**
  57784. * Gets a value indicating if we are currently in VR mode.
  57785. */
  57786. get isInVRMode(): boolean;
  57787. private onVrDisplayPresentChange;
  57788. private onVRDisplayChanged;
  57789. private moveButtonToBottomRight;
  57790. private displayVRButton;
  57791. private updateButtonVisibility;
  57792. private _cachedAngularSensibility;
  57793. /**
  57794. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  57795. * Otherwise, will use the fullscreen API.
  57796. */
  57797. enterVR(): void;
  57798. /**
  57799. * Attempt to exit VR, or fullscreen.
  57800. */
  57801. exitVR(): void;
  57802. /**
  57803. * The position of the vr experience helper.
  57804. */
  57805. get position(): Vector3;
  57806. /**
  57807. * Sets the position of the vr experience helper.
  57808. */
  57809. set position(value: Vector3);
  57810. /**
  57811. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  57812. */
  57813. enableInteractions(): void;
  57814. private get _noControllerIsActive();
  57815. private beforeRender;
  57816. private _isTeleportationFloor;
  57817. /**
  57818. * Adds a floor mesh to be used for teleportation.
  57819. * @param floorMesh the mesh to be used for teleportation.
  57820. */
  57821. addFloorMesh(floorMesh: Mesh): void;
  57822. /**
  57823. * Removes a floor mesh from being used for teleportation.
  57824. * @param floorMesh the mesh to be removed.
  57825. */
  57826. removeFloorMesh(floorMesh: Mesh): void;
  57827. /**
  57828. * Enables interactions and teleportation using the VR controllers and gaze.
  57829. * @param vrTeleportationOptions options to modify teleportation behavior.
  57830. */
  57831. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  57832. private _onNewGamepadConnected;
  57833. private _tryEnableInteractionOnController;
  57834. private _onNewGamepadDisconnected;
  57835. private _enableInteractionOnController;
  57836. private _checkTeleportWithRay;
  57837. private _checkRotate;
  57838. private _checkTeleportBackwards;
  57839. private _enableTeleportationOnController;
  57840. private _createTeleportationCircles;
  57841. private _displayTeleportationTarget;
  57842. private _hideTeleportationTarget;
  57843. private _rotateCamera;
  57844. private _moveTeleportationSelectorTo;
  57845. private _workingVector;
  57846. private _workingQuaternion;
  57847. private _workingMatrix;
  57848. /**
  57849. * Time Constant Teleportation Mode
  57850. */
  57851. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  57852. /**
  57853. * Speed Constant Teleportation Mode
  57854. */
  57855. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  57856. /**
  57857. * Teleports the users feet to the desired location
  57858. * @param location The location where the user's feet should be placed
  57859. */
  57860. teleportCamera(location: Vector3): void;
  57861. private _convertNormalToDirectionOfRay;
  57862. private _castRayAndSelectObject;
  57863. private _notifySelectedMeshUnselected;
  57864. /**
  57865. * Permanently set new colors for the laser pointer
  57866. * @param color the new laser color
  57867. * @param pickedColor the new laser color when picked mesh detected
  57868. */
  57869. setLaserColor(color: Color3, pickedColor?: Color3): void;
  57870. /**
  57871. * Set lighting enabled / disabled on the laser pointer of both controllers
  57872. * @param enabled should the lighting be enabled on the laser pointer
  57873. */
  57874. setLaserLightingState(enabled?: boolean): void;
  57875. /**
  57876. * Permanently set new colors for the gaze pointer
  57877. * @param color the new gaze color
  57878. * @param pickedColor the new gaze color when picked mesh detected
  57879. */
  57880. setGazeColor(color: Color3, pickedColor?: Color3): void;
  57881. /**
  57882. * Sets the color of the laser ray from the vr controllers.
  57883. * @param color new color for the ray.
  57884. */
  57885. changeLaserColor(color: Color3): void;
  57886. /**
  57887. * Sets the color of the ray from the vr headsets gaze.
  57888. * @param color new color for the ray.
  57889. */
  57890. changeGazeColor(color: Color3): void;
  57891. /**
  57892. * Exits VR and disposes of the vr experience helper
  57893. */
  57894. dispose(): void;
  57895. /**
  57896. * Gets the name of the VRExperienceHelper class
  57897. * @returns "VRExperienceHelper"
  57898. */
  57899. getClassName(): string;
  57900. }
  57901. }
  57902. declare module BABYLON {
  57903. /**
  57904. * Contains an array of blocks representing the octree
  57905. */
  57906. export interface IOctreeContainer<T> {
  57907. /**
  57908. * Blocks within the octree
  57909. */
  57910. blocks: Array<OctreeBlock<T>>;
  57911. }
  57912. /**
  57913. * Class used to store a cell in an octree
  57914. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57915. */
  57916. export class OctreeBlock<T> {
  57917. /**
  57918. * Gets the content of the current block
  57919. */
  57920. entries: T[];
  57921. /**
  57922. * Gets the list of block children
  57923. */
  57924. blocks: Array<OctreeBlock<T>>;
  57925. private _depth;
  57926. private _maxDepth;
  57927. private _capacity;
  57928. private _minPoint;
  57929. private _maxPoint;
  57930. private _boundingVectors;
  57931. private _creationFunc;
  57932. /**
  57933. * Creates a new block
  57934. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  57935. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  57936. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  57937. * @param depth defines the current depth of this block in the octree
  57938. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  57939. * @param creationFunc defines a callback to call when an element is added to the block
  57940. */
  57941. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  57942. /**
  57943. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  57944. */
  57945. get capacity(): number;
  57946. /**
  57947. * Gets the minimum vector (in world space) of the block's bounding box
  57948. */
  57949. get minPoint(): Vector3;
  57950. /**
  57951. * Gets the maximum vector (in world space) of the block's bounding box
  57952. */
  57953. get maxPoint(): Vector3;
  57954. /**
  57955. * Add a new element to this block
  57956. * @param entry defines the element to add
  57957. */
  57958. addEntry(entry: T): void;
  57959. /**
  57960. * Remove an element from this block
  57961. * @param entry defines the element to remove
  57962. */
  57963. removeEntry(entry: T): void;
  57964. /**
  57965. * Add an array of elements to this block
  57966. * @param entries defines the array of elements to add
  57967. */
  57968. addEntries(entries: T[]): void;
  57969. /**
  57970. * Test if the current block intersects the frustum planes and if yes, then add its content to the selection array
  57971. * @param frustumPlanes defines the frustum planes to test
  57972. * @param selection defines the array to store current content if selection is positive
  57973. * @param allowDuplicate defines if the selection array can contains duplicated entries
  57974. */
  57975. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  57976. /**
  57977. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  57978. * @param sphereCenter defines the bounding sphere center
  57979. * @param sphereRadius defines the bounding sphere radius
  57980. * @param selection defines the array to store current content if selection is positive
  57981. * @param allowDuplicate defines if the selection array can contains duplicated entries
  57982. */
  57983. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  57984. /**
  57985. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  57986. * @param ray defines the ray to test with
  57987. * @param selection defines the array to store current content if selection is positive
  57988. */
  57989. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  57990. /**
  57991. * Subdivide the content into child blocks (this block will then be empty)
  57992. */
  57993. createInnerBlocks(): void;
  57994. /**
  57995. * @hidden
  57996. */
  57997. 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;
  57998. }
  57999. }
  58000. declare module BABYLON {
  58001. /**
  58002. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  58003. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  58004. */
  58005. export class Octree<T> {
  58006. /** 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.) */
  58007. maxDepth: number;
  58008. /**
  58009. * Blocks within the octree containing objects
  58010. */
  58011. blocks: Array<OctreeBlock<T>>;
  58012. /**
  58013. * Content stored in the octree
  58014. */
  58015. dynamicContent: T[];
  58016. private _maxBlockCapacity;
  58017. private _selectionContent;
  58018. private _creationFunc;
  58019. /**
  58020. * Creates a octree
  58021. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  58022. * @param creationFunc function to be used to instantiate the octree
  58023. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  58024. * @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.)
  58025. */
  58026. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  58027. /** 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.) */
  58028. maxDepth?: number);
  58029. /**
  58030. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  58031. * @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);
  58032. * @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);
  58033. * @param entries meshes to be added to the octree blocks
  58034. */
  58035. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  58036. /**
  58037. * Adds a mesh to the octree
  58038. * @param entry Mesh to add to the octree
  58039. */
  58040. addMesh(entry: T): void;
  58041. /**
  58042. * Remove an element from the octree
  58043. * @param entry defines the element to remove
  58044. */
  58045. removeMesh(entry: T): void;
  58046. /**
  58047. * Selects an array of meshes within the frustum
  58048. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  58049. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  58050. * @returns array of meshes within the frustum
  58051. */
  58052. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  58053. /**
  58054. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  58055. * @param sphereCenter defines the bounding sphere center
  58056. * @param sphereRadius defines the bounding sphere radius
  58057. * @param allowDuplicate defines if the selection array can contains duplicated entries
  58058. * @returns an array of objects that intersect the sphere
  58059. */
  58060. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  58061. /**
  58062. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  58063. * @param ray defines the ray to test with
  58064. * @returns array of intersected objects
  58065. */
  58066. intersectsRay(ray: Ray): SmartArray<T>;
  58067. /**
  58068. * Adds a mesh into the octree block if it intersects the block
  58069. */
  58070. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  58071. /**
  58072. * Adds a submesh into the octree block if it intersects the block
  58073. */
  58074. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  58075. }
  58076. }
  58077. declare module BABYLON {
  58078. interface Scene {
  58079. /**
  58080. * @hidden
  58081. * Backing Filed
  58082. */
  58083. _selectionOctree: Octree<AbstractMesh>;
  58084. /**
  58085. * Gets the octree used to boost mesh selection (picking)
  58086. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  58087. */
  58088. selectionOctree: Octree<AbstractMesh>;
  58089. /**
  58090. * Creates or updates the octree used to boost selection (picking)
  58091. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  58092. * @param maxCapacity defines the maximum capacity per leaf
  58093. * @param maxDepth defines the maximum depth of the octree
  58094. * @returns an octree of AbstractMesh
  58095. */
  58096. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  58097. }
  58098. interface AbstractMesh {
  58099. /**
  58100. * @hidden
  58101. * Backing Field
  58102. */
  58103. _submeshesOctree: Octree<SubMesh>;
  58104. /**
  58105. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  58106. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  58107. * @param maxCapacity defines the maximum size of each block (64 by default)
  58108. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  58109. * @returns the new octree
  58110. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  58111. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  58112. */
  58113. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  58114. }
  58115. /**
  58116. * Defines the octree scene component responsible to manage any octrees
  58117. * in a given scene.
  58118. */
  58119. export class OctreeSceneComponent {
  58120. /**
  58121. * The component name help to identify the component in the list of scene components.
  58122. */
  58123. readonly name: string;
  58124. /**
  58125. * The scene the component belongs to.
  58126. */
  58127. scene: Scene;
  58128. /**
  58129. * Indicates if the meshes have been checked to make sure they are isEnabled()
  58130. */
  58131. readonly checksIsEnabled: boolean;
  58132. /**
  58133. * Creates a new instance of the component for the given scene
  58134. * @param scene Defines the scene to register the component in
  58135. */
  58136. constructor(scene: Scene);
  58137. /**
  58138. * Registers the component in a given scene
  58139. */
  58140. register(): void;
  58141. /**
  58142. * Return the list of active meshes
  58143. * @returns the list of active meshes
  58144. */
  58145. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  58146. /**
  58147. * Return the list of active sub meshes
  58148. * @param mesh The mesh to get the candidates sub meshes from
  58149. * @returns the list of active sub meshes
  58150. */
  58151. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  58152. private _tempRay;
  58153. /**
  58154. * Return the list of sub meshes intersecting with a given local ray
  58155. * @param mesh defines the mesh to find the submesh for
  58156. * @param localRay defines the ray in local space
  58157. * @returns the list of intersecting sub meshes
  58158. */
  58159. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  58160. /**
  58161. * Return the list of sub meshes colliding with a collider
  58162. * @param mesh defines the mesh to find the submesh for
  58163. * @param collider defines the collider to evaluate the collision against
  58164. * @returns the list of colliding sub meshes
  58165. */
  58166. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  58167. /**
  58168. * Rebuilds the elements related to this component in case of
  58169. * context lost for instance.
  58170. */
  58171. rebuild(): void;
  58172. /**
  58173. * Disposes the component and the associated resources.
  58174. */
  58175. dispose(): void;
  58176. }
  58177. }
  58178. declare module BABYLON {
  58179. /**
  58180. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  58181. */
  58182. export interface GizmoAxisCache {
  58183. /** Mesh used to render the Gizmo */
  58184. gizmoMeshes: Mesh[];
  58185. /** Mesh used to detect user interaction with Gizmo */
  58186. colliderMeshes: Mesh[];
  58187. /** Material used to indicate color of gizmo mesh */
  58188. material: StandardMaterial;
  58189. /** Material used to indicate hover state of the Gizmo */
  58190. hoverMaterial: StandardMaterial;
  58191. /** Material used to indicate disabled state of the Gizmo */
  58192. disableMaterial: StandardMaterial;
  58193. /** Used to indicate Active state of the Gizmo */
  58194. active: boolean;
  58195. }
  58196. /**
  58197. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  58198. */
  58199. export class Gizmo implements IDisposable {
  58200. /** The utility layer the gizmo will be added to */
  58201. gizmoLayer: UtilityLayerRenderer;
  58202. /**
  58203. * The root mesh of the gizmo
  58204. */
  58205. _rootMesh: Mesh;
  58206. private _attachedMesh;
  58207. private _attachedNode;
  58208. /**
  58209. * Ratio for the scale of the gizmo (Default: 1)
  58210. */
  58211. protected _scaleRatio: number;
  58212. /**
  58213. * boolean updated by pointermove when a gizmo mesh is hovered
  58214. */
  58215. protected _isHovered: boolean;
  58216. /**
  58217. * Ratio for the scale of the gizmo (Default: 1)
  58218. */
  58219. set scaleRatio(value: number);
  58220. get scaleRatio(): number;
  58221. /**
  58222. * True when the mouse pointer is hovered a gizmo mesh
  58223. */
  58224. get isHovered(): boolean;
  58225. /**
  58226. * If a custom mesh has been set (Default: false)
  58227. */
  58228. protected _customMeshSet: boolean;
  58229. /**
  58230. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  58231. * * When set, interactions will be enabled
  58232. */
  58233. get attachedMesh(): Nullable<AbstractMesh>;
  58234. set attachedMesh(value: Nullable<AbstractMesh>);
  58235. /**
  58236. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  58237. * * When set, interactions will be enabled
  58238. */
  58239. get attachedNode(): Nullable<Node>;
  58240. set attachedNode(value: Nullable<Node>);
  58241. /**
  58242. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  58243. * @param mesh The mesh to replace the default mesh of the gizmo
  58244. */
  58245. setCustomMesh(mesh: Mesh): void;
  58246. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  58247. /**
  58248. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  58249. */
  58250. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  58251. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  58252. /**
  58253. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  58254. */
  58255. updateGizmoPositionToMatchAttachedMesh: boolean;
  58256. /**
  58257. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  58258. */
  58259. updateScale: boolean;
  58260. protected _interactionsEnabled: boolean;
  58261. protected _attachedNodeChanged(value: Nullable<Node>): void;
  58262. private _beforeRenderObserver;
  58263. private _tempQuaternion;
  58264. private _tempVector;
  58265. private _tempVector2;
  58266. private _tempMatrix1;
  58267. private _tempMatrix2;
  58268. private _rightHandtoLeftHandMatrix;
  58269. /**
  58270. * Creates a gizmo
  58271. * @param gizmoLayer The utility layer the gizmo will be added to
  58272. */
  58273. constructor(
  58274. /** The utility layer the gizmo will be added to */
  58275. gizmoLayer?: UtilityLayerRenderer);
  58276. /**
  58277. * Updates the gizmo to match the attached mesh's position/rotation
  58278. */
  58279. protected _update(): void;
  58280. /**
  58281. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  58282. * @param value Node, TransformNode or mesh
  58283. */
  58284. protected _matrixChanged(): void;
  58285. /**
  58286. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  58287. * @param gizmoLayer The utility layer the gizmo will be added to
  58288. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  58289. * @returns {Observer<PointerInfo>} pointerObserver
  58290. */
  58291. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  58292. /**
  58293. * Disposes of the gizmo
  58294. */
  58295. dispose(): void;
  58296. }
  58297. }
  58298. declare module BABYLON {
  58299. /**
  58300. * Single plane drag gizmo
  58301. */
  58302. export class PlaneDragGizmo extends Gizmo {
  58303. /**
  58304. * Drag behavior responsible for the gizmos dragging interactions
  58305. */
  58306. dragBehavior: PointerDragBehavior;
  58307. private _pointerObserver;
  58308. /**
  58309. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  58310. */
  58311. snapDistance: number;
  58312. /**
  58313. * Event that fires each time the gizmo snaps to a new location.
  58314. * * snapDistance is the the change in distance
  58315. */
  58316. onSnapObservable: Observable<{
  58317. snapDistance: number;
  58318. }>;
  58319. private _gizmoMesh;
  58320. private _coloredMaterial;
  58321. private _hoverMaterial;
  58322. private _disableMaterial;
  58323. private _isEnabled;
  58324. private _parent;
  58325. private _dragging;
  58326. /** @hidden */
  58327. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  58328. /**
  58329. * Creates a PlaneDragGizmo
  58330. * @param gizmoLayer The utility layer the gizmo will be added to
  58331. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  58332. * @param color The color of the gizmo
  58333. */
  58334. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  58335. protected _attachedNodeChanged(value: Nullable<Node>): void;
  58336. /**
  58337. * If the gizmo is enabled
  58338. */
  58339. set isEnabled(value: boolean);
  58340. get isEnabled(): boolean;
  58341. /**
  58342. * Disposes of the gizmo
  58343. */
  58344. dispose(): void;
  58345. }
  58346. }
  58347. declare module BABYLON {
  58348. /**
  58349. * Single plane rotation gizmo
  58350. */
  58351. export class PlaneRotationGizmo extends Gizmo {
  58352. /**
  58353. * Drag behavior responsible for the gizmos dragging interactions
  58354. */
  58355. dragBehavior: PointerDragBehavior;
  58356. private _pointerObserver;
  58357. /**
  58358. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  58359. */
  58360. snapDistance: number;
  58361. /**
  58362. * Event that fires each time the gizmo snaps to a new location.
  58363. * * snapDistance is the the change in distance
  58364. */
  58365. onSnapObservable: Observable<{
  58366. snapDistance: number;
  58367. }>;
  58368. private _isEnabled;
  58369. private _parent;
  58370. private _coloredMaterial;
  58371. private _hoverMaterial;
  58372. private _disableMaterial;
  58373. private _gizmoMesh;
  58374. private _rotationDisplayPlane;
  58375. private _dragging;
  58376. private _angles;
  58377. private static _rotationGizmoVertexShader;
  58378. private static _rotationGizmoFragmentShader;
  58379. private _rotationShaderMaterial;
  58380. /**
  58381. * Creates a PlaneRotationGizmo
  58382. * @param gizmoLayer The utility layer the gizmo will be added to
  58383. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  58384. * @param color The color of the gizmo
  58385. * @param tessellation Amount of tessellation to be used when creating rotation circles
  58386. * @param useEulerRotation Use and update Euler angle instead of quaternion
  58387. * @param thickness display gizmo axis thickness
  58388. */
  58389. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  58390. /** Create Geometry for Gizmo */
  58391. private _createGizmoMesh;
  58392. protected _attachedNodeChanged(value: Nullable<Node>): void;
  58393. /**
  58394. * If the gizmo is enabled
  58395. */
  58396. set isEnabled(value: boolean);
  58397. get isEnabled(): boolean;
  58398. /**
  58399. * Disposes of the gizmo
  58400. */
  58401. dispose(): void;
  58402. }
  58403. }
  58404. declare module BABYLON {
  58405. /**
  58406. * Gizmo that enables rotating a mesh along 3 axis
  58407. */
  58408. export class RotationGizmo extends Gizmo {
  58409. /**
  58410. * Internal gizmo used for interactions on the x axis
  58411. */
  58412. xGizmo: PlaneRotationGizmo;
  58413. /**
  58414. * Internal gizmo used for interactions on the y axis
  58415. */
  58416. yGizmo: PlaneRotationGizmo;
  58417. /**
  58418. * Internal gizmo used for interactions on the z axis
  58419. */
  58420. zGizmo: PlaneRotationGizmo;
  58421. /** Fires an event when any of it's sub gizmos are dragged */
  58422. onDragStartObservable: Observable<unknown>;
  58423. /** Fires an event when any of it's sub gizmos are released from dragging */
  58424. onDragEndObservable: Observable<unknown>;
  58425. private _meshAttached;
  58426. private _nodeAttached;
  58427. private _observables;
  58428. /** Node Caching for quick lookup */
  58429. private _gizmoAxisCache;
  58430. get attachedMesh(): Nullable<AbstractMesh>;
  58431. set attachedMesh(mesh: Nullable<AbstractMesh>);
  58432. get attachedNode(): Nullable<Node>;
  58433. set attachedNode(node: Nullable<Node>);
  58434. protected _checkBillboardTransform(): void;
  58435. /**
  58436. * True when the mouse pointer is hovering a gizmo mesh
  58437. */
  58438. get isHovered(): boolean;
  58439. /**
  58440. * Creates a RotationGizmo
  58441. * @param gizmoLayer The utility layer the gizmo will be added to
  58442. * @param tessellation Amount of tessellation to be used when creating rotation circles
  58443. * @param useEulerRotation Use and update Euler angle instead of quaternion
  58444. * @param thickness display gizmo axis thickness
  58445. */
  58446. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  58447. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  58448. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  58449. /**
  58450. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  58451. */
  58452. set snapDistance(value: number);
  58453. get snapDistance(): number;
  58454. /**
  58455. * Ratio for the scale of the gizmo (Default: 1)
  58456. */
  58457. set scaleRatio(value: number);
  58458. get scaleRatio(): number;
  58459. /**
  58460. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  58461. * @param mesh Axis gizmo mesh
  58462. * @param cache Gizmo axis definition used for reactive gizmo UI
  58463. */
  58464. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  58465. /**
  58466. * Disposes of the gizmo
  58467. */
  58468. dispose(): void;
  58469. /**
  58470. * CustomMeshes are not supported by this gizmo
  58471. * @param mesh The mesh to replace the default mesh of the gizmo
  58472. */
  58473. setCustomMesh(mesh: Mesh): void;
  58474. }
  58475. }
  58476. declare module BABYLON {
  58477. /**
  58478. * Class containing static functions to help procedurally build meshes
  58479. */
  58480. export class PolyhedronBuilder {
  58481. /**
  58482. * Creates a polyhedron mesh
  58483. * * 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
  58484. * * The parameter `size` (positive float, default 1) sets the polygon size
  58485. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  58486. * * 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`
  58487. * * 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
  58488. * * 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)`)
  58489. * * 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
  58490. * * 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
  58491. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58492. * * 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
  58493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58494. * @param name defines the name of the mesh
  58495. * @param options defines the options used to create the mesh
  58496. * @param scene defines the hosting scene
  58497. * @returns the polyhedron mesh
  58498. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  58499. */
  58500. static CreatePolyhedron(name: string, options: {
  58501. type?: number;
  58502. size?: number;
  58503. sizeX?: number;
  58504. sizeY?: number;
  58505. sizeZ?: number;
  58506. custom?: any;
  58507. faceUV?: Vector4[];
  58508. faceColors?: Color4[];
  58509. flat?: boolean;
  58510. updatable?: boolean;
  58511. sideOrientation?: number;
  58512. frontUVs?: Vector4;
  58513. backUVs?: Vector4;
  58514. }, scene?: Nullable<Scene>): Mesh;
  58515. }
  58516. }
  58517. declare module BABYLON {
  58518. /**
  58519. * Class containing static functions to help procedurally build meshes
  58520. */
  58521. export class BoxBuilder {
  58522. /**
  58523. * Creates a box mesh
  58524. * * The parameter `size` sets the size (float) of each box side (default 1)
  58525. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  58526. * * 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)
  58527. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58528. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58529. * * 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
  58530. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58531. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58532. * @param name defines the name of the mesh
  58533. * @param options defines the options used to create the mesh
  58534. * @param scene defines the hosting scene
  58535. * @returns the box mesh
  58536. */
  58537. static CreateBox(name: string, options: {
  58538. size?: number;
  58539. width?: number;
  58540. height?: number;
  58541. depth?: number;
  58542. faceUV?: Vector4[];
  58543. faceColors?: Color4[];
  58544. sideOrientation?: number;
  58545. frontUVs?: Vector4;
  58546. backUVs?: Vector4;
  58547. wrap?: boolean;
  58548. topBaseAt?: number;
  58549. bottomBaseAt?: number;
  58550. updatable?: boolean;
  58551. }, scene?: Nullable<Scene>): Mesh;
  58552. }
  58553. }
  58554. declare module BABYLON {
  58555. /**
  58556. * Single axis scale gizmo
  58557. */
  58558. export class AxisScaleGizmo extends Gizmo {
  58559. /**
  58560. * Drag behavior responsible for the gizmos dragging interactions
  58561. */
  58562. dragBehavior: PointerDragBehavior;
  58563. private _pointerObserver;
  58564. /**
  58565. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  58566. */
  58567. snapDistance: number;
  58568. /**
  58569. * Event that fires each time the gizmo snaps to a new location.
  58570. * * snapDistance is the the change in distance
  58571. */
  58572. onSnapObservable: Observable<{
  58573. snapDistance: number;
  58574. }>;
  58575. /**
  58576. * If the scaling operation should be done on all axis (default: false)
  58577. */
  58578. uniformScaling: boolean;
  58579. /**
  58580. * Custom sensitivity value for the drag strength
  58581. */
  58582. sensitivity: number;
  58583. private _isEnabled;
  58584. private _parent;
  58585. private _gizmoMesh;
  58586. private _coloredMaterial;
  58587. private _hoverMaterial;
  58588. private _disableMaterial;
  58589. private _dragging;
  58590. private _tmpVector;
  58591. private _tmpMatrix;
  58592. private _tmpMatrix2;
  58593. /**
  58594. * Creates an AxisScaleGizmo
  58595. * @param gizmoLayer The utility layer the gizmo will be added to
  58596. * @param dragAxis The axis which the gizmo will be able to scale on
  58597. * @param color The color of the gizmo
  58598. * @param thickness display gizmo axis thickness
  58599. */
  58600. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  58601. /** Create Geometry for Gizmo */
  58602. private _createGizmoMesh;
  58603. protected _attachedNodeChanged(value: Nullable<Node>): void;
  58604. /**
  58605. * If the gizmo is enabled
  58606. */
  58607. set isEnabled(value: boolean);
  58608. get isEnabled(): boolean;
  58609. /**
  58610. * Disposes of the gizmo
  58611. */
  58612. dispose(): void;
  58613. /**
  58614. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  58615. * @param mesh The mesh to replace the default mesh of the gizmo
  58616. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  58617. */
  58618. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  58619. }
  58620. }
  58621. declare module BABYLON {
  58622. /**
  58623. * Gizmo that enables scaling a mesh along 3 axis
  58624. */
  58625. export class ScaleGizmo extends Gizmo {
  58626. /**
  58627. * Internal gizmo used for interactions on the x axis
  58628. */
  58629. xGizmo: AxisScaleGizmo;
  58630. /**
  58631. * Internal gizmo used for interactions on the y axis
  58632. */
  58633. yGizmo: AxisScaleGizmo;
  58634. /**
  58635. * Internal gizmo used for interactions on the z axis
  58636. */
  58637. zGizmo: AxisScaleGizmo;
  58638. /**
  58639. * Internal gizmo used to scale all axis equally
  58640. */
  58641. uniformScaleGizmo: AxisScaleGizmo;
  58642. private _meshAttached;
  58643. private _nodeAttached;
  58644. private _snapDistance;
  58645. private _uniformScalingMesh;
  58646. private _octahedron;
  58647. private _sensitivity;
  58648. private _coloredMaterial;
  58649. private _hoverMaterial;
  58650. private _disableMaterial;
  58651. private _observables;
  58652. /** Node Caching for quick lookup */
  58653. private _gizmoAxisCache;
  58654. /** Fires an event when any of it's sub gizmos are dragged */
  58655. onDragStartObservable: Observable<unknown>;
  58656. /** Fires an event when any of it's sub gizmos are released from dragging */
  58657. onDragEndObservable: Observable<unknown>;
  58658. get attachedMesh(): Nullable<AbstractMesh>;
  58659. set attachedMesh(mesh: Nullable<AbstractMesh>);
  58660. get attachedNode(): Nullable<Node>;
  58661. set attachedNode(node: Nullable<Node>);
  58662. /**
  58663. * True when the mouse pointer is hovering a gizmo mesh
  58664. */
  58665. get isHovered(): boolean;
  58666. /**
  58667. * Creates a ScaleGizmo
  58668. * @param gizmoLayer The utility layer the gizmo will be added to
  58669. * @param thickness display gizmo axis thickness
  58670. */
  58671. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  58672. /** Create Geometry for Gizmo */
  58673. private _createUniformScaleMesh;
  58674. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  58675. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  58676. /**
  58677. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  58678. */
  58679. set snapDistance(value: number);
  58680. get snapDistance(): number;
  58681. /**
  58682. * Ratio for the scale of the gizmo (Default: 1)
  58683. */
  58684. set scaleRatio(value: number);
  58685. get scaleRatio(): number;
  58686. /**
  58687. * Sensitivity factor for dragging (Default: 1)
  58688. */
  58689. set sensitivity(value: number);
  58690. get sensitivity(): number;
  58691. /**
  58692. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  58693. * @param mesh Axis gizmo mesh
  58694. * @param cache Gizmo axis definition used for reactive gizmo UI
  58695. */
  58696. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  58697. /**
  58698. * Disposes of the gizmo
  58699. */
  58700. dispose(): void;
  58701. }
  58702. }
  58703. declare module BABYLON {
  58704. /**
  58705. * Bounding box gizmo
  58706. */
  58707. export class BoundingBoxGizmo extends Gizmo {
  58708. private _lineBoundingBox;
  58709. private _rotateSpheresParent;
  58710. private _scaleBoxesParent;
  58711. private _boundingDimensions;
  58712. private _renderObserver;
  58713. private _pointerObserver;
  58714. private _scaleDragSpeed;
  58715. private _tmpQuaternion;
  58716. private _tmpVector;
  58717. private _tmpRotationMatrix;
  58718. /**
  58719. * 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)
  58720. */
  58721. ignoreChildren: boolean;
  58722. /**
  58723. * 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)
  58724. */
  58725. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  58726. /**
  58727. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  58728. */
  58729. rotationSphereSize: number;
  58730. /**
  58731. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  58732. */
  58733. scaleBoxSize: number;
  58734. /**
  58735. * 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)
  58736. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  58737. */
  58738. fixedDragMeshScreenSize: boolean;
  58739. /**
  58740. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  58741. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  58742. */
  58743. fixedDragMeshBoundsSize: boolean;
  58744. /**
  58745. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  58746. */
  58747. fixedDragMeshScreenSizeDistanceFactor: number;
  58748. /**
  58749. * Fired when a rotation sphere or scale box is dragged
  58750. */
  58751. onDragStartObservable: Observable<{}>;
  58752. /**
  58753. * Fired when a scale box is dragged
  58754. */
  58755. onScaleBoxDragObservable: Observable<{}>;
  58756. /**
  58757. * Fired when a scale box drag is ended
  58758. */
  58759. onScaleBoxDragEndObservable: Observable<{}>;
  58760. /**
  58761. * Fired when a rotation sphere is dragged
  58762. */
  58763. onRotationSphereDragObservable: Observable<{}>;
  58764. /**
  58765. * Fired when a rotation sphere drag is ended
  58766. */
  58767. onRotationSphereDragEndObservable: Observable<{}>;
  58768. /**
  58769. * 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)
  58770. */
  58771. scalePivot: Nullable<Vector3>;
  58772. /**
  58773. * Mesh used as a pivot to rotate the attached node
  58774. */
  58775. private _anchorMesh;
  58776. private _existingMeshScale;
  58777. private _dragMesh;
  58778. private pointerDragBehavior;
  58779. private coloredMaterial;
  58780. private hoverColoredMaterial;
  58781. /**
  58782. * Sets the color of the bounding box gizmo
  58783. * @param color the color to set
  58784. */
  58785. setColor(color: Color3): void;
  58786. /**
  58787. * Creates an BoundingBoxGizmo
  58788. * @param gizmoLayer The utility layer the gizmo will be added to
  58789. * @param color The color of the gizmo
  58790. */
  58791. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  58792. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  58793. private _selectNode;
  58794. /**
  58795. * Updates the bounding box information for the Gizmo
  58796. */
  58797. updateBoundingBox(): void;
  58798. private _updateRotationSpheres;
  58799. private _updateScaleBoxes;
  58800. /**
  58801. * Enables rotation on the specified axis and disables rotation on the others
  58802. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  58803. */
  58804. setEnabledRotationAxis(axis: string): void;
  58805. /**
  58806. * Enables/disables scaling
  58807. * @param enable if scaling should be enabled
  58808. * @param homogeneousScaling defines if scaling should only be homogeneous
  58809. */
  58810. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  58811. private _updateDummy;
  58812. /**
  58813. * Enables a pointer drag behavior on the bounding box of the gizmo
  58814. */
  58815. enableDragBehavior(): void;
  58816. /**
  58817. * Disposes of the gizmo
  58818. */
  58819. dispose(): void;
  58820. /**
  58821. * 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)
  58822. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  58823. * @returns the bounding box mesh with the passed in mesh as a child
  58824. */
  58825. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  58826. /**
  58827. * CustomMeshes are not supported by this gizmo
  58828. * @param mesh The mesh to replace the default mesh of the gizmo
  58829. */
  58830. setCustomMesh(mesh: Mesh): void;
  58831. }
  58832. }
  58833. declare module BABYLON {
  58834. /**
  58835. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  58836. */
  58837. export class GizmoManager implements IDisposable {
  58838. private scene;
  58839. /**
  58840. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  58841. */
  58842. gizmos: {
  58843. positionGizmo: Nullable<PositionGizmo>;
  58844. rotationGizmo: Nullable<RotationGizmo>;
  58845. scaleGizmo: Nullable<ScaleGizmo>;
  58846. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  58847. };
  58848. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  58849. clearGizmoOnEmptyPointerEvent: boolean;
  58850. /** Fires an event when the manager is attached to a mesh */
  58851. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  58852. /** Fires an event when the manager is attached to a node */
  58853. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  58854. private _gizmosEnabled;
  58855. private _pointerObservers;
  58856. private _attachedMesh;
  58857. private _attachedNode;
  58858. private _boundingBoxColor;
  58859. private _defaultUtilityLayer;
  58860. private _defaultKeepDepthUtilityLayer;
  58861. private _thickness;
  58862. /** Node Caching for quick lookup */
  58863. private _gizmoAxisCache;
  58864. /**
  58865. * When bounding box gizmo is enabled, this can be used to track drag/end events
  58866. */
  58867. boundingBoxDragBehavior: SixDofDragBehavior;
  58868. /**
  58869. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  58870. */
  58871. attachableMeshes: Nullable<Array<AbstractMesh>>;
  58872. /**
  58873. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  58874. */
  58875. attachableNodes: Nullable<Array<Node>>;
  58876. /**
  58877. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  58878. */
  58879. usePointerToAttachGizmos: boolean;
  58880. /**
  58881. * Utility layer that the bounding box gizmo belongs to
  58882. */
  58883. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  58884. /**
  58885. * Utility layer that all gizmos besides bounding box belong to
  58886. */
  58887. get utilityLayer(): UtilityLayerRenderer;
  58888. /**
  58889. * True when the mouse pointer is hovering a gizmo mesh
  58890. */
  58891. get isHovered(): boolean;
  58892. /**
  58893. * Instantiates a gizmo manager
  58894. * @param scene the scene to overlay the gizmos on top of
  58895. * @param thickness display gizmo axis thickness
  58896. * @param utilityLayer the layer where gizmos are rendered
  58897. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  58898. */
  58899. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  58900. /**
  58901. * Subscribes to pointer down events, for attaching and detaching mesh
  58902. * @param scene The scene layer the observer will be added to
  58903. */
  58904. private _attachToMeshPointerObserver;
  58905. /**
  58906. * Attaches a set of gizmos to the specified mesh
  58907. * @param mesh The mesh the gizmo's should be attached to
  58908. */
  58909. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58910. /**
  58911. * Attaches a set of gizmos to the specified node
  58912. * @param node The node the gizmo's should be attached to
  58913. */
  58914. attachToNode(node: Nullable<Node>): void;
  58915. /**
  58916. * If the position gizmo is enabled
  58917. */
  58918. set positionGizmoEnabled(value: boolean);
  58919. get positionGizmoEnabled(): boolean;
  58920. /**
  58921. * If the rotation gizmo is enabled
  58922. */
  58923. set rotationGizmoEnabled(value: boolean);
  58924. get rotationGizmoEnabled(): boolean;
  58925. /**
  58926. * If the scale gizmo is enabled
  58927. */
  58928. set scaleGizmoEnabled(value: boolean);
  58929. get scaleGizmoEnabled(): boolean;
  58930. /**
  58931. * If the boundingBox gizmo is enabled
  58932. */
  58933. set boundingBoxGizmoEnabled(value: boolean);
  58934. get boundingBoxGizmoEnabled(): boolean;
  58935. /**
  58936. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  58937. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  58938. */
  58939. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  58940. /**
  58941. * Disposes of the gizmo manager
  58942. */
  58943. dispose(): void;
  58944. }
  58945. }
  58946. declare module BABYLON {
  58947. /**
  58948. * Gizmo that enables dragging a mesh along 3 axis
  58949. */
  58950. export class PositionGizmo extends Gizmo {
  58951. /**
  58952. * Internal gizmo used for interactions on the x axis
  58953. */
  58954. xGizmo: AxisDragGizmo;
  58955. /**
  58956. * Internal gizmo used for interactions on the y axis
  58957. */
  58958. yGizmo: AxisDragGizmo;
  58959. /**
  58960. * Internal gizmo used for interactions on the z axis
  58961. */
  58962. zGizmo: AxisDragGizmo;
  58963. /**
  58964. * Internal gizmo used for interactions on the yz plane
  58965. */
  58966. xPlaneGizmo: PlaneDragGizmo;
  58967. /**
  58968. * Internal gizmo used for interactions on the xz plane
  58969. */
  58970. yPlaneGizmo: PlaneDragGizmo;
  58971. /**
  58972. * Internal gizmo used for interactions on the xy plane
  58973. */
  58974. zPlaneGizmo: PlaneDragGizmo;
  58975. /**
  58976. * private variables
  58977. */
  58978. private _meshAttached;
  58979. private _nodeAttached;
  58980. private _snapDistance;
  58981. private _observables;
  58982. /** Node Caching for quick lookup */
  58983. private _gizmoAxisCache;
  58984. /** Fires an event when any of it's sub gizmos are dragged */
  58985. onDragStartObservable: Observable<unknown>;
  58986. /** Fires an event when any of it's sub gizmos are released from dragging */
  58987. onDragEndObservable: Observable<unknown>;
  58988. /**
  58989. * If set to true, planar drag is enabled
  58990. */
  58991. private _planarGizmoEnabled;
  58992. get attachedMesh(): Nullable<AbstractMesh>;
  58993. set attachedMesh(mesh: Nullable<AbstractMesh>);
  58994. get attachedNode(): Nullable<Node>;
  58995. set attachedNode(node: Nullable<Node>);
  58996. /**
  58997. * True when the mouse pointer is hovering a gizmo mesh
  58998. */
  58999. get isHovered(): boolean;
  59000. /**
  59001. * Creates a PositionGizmo
  59002. * @param gizmoLayer The utility layer the gizmo will be added to
  59003. @param thickness display gizmo axis thickness
  59004. */
  59005. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  59006. /**
  59007. * If the planar drag gizmo is enabled
  59008. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  59009. */
  59010. set planarGizmoEnabled(value: boolean);
  59011. get planarGizmoEnabled(): boolean;
  59012. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59013. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59014. /**
  59015. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59016. */
  59017. set snapDistance(value: number);
  59018. get snapDistance(): number;
  59019. /**
  59020. * Ratio for the scale of the gizmo (Default: 1)
  59021. */
  59022. set scaleRatio(value: number);
  59023. get scaleRatio(): number;
  59024. /**
  59025. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  59026. * @param mesh Axis gizmo mesh
  59027. * @param cache Gizmo axis definition used for reactive gizmo UI
  59028. */
  59029. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  59030. /**
  59031. * Disposes of the gizmo
  59032. */
  59033. dispose(): void;
  59034. /**
  59035. * CustomMeshes are not supported by this gizmo
  59036. * @param mesh The mesh to replace the default mesh of the gizmo
  59037. */
  59038. setCustomMesh(mesh: Mesh): void;
  59039. }
  59040. }
  59041. declare module BABYLON {
  59042. /**
  59043. * Single axis drag gizmo
  59044. */
  59045. export class AxisDragGizmo extends Gizmo {
  59046. /**
  59047. * Drag behavior responsible for the gizmos dragging interactions
  59048. */
  59049. dragBehavior: PointerDragBehavior;
  59050. private _pointerObserver;
  59051. /**
  59052. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59053. */
  59054. snapDistance: number;
  59055. /**
  59056. * Event that fires each time the gizmo snaps to a new location.
  59057. * * snapDistance is the the change in distance
  59058. */
  59059. onSnapObservable: Observable<{
  59060. snapDistance: number;
  59061. }>;
  59062. private _isEnabled;
  59063. private _parent;
  59064. private _gizmoMesh;
  59065. private _coloredMaterial;
  59066. private _hoverMaterial;
  59067. private _disableMaterial;
  59068. private _dragging;
  59069. /** @hidden */
  59070. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  59071. /** @hidden */
  59072. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  59073. /**
  59074. * Creates an AxisDragGizmo
  59075. * @param gizmoLayer The utility layer the gizmo will be added to
  59076. * @param dragAxis The axis which the gizmo will be able to drag on
  59077. * @param color The color of the gizmo
  59078. * @param thickness display gizmo axis thickness
  59079. */
  59080. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  59081. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59082. /**
  59083. * If the gizmo is enabled
  59084. */
  59085. set isEnabled(value: boolean);
  59086. get isEnabled(): boolean;
  59087. /**
  59088. * Disposes of the gizmo
  59089. */
  59090. dispose(): void;
  59091. }
  59092. }
  59093. declare module BABYLON.Debug {
  59094. /**
  59095. * The Axes viewer will show 3 axes in a specific point in space
  59096. */
  59097. export class AxesViewer {
  59098. private _xAxis;
  59099. private _yAxis;
  59100. private _zAxis;
  59101. private _scaleLinesFactor;
  59102. private _instanced;
  59103. /**
  59104. * Gets the hosting scene
  59105. */
  59106. scene: Nullable<Scene>;
  59107. /**
  59108. * Gets or sets a number used to scale line length
  59109. */
  59110. scaleLines: number;
  59111. /** Gets the node hierarchy used to render x-axis */
  59112. get xAxis(): TransformNode;
  59113. /** Gets the node hierarchy used to render y-axis */
  59114. get yAxis(): TransformNode;
  59115. /** Gets the node hierarchy used to render z-axis */
  59116. get zAxis(): TransformNode;
  59117. /**
  59118. * Creates a new AxesViewer
  59119. * @param scene defines the hosting scene
  59120. * @param scaleLines defines a number used to scale line length (1 by default)
  59121. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  59122. * @param xAxis defines the node hierarchy used to render the x-axis
  59123. * @param yAxis defines the node hierarchy used to render the y-axis
  59124. * @param zAxis defines the node hierarchy used to render the z-axis
  59125. */
  59126. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  59127. /**
  59128. * Force the viewer to update
  59129. * @param position defines the position of the viewer
  59130. * @param xaxis defines the x axis of the viewer
  59131. * @param yaxis defines the y axis of the viewer
  59132. * @param zaxis defines the z axis of the viewer
  59133. */
  59134. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  59135. /**
  59136. * Creates an instance of this axes viewer.
  59137. * @returns a new axes viewer with instanced meshes
  59138. */
  59139. createInstance(): AxesViewer;
  59140. /** Releases resources */
  59141. dispose(): void;
  59142. private static _SetRenderingGroupId;
  59143. }
  59144. }
  59145. declare module BABYLON.Debug {
  59146. /**
  59147. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  59148. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  59149. */
  59150. export class BoneAxesViewer extends AxesViewer {
  59151. /**
  59152. * Gets or sets the target mesh where to display the axes viewer
  59153. */
  59154. mesh: Nullable<Mesh>;
  59155. /**
  59156. * Gets or sets the target bone where to display the axes viewer
  59157. */
  59158. bone: Nullable<Bone>;
  59159. /** Gets current position */
  59160. pos: Vector3;
  59161. /** Gets direction of X axis */
  59162. xaxis: Vector3;
  59163. /** Gets direction of Y axis */
  59164. yaxis: Vector3;
  59165. /** Gets direction of Z axis */
  59166. zaxis: Vector3;
  59167. /**
  59168. * Creates a new BoneAxesViewer
  59169. * @param scene defines the hosting scene
  59170. * @param bone defines the target bone
  59171. * @param mesh defines the target mesh
  59172. * @param scaleLines defines a scaling factor for line length (1 by default)
  59173. */
  59174. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  59175. /**
  59176. * Force the viewer to update
  59177. */
  59178. update(): void;
  59179. /** Releases resources */
  59180. dispose(): void;
  59181. }
  59182. }
  59183. declare module BABYLON {
  59184. /**
  59185. * Interface used to define scene explorer extensibility option
  59186. */
  59187. export interface IExplorerExtensibilityOption {
  59188. /**
  59189. * Define the option label
  59190. */
  59191. label: string;
  59192. /**
  59193. * Defines the action to execute on click
  59194. */
  59195. action: (entity: any) => void;
  59196. }
  59197. /**
  59198. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  59199. */
  59200. export interface IExplorerExtensibilityGroup {
  59201. /**
  59202. * Defines a predicate to test if a given type mut be extended
  59203. */
  59204. predicate: (entity: any) => boolean;
  59205. /**
  59206. * Gets the list of options added to a type
  59207. */
  59208. entries: IExplorerExtensibilityOption[];
  59209. }
  59210. /**
  59211. * Interface used to define the options to use to create the Inspector
  59212. */
  59213. export interface IInspectorOptions {
  59214. /**
  59215. * Display in overlay mode (default: false)
  59216. */
  59217. overlay?: boolean;
  59218. /**
  59219. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  59220. */
  59221. globalRoot?: HTMLElement;
  59222. /**
  59223. * Display the Scene explorer
  59224. */
  59225. showExplorer?: boolean;
  59226. /**
  59227. * Display the property inspector
  59228. */
  59229. showInspector?: boolean;
  59230. /**
  59231. * Display in embed mode (both panes on the right)
  59232. */
  59233. embedMode?: boolean;
  59234. /**
  59235. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  59236. */
  59237. handleResize?: boolean;
  59238. /**
  59239. * Allow the panes to popup (default: true)
  59240. */
  59241. enablePopup?: boolean;
  59242. /**
  59243. * Allow the panes to be closed by users (default: true)
  59244. */
  59245. enableClose?: boolean;
  59246. /**
  59247. * Optional list of extensibility entries
  59248. */
  59249. explorerExtensibility?: IExplorerExtensibilityGroup[];
  59250. /**
  59251. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  59252. */
  59253. inspectorURL?: string;
  59254. /**
  59255. * Optional initial tab (default to DebugLayerTab.Properties)
  59256. */
  59257. initialTab?: DebugLayerTab;
  59258. }
  59259. interface Scene {
  59260. /**
  59261. * @hidden
  59262. * Backing field
  59263. */
  59264. _debugLayer: DebugLayer;
  59265. /**
  59266. * Gets the debug layer (aka Inspector) associated with the scene
  59267. * @see https://doc.babylonjs.com/features/playground_debuglayer
  59268. */
  59269. debugLayer: DebugLayer;
  59270. }
  59271. /**
  59272. * Enum of inspector action tab
  59273. */
  59274. export enum DebugLayerTab {
  59275. /**
  59276. * Properties tag (default)
  59277. */
  59278. Properties = 0,
  59279. /**
  59280. * Debug tab
  59281. */
  59282. Debug = 1,
  59283. /**
  59284. * Statistics tab
  59285. */
  59286. Statistics = 2,
  59287. /**
  59288. * Tools tab
  59289. */
  59290. Tools = 3,
  59291. /**
  59292. * Settings tab
  59293. */
  59294. Settings = 4
  59295. }
  59296. /**
  59297. * The debug layer (aka Inspector) is the go to tool in order to better understand
  59298. * what is happening in your scene
  59299. * @see https://doc.babylonjs.com/features/playground_debuglayer
  59300. */
  59301. export class DebugLayer {
  59302. /**
  59303. * Define the url to get the inspector script from.
  59304. * By default it uses the babylonjs CDN.
  59305. * @ignoreNaming
  59306. */
  59307. static InspectorURL: string;
  59308. private _scene;
  59309. private BJSINSPECTOR;
  59310. private _onPropertyChangedObservable?;
  59311. /**
  59312. * Observable triggered when a property is changed through the inspector.
  59313. */
  59314. get onPropertyChangedObservable(): any;
  59315. /**
  59316. * Instantiates a new debug layer.
  59317. * The debug layer (aka Inspector) is the go to tool in order to better understand
  59318. * what is happening in your scene
  59319. * @see https://doc.babylonjs.com/features/playground_debuglayer
  59320. * @param scene Defines the scene to inspect
  59321. */
  59322. constructor(scene: Scene);
  59323. /** Creates the inspector window. */
  59324. private _createInspector;
  59325. /**
  59326. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  59327. * @param entity defines the entity to select
  59328. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  59329. */
  59330. select(entity: any, lineContainerTitles?: string | string[]): void;
  59331. /** Get the inspector from bundle or global */
  59332. private _getGlobalInspector;
  59333. /**
  59334. * Get if the inspector is visible or not.
  59335. * @returns true if visible otherwise, false
  59336. */
  59337. isVisible(): boolean;
  59338. /**
  59339. * Hide the inspector and close its window.
  59340. */
  59341. hide(): void;
  59342. /**
  59343. * Update the scene in the inspector
  59344. */
  59345. setAsActiveScene(): void;
  59346. /**
  59347. * Launch the debugLayer.
  59348. * @param config Define the configuration of the inspector
  59349. * @return a promise fulfilled when the debug layer is visible
  59350. */
  59351. show(config?: IInspectorOptions): Promise<DebugLayer>;
  59352. }
  59353. }
  59354. declare module BABYLON.Debug {
  59355. /**
  59356. * Used to show the physics impostor around the specific mesh
  59357. */
  59358. export class PhysicsViewer {
  59359. /** @hidden */
  59360. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  59361. /** @hidden */
  59362. protected _meshes: Array<Nullable<AbstractMesh>>;
  59363. /** @hidden */
  59364. protected _scene: Nullable<Scene>;
  59365. /** @hidden */
  59366. protected _numMeshes: number;
  59367. /** @hidden */
  59368. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  59369. private _renderFunction;
  59370. private _utilityLayer;
  59371. private _debugBoxMesh;
  59372. private _debugSphereMesh;
  59373. private _debugCylinderMesh;
  59374. private _debugMaterial;
  59375. private _debugMeshMeshes;
  59376. /**
  59377. * Creates a new PhysicsViewer
  59378. * @param scene defines the hosting scene
  59379. */
  59380. constructor(scene: Scene);
  59381. /** @hidden */
  59382. protected _updateDebugMeshes(): void;
  59383. /**
  59384. * Renders a specified physic impostor
  59385. * @param impostor defines the impostor to render
  59386. * @param targetMesh defines the mesh represented by the impostor
  59387. * @returns the new debug mesh used to render the impostor
  59388. */
  59389. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  59390. /**
  59391. * Hides a specified physic impostor
  59392. * @param impostor defines the impostor to hide
  59393. */
  59394. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  59395. private _getDebugMaterial;
  59396. private _getDebugBoxMesh;
  59397. private _getDebugSphereMesh;
  59398. private _getDebugCylinderMesh;
  59399. private _getDebugMeshMesh;
  59400. private _getDebugMesh;
  59401. /** Releases all resources */
  59402. dispose(): void;
  59403. }
  59404. }
  59405. declare module BABYLON {
  59406. /**
  59407. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  59408. * in order to better appreciate the issue one might have.
  59409. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  59410. */
  59411. export class RayHelper {
  59412. /**
  59413. * Defines the ray we are currently tryin to visualize.
  59414. */
  59415. ray: Nullable<Ray>;
  59416. private _renderPoints;
  59417. private _renderLine;
  59418. private _renderFunction;
  59419. private _scene;
  59420. private _onAfterRenderObserver;
  59421. private _onAfterStepObserver;
  59422. private _attachedToMesh;
  59423. private _meshSpaceDirection;
  59424. private _meshSpaceOrigin;
  59425. /**
  59426. * Helper function to create a colored helper in a scene in one line.
  59427. * @param ray Defines the ray we are currently tryin to visualize
  59428. * @param scene Defines the scene the ray is used in
  59429. * @param color Defines the color we want to see the ray in
  59430. * @returns The newly created ray helper.
  59431. */
  59432. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  59433. /**
  59434. * Instantiate a new ray helper.
  59435. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  59436. * in order to better appreciate the issue one might have.
  59437. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  59438. * @param ray Defines the ray we are currently tryin to visualize
  59439. */
  59440. constructor(ray: Ray);
  59441. /**
  59442. * Shows the ray we are willing to debug.
  59443. * @param scene Defines the scene the ray needs to be rendered in
  59444. * @param color Defines the color the ray needs to be rendered in
  59445. */
  59446. show(scene: Scene, color?: Color3): void;
  59447. /**
  59448. * Hides the ray we are debugging.
  59449. */
  59450. hide(): void;
  59451. private _render;
  59452. /**
  59453. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  59454. * @param mesh Defines the mesh we want the helper attached to
  59455. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  59456. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  59457. * @param length Defines the length of the ray
  59458. */
  59459. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  59460. /**
  59461. * Detach the ray helper from the mesh it has previously been attached to.
  59462. */
  59463. detachFromMesh(): void;
  59464. private _updateToMesh;
  59465. /**
  59466. * Dispose the helper and release its associated resources.
  59467. */
  59468. dispose(): void;
  59469. }
  59470. }
  59471. declare module BABYLON {
  59472. /**
  59473. * Defines the options associated with the creation of a SkeletonViewer.
  59474. */
  59475. export interface ISkeletonViewerOptions {
  59476. /** Should the system pause animations before building the Viewer? */
  59477. pauseAnimations: boolean;
  59478. /** Should the system return the skeleton to rest before building? */
  59479. returnToRest: boolean;
  59480. /** public Display Mode of the Viewer */
  59481. displayMode: number;
  59482. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  59483. displayOptions: ISkeletonViewerDisplayOptions;
  59484. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  59485. computeBonesUsingShaders: boolean;
  59486. /** Flag ignore non weighted bones */
  59487. useAllBones: boolean;
  59488. }
  59489. /**
  59490. * Defines how to display the various bone meshes for the viewer.
  59491. */
  59492. export interface ISkeletonViewerDisplayOptions {
  59493. /** How far down to start tapering the bone spurs */
  59494. midStep?: number;
  59495. /** How big is the midStep? */
  59496. midStepFactor?: number;
  59497. /** Base for the Sphere Size */
  59498. sphereBaseSize?: number;
  59499. /** The ratio of the sphere to the longest bone in units */
  59500. sphereScaleUnit?: number;
  59501. /** Ratio for the Sphere Size */
  59502. sphereFactor?: number;
  59503. /** Whether a spur should attach its far end to the child bone position */
  59504. spurFollowsChild?: boolean;
  59505. /** Whether to show local axes or not */
  59506. showLocalAxes?: boolean;
  59507. /** Length of each local axis */
  59508. localAxesSize?: number;
  59509. }
  59510. /**
  59511. * Defines the constructor options for the BoneWeight Shader.
  59512. */
  59513. export interface IBoneWeightShaderOptions {
  59514. /** Skeleton to Map */
  59515. skeleton: Skeleton;
  59516. /** Colors for Uninfluenced bones */
  59517. colorBase?: Color3;
  59518. /** Colors for 0.0-0.25 Weight bones */
  59519. colorZero?: Color3;
  59520. /** Color for 0.25-0.5 Weight Influence */
  59521. colorQuarter?: Color3;
  59522. /** Color for 0.5-0.75 Weight Influence */
  59523. colorHalf?: Color3;
  59524. /** Color for 0.75-1 Weight Influence */
  59525. colorFull?: Color3;
  59526. /** Color for Zero Weight Influence */
  59527. targetBoneIndex?: number;
  59528. }
  59529. /**
  59530. * Simple structure of the gradient steps for the Color Map.
  59531. */
  59532. export interface ISkeletonMapShaderColorMapKnot {
  59533. /** Color of the Knot */
  59534. color: Color3;
  59535. /** Location of the Knot */
  59536. location: number;
  59537. }
  59538. /**
  59539. * Defines the constructor options for the SkeletonMap Shader.
  59540. */
  59541. export interface ISkeletonMapShaderOptions {
  59542. /** Skeleton to Map */
  59543. skeleton: Skeleton;
  59544. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  59545. colorMap?: ISkeletonMapShaderColorMapKnot[];
  59546. }
  59547. }
  59548. declare module BABYLON {
  59549. /**
  59550. * Class containing static functions to help procedurally build meshes
  59551. */
  59552. export class RibbonBuilder {
  59553. /**
  59554. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59555. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59556. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59557. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59558. * * 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
  59559. * * 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
  59560. * * 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
  59561. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59562. * * 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
  59563. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59564. * * 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
  59565. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59566. * * 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
  59567. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59568. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59569. * @param name defines the name of the mesh
  59570. * @param options defines the options used to create the mesh
  59571. * @param scene defines the hosting scene
  59572. * @returns the ribbon mesh
  59573. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59574. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59575. */
  59576. static CreateRibbon(name: string, options: {
  59577. pathArray: Vector3[][];
  59578. closeArray?: boolean;
  59579. closePath?: boolean;
  59580. offset?: number;
  59581. updatable?: boolean;
  59582. sideOrientation?: number;
  59583. frontUVs?: Vector4;
  59584. backUVs?: Vector4;
  59585. instance?: Mesh;
  59586. invertUV?: boolean;
  59587. uvs?: Vector2[];
  59588. colors?: Color4[];
  59589. }, scene?: Nullable<Scene>): Mesh;
  59590. }
  59591. }
  59592. declare module BABYLON {
  59593. /**
  59594. * Class containing static functions to help procedurally build meshes
  59595. */
  59596. export class ShapeBuilder {
  59597. /**
  59598. * 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.
  59599. * * 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.
  59600. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59601. * * 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.
  59602. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59603. * * 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
  59604. * * 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
  59605. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59606. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59607. * * 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
  59608. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59610. * @param name defines the name of the mesh
  59611. * @param options defines the options used to create the mesh
  59612. * @param scene defines the hosting scene
  59613. * @returns the extruded shape mesh
  59614. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59615. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59616. */
  59617. static ExtrudeShape(name: string, options: {
  59618. shape: Vector3[];
  59619. path: Vector3[];
  59620. scale?: number;
  59621. rotation?: number;
  59622. cap?: number;
  59623. updatable?: boolean;
  59624. sideOrientation?: number;
  59625. frontUVs?: Vector4;
  59626. backUVs?: Vector4;
  59627. instance?: Mesh;
  59628. invertUV?: boolean;
  59629. }, scene?: Nullable<Scene>): Mesh;
  59630. /**
  59631. * Creates an custom extruded shape mesh.
  59632. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59633. * * 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.
  59634. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59635. * * 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
  59636. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59637. * * 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
  59638. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59639. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59640. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59641. * * 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
  59642. * * 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
  59643. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59644. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59645. * * 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
  59646. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59648. * @param name defines the name of the mesh
  59649. * @param options defines the options used to create the mesh
  59650. * @param scene defines the hosting scene
  59651. * @returns the custom extruded shape mesh
  59652. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59653. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59654. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59655. */
  59656. static ExtrudeShapeCustom(name: string, options: {
  59657. shape: Vector3[];
  59658. path: Vector3[];
  59659. scaleFunction?: any;
  59660. rotationFunction?: any;
  59661. ribbonCloseArray?: boolean;
  59662. ribbonClosePath?: boolean;
  59663. cap?: number;
  59664. updatable?: boolean;
  59665. sideOrientation?: number;
  59666. frontUVs?: Vector4;
  59667. backUVs?: Vector4;
  59668. instance?: Mesh;
  59669. invertUV?: boolean;
  59670. }, scene?: Nullable<Scene>): Mesh;
  59671. private static _ExtrudeShapeGeneric;
  59672. }
  59673. }
  59674. declare module BABYLON.Debug {
  59675. /**
  59676. * Class used to render a debug view of a given skeleton
  59677. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  59678. */
  59679. export class SkeletonViewer {
  59680. /** defines the skeleton to render */
  59681. skeleton: Skeleton;
  59682. /** defines the mesh attached to the skeleton */
  59683. mesh: AbstractMesh;
  59684. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  59685. autoUpdateBonesMatrices: boolean;
  59686. /** defines the rendering group id to use with the viewer */
  59687. renderingGroupId: number;
  59688. /** is the options for the viewer */
  59689. options: Partial<ISkeletonViewerOptions>;
  59690. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  59691. static readonly DISPLAY_LINES: number;
  59692. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  59693. static readonly DISPLAY_SPHERES: number;
  59694. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  59695. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  59696. /** public static method to create a BoneWeight Shader
  59697. * @param options The constructor options
  59698. * @param scene The scene that the shader is scoped to
  59699. * @returns The created ShaderMaterial
  59700. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  59701. */
  59702. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  59703. /** public static method to create a BoneWeight Shader
  59704. * @param options The constructor options
  59705. * @param scene The scene that the shader is scoped to
  59706. * @returns The created ShaderMaterial
  59707. */
  59708. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  59709. /** private static method to create a BoneWeight Shader
  59710. * @param size The size of the buffer to create (usually the bone count)
  59711. * @param colorMap The gradient data to generate
  59712. * @param scene The scene that the shader is scoped to
  59713. * @returns an Array of floats from the color gradient values
  59714. */
  59715. private static _CreateBoneMapColorBuffer;
  59716. /** If SkeletonViewer scene scope. */
  59717. private _scene;
  59718. /** Gets or sets the color used to render the skeleton */
  59719. color: Color3;
  59720. /** Array of the points of the skeleton fo the line view. */
  59721. private _debugLines;
  59722. /** The SkeletonViewers Mesh. */
  59723. private _debugMesh;
  59724. /** The local axes Meshes. */
  59725. private _localAxes;
  59726. /** If SkeletonViewer is enabled. */
  59727. private _isEnabled;
  59728. /** If SkeletonViewer is ready. */
  59729. private _ready;
  59730. /** SkeletonViewer render observable. */
  59731. private _obs;
  59732. /** The Utility Layer to render the gizmos in. */
  59733. private _utilityLayer;
  59734. private _boneIndices;
  59735. /** Gets the Scene. */
  59736. get scene(): Scene;
  59737. /** Gets the utilityLayer. */
  59738. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  59739. /** Checks Ready Status. */
  59740. get isReady(): Boolean;
  59741. /** Sets Ready Status. */
  59742. set ready(value: boolean);
  59743. /** Gets the debugMesh */
  59744. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  59745. /** Sets the debugMesh */
  59746. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  59747. /** Gets the displayMode */
  59748. get displayMode(): number;
  59749. /** Sets the displayMode */
  59750. set displayMode(value: number);
  59751. /**
  59752. * Creates a new SkeletonViewer
  59753. * @param skeleton defines the skeleton to render
  59754. * @param mesh defines the mesh attached to the skeleton
  59755. * @param scene defines the hosting scene
  59756. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  59757. * @param renderingGroupId defines the rendering group id to use with the viewer
  59758. * @param options All of the extra constructor options for the SkeletonViewer
  59759. */
  59760. constructor(
  59761. /** defines the skeleton to render */
  59762. skeleton: Skeleton,
  59763. /** defines the mesh attached to the skeleton */
  59764. mesh: AbstractMesh,
  59765. /** The Scene scope*/
  59766. scene: Scene,
  59767. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  59768. autoUpdateBonesMatrices?: boolean,
  59769. /** defines the rendering group id to use with the viewer */
  59770. renderingGroupId?: number,
  59771. /** is the options for the viewer */
  59772. options?: Partial<ISkeletonViewerOptions>);
  59773. /** The Dynamic bindings for the update functions */
  59774. private _bindObs;
  59775. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  59776. update(): void;
  59777. /** Gets or sets a boolean indicating if the viewer is enabled */
  59778. set isEnabled(value: boolean);
  59779. get isEnabled(): boolean;
  59780. private _getBonePosition;
  59781. private _getLinesForBonesWithLength;
  59782. private _getLinesForBonesNoLength;
  59783. /** function to revert the mesh and scene back to the initial state. */
  59784. private _revert;
  59785. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  59786. private _getAbsoluteBindPoseToRef;
  59787. /** function to build and bind sphere joint points and spur bone representations. */
  59788. private _buildSpheresAndSpurs;
  59789. private _buildLocalAxes;
  59790. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  59791. private _displayLinesUpdate;
  59792. /** Changes the displayMode of the skeleton viewer
  59793. * @param mode The displayMode numerical value
  59794. */
  59795. changeDisplayMode(mode: number): void;
  59796. /** Sets a display option of the skeleton viewer
  59797. *
  59798. * | Option | Type | Default | Description |
  59799. * | ---------------- | ------- | ------- | ----------- |
  59800. * | 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`. |
  59801. * | 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`. |
  59802. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  59803. * | 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`. |
  59804. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  59805. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  59806. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  59807. *
  59808. * @param option String of the option name
  59809. * @param value The numerical option value
  59810. */
  59811. changeDisplayOptions(option: string, value: number): void;
  59812. /** Release associated resources */
  59813. dispose(): void;
  59814. }
  59815. }
  59816. declare module BABYLON {
  59817. /**
  59818. * A directional light is defined by a direction (what a surprise!).
  59819. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  59820. * 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.
  59821. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59822. */
  59823. export class DirectionalLight extends ShadowLight {
  59824. private _shadowFrustumSize;
  59825. /**
  59826. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  59827. */
  59828. get shadowFrustumSize(): number;
  59829. /**
  59830. * Specifies a fix frustum size for the shadow generation.
  59831. */
  59832. set shadowFrustumSize(value: number);
  59833. private _shadowOrthoScale;
  59834. /**
  59835. * Gets 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. get shadowOrthoScale(): number;
  59840. /**
  59841. * Sets the shadow projection scale against the optimal computed one.
  59842. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  59843. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  59844. */
  59845. set shadowOrthoScale(value: number);
  59846. /**
  59847. * Automatically compute the projection matrix to best fit (including all the casters)
  59848. * on each frame.
  59849. */
  59850. autoUpdateExtends: boolean;
  59851. /**
  59852. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  59853. * on each frame. autoUpdateExtends must be set to true for this to work
  59854. */
  59855. autoCalcShadowZBounds: boolean;
  59856. private _orthoLeft;
  59857. private _orthoRight;
  59858. private _orthoTop;
  59859. private _orthoBottom;
  59860. /**
  59861. * Gets or sets the orthoLeft property used to build the light frustum
  59862. */
  59863. get orthoLeft(): number;
  59864. set orthoLeft(left: number);
  59865. /**
  59866. * Gets or sets the orthoRight property used to build the light frustum
  59867. */
  59868. get orthoRight(): number;
  59869. set orthoRight(right: number);
  59870. /**
  59871. * Gets or sets the orthoTop property used to build the light frustum
  59872. */
  59873. get orthoTop(): number;
  59874. set orthoTop(top: number);
  59875. /**
  59876. * Gets or sets the orthoBottom property used to build the light frustum
  59877. */
  59878. get orthoBottom(): number;
  59879. set orthoBottom(bottom: number);
  59880. /**
  59881. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  59882. * The directional light is emitted from everywhere in the given direction.
  59883. * It can cast shadows.
  59884. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59885. * @param name The friendly name of the light
  59886. * @param direction The direction of the light
  59887. * @param scene The scene the light belongs to
  59888. */
  59889. constructor(name: string, direction: Vector3, scene: Scene);
  59890. /**
  59891. * Returns the string "DirectionalLight".
  59892. * @return The class name
  59893. */
  59894. getClassName(): string;
  59895. /**
  59896. * Returns the integer 1.
  59897. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59898. */
  59899. getTypeID(): number;
  59900. /**
  59901. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  59902. * Returns the DirectionalLight Shadow projection matrix.
  59903. */
  59904. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59905. /**
  59906. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  59907. * Returns the DirectionalLight Shadow projection matrix.
  59908. */
  59909. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  59910. /**
  59911. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  59912. * Returns the DirectionalLight Shadow projection matrix.
  59913. */
  59914. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59915. protected _buildUniformLayout(): void;
  59916. /**
  59917. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  59918. * @param effect The effect to update
  59919. * @param lightIndex The index of the light in the effect to update
  59920. * @returns The directional light
  59921. */
  59922. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  59923. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  59924. /**
  59925. * Gets the minZ used for shadow according to both the scene and the light.
  59926. *
  59927. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  59928. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  59929. * @param activeCamera The camera we are returning the min for
  59930. * @returns the depth min z
  59931. */
  59932. getDepthMinZ(activeCamera: Camera): number;
  59933. /**
  59934. * Gets the maxZ used for shadow according to both the scene and the light.
  59935. *
  59936. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  59937. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  59938. * @param activeCamera The camera we are returning the max for
  59939. * @returns the depth max z
  59940. */
  59941. getDepthMaxZ(activeCamera: Camera): number;
  59942. /**
  59943. * Prepares the list of defines specific to the light type.
  59944. * @param defines the list of defines
  59945. * @param lightIndex defines the index of the light for the effect
  59946. */
  59947. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59948. }
  59949. }
  59950. declare module BABYLON {
  59951. /**
  59952. * Class used to render a debug view of the frustum for a directional light
  59953. * @see https://playground.babylonjs.com/#7EFGSG#3
  59954. */
  59955. export class DirectionalLightFrustumViewer {
  59956. private _scene;
  59957. private _light;
  59958. private _camera;
  59959. private _inverseViewMatrix;
  59960. private _visible;
  59961. private _rootNode;
  59962. private _lightHelperFrustumMeshes;
  59963. private _nearLinesPoints;
  59964. private _farLinesPoints;
  59965. private _trLinesPoints;
  59966. private _brLinesPoints;
  59967. private _tlLinesPoints;
  59968. private _blLinesPoints;
  59969. private _nearPlaneVertices;
  59970. private _farPlaneVertices;
  59971. private _rightPlaneVertices;
  59972. private _leftPlaneVertices;
  59973. private _topPlaneVertices;
  59974. private _bottomPlaneVertices;
  59975. private _oldPosition;
  59976. private _oldDirection;
  59977. private _oldAutoCalc;
  59978. private _oldMinZ;
  59979. private _oldMaxZ;
  59980. private _transparency;
  59981. /**
  59982. * Gets or sets the transparency of the frustum planes
  59983. */
  59984. get transparency(): number;
  59985. set transparency(alpha: number);
  59986. private _showLines;
  59987. /**
  59988. * true to display the edges of the frustum
  59989. */
  59990. get showLines(): boolean;
  59991. set showLines(show: boolean);
  59992. private _showPlanes;
  59993. /**
  59994. * true to display the planes of the frustum
  59995. */
  59996. get showPlanes(): boolean;
  59997. set showPlanes(show: boolean);
  59998. /**
  59999. * Creates a new frustum viewer
  60000. * @param light directional light to display the frustum for
  60001. * @param camera camera used to retrieve the minZ / maxZ values if the shadowMinZ/shadowMaxZ values of the light are not setup
  60002. */
  60003. constructor(light: DirectionalLight, camera: Camera);
  60004. /**
  60005. * Shows the frustum
  60006. */
  60007. show(): void;
  60008. /**
  60009. * Hides the frustum
  60010. */
  60011. hide(): void;
  60012. /**
  60013. * Updates the frustum.
  60014. * Call this method to update the frustum view if the light has changed position/direction
  60015. */
  60016. update(): void;
  60017. /**
  60018. * Dispose of the class / remove the frustum view
  60019. */
  60020. dispose(): void;
  60021. protected _createGeometry(): void;
  60022. protected _getInvertViewMatrix(): Matrix;
  60023. }
  60024. }
  60025. declare module BABYLON {
  60026. /**
  60027. * Type to handle enforcement of inputs
  60028. */
  60029. 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;
  60030. }
  60031. declare module BABYLON {
  60032. /**
  60033. * Class that handles all input for a specific device
  60034. */
  60035. export class DeviceSource<T extends DeviceType> {
  60036. /** Type of device */
  60037. readonly deviceType: DeviceType;
  60038. /** "Slot" or index that device is referenced in */
  60039. readonly deviceSlot: number;
  60040. /**
  60041. * Observable to handle device input changes per device
  60042. */
  60043. readonly onInputChangedObservable: Observable<{
  60044. inputIndex: DeviceInput<T>;
  60045. previousState: Nullable<number>;
  60046. currentState: Nullable<number>;
  60047. }>;
  60048. private readonly _deviceInputSystem;
  60049. /**
  60050. * Default Constructor
  60051. * @param deviceInputSystem Reference to DeviceInputSystem
  60052. * @param deviceType Type of device
  60053. * @param deviceSlot "Slot" or index that device is referenced in
  60054. */
  60055. constructor(deviceInputSystem: DeviceInputSystem,
  60056. /** Type of device */
  60057. deviceType: DeviceType,
  60058. /** "Slot" or index that device is referenced in */
  60059. deviceSlot?: number);
  60060. /**
  60061. * Get input for specific input
  60062. * @param inputIndex index of specific input on device
  60063. * @returns Input value from DeviceInputSystem
  60064. */
  60065. getInput(inputIndex: DeviceInput<T>): number;
  60066. }
  60067. /**
  60068. * Class to keep track of devices
  60069. */
  60070. export class DeviceSourceManager implements IDisposable {
  60071. /**
  60072. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  60073. */
  60074. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  60075. /**
  60076. * Observable to be triggered when after a device is disconnected
  60077. */
  60078. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  60079. private readonly _devices;
  60080. private readonly _firstDevice;
  60081. private readonly _deviceInputSystem;
  60082. /**
  60083. * Default Constructor
  60084. * @param engine engine to pull input element from
  60085. */
  60086. constructor(engine: Engine);
  60087. /**
  60088. * Gets a DeviceSource, given a type and slot
  60089. * @param deviceType Enum specifying device type
  60090. * @param deviceSlot "Slot" or index that device is referenced in
  60091. * @returns DeviceSource object
  60092. */
  60093. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  60094. /**
  60095. * Gets an array of DeviceSource objects for a given device type
  60096. * @param deviceType Enum specifying device type
  60097. * @returns Array of DeviceSource objects
  60098. */
  60099. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  60100. /**
  60101. * Returns a read-only list of all available devices
  60102. * @returns Read-only array with active devices
  60103. */
  60104. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  60105. /**
  60106. * Dispose of DeviceInputSystem and other parts
  60107. */
  60108. dispose(): void;
  60109. /**
  60110. * Function to add 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 _addDevice;
  60115. /**
  60116. * Function to remove device name to device list
  60117. * @param deviceType Enum specifying device type
  60118. * @param deviceSlot "Slot" or index that device is referenced in
  60119. */
  60120. private _removeDevice;
  60121. /**
  60122. * Updates array storing first connected device of each type
  60123. * @param type Type of Device
  60124. */
  60125. private _updateFirstDevices;
  60126. }
  60127. }
  60128. declare module BABYLON {
  60129. /**
  60130. * Options to create the null engine
  60131. */
  60132. export class NullEngineOptions {
  60133. /**
  60134. * Render width (Default: 512)
  60135. */
  60136. renderWidth: number;
  60137. /**
  60138. * Render height (Default: 256)
  60139. */
  60140. renderHeight: number;
  60141. /**
  60142. * Texture size (Default: 512)
  60143. */
  60144. textureSize: number;
  60145. /**
  60146. * If delta time between frames should be constant
  60147. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  60148. */
  60149. deterministicLockstep: boolean;
  60150. /**
  60151. * Maximum about of steps between frames (Default: 4)
  60152. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  60153. */
  60154. lockstepMaxSteps: number;
  60155. /**
  60156. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  60157. */
  60158. useHighPrecisionMatrix?: boolean;
  60159. }
  60160. /**
  60161. * The null engine class provides support for headless version of babylon.js.
  60162. * This can be used in server side scenario or for testing purposes
  60163. */
  60164. export class NullEngine extends Engine {
  60165. private _options;
  60166. /**
  60167. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  60168. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  60169. * @returns true if engine is in deterministic lock step mode
  60170. */
  60171. isDeterministicLockStep(): boolean;
  60172. /**
  60173. * Gets the max steps when engine is running in deterministic lock step
  60174. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  60175. * @returns the max steps
  60176. */
  60177. getLockstepMaxSteps(): number;
  60178. /**
  60179. * Gets the current hardware scaling level.
  60180. * By default the hardware scaling level is computed from the window device ratio.
  60181. * 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.
  60182. * @returns a number indicating the current hardware scaling level
  60183. */
  60184. getHardwareScalingLevel(): number;
  60185. constructor(options?: NullEngineOptions);
  60186. /**
  60187. * Creates a vertex buffer
  60188. * @param vertices the data for the vertex buffer
  60189. * @returns the new WebGL static buffer
  60190. */
  60191. createVertexBuffer(vertices: FloatArray): DataBuffer;
  60192. /**
  60193. * Creates a new index buffer
  60194. * @param indices defines the content of the index buffer
  60195. * @param updatable defines if the index buffer must be updatable
  60196. * @returns a new webGL buffer
  60197. */
  60198. createIndexBuffer(indices: IndicesArray): DataBuffer;
  60199. /**
  60200. * Clear the current render buffer or the current render target (if any is set up)
  60201. * @param color defines the color to use
  60202. * @param backBuffer defines if the back buffer must be cleared
  60203. * @param depth defines if the depth buffer must be cleared
  60204. * @param stencil defines if the stencil buffer must be cleared
  60205. */
  60206. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  60207. /**
  60208. * Gets the current render width
  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 width
  60211. */
  60212. getRenderWidth(useScreen?: boolean): number;
  60213. /**
  60214. * Gets the current render height
  60215. * @param useScreen defines if screen size must be used (or the current render target if any)
  60216. * @returns a number defining the current render height
  60217. */
  60218. getRenderHeight(useScreen?: boolean): number;
  60219. /**
  60220. * Set the WebGL's viewport
  60221. * @param viewport defines the viewport element to be used
  60222. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  60223. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  60224. */
  60225. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  60226. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  60227. /**
  60228. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  60229. * @param pipelineContext defines the pipeline context to use
  60230. * @param uniformsNames defines the list of uniform names
  60231. * @returns an array of webGL uniform locations
  60232. */
  60233. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  60234. /**
  60235. * Gets the lsit of active attributes for a given webGL program
  60236. * @param pipelineContext defines the pipeline context to use
  60237. * @param attributesNames defines the list of attribute names to get
  60238. * @returns an array of indices indicating the offset of each attribute
  60239. */
  60240. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  60241. /**
  60242. * Binds an effect to the webGL context
  60243. * @param effect defines the effect to bind
  60244. */
  60245. bindSamplers(effect: Effect): void;
  60246. /**
  60247. * Activates an effect, making it the current one (ie. the one used for rendering)
  60248. * @param effect defines the effect to activate
  60249. */
  60250. enableEffect(effect: Effect): void;
  60251. /**
  60252. * Set various states to the webGL context
  60253. * @param culling defines backface culling state
  60254. * @param zOffset defines the value to apply to zOffset (0 by default)
  60255. * @param force defines if states must be applied even if cache is up to date
  60256. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  60257. */
  60258. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  60259. /**
  60260. * Set the value of an uniform to an array of int32
  60261. * @param uniform defines the webGL uniform location where to store the value
  60262. * @param array defines the array of int32 to store
  60263. * @returns true if value was set
  60264. */
  60265. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60266. /**
  60267. * Set the value of an uniform to an array of int32 (stored as vec2)
  60268. * @param uniform defines the webGL uniform location where to store the value
  60269. * @param array defines the array of int32 to store
  60270. * @returns true if value was set
  60271. */
  60272. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60273. /**
  60274. * Set the value of an uniform to an array of int32 (stored as vec3)
  60275. * @param uniform defines the webGL uniform location where to store the value
  60276. * @param array defines the array of int32 to store
  60277. * @returns true if value was set
  60278. */
  60279. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60280. /**
  60281. * Set the value of an uniform to an array of int32 (stored as vec4)
  60282. * @param uniform defines the webGL uniform location where to store the value
  60283. * @param array defines the array of int32 to store
  60284. * @returns true if value was set
  60285. */
  60286. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60287. /**
  60288. * Set the value of an uniform to an array of float32
  60289. * @param uniform defines the webGL uniform location where to store the value
  60290. * @param array defines the array of float32 to store
  60291. * @returns true if value was set
  60292. */
  60293. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60294. /**
  60295. * Set the value of an uniform to an array of float32 (stored as vec2)
  60296. * @param uniform defines the webGL uniform location where to store the value
  60297. * @param array defines the array of float32 to store
  60298. * @returns true if value was set
  60299. */
  60300. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60301. /**
  60302. * Set the value of an uniform to an array of float32 (stored as vec3)
  60303. * @param uniform defines the webGL uniform location where to store the value
  60304. * @param array defines the array of float32 to store
  60305. * @returns true if value was set
  60306. */
  60307. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60308. /**
  60309. * Set the value of an uniform to an array of float32 (stored as vec4)
  60310. * @param uniform defines the webGL uniform location where to store the value
  60311. * @param array defines the array of float32 to store
  60312. * @returns true if value was set
  60313. */
  60314. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60315. /**
  60316. * Set the value of an uniform to an array of number
  60317. * @param uniform defines the webGL uniform location where to store the value
  60318. * @param array defines the array of number to store
  60319. * @returns true if value was set
  60320. */
  60321. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  60322. /**
  60323. * Set the value of an uniform to an array of number (stored as vec2)
  60324. * @param uniform defines the webGL uniform location where to store the value
  60325. * @param array defines the array of number to store
  60326. * @returns true if value was set
  60327. */
  60328. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  60329. /**
  60330. * Set the value of an uniform to an array of number (stored as vec3)
  60331. * @param uniform defines the webGL uniform location where to store the value
  60332. * @param array defines the array of number to store
  60333. * @returns true if value was set
  60334. */
  60335. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  60336. /**
  60337. * Set the value of an uniform to an array of number (stored as vec4)
  60338. * @param uniform defines the webGL uniform location where to store the value
  60339. * @param array defines the array of number to store
  60340. * @returns true if value was set
  60341. */
  60342. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  60343. /**
  60344. * Set the value of an uniform to an array of float32 (stored as matrices)
  60345. * @param uniform defines the webGL uniform location where to store the value
  60346. * @param matrices defines the array of float32 to store
  60347. * @returns true if value was set
  60348. */
  60349. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  60350. /**
  60351. * Set the value of an uniform to a matrix (3x3)
  60352. * @param uniform defines the webGL uniform location where to store the value
  60353. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  60354. * @returns true if value was set
  60355. */
  60356. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  60357. /**
  60358. * Set the value of an uniform to a matrix (2x2)
  60359. * @param uniform defines the webGL uniform location where to store the value
  60360. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  60361. * @returns true if value was set
  60362. */
  60363. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  60364. /**
  60365. * Set the value of an uniform to a number (float)
  60366. * @param uniform defines the webGL uniform location where to store the value
  60367. * @param value defines the float number to store
  60368. * @returns true if value was set
  60369. */
  60370. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  60371. /**
  60372. * Set the value of an uniform to a vec2
  60373. * @param uniform defines the webGL uniform location where to store the value
  60374. * @param x defines the 1st component of the value
  60375. * @param y defines the 2nd component of the value
  60376. * @returns true if value was set
  60377. */
  60378. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  60379. /**
  60380. * Set the value of an uniform to a vec3
  60381. * @param uniform defines the webGL uniform location where to store the value
  60382. * @param x defines the 1st component of the value
  60383. * @param y defines the 2nd component of the value
  60384. * @param z defines the 3rd component of the value
  60385. * @returns true if value was set
  60386. */
  60387. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  60388. /**
  60389. * Set the value of an uniform to a boolean
  60390. * @param uniform defines the webGL uniform location where to store the value
  60391. * @param bool defines the boolean to store
  60392. * @returns true if value was set
  60393. */
  60394. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  60395. /**
  60396. * Set the value of an uniform to a vec4
  60397. * @param uniform defines the webGL uniform location where to store the value
  60398. * @param x defines the 1st component of the value
  60399. * @param y defines the 2nd component of the value
  60400. * @param z defines the 3rd component of the value
  60401. * @param w defines the 4th component of the value
  60402. * @returns true if value was set
  60403. */
  60404. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  60405. /**
  60406. * Sets the current alpha mode
  60407. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  60408. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  60409. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  60410. */
  60411. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  60412. /**
  60413. * Bind webGl buffers directly to the webGL context
  60414. * @param vertexBuffers defines the vertex buffer to bind
  60415. * @param indexBuffer defines the index buffer to bind
  60416. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  60417. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  60418. * @param effect defines the effect associated with the vertex buffer
  60419. */
  60420. bindBuffers(vertexBuffers: {
  60421. [key: string]: VertexBuffer;
  60422. }, indexBuffer: DataBuffer, effect: Effect): void;
  60423. /**
  60424. * Force the entire cache to be cleared
  60425. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  60426. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  60427. */
  60428. wipeCaches(bruteForce?: boolean): void;
  60429. /**
  60430. * Send a draw order
  60431. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  60432. * @param indexStart defines the starting index
  60433. * @param indexCount defines the number of index to draw
  60434. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  60435. */
  60436. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  60437. /**
  60438. * Draw a list of indexed primitives
  60439. * @param fillMode defines the primitive to use
  60440. * @param indexStart defines the starting index
  60441. * @param indexCount defines the number of index to draw
  60442. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  60443. */
  60444. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  60445. /**
  60446. * Draw a list of unindexed primitives
  60447. * @param fillMode defines the primitive to use
  60448. * @param verticesStart defines the index of first vertex to draw
  60449. * @param verticesCount defines the count of vertices to draw
  60450. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  60451. */
  60452. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  60453. /** @hidden */
  60454. protected _createTexture(): WebGLTexture;
  60455. /** @hidden */
  60456. _releaseTexture(texture: InternalTexture): void;
  60457. /**
  60458. * Usually called from Texture.ts.
  60459. * Passed information to create a WebGLTexture
  60460. * @param urlArg defines a value which contains one of the following:
  60461. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  60462. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  60463. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  60464. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  60465. * @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)
  60466. * @param scene needed for loading to the correct scene
  60467. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  60468. * @param onLoad optional callback to be called upon successful completion
  60469. * @param onError optional callback to be called upon failure
  60470. * @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
  60471. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  60472. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  60473. * @param forcedExtension defines the extension to use to pick the right loader
  60474. * @param mimeType defines an optional mime type
  60475. * @returns a InternalTexture for assignment back into BABYLON.Texture
  60476. */
  60477. 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;
  60478. /**
  60479. * Creates a new render target texture
  60480. * @param size defines the size of the texture
  60481. * @param options defines the options used to create the texture
  60482. * @returns a new render target texture stored in an InternalTexture
  60483. */
  60484. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  60485. /**
  60486. * Update the sampling mode of a given texture
  60487. * @param samplingMode defines the required sampling mode
  60488. * @param texture defines the texture to update
  60489. */
  60490. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  60491. /**
  60492. * Binds the frame buffer to the specified texture.
  60493. * @param texture The texture to render to or null for the default canvas
  60494. * @param faceIndex The face of the texture to render to in case of cube texture
  60495. * @param requiredWidth The width of the target to render to
  60496. * @param requiredHeight The height of the target to render to
  60497. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  60498. * @param lodLevel defines le lod level to bind to the frame buffer
  60499. */
  60500. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  60501. /**
  60502. * Unbind the current render target texture from the webGL context
  60503. * @param texture defines the render target texture to unbind
  60504. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  60505. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  60506. */
  60507. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  60508. /**
  60509. * Creates a dynamic vertex buffer
  60510. * @param vertices the data for the dynamic vertex buffer
  60511. * @returns the new WebGL dynamic buffer
  60512. */
  60513. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  60514. /**
  60515. * Update the content of a dynamic texture
  60516. * @param texture defines the texture to update
  60517. * @param canvas defines the canvas containing the source
  60518. * @param invertY defines if data must be stored with Y axis inverted
  60519. * @param premulAlpha defines if alpha is stored as premultiplied
  60520. * @param format defines the format of the data
  60521. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  60522. */
  60523. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  60524. /**
  60525. * Gets a boolean indicating if all created effects are ready
  60526. * @returns true if all effects are ready
  60527. */
  60528. areAllEffectsReady(): boolean;
  60529. /**
  60530. * @hidden
  60531. * Get the current error code of the webGL context
  60532. * @returns the error code
  60533. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  60534. */
  60535. getError(): number;
  60536. /** @hidden */
  60537. _getUnpackAlignement(): number;
  60538. /** @hidden */
  60539. _unpackFlipY(value: boolean): void;
  60540. /**
  60541. * Update a dynamic index buffer
  60542. * @param indexBuffer defines the target index buffer
  60543. * @param indices defines the data to update
  60544. * @param offset defines the offset in the target index buffer where update should start
  60545. */
  60546. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  60547. /**
  60548. * Updates a dynamic vertex buffer.
  60549. * @param vertexBuffer the vertex buffer to update
  60550. * @param vertices the data used to update the vertex buffer
  60551. * @param byteOffset the byte offset of the data (optional)
  60552. * @param byteLength the byte length of the data (optional)
  60553. */
  60554. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  60555. /** @hidden */
  60556. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  60557. /** @hidden */
  60558. _bindTexture(channel: number, texture: InternalTexture): void;
  60559. protected _deleteBuffer(buffer: WebGLBuffer): void;
  60560. /**
  60561. * 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
  60562. */
  60563. releaseEffects(): void;
  60564. displayLoadingUI(): void;
  60565. hideLoadingUI(): void;
  60566. /** @hidden */
  60567. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60568. /** @hidden */
  60569. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60570. /** @hidden */
  60571. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60572. /** @hidden */
  60573. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  60574. }
  60575. }
  60576. declare module BABYLON {
  60577. /** @hidden */
  60578. export class _OcclusionDataStorage {
  60579. /** @hidden */
  60580. occlusionInternalRetryCounter: number;
  60581. /** @hidden */
  60582. isOcclusionQueryInProgress: boolean;
  60583. /** @hidden */
  60584. isOccluded: boolean;
  60585. /** @hidden */
  60586. occlusionRetryCount: number;
  60587. /** @hidden */
  60588. occlusionType: number;
  60589. /** @hidden */
  60590. occlusionQueryAlgorithmType: number;
  60591. }
  60592. interface Engine {
  60593. /**
  60594. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  60595. * @return the new query
  60596. */
  60597. createQuery(): WebGLQuery;
  60598. /**
  60599. * Delete and release a webGL query
  60600. * @param query defines the query to delete
  60601. * @return the current engine
  60602. */
  60603. deleteQuery(query: WebGLQuery): Engine;
  60604. /**
  60605. * Check if a given query has resolved and got its value
  60606. * @param query defines the query to check
  60607. * @returns true if the query got its value
  60608. */
  60609. isQueryResultAvailable(query: WebGLQuery): boolean;
  60610. /**
  60611. * Gets the value of a given query
  60612. * @param query defines the query to check
  60613. * @returns the value of the query
  60614. */
  60615. getQueryResult(query: WebGLQuery): number;
  60616. /**
  60617. * Initiates an occlusion query
  60618. * @param algorithmType defines the algorithm to use
  60619. * @param query defines the query to use
  60620. * @returns the current engine
  60621. * @see https://doc.babylonjs.com/features/occlusionquery
  60622. */
  60623. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  60624. /**
  60625. * Ends an occlusion query
  60626. * @see https://doc.babylonjs.com/features/occlusionquery
  60627. * @param algorithmType defines the algorithm to use
  60628. * @returns the current engine
  60629. */
  60630. endOcclusionQuery(algorithmType: number): Engine;
  60631. /**
  60632. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  60633. * Please note that only one query can be issued at a time
  60634. * @returns a time token used to track the time span
  60635. */
  60636. startTimeQuery(): Nullable<_TimeToken>;
  60637. /**
  60638. * Ends a time query
  60639. * @param token defines the token used to measure the time span
  60640. * @returns the time spent (in ns)
  60641. */
  60642. endTimeQuery(token: _TimeToken): int;
  60643. /** @hidden */
  60644. _currentNonTimestampToken: Nullable<_TimeToken>;
  60645. /** @hidden */
  60646. _createTimeQuery(): WebGLQuery;
  60647. /** @hidden */
  60648. _deleteTimeQuery(query: WebGLQuery): void;
  60649. /** @hidden */
  60650. _getGlAlgorithmType(algorithmType: number): number;
  60651. /** @hidden */
  60652. _getTimeQueryResult(query: WebGLQuery): any;
  60653. /** @hidden */
  60654. _getTimeQueryAvailability(query: WebGLQuery): any;
  60655. }
  60656. interface AbstractMesh {
  60657. /**
  60658. * Backing filed
  60659. * @hidden
  60660. */
  60661. __occlusionDataStorage: _OcclusionDataStorage;
  60662. /**
  60663. * Access property
  60664. * @hidden
  60665. */
  60666. _occlusionDataStorage: _OcclusionDataStorage;
  60667. /**
  60668. * 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.
  60669. * The default value is -1 which means don't break the query and wait till the result
  60670. * @see https://doc.babylonjs.com/features/occlusionquery
  60671. */
  60672. occlusionRetryCount: number;
  60673. /**
  60674. * 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:
  60675. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query within the Mesh.
  60676. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  60677. * * 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.
  60678. * @see https://doc.babylonjs.com/features/occlusionquery
  60679. */
  60680. occlusionType: number;
  60681. /**
  60682. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  60683. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  60684. * * 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.
  60685. * @see https://doc.babylonjs.com/features/occlusionquery
  60686. */
  60687. occlusionQueryAlgorithmType: number;
  60688. /**
  60689. * 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
  60690. * @see https://doc.babylonjs.com/features/occlusionquery
  60691. */
  60692. isOccluded: boolean;
  60693. /**
  60694. * Flag to check the progress status of the query
  60695. * @see https://doc.babylonjs.com/features/occlusionquery
  60696. */
  60697. isOcclusionQueryInProgress: boolean;
  60698. }
  60699. }
  60700. declare module BABYLON {
  60701. /** @hidden */
  60702. export var _forceTransformFeedbackToBundle: boolean;
  60703. interface Engine {
  60704. /**
  60705. * Creates a webGL transform feedback object
  60706. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  60707. * @returns the webGL transform feedback object
  60708. */
  60709. createTransformFeedback(): WebGLTransformFeedback;
  60710. /**
  60711. * Delete a webGL transform feedback object
  60712. * @param value defines the webGL transform feedback object to delete
  60713. */
  60714. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  60715. /**
  60716. * Bind a webGL transform feedback object to the webgl context
  60717. * @param value defines the webGL transform feedback object to bind
  60718. */
  60719. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  60720. /**
  60721. * Begins a transform feedback operation
  60722. * @param usePoints defines if points or triangles must be used
  60723. */
  60724. beginTransformFeedback(usePoints: boolean): void;
  60725. /**
  60726. * Ends a transform feedback operation
  60727. */
  60728. endTransformFeedback(): void;
  60729. /**
  60730. * Specify the varyings to use with transform feedback
  60731. * @param program defines the associated webGL program
  60732. * @param value defines the list of strings representing the varying names
  60733. */
  60734. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  60735. /**
  60736. * Bind a webGL buffer for a transform feedback operation
  60737. * @param value defines the webGL buffer to bind
  60738. */
  60739. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  60740. }
  60741. }
  60742. declare module BABYLON {
  60743. /**
  60744. * Class used to define an additional view for the engine
  60745. * @see https://doc.babylonjs.com/how_to/multi_canvases
  60746. */
  60747. export class EngineView {
  60748. /** Defines the canvas where to render the view */
  60749. target: HTMLCanvasElement;
  60750. /** Defines an optional camera used to render the view (will use active camera else) */
  60751. camera?: Camera;
  60752. }
  60753. interface Engine {
  60754. /**
  60755. * Gets or sets the HTML element to use for attaching events
  60756. */
  60757. inputElement: Nullable<HTMLElement>;
  60758. /**
  60759. * Gets the current engine view
  60760. * @see https://doc.babylonjs.com/how_to/multi_canvases
  60761. */
  60762. activeView: Nullable<EngineView>;
  60763. /** Gets or sets the list of views */
  60764. views: EngineView[];
  60765. /**
  60766. * Register a new child canvas
  60767. * @param canvas defines the canvas to register
  60768. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  60769. * @returns the associated view
  60770. */
  60771. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  60772. /**
  60773. * Remove a registered child canvas
  60774. * @param canvas defines the canvas to remove
  60775. * @returns the current engine
  60776. */
  60777. unRegisterView(canvas: HTMLCanvasElement): Engine;
  60778. }
  60779. }
  60780. declare module BABYLON {
  60781. interface Engine {
  60782. /** @hidden */
  60783. _excludedCompressedTextures: string[];
  60784. /** @hidden */
  60785. _textureFormatInUse: string;
  60786. /**
  60787. * Gets the list of texture formats supported
  60788. */
  60789. readonly texturesSupported: Array<string>;
  60790. /**
  60791. * Gets the texture format in use
  60792. */
  60793. readonly textureFormatInUse: Nullable<string>;
  60794. /**
  60795. * Set the compressed texture extensions or file names to skip.
  60796. *
  60797. * @param skippedFiles defines the list of those texture files you want to skip
  60798. * Example: [".dds", ".env", "myfile.png"]
  60799. */
  60800. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  60801. /**
  60802. * Set the compressed texture format to use, based on the formats you have, and the formats
  60803. * supported by the hardware / browser.
  60804. *
  60805. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  60806. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  60807. * to API arguments needed to compressed textures. This puts the burden on the container
  60808. * generator to house the arcane code for determining these for current & future formats.
  60809. *
  60810. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  60811. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  60812. *
  60813. * Note: The result of this call is not taken into account when a texture is base64.
  60814. *
  60815. * @param formatsAvailable defines the list of those format families you have created
  60816. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  60817. *
  60818. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  60819. * @returns The extension selected.
  60820. */
  60821. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  60822. }
  60823. }
  60824. declare module BABYLON {
  60825. /** @hidden */
  60826. export var rgbdEncodePixelShader: {
  60827. name: string;
  60828. shader: string;
  60829. };
  60830. }
  60831. declare module BABYLON {
  60832. /**
  60833. * Raw texture data and descriptor sufficient for WebGL texture upload
  60834. */
  60835. export interface EnvironmentTextureInfo {
  60836. /**
  60837. * Version of the environment map
  60838. */
  60839. version: number;
  60840. /**
  60841. * Width of image
  60842. */
  60843. width: number;
  60844. /**
  60845. * Irradiance information stored in the file.
  60846. */
  60847. irradiance: any;
  60848. /**
  60849. * Specular information stored in the file.
  60850. */
  60851. specular: any;
  60852. }
  60853. /**
  60854. * Defines One Image in the file. It requires only the position in the file
  60855. * as well as the length.
  60856. */
  60857. interface BufferImageData {
  60858. /**
  60859. * Length of the image data.
  60860. */
  60861. length: number;
  60862. /**
  60863. * Position of the data from the null terminator delimiting the end of the JSON.
  60864. */
  60865. position: number;
  60866. }
  60867. /**
  60868. * Defines the specular data enclosed in the file.
  60869. * This corresponds to the version 1 of the data.
  60870. */
  60871. export interface EnvironmentTextureSpecularInfoV1 {
  60872. /**
  60873. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  60874. */
  60875. specularDataPosition?: number;
  60876. /**
  60877. * This contains all the images data needed to reconstruct the cubemap.
  60878. */
  60879. mipmaps: Array<BufferImageData>;
  60880. /**
  60881. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  60882. */
  60883. lodGenerationScale: number;
  60884. }
  60885. /**
  60886. * Sets of helpers addressing the serialization and deserialization of environment texture
  60887. * stored in a BabylonJS env file.
  60888. * Those files are usually stored as .env files.
  60889. */
  60890. export class EnvironmentTextureTools {
  60891. /**
  60892. * Magic number identifying the env file.
  60893. */
  60894. private static _MagicBytes;
  60895. /**
  60896. * Gets the environment info from an env file.
  60897. * @param data The array buffer containing the .env bytes.
  60898. * @returns the environment file info (the json header) if successfully parsed.
  60899. */
  60900. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  60901. /**
  60902. * Creates an environment texture from a loaded cube texture.
  60903. * @param texture defines the cube texture to convert in env file
  60904. * @return a promise containing the environment data if successful.
  60905. */
  60906. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  60907. /**
  60908. * Creates a JSON representation of the spherical data.
  60909. * @param texture defines the texture containing the polynomials
  60910. * @return the JSON representation of the spherical info
  60911. */
  60912. private static _CreateEnvTextureIrradiance;
  60913. /**
  60914. * Creates the ArrayBufferViews used for initializing environment texture image data.
  60915. * @param data the image data
  60916. * @param info parameters that determine what views will be created for accessing the underlying buffer
  60917. * @return the views described by info providing access to the underlying buffer
  60918. */
  60919. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  60920. /**
  60921. * Uploads the texture info contained in the env file to the GPU.
  60922. * @param texture defines the internal texture to upload to
  60923. * @param data defines the data to load
  60924. * @param info defines the texture info retrieved through the GetEnvInfo method
  60925. * @returns a promise
  60926. */
  60927. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  60928. private static _OnImageReadyAsync;
  60929. /**
  60930. * Uploads the levels of image data to the GPU.
  60931. * @param texture defines the internal texture to upload to
  60932. * @param imageData defines the array buffer views of image data [mipmap][face]
  60933. * @returns a promise
  60934. */
  60935. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  60936. /**
  60937. * Uploads spherical polynomials information to the texture.
  60938. * @param texture defines the texture we are trying to upload the information to
  60939. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  60940. */
  60941. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  60942. /** @hidden */
  60943. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  60944. }
  60945. }
  60946. declare module BABYLON {
  60947. /**
  60948. * Container for accessors for natively-stored mesh data buffers.
  60949. */
  60950. class NativeDataBuffer extends DataBuffer {
  60951. /**
  60952. * Accessor value used to identify/retrieve a natively-stored index buffer.
  60953. */
  60954. nativeIndexBuffer?: any;
  60955. /**
  60956. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  60957. */
  60958. nativeVertexBuffer?: any;
  60959. }
  60960. /** @hidden */
  60961. class NativeTexture extends InternalTexture {
  60962. getInternalTexture(): InternalTexture;
  60963. getViewCount(): number;
  60964. }
  60965. /** @hidden */
  60966. export class NativeEngine extends Engine {
  60967. private readonly _native;
  60968. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  60969. private readonly INVALID_HANDLE;
  60970. private _boundBuffersVertexArray;
  60971. private _currentDepthTest;
  60972. getHardwareScalingLevel(): number;
  60973. setHardwareScalingLevel(level: number): void;
  60974. constructor();
  60975. dispose(): void;
  60976. /**
  60977. * Can be used to override the current requestAnimationFrame requester.
  60978. * @hidden
  60979. */
  60980. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  60981. /**
  60982. * Override default engine behavior.
  60983. * @param color
  60984. * @param backBuffer
  60985. * @param depth
  60986. * @param stencil
  60987. */
  60988. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  60989. /**
  60990. * Gets host document
  60991. * @returns the host document object
  60992. */
  60993. getHostDocument(): Nullable<Document>;
  60994. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  60995. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  60996. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  60997. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  60998. [key: string]: VertexBuffer;
  60999. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  61000. bindBuffers(vertexBuffers: {
  61001. [key: string]: VertexBuffer;
  61002. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  61003. recordVertexArrayObject(vertexBuffers: {
  61004. [key: string]: VertexBuffer;
  61005. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  61006. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  61007. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  61008. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  61009. /**
  61010. * Draw a list of indexed primitives
  61011. * @param fillMode defines the primitive to use
  61012. * @param indexStart defines the starting index
  61013. * @param indexCount defines the number of index to draw
  61014. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  61015. */
  61016. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  61017. /**
  61018. * Draw a list of unindexed primitives
  61019. * @param fillMode defines the primitive to use
  61020. * @param verticesStart defines the index of first vertex to draw
  61021. * @param verticesCount defines the count of vertices to draw
  61022. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  61023. */
  61024. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  61025. createPipelineContext(): IPipelineContext;
  61026. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  61027. /** @hidden */
  61028. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  61029. /** @hidden */
  61030. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  61031. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  61032. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  61033. protected _setProgram(program: WebGLProgram): void;
  61034. _releaseEffect(effect: Effect): void;
  61035. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  61036. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  61037. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  61038. bindSamplers(effect: Effect): void;
  61039. setMatrix(uniform: WebGLUniformLocation, matrix: IMatrixLike): void;
  61040. getRenderWidth(useScreen?: boolean): number;
  61041. getRenderHeight(useScreen?: boolean): number;
  61042. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  61043. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  61044. /**
  61045. * Gets the client rect of native canvas. Needed for InputManager.
  61046. * @returns a client rectangle
  61047. */
  61048. getInputElementClientRect(): Nullable<ClientRect>;
  61049. /**
  61050. * Set the z offset to apply to current rendering
  61051. * @param value defines the offset to apply
  61052. */
  61053. setZOffset(value: number): void;
  61054. /**
  61055. * Gets the current value of the zOffset
  61056. * @returns the current zOffset state
  61057. */
  61058. getZOffset(): number;
  61059. /**
  61060. * Enable or disable depth buffering
  61061. * @param enable defines the state to set
  61062. */
  61063. setDepthBuffer(enable: boolean): void;
  61064. /**
  61065. * Gets a boolean indicating if depth writing is enabled
  61066. * @returns the current depth writing state
  61067. */
  61068. getDepthWrite(): boolean;
  61069. setDepthFunctionToGreater(): void;
  61070. setDepthFunctionToGreaterOrEqual(): void;
  61071. setDepthFunctionToLess(): void;
  61072. setDepthFunctionToLessOrEqual(): void;
  61073. /**
  61074. * Enable or disable depth writing
  61075. * @param enable defines the state to set
  61076. */
  61077. setDepthWrite(enable: boolean): void;
  61078. /**
  61079. * Enable or disable color writing
  61080. * @param enable defines the state to set
  61081. */
  61082. setColorWrite(enable: boolean): void;
  61083. /**
  61084. * Gets a boolean indicating if color writing is enabled
  61085. * @returns the current color writing state
  61086. */
  61087. getColorWrite(): boolean;
  61088. /**
  61089. * Sets alpha constants used by some alpha blending modes
  61090. * @param r defines the red component
  61091. * @param g defines the green component
  61092. * @param b defines the blue component
  61093. * @param a defines the alpha component
  61094. */
  61095. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  61096. /**
  61097. * Sets the current alpha mode
  61098. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  61099. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  61100. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  61101. */
  61102. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  61103. /**
  61104. * Gets the current alpha mode
  61105. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  61106. * @returns the current alpha mode
  61107. */
  61108. getAlphaMode(): number;
  61109. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  61110. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  61111. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  61112. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  61113. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  61114. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  61115. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  61116. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  61117. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  61118. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  61119. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  61120. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  61121. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  61122. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  61123. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  61124. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  61125. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  61126. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  61127. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  61128. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  61129. setColor3(uniform: WebGLUniformLocation, color3: IColor3Like): boolean;
  61130. setColor4(uniform: WebGLUniformLocation, color3: IColor3Like, alpha: number): boolean;
  61131. wipeCaches(bruteForce?: boolean): void;
  61132. protected _createTexture(): WebGLTexture;
  61133. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  61134. /**
  61135. * Update the content of a dynamic texture
  61136. * @param texture defines the texture to update
  61137. * @param canvas defines the canvas containing the source
  61138. * @param invertY defines if data must be stored with Y axis inverted
  61139. * @param premulAlpha defines if alpha is stored as premultiplied
  61140. * @param format defines the format of the data
  61141. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  61142. */
  61143. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  61144. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  61145. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  61146. /**
  61147. * Usually called from Texture.ts.
  61148. * Passed information to create a WebGLTexture
  61149. * @param url defines a value which contains one of the following:
  61150. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  61151. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  61152. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  61153. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  61154. * @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)
  61155. * @param scene needed for loading to the correct scene
  61156. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  61157. * @param onLoad optional callback to be called upon successful completion
  61158. * @param onError optional callback to be called upon failure
  61159. * @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
  61160. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  61161. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  61162. * @param forcedExtension defines the extension to use to pick the right loader
  61163. * @param mimeType defines an optional mime type
  61164. * @param loaderOptions options to be passed to the loader
  61165. * @returns a InternalTexture for assignment back into BABYLON.Texture
  61166. */
  61167. 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;
  61168. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  61169. _releaseFramebufferObjects(texture: InternalTexture): void;
  61170. /**
  61171. * Creates a cube texture
  61172. * @param rootUrl defines the url where the files to load is located
  61173. * @param scene defines the current scene
  61174. * @param files defines the list of files to load (1 per face)
  61175. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  61176. * @param onLoad defines an optional callback raised when the texture is loaded
  61177. * @param onError defines an optional callback raised if there is an issue to load the texture
  61178. * @param format defines the format of the data
  61179. * @param forcedExtension defines the extension to use to pick the right loader
  61180. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  61181. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  61182. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  61183. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  61184. * @returns the cube texture as an InternalTexture
  61185. */
  61186. 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;
  61187. createRenderTargetTexture(size: number | {
  61188. width: number;
  61189. height: number;
  61190. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  61191. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  61192. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  61193. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  61194. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  61195. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  61196. /**
  61197. * Updates a dynamic vertex buffer.
  61198. * @param vertexBuffer the vertex buffer to update
  61199. * @param data the data used to update the vertex buffer
  61200. * @param byteOffset the byte offset of the data (optional)
  61201. * @param byteLength the byte length of the data (optional)
  61202. */
  61203. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  61204. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  61205. private _updateAnisotropicLevel;
  61206. private _getAddressMode;
  61207. /** @hidden */
  61208. _bindTexture(channel: number, texture: InternalTexture): void;
  61209. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  61210. releaseEffects(): void;
  61211. /** @hidden */
  61212. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  61213. /** @hidden */
  61214. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  61215. /** @hidden */
  61216. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  61217. /** @hidden */
  61218. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  61219. private _getNativeSamplingMode;
  61220. private _getNativeTextureFormat;
  61221. private _getNativeAlphaMode;
  61222. private _getNativeAttribType;
  61223. }
  61224. }
  61225. declare module BABYLON {
  61226. /**
  61227. * Helper class to create the best engine depending on the current hardware
  61228. */
  61229. export class EngineFactory {
  61230. /**
  61231. * Creates an engine based on the capabilities of the underlying hardware
  61232. * @param canvas Defines the canvas to use to display the result
  61233. * @param options Defines the options passed to the engine to create the context dependencies
  61234. * @returns a promise that resolves with the created engine
  61235. */
  61236. static CreateAsync(canvas: HTMLCanvasElement, options: any): Promise<ThinEngine>;
  61237. }
  61238. }
  61239. declare module BABYLON {
  61240. /**
  61241. * Gather the list of clipboard event types as constants.
  61242. */
  61243. export class ClipboardEventTypes {
  61244. /**
  61245. * The clipboard event is fired when a copy command is active (pressed).
  61246. */
  61247. static readonly COPY: number;
  61248. /**
  61249. * The clipboard event is fired when a cut command is active (pressed).
  61250. */
  61251. static readonly CUT: number;
  61252. /**
  61253. * The clipboard event is fired when a paste command is active (pressed).
  61254. */
  61255. static readonly PASTE: number;
  61256. }
  61257. /**
  61258. * This class is used to store clipboard related info for the onClipboardObservable event.
  61259. */
  61260. export class ClipboardInfo {
  61261. /**
  61262. * Defines the type of event (BABYLON.ClipboardEventTypes)
  61263. */
  61264. type: number;
  61265. /**
  61266. * Defines the related dom event
  61267. */
  61268. event: ClipboardEvent;
  61269. /**
  61270. *Creates an instance of ClipboardInfo.
  61271. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  61272. * @param event Defines the related dom event
  61273. */
  61274. constructor(
  61275. /**
  61276. * Defines the type of event (BABYLON.ClipboardEventTypes)
  61277. */
  61278. type: number,
  61279. /**
  61280. * Defines the related dom event
  61281. */
  61282. event: ClipboardEvent);
  61283. /**
  61284. * Get the clipboard event's type from the keycode.
  61285. * @param keyCode Defines the keyCode for the current keyboard event.
  61286. * @return {number}
  61287. */
  61288. static GetTypeFromCharacter(keyCode: number): number;
  61289. }
  61290. }
  61291. declare module BABYLON {
  61292. /**
  61293. * Google Daydream controller
  61294. */
  61295. export class DaydreamController extends WebVRController {
  61296. /**
  61297. * Base Url for the controller model.
  61298. */
  61299. static MODEL_BASE_URL: string;
  61300. /**
  61301. * File name for the controller model.
  61302. */
  61303. static MODEL_FILENAME: string;
  61304. /**
  61305. * Gamepad Id prefix used to identify Daydream Controller.
  61306. */
  61307. static readonly GAMEPAD_ID_PREFIX: string;
  61308. /**
  61309. * Creates a new DaydreamController from a gamepad
  61310. * @param vrGamepad the gamepad that the controller should be created from
  61311. */
  61312. constructor(vrGamepad: any);
  61313. /**
  61314. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  61315. * @param scene scene in which to add meshes
  61316. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  61317. */
  61318. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  61319. /**
  61320. * Called once for each button that changed state since the last frame
  61321. * @param buttonIdx Which button index changed
  61322. * @param state New state of the button
  61323. * @param changes Which properties on the state changed since last frame
  61324. */
  61325. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  61326. }
  61327. }
  61328. declare module BABYLON {
  61329. /**
  61330. * Gear VR Controller
  61331. */
  61332. export class GearVRController extends WebVRController {
  61333. /**
  61334. * Base Url for the controller model.
  61335. */
  61336. static MODEL_BASE_URL: string;
  61337. /**
  61338. * File name for the controller model.
  61339. */
  61340. static MODEL_FILENAME: string;
  61341. /**
  61342. * Gamepad Id prefix used to identify this controller.
  61343. */
  61344. static readonly GAMEPAD_ID_PREFIX: string;
  61345. private readonly _buttonIndexToObservableNameMap;
  61346. /**
  61347. * Creates a new GearVRController from a gamepad
  61348. * @param vrGamepad the gamepad that the controller should be created from
  61349. */
  61350. constructor(vrGamepad: any);
  61351. /**
  61352. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  61353. * @param scene scene in which to add meshes
  61354. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  61355. */
  61356. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  61357. /**
  61358. * Called once for each button that changed state since the last frame
  61359. * @param buttonIdx Which button index changed
  61360. * @param state New state of the button
  61361. * @param changes Which properties on the state changed since last frame
  61362. */
  61363. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  61364. }
  61365. }
  61366. declare module BABYLON {
  61367. /**
  61368. * Generic Controller
  61369. */
  61370. export class GenericController extends WebVRController {
  61371. /**
  61372. * Base Url for the controller model.
  61373. */
  61374. static readonly MODEL_BASE_URL: string;
  61375. /**
  61376. * File name for the controller model.
  61377. */
  61378. static readonly MODEL_FILENAME: string;
  61379. /**
  61380. * Creates a new GenericController from a gamepad
  61381. * @param vrGamepad the gamepad that the controller should be created from
  61382. */
  61383. constructor(vrGamepad: any);
  61384. /**
  61385. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  61386. * @param scene scene in which to add meshes
  61387. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  61388. */
  61389. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  61390. /**
  61391. * Called once for each button that changed state since the last frame
  61392. * @param buttonIdx Which button index changed
  61393. * @param state New state of the button
  61394. * @param changes Which properties on the state changed since last frame
  61395. */
  61396. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  61397. }
  61398. }
  61399. declare module BABYLON {
  61400. /**
  61401. * Oculus Touch Controller
  61402. */
  61403. export class OculusTouchController extends WebVRController {
  61404. /**
  61405. * Base Url for the controller model.
  61406. */
  61407. static MODEL_BASE_URL: string;
  61408. /**
  61409. * File name for the left controller model.
  61410. */
  61411. static MODEL_LEFT_FILENAME: string;
  61412. /**
  61413. * File name for the right controller model.
  61414. */
  61415. static MODEL_RIGHT_FILENAME: string;
  61416. /**
  61417. * Base Url for the Quest controller model.
  61418. */
  61419. static QUEST_MODEL_BASE_URL: string;
  61420. /**
  61421. * @hidden
  61422. * If the controllers are running on a device that needs the updated Quest controller models
  61423. */
  61424. static _IsQuest: boolean;
  61425. /**
  61426. * Fired when the secondary trigger on this controller is modified
  61427. */
  61428. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  61429. /**
  61430. * Fired when the thumb rest on this controller is modified
  61431. */
  61432. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  61433. /**
  61434. * Creates a new OculusTouchController from a gamepad
  61435. * @param vrGamepad the gamepad that the controller should be created from
  61436. */
  61437. constructor(vrGamepad: any);
  61438. /**
  61439. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  61440. * @param scene scene in which to add meshes
  61441. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  61442. */
  61443. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  61444. /**
  61445. * Fired when the A button on this controller is modified
  61446. */
  61447. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61448. /**
  61449. * Fired when the B button on this controller is modified
  61450. */
  61451. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61452. /**
  61453. * Fired when the X button on this controller is modified
  61454. */
  61455. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61456. /**
  61457. * Fired when the Y button on this controller is modified
  61458. */
  61459. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61460. /**
  61461. * Called once for each button that changed state since the last frame
  61462. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  61463. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  61464. * 2) secondary trigger (same)
  61465. * 3) A (right) X (left), touch, pressed = value
  61466. * 4) B / Y
  61467. * 5) thumb rest
  61468. * @param buttonIdx Which button index changed
  61469. * @param state New state of the button
  61470. * @param changes Which properties on the state changed since last frame
  61471. */
  61472. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  61473. }
  61474. }
  61475. declare module BABYLON {
  61476. /**
  61477. * Vive Controller
  61478. */
  61479. export class ViveController extends WebVRController {
  61480. /**
  61481. * Base Url for the controller model.
  61482. */
  61483. static MODEL_BASE_URL: string;
  61484. /**
  61485. * File name for the controller model.
  61486. */
  61487. static MODEL_FILENAME: string;
  61488. /**
  61489. * Creates a new ViveController from a gamepad
  61490. * @param vrGamepad the gamepad that the controller should be created from
  61491. */
  61492. constructor(vrGamepad: any);
  61493. /**
  61494. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  61495. * @param scene scene in which to add meshes
  61496. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  61497. */
  61498. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  61499. /**
  61500. * Fired when the left button on this controller is modified
  61501. */
  61502. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61503. /**
  61504. * Fired when the right button on this controller is modified
  61505. */
  61506. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61507. /**
  61508. * Fired when the menu button on this controller is modified
  61509. */
  61510. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61511. /**
  61512. * Called once for each button that changed state since the last frame
  61513. * Vive mapping:
  61514. * 0: touchpad
  61515. * 1: trigger
  61516. * 2: left AND right buttons
  61517. * 3: menu button
  61518. * @param buttonIdx Which button index changed
  61519. * @param state New state of the button
  61520. * @param changes Which properties on the state changed since last frame
  61521. */
  61522. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  61523. }
  61524. }
  61525. declare module BABYLON {
  61526. /**
  61527. * Defines the WindowsMotionController object that the state of the windows motion controller
  61528. */
  61529. export class WindowsMotionController extends WebVRController {
  61530. /**
  61531. * The base url used to load the left and right controller models
  61532. */
  61533. static MODEL_BASE_URL: string;
  61534. /**
  61535. * The name of the left controller model file
  61536. */
  61537. static MODEL_LEFT_FILENAME: string;
  61538. /**
  61539. * The name of the right controller model file
  61540. */
  61541. static MODEL_RIGHT_FILENAME: string;
  61542. /**
  61543. * The controller name prefix for this controller type
  61544. */
  61545. static readonly GAMEPAD_ID_PREFIX: string;
  61546. /**
  61547. * The controller id pattern for this controller type
  61548. */
  61549. private static readonly GAMEPAD_ID_PATTERN;
  61550. private _loadedMeshInfo;
  61551. protected readonly _mapping: {
  61552. buttons: string[];
  61553. buttonMeshNames: {
  61554. trigger: string;
  61555. menu: string;
  61556. grip: string;
  61557. thumbstick: string;
  61558. trackpad: string;
  61559. };
  61560. buttonObservableNames: {
  61561. trigger: string;
  61562. menu: string;
  61563. grip: string;
  61564. thumbstick: string;
  61565. trackpad: string;
  61566. };
  61567. axisMeshNames: string[];
  61568. pointingPoseMeshName: string;
  61569. };
  61570. /**
  61571. * Fired when the trackpad on this controller is clicked
  61572. */
  61573. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  61574. /**
  61575. * Fired when the trackpad on this controller is modified
  61576. */
  61577. onTrackpadValuesChangedObservable: Observable<StickValues>;
  61578. /**
  61579. * The current x and y values of this controller's trackpad
  61580. */
  61581. trackpad: StickValues;
  61582. /**
  61583. * Creates a new WindowsMotionController from a gamepad
  61584. * @param vrGamepad the gamepad that the controller should be created from
  61585. */
  61586. constructor(vrGamepad: any);
  61587. /**
  61588. * Fired when the trigger on this controller is modified
  61589. */
  61590. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61591. /**
  61592. * Fired when the menu button on this controller is modified
  61593. */
  61594. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61595. /**
  61596. * Fired when the grip button on this controller is modified
  61597. */
  61598. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61599. /**
  61600. * Fired when the thumbstick button on this controller is modified
  61601. */
  61602. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61603. /**
  61604. * Fired when the touchpad button on this controller is modified
  61605. */
  61606. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61607. /**
  61608. * Fired when the touchpad values on this controller are modified
  61609. */
  61610. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  61611. protected _updateTrackpad(): void;
  61612. /**
  61613. * Called once per frame by the engine.
  61614. */
  61615. update(): void;
  61616. /**
  61617. * Called once for each button that changed state since the last frame
  61618. * @param buttonIdx Which button index changed
  61619. * @param state New state of the button
  61620. * @param changes Which properties on the state changed since last frame
  61621. */
  61622. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  61623. /**
  61624. * Moves the buttons on the controller mesh based on their current state
  61625. * @param buttonName the name of the button to move
  61626. * @param buttonValue the value of the button which determines the buttons new position
  61627. */
  61628. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  61629. /**
  61630. * Moves the axis on the controller mesh based on its current state
  61631. * @param axis the index of the axis
  61632. * @param axisValue the value of the axis which determines the meshes new position
  61633. * @hidden
  61634. */
  61635. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  61636. /**
  61637. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  61638. * @param scene scene in which to add meshes
  61639. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  61640. */
  61641. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  61642. /**
  61643. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  61644. * can be transformed by button presses and axes values, based on this._mapping.
  61645. *
  61646. * @param scene scene in which the meshes exist
  61647. * @param meshes list of meshes that make up the controller model to process
  61648. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  61649. */
  61650. private processModel;
  61651. private createMeshInfo;
  61652. /**
  61653. * Gets the ray of the controller in the direction the controller is pointing
  61654. * @param length the length the resulting ray should be
  61655. * @returns a ray in the direction the controller is pointing
  61656. */
  61657. getForwardRay(length?: number): Ray;
  61658. /**
  61659. * Disposes of the controller
  61660. */
  61661. dispose(): void;
  61662. }
  61663. /**
  61664. * This class represents a new windows motion controller in XR.
  61665. */
  61666. export class XRWindowsMotionController extends WindowsMotionController {
  61667. /**
  61668. * Changing the original WIndowsMotionController mapping to fir the new mapping
  61669. */
  61670. protected readonly _mapping: {
  61671. buttons: string[];
  61672. buttonMeshNames: {
  61673. trigger: string;
  61674. menu: string;
  61675. grip: string;
  61676. thumbstick: string;
  61677. trackpad: string;
  61678. };
  61679. buttonObservableNames: {
  61680. trigger: string;
  61681. menu: string;
  61682. grip: string;
  61683. thumbstick: string;
  61684. trackpad: string;
  61685. };
  61686. axisMeshNames: string[];
  61687. pointingPoseMeshName: string;
  61688. };
  61689. /**
  61690. * Construct a new XR-Based windows motion controller
  61691. *
  61692. * @param gamepadInfo the gamepad object from the browser
  61693. */
  61694. constructor(gamepadInfo: any);
  61695. /**
  61696. * holds the thumbstick values (X,Y)
  61697. */
  61698. thumbstickValues: StickValues;
  61699. /**
  61700. * Fired when the thumbstick on this controller is clicked
  61701. */
  61702. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  61703. /**
  61704. * Fired when the thumbstick on this controller is modified
  61705. */
  61706. onThumbstickValuesChangedObservable: Observable<StickValues>;
  61707. /**
  61708. * Fired when the touchpad button on this controller is modified
  61709. */
  61710. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  61711. /**
  61712. * Fired when the touchpad values on this controller are modified
  61713. */
  61714. onTrackpadValuesChangedObservable: Observable<StickValues>;
  61715. /**
  61716. * Fired when the thumbstick button on this controller is modified
  61717. * here to prevent breaking changes
  61718. */
  61719. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61720. /**
  61721. * updating the thumbstick(!) and not the trackpad.
  61722. * This is named this way due to the difference between WebVR and XR and to avoid
  61723. * changing the parent class.
  61724. */
  61725. protected _updateTrackpad(): void;
  61726. /**
  61727. * Disposes the class with joy
  61728. */
  61729. dispose(): void;
  61730. }
  61731. }
  61732. declare module BABYLON {
  61733. /**
  61734. * Class containing static functions to help procedurally build meshes
  61735. */
  61736. export class HemisphereBuilder {
  61737. /**
  61738. * Creates a hemisphere mesh
  61739. * @param name defines the name of the mesh
  61740. * @param options defines the options used to create the mesh
  61741. * @param scene defines the hosting scene
  61742. * @returns the hemisphere mesh
  61743. */
  61744. static CreateHemisphere(name: string, options: {
  61745. segments?: number;
  61746. diameter?: number;
  61747. sideOrientation?: number;
  61748. }, scene: any): Mesh;
  61749. }
  61750. }
  61751. declare module BABYLON {
  61752. /**
  61753. * A spot light is defined by a position, a direction, an angle, and an exponent.
  61754. * These values define a cone of light starting from the position, emitting toward the direction.
  61755. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  61756. * and the exponent defines the speed of the decay of the light with distance (reach).
  61757. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61758. */
  61759. export class SpotLight extends ShadowLight {
  61760. private _angle;
  61761. private _innerAngle;
  61762. private _cosHalfAngle;
  61763. private _lightAngleScale;
  61764. private _lightAngleOffset;
  61765. /**
  61766. * Gets the cone angle of the spot light in Radians.
  61767. */
  61768. get angle(): number;
  61769. /**
  61770. * Sets the cone angle of the spot light in Radians.
  61771. */
  61772. set angle(value: number);
  61773. /**
  61774. * Only used in gltf falloff mode, this defines the angle where
  61775. * the directional falloff will start before cutting at angle which could be seen
  61776. * as outer angle.
  61777. */
  61778. get innerAngle(): number;
  61779. /**
  61780. * Only used in gltf falloff mode, this defines the angle where
  61781. * the directional falloff will start before cutting at angle which could be seen
  61782. * as outer angle.
  61783. */
  61784. set innerAngle(value: number);
  61785. private _shadowAngleScale;
  61786. /**
  61787. * Allows scaling the angle of the light for shadow generation only.
  61788. */
  61789. get shadowAngleScale(): number;
  61790. /**
  61791. * Allows scaling the angle of the light for shadow generation only.
  61792. */
  61793. set shadowAngleScale(value: number);
  61794. /**
  61795. * The light decay speed with the distance from the emission spot.
  61796. */
  61797. exponent: number;
  61798. private _projectionTextureMatrix;
  61799. /**
  61800. * Allows reading the projection texture
  61801. */
  61802. get projectionTextureMatrix(): Matrix;
  61803. protected _projectionTextureLightNear: number;
  61804. /**
  61805. * Gets the near clip of the Spotlight for texture projection.
  61806. */
  61807. get projectionTextureLightNear(): number;
  61808. /**
  61809. * Sets the near clip of the Spotlight for texture projection.
  61810. */
  61811. set projectionTextureLightNear(value: number);
  61812. protected _projectionTextureLightFar: number;
  61813. /**
  61814. * Gets the far clip of the Spotlight for texture projection.
  61815. */
  61816. get projectionTextureLightFar(): number;
  61817. /**
  61818. * Sets the far clip of the Spotlight for texture projection.
  61819. */
  61820. set projectionTextureLightFar(value: number);
  61821. protected _projectionTextureUpDirection: Vector3;
  61822. /**
  61823. * Gets the Up vector of the Spotlight for texture projection.
  61824. */
  61825. get projectionTextureUpDirection(): Vector3;
  61826. /**
  61827. * Sets the Up vector of the Spotlight for texture projection.
  61828. */
  61829. set projectionTextureUpDirection(value: Vector3);
  61830. private _projectionTexture;
  61831. /**
  61832. * Gets the projection texture of the light.
  61833. */
  61834. get projectionTexture(): Nullable<BaseTexture>;
  61835. /**
  61836. * Sets the projection texture of the light.
  61837. */
  61838. set projectionTexture(value: Nullable<BaseTexture>);
  61839. private static _IsProceduralTexture;
  61840. private static _IsTexture;
  61841. private _projectionTextureViewLightDirty;
  61842. private _projectionTextureProjectionLightDirty;
  61843. private _projectionTextureDirty;
  61844. private _projectionTextureViewTargetVector;
  61845. private _projectionTextureViewLightMatrix;
  61846. private _projectionTextureProjectionLightMatrix;
  61847. private _projectionTextureScalingMatrix;
  61848. /**
  61849. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  61850. * It can cast shadows.
  61851. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61852. * @param name The light friendly name
  61853. * @param position The position of the spot light in the scene
  61854. * @param direction The direction of the light in the scene
  61855. * @param angle The cone angle of the light in Radians
  61856. * @param exponent The light decay speed with the distance from the emission spot
  61857. * @param scene The scene the lights belongs to
  61858. */
  61859. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  61860. /**
  61861. * Returns the string "SpotLight".
  61862. * @returns the class name
  61863. */
  61864. getClassName(): string;
  61865. /**
  61866. * Returns the integer 2.
  61867. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61868. */
  61869. getTypeID(): number;
  61870. /**
  61871. * Overrides the direction setter to recompute the projection texture view light Matrix.
  61872. */
  61873. protected _setDirection(value: Vector3): void;
  61874. /**
  61875. * Overrides the position setter to recompute the projection texture view light Matrix.
  61876. */
  61877. protected _setPosition(value: Vector3): void;
  61878. /**
  61879. * 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.
  61880. * Returns the SpotLight.
  61881. */
  61882. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61883. protected _computeProjectionTextureViewLightMatrix(): void;
  61884. protected _computeProjectionTextureProjectionLightMatrix(): void;
  61885. /**
  61886. * Main function for light texture projection matrix computing.
  61887. */
  61888. protected _computeProjectionTextureMatrix(): void;
  61889. protected _buildUniformLayout(): void;
  61890. private _computeAngleValues;
  61891. /**
  61892. * Sets the passed Effect "effect" with the Light textures.
  61893. * @param effect The effect to update
  61894. * @param lightIndex The index of the light in the effect to update
  61895. * @returns The light
  61896. */
  61897. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  61898. /**
  61899. * Sets the passed Effect object with the SpotLight transformed position (or position if not parented) and normalized direction.
  61900. * @param effect The effect to update
  61901. * @param lightIndex The index of the light in the effect to update
  61902. * @returns The spot light
  61903. */
  61904. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  61905. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61906. /**
  61907. * Disposes the light and the associated resources.
  61908. */
  61909. dispose(): void;
  61910. /**
  61911. * Prepares the list of defines specific to the light type.
  61912. * @param defines the list of defines
  61913. * @param lightIndex defines the index of the light for the effect
  61914. */
  61915. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61916. }
  61917. }
  61918. declare module BABYLON {
  61919. /**
  61920. * Gizmo that enables viewing a light
  61921. */
  61922. export class LightGizmo extends Gizmo {
  61923. private _lightMesh;
  61924. private _material;
  61925. private _cachedPosition;
  61926. private _cachedForward;
  61927. private _attachedMeshParent;
  61928. private _pointerObserver;
  61929. /**
  61930. * Event that fires each time the gizmo is clicked
  61931. */
  61932. onClickedObservable: Observable<Light>;
  61933. /**
  61934. * Creates a LightGizmo
  61935. * @param gizmoLayer The utility layer the gizmo will be added to
  61936. */
  61937. constructor(gizmoLayer?: UtilityLayerRenderer);
  61938. private _light;
  61939. /**
  61940. * The light that the gizmo is attached to
  61941. */
  61942. set light(light: Nullable<Light>);
  61943. get light(): Nullable<Light>;
  61944. /**
  61945. * Gets the material used to render the light gizmo
  61946. */
  61947. get material(): StandardMaterial;
  61948. /**
  61949. * @hidden
  61950. * Updates the gizmo to match the attached mesh's position/rotation
  61951. */
  61952. protected _update(): void;
  61953. private static _Scale;
  61954. /**
  61955. * Creates the lines for a light mesh
  61956. */
  61957. private static _CreateLightLines;
  61958. /**
  61959. * Disposes of the light gizmo
  61960. */
  61961. dispose(): void;
  61962. private static _CreateHemisphericLightMesh;
  61963. private static _CreatePointLightMesh;
  61964. private static _CreateSpotLightMesh;
  61965. private static _CreateDirectionalLightMesh;
  61966. }
  61967. }
  61968. declare module BABYLON {
  61969. /**
  61970. * Gizmo that enables viewing a camera
  61971. */
  61972. export class CameraGizmo extends Gizmo {
  61973. private _cameraMesh;
  61974. private _cameraLinesMesh;
  61975. private _material;
  61976. private _pointerObserver;
  61977. /**
  61978. * Event that fires each time the gizmo is clicked
  61979. */
  61980. onClickedObservable: Observable<Camera>;
  61981. /**
  61982. * Creates a CameraGizmo
  61983. * @param gizmoLayer The utility layer the gizmo will be added to
  61984. */
  61985. constructor(gizmoLayer?: UtilityLayerRenderer);
  61986. private _camera;
  61987. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  61988. get displayFrustum(): boolean;
  61989. set displayFrustum(value: boolean);
  61990. /**
  61991. * The camera that the gizmo is attached to
  61992. */
  61993. set camera(camera: Nullable<Camera>);
  61994. get camera(): Nullable<Camera>;
  61995. /**
  61996. * Gets the material used to render the camera gizmo
  61997. */
  61998. get material(): StandardMaterial;
  61999. /**
  62000. * @hidden
  62001. * Updates the gizmo to match the attached mesh's position/rotation
  62002. */
  62003. protected _update(): void;
  62004. private static _Scale;
  62005. private _invProjection;
  62006. /**
  62007. * Disposes of the camera gizmo
  62008. */
  62009. dispose(): void;
  62010. private static _CreateCameraMesh;
  62011. private static _CreateCameraFrustum;
  62012. }
  62013. }
  62014. declare module BABYLON {
  62015. /** @hidden */
  62016. export var backgroundFragmentDeclaration: {
  62017. name: string;
  62018. shader: string;
  62019. };
  62020. }
  62021. declare module BABYLON {
  62022. /** @hidden */
  62023. export var backgroundUboDeclaration: {
  62024. name: string;
  62025. shader: string;
  62026. };
  62027. }
  62028. declare module BABYLON {
  62029. /** @hidden */
  62030. export var backgroundPixelShader: {
  62031. name: string;
  62032. shader: string;
  62033. };
  62034. }
  62035. declare module BABYLON {
  62036. /** @hidden */
  62037. export var backgroundVertexDeclaration: {
  62038. name: string;
  62039. shader: string;
  62040. };
  62041. }
  62042. declare module BABYLON {
  62043. /** @hidden */
  62044. export var backgroundVertexShader: {
  62045. name: string;
  62046. shader: string;
  62047. };
  62048. }
  62049. declare module BABYLON {
  62050. /**
  62051. * Background material used to create an efficient environment around your scene.
  62052. */
  62053. export class BackgroundMaterial extends PushMaterial {
  62054. /**
  62055. * Standard reflectance value at parallel view angle.
  62056. */
  62057. static StandardReflectance0: number;
  62058. /**
  62059. * Standard reflectance value at grazing angle.
  62060. */
  62061. static StandardReflectance90: number;
  62062. protected _primaryColor: Color3;
  62063. /**
  62064. * Key light Color (multiply against the environment texture)
  62065. */
  62066. primaryColor: Color3;
  62067. protected __perceptualColor: Nullable<Color3>;
  62068. /**
  62069. * Experimental Internal Use Only.
  62070. *
  62071. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  62072. * This acts as a helper to set the primary color to a more "human friendly" value.
  62073. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  62074. * output color as close as possible from the chosen value.
  62075. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  62076. * part of lighting setup.)
  62077. */
  62078. get _perceptualColor(): Nullable<Color3>;
  62079. set _perceptualColor(value: Nullable<Color3>);
  62080. protected _primaryColorShadowLevel: float;
  62081. /**
  62082. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  62083. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  62084. */
  62085. get primaryColorShadowLevel(): float;
  62086. set primaryColorShadowLevel(value: float);
  62087. protected _primaryColorHighlightLevel: float;
  62088. /**
  62089. * Defines the level of the highlights (highlight area of the reflection map) in order to help scaling the colors.
  62090. * The primary color is used at the level chosen to define what the white area would look.
  62091. */
  62092. get primaryColorHighlightLevel(): float;
  62093. set primaryColorHighlightLevel(value: float);
  62094. protected _reflectionTexture: Nullable<BaseTexture>;
  62095. /**
  62096. * Reflection Texture used in the material.
  62097. * Should be author in a specific way for the best result (refer to the documentation).
  62098. */
  62099. reflectionTexture: Nullable<BaseTexture>;
  62100. protected _reflectionBlur: float;
  62101. /**
  62102. * Reflection Texture level of blur.
  62103. *
  62104. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  62105. * texture twice.
  62106. */
  62107. reflectionBlur: float;
  62108. protected _diffuseTexture: Nullable<BaseTexture>;
  62109. /**
  62110. * Diffuse Texture used in the material.
  62111. * Should be author in a specific way for the best result (refer to the documentation).
  62112. */
  62113. diffuseTexture: Nullable<BaseTexture>;
  62114. protected _shadowLights: Nullable<IShadowLight[]>;
  62115. /**
  62116. * Specify the list of lights casting shadow on the material.
  62117. * All scene shadow lights will be included if null.
  62118. */
  62119. shadowLights: Nullable<IShadowLight[]>;
  62120. protected _shadowLevel: float;
  62121. /**
  62122. * Helps adjusting the shadow to a softer level if required.
  62123. * 0 means black shadows and 1 means no shadows.
  62124. */
  62125. shadowLevel: float;
  62126. protected _sceneCenter: Vector3;
  62127. /**
  62128. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  62129. * It is usually zero but might be interesting to modify according to your setup.
  62130. */
  62131. sceneCenter: Vector3;
  62132. protected _opacityFresnel: boolean;
  62133. /**
  62134. * This helps specifying that the material is falling off to the sky box at grazing angle.
  62135. * This helps ensuring a nice transition when the camera goes under the ground.
  62136. */
  62137. opacityFresnel: boolean;
  62138. protected _reflectionFresnel: boolean;
  62139. /**
  62140. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  62141. * This helps adding a mirror texture on the ground.
  62142. */
  62143. reflectionFresnel: boolean;
  62144. protected _reflectionFalloffDistance: number;
  62145. /**
  62146. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  62147. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  62148. */
  62149. reflectionFalloffDistance: number;
  62150. protected _reflectionAmount: number;
  62151. /**
  62152. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  62153. */
  62154. reflectionAmount: number;
  62155. protected _reflectionReflectance0: number;
  62156. /**
  62157. * This specifies the weight of the reflection at grazing angle.
  62158. */
  62159. reflectionReflectance0: number;
  62160. protected _reflectionReflectance90: number;
  62161. /**
  62162. * This specifies the weight of the reflection at a perpendicular point of view.
  62163. */
  62164. reflectionReflectance90: number;
  62165. /**
  62166. * Sets the reflection reflectance fresnel values according to the default standard
  62167. * empirically know to work well :-)
  62168. */
  62169. set reflectionStandardFresnelWeight(value: number);
  62170. protected _useRGBColor: boolean;
  62171. /**
  62172. * Helps to directly use the maps channels instead of their level.
  62173. */
  62174. useRGBColor: boolean;
  62175. protected _enableNoise: boolean;
  62176. /**
  62177. * This helps reducing the banding effect that could occur on the background.
  62178. */
  62179. enableNoise: boolean;
  62180. /**
  62181. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  62182. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  62183. * Recommended to be keep at 1.0 except for special cases.
  62184. */
  62185. get fovMultiplier(): number;
  62186. set fovMultiplier(value: number);
  62187. private _fovMultiplier;
  62188. /**
  62189. * Enable the FOV adjustment feature controlled by fovMultiplier.
  62190. */
  62191. useEquirectangularFOV: boolean;
  62192. private _maxSimultaneousLights;
  62193. /**
  62194. * Number of Simultaneous lights allowed on the material.
  62195. */
  62196. maxSimultaneousLights: int;
  62197. private _shadowOnly;
  62198. /**
  62199. * Make the material only render shadows
  62200. */
  62201. shadowOnly: boolean;
  62202. /**
  62203. * Default configuration related to image processing available in the Background Material.
  62204. */
  62205. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  62206. /**
  62207. * Keep track of the image processing observer to allow dispose and replace.
  62208. */
  62209. private _imageProcessingObserver;
  62210. /**
  62211. * Attaches a new image processing configuration to the PBR Material.
  62212. * @param configuration (if null the scene configuration will be use)
  62213. */
  62214. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  62215. /**
  62216. * Gets the image processing configuration used either in this material.
  62217. */
  62218. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  62219. /**
  62220. * Sets the Default image processing configuration used either in the this material.
  62221. *
  62222. * If sets to null, the scene one is in use.
  62223. */
  62224. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  62225. /**
  62226. * Gets whether the color curves effect is enabled.
  62227. */
  62228. get cameraColorCurvesEnabled(): boolean;
  62229. /**
  62230. * Sets whether the color curves effect is enabled.
  62231. */
  62232. set cameraColorCurvesEnabled(value: boolean);
  62233. /**
  62234. * Gets whether the color grading effect is enabled.
  62235. */
  62236. get cameraColorGradingEnabled(): boolean;
  62237. /**
  62238. * Gets whether the color grading effect is enabled.
  62239. */
  62240. set cameraColorGradingEnabled(value: boolean);
  62241. /**
  62242. * Gets whether tonemapping is enabled or not.
  62243. */
  62244. get cameraToneMappingEnabled(): boolean;
  62245. /**
  62246. * Sets whether tonemapping is enabled or not
  62247. */
  62248. set cameraToneMappingEnabled(value: boolean);
  62249. /**
  62250. * The camera exposure used on this material.
  62251. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  62252. * This corresponds to a photographic exposure.
  62253. */
  62254. get cameraExposure(): float;
  62255. /**
  62256. * The camera exposure used on this material.
  62257. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  62258. * This corresponds to a photographic exposure.
  62259. */
  62260. set cameraExposure(value: float);
  62261. /**
  62262. * Gets The camera contrast used on this material.
  62263. */
  62264. get cameraContrast(): float;
  62265. /**
  62266. * Sets The camera contrast used on this material.
  62267. */
  62268. set cameraContrast(value: float);
  62269. /**
  62270. * Gets the Color Grading 2D Lookup Texture.
  62271. */
  62272. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  62273. /**
  62274. * Sets the Color Grading 2D Lookup Texture.
  62275. */
  62276. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  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. get cameraColorCurves(): Nullable<ColorCurves>;
  62284. /**
  62285. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  62286. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  62287. * 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;
  62288. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  62289. */
  62290. set cameraColorCurves(value: Nullable<ColorCurves>);
  62291. /**
  62292. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  62293. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  62294. */
  62295. switchToBGR: boolean;
  62296. private _renderTargets;
  62297. private _reflectionControls;
  62298. private _white;
  62299. private _primaryShadowColor;
  62300. private _primaryHighlightColor;
  62301. /**
  62302. * Instantiates a Background Material in the given scene
  62303. * @param name The friendly name of the material
  62304. * @param scene The scene to add the material to
  62305. */
  62306. constructor(name: string, scene: Scene);
  62307. /**
  62308. * Gets a boolean indicating that current material needs to register RTT
  62309. */
  62310. get hasRenderTargetTextures(): boolean;
  62311. /**
  62312. * The entire material has been created in order to prevent overdraw.
  62313. * @returns false
  62314. */
  62315. needAlphaTesting(): boolean;
  62316. /**
  62317. * The entire material has been created in order to prevent overdraw.
  62318. * @returns true if blending is enable
  62319. */
  62320. needAlphaBlending(): boolean;
  62321. /**
  62322. * Checks whether the material is ready to be rendered for a given mesh.
  62323. * @param mesh The mesh to render
  62324. * @param subMesh The submesh to check against
  62325. * @param useInstances Specify wether or not the material is used with instances
  62326. * @returns true if all the dependencies are ready (Textures, Effects...)
  62327. */
  62328. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  62329. /**
  62330. * Compute the primary color according to the chosen perceptual color.
  62331. */
  62332. private _computePrimaryColorFromPerceptualColor;
  62333. /**
  62334. * Compute the highlights and shadow colors according to their chosen levels.
  62335. */
  62336. private _computePrimaryColors;
  62337. /**
  62338. * Build the uniform buffer used in the material.
  62339. */
  62340. buildUniformLayout(): void;
  62341. /**
  62342. * Unbind the material.
  62343. */
  62344. unbind(): void;
  62345. /**
  62346. * Bind only the world matrix to the material.
  62347. * @param world The world matrix to bind.
  62348. */
  62349. bindOnlyWorldMatrix(world: Matrix): void;
  62350. /**
  62351. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  62352. * @param world The world matrix to bind.
  62353. * @param subMesh The submesh to bind for.
  62354. */
  62355. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  62356. /**
  62357. * Checks to see if a texture is used in the material.
  62358. * @param texture - Base texture to use.
  62359. * @returns - Boolean specifying if a texture is used in the material.
  62360. */
  62361. hasTexture(texture: BaseTexture): boolean;
  62362. /**
  62363. * Dispose the material.
  62364. * @param forceDisposeEffect Force disposal of the associated effect.
  62365. * @param forceDisposeTextures Force disposal of the associated textures.
  62366. */
  62367. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  62368. /**
  62369. * Clones the material.
  62370. * @param name The cloned name.
  62371. * @returns The cloned material.
  62372. */
  62373. clone(name: string): BackgroundMaterial;
  62374. /**
  62375. * Serializes the current material to its JSON representation.
  62376. * @returns The JSON representation.
  62377. */
  62378. serialize(): any;
  62379. /**
  62380. * Gets the class name of the material
  62381. * @returns "BackgroundMaterial"
  62382. */
  62383. getClassName(): string;
  62384. /**
  62385. * Parse a JSON input to create back a background material.
  62386. * @param source The JSON data to parse
  62387. * @param scene The scene to create the parsed material in
  62388. * @param rootUrl The root url of the assets the material depends upon
  62389. * @returns the instantiated BackgroundMaterial.
  62390. */
  62391. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  62392. }
  62393. }
  62394. declare module BABYLON {
  62395. /**
  62396. * Represents the different options available during the creation of
  62397. * a Environment helper.
  62398. *
  62399. * This can control the default ground, skybox and image processing setup of your scene.
  62400. */
  62401. export interface IEnvironmentHelperOptions {
  62402. /**
  62403. * Specifies whether or not to create a ground.
  62404. * True by default.
  62405. */
  62406. createGround: boolean;
  62407. /**
  62408. * Specifies the ground size.
  62409. * 15 by default.
  62410. */
  62411. groundSize: number;
  62412. /**
  62413. * The texture used on the ground for the main color.
  62414. * Comes from the BabylonJS CDN by default.
  62415. *
  62416. * Remarks: Can be either a texture or a url.
  62417. */
  62418. groundTexture: string | BaseTexture;
  62419. /**
  62420. * The color mixed in the ground texture by default.
  62421. * BabylonJS clearColor by default.
  62422. */
  62423. groundColor: Color3;
  62424. /**
  62425. * Specifies the ground opacity.
  62426. * 1 by default.
  62427. */
  62428. groundOpacity: number;
  62429. /**
  62430. * Enables the ground to receive shadows.
  62431. * True by default.
  62432. */
  62433. enableGroundShadow: boolean;
  62434. /**
  62435. * Helps preventing the shadow to be fully black on the ground.
  62436. * 0.5 by default.
  62437. */
  62438. groundShadowLevel: number;
  62439. /**
  62440. * Creates a mirror texture attach to the ground.
  62441. * false by default.
  62442. */
  62443. enableGroundMirror: boolean;
  62444. /**
  62445. * Specifies the ground mirror size ratio.
  62446. * 0.3 by default as the default kernel is 64.
  62447. */
  62448. groundMirrorSizeRatio: number;
  62449. /**
  62450. * Specifies the ground mirror blur kernel size.
  62451. * 64 by default.
  62452. */
  62453. groundMirrorBlurKernel: number;
  62454. /**
  62455. * Specifies the ground mirror visibility amount.
  62456. * 1 by default
  62457. */
  62458. groundMirrorAmount: number;
  62459. /**
  62460. * Specifies the ground mirror reflectance weight.
  62461. * This uses the standard weight of the background material to setup the fresnel effect
  62462. * of the mirror.
  62463. * 1 by default.
  62464. */
  62465. groundMirrorFresnelWeight: number;
  62466. /**
  62467. * Specifies the ground mirror Falloff distance.
  62468. * This can helps reducing the size of the reflection.
  62469. * 0 by Default.
  62470. */
  62471. groundMirrorFallOffDistance: number;
  62472. /**
  62473. * Specifies the ground mirror texture type.
  62474. * Unsigned Int by Default.
  62475. */
  62476. groundMirrorTextureType: number;
  62477. /**
  62478. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  62479. * the shown objects.
  62480. */
  62481. groundYBias: number;
  62482. /**
  62483. * Specifies whether or not to create a skybox.
  62484. * True by default.
  62485. */
  62486. createSkybox: boolean;
  62487. /**
  62488. * Specifies the skybox size.
  62489. * 20 by default.
  62490. */
  62491. skyboxSize: number;
  62492. /**
  62493. * The texture used on the skybox for the main color.
  62494. * Comes from the BabylonJS CDN by default.
  62495. *
  62496. * Remarks: Can be either a texture or a url.
  62497. */
  62498. skyboxTexture: string | BaseTexture;
  62499. /**
  62500. * The color mixed in the skybox texture by default.
  62501. * BabylonJS clearColor by default.
  62502. */
  62503. skyboxColor: Color3;
  62504. /**
  62505. * The background rotation around the Y axis of the scene.
  62506. * This helps aligning the key lights of your scene with the background.
  62507. * 0 by default.
  62508. */
  62509. backgroundYRotation: number;
  62510. /**
  62511. * Compute automatically the size of the elements to best fit with the scene.
  62512. */
  62513. sizeAuto: boolean;
  62514. /**
  62515. * Default position of the rootMesh if autoSize is not true.
  62516. */
  62517. rootPosition: Vector3;
  62518. /**
  62519. * Sets up the image processing in the scene.
  62520. * true by default.
  62521. */
  62522. setupImageProcessing: boolean;
  62523. /**
  62524. * The texture used as your environment texture in the scene.
  62525. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  62526. *
  62527. * Remarks: Can be either a texture or a url.
  62528. */
  62529. environmentTexture: string | BaseTexture;
  62530. /**
  62531. * The value of the exposure to apply to the scene.
  62532. * 0.6 by default if setupImageProcessing is true.
  62533. */
  62534. cameraExposure: number;
  62535. /**
  62536. * The value of the contrast to apply to the scene.
  62537. * 1.6 by default if setupImageProcessing is true.
  62538. */
  62539. cameraContrast: number;
  62540. /**
  62541. * Specifies whether or not tonemapping should be enabled in the scene.
  62542. * true by default if setupImageProcessing is true.
  62543. */
  62544. toneMappingEnabled: boolean;
  62545. }
  62546. /**
  62547. * The Environment helper class can be used to add a fully featured none expensive background to your scene.
  62548. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  62549. * It also helps with the default setup of your imageProcessing configuration.
  62550. */
  62551. export class EnvironmentHelper {
  62552. /**
  62553. * Default ground texture URL.
  62554. */
  62555. private static _groundTextureCDNUrl;
  62556. /**
  62557. * Default skybox texture URL.
  62558. */
  62559. private static _skyboxTextureCDNUrl;
  62560. /**
  62561. * Default environment texture URL.
  62562. */
  62563. private static _environmentTextureCDNUrl;
  62564. /**
  62565. * Creates the default options for the helper.
  62566. */
  62567. private static _getDefaultOptions;
  62568. private _rootMesh;
  62569. /**
  62570. * Gets the root mesh created by the helper.
  62571. */
  62572. get rootMesh(): Mesh;
  62573. private _skybox;
  62574. /**
  62575. * Gets the skybox created by the helper.
  62576. */
  62577. get skybox(): Nullable<Mesh>;
  62578. private _skyboxTexture;
  62579. /**
  62580. * Gets the skybox texture created by the helper.
  62581. */
  62582. get skyboxTexture(): Nullable<BaseTexture>;
  62583. private _skyboxMaterial;
  62584. /**
  62585. * Gets the skybox material created by the helper.
  62586. */
  62587. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  62588. private _ground;
  62589. /**
  62590. * Gets the ground mesh created by the helper.
  62591. */
  62592. get ground(): Nullable<Mesh>;
  62593. private _groundTexture;
  62594. /**
  62595. * Gets the ground texture created by the helper.
  62596. */
  62597. get groundTexture(): Nullable<BaseTexture>;
  62598. private _groundMirror;
  62599. /**
  62600. * Gets the ground mirror created by the helper.
  62601. */
  62602. get groundMirror(): Nullable<MirrorTexture>;
  62603. /**
  62604. * Gets the ground mirror render list to helps pushing the meshes
  62605. * you wish in the ground reflection.
  62606. */
  62607. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  62608. private _groundMaterial;
  62609. /**
  62610. * Gets the ground material created by the helper.
  62611. */
  62612. get groundMaterial(): Nullable<BackgroundMaterial>;
  62613. /**
  62614. * Stores the creation options.
  62615. */
  62616. private readonly _scene;
  62617. private _options;
  62618. /**
  62619. * This observable will be notified with any error during the creation of the environment,
  62620. * mainly texture creation errors.
  62621. */
  62622. onErrorObservable: Observable<{
  62623. message?: string;
  62624. exception?: any;
  62625. }>;
  62626. /**
  62627. * constructor
  62628. * @param options Defines the options we want to customize the helper
  62629. * @param scene The scene to add the material to
  62630. */
  62631. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  62632. /**
  62633. * Updates the background according to the new options
  62634. * @param options
  62635. */
  62636. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  62637. /**
  62638. * Sets the primary color of all the available elements.
  62639. * @param color the main color to affect to the ground and the background
  62640. */
  62641. setMainColor(color: Color3): void;
  62642. /**
  62643. * Setup the image processing according to the specified options.
  62644. */
  62645. private _setupImageProcessing;
  62646. /**
  62647. * Setup the environment texture according to the specified options.
  62648. */
  62649. private _setupEnvironmentTexture;
  62650. /**
  62651. * Setup the background according to the specified options.
  62652. */
  62653. private _setupBackground;
  62654. /**
  62655. * Get the scene sizes according to the setup.
  62656. */
  62657. private _getSceneSize;
  62658. /**
  62659. * Setup the ground according to the specified options.
  62660. */
  62661. private _setupGround;
  62662. /**
  62663. * Setup the ground material according to the specified options.
  62664. */
  62665. private _setupGroundMaterial;
  62666. /**
  62667. * Setup the ground diffuse texture according to the specified options.
  62668. */
  62669. private _setupGroundDiffuseTexture;
  62670. /**
  62671. * Setup the ground mirror texture according to the specified options.
  62672. */
  62673. private _setupGroundMirrorTexture;
  62674. /**
  62675. * Setup the ground to receive the mirror texture.
  62676. */
  62677. private _setupMirrorInGroundMaterial;
  62678. /**
  62679. * Setup the skybox according to the specified options.
  62680. */
  62681. private _setupSkybox;
  62682. /**
  62683. * Setup the skybox material according to the specified options.
  62684. */
  62685. private _setupSkyboxMaterial;
  62686. /**
  62687. * Setup the skybox reflection texture according to the specified options.
  62688. */
  62689. private _setupSkyboxReflectionTexture;
  62690. private _errorHandler;
  62691. /**
  62692. * Dispose all the elements created by the Helper.
  62693. */
  62694. dispose(): void;
  62695. }
  62696. }
  62697. declare module BABYLON {
  62698. /**
  62699. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  62700. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  62701. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  62702. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62703. */
  62704. export abstract class TextureDome<T extends Texture> extends TransformNode {
  62705. protected onError: Nullable<(message?: string, exception?: any) => void>;
  62706. /**
  62707. * Define the source as a Monoscopic panoramic 360/180.
  62708. */
  62709. static readonly MODE_MONOSCOPIC: number;
  62710. /**
  62711. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  62712. */
  62713. static readonly MODE_TOPBOTTOM: number;
  62714. /**
  62715. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  62716. */
  62717. static readonly MODE_SIDEBYSIDE: number;
  62718. private _halfDome;
  62719. private _crossEye;
  62720. protected _useDirectMapping: boolean;
  62721. /**
  62722. * The texture being displayed on the sphere
  62723. */
  62724. protected _texture: T;
  62725. /**
  62726. * Gets the texture being displayed on the sphere
  62727. */
  62728. get texture(): T;
  62729. /**
  62730. * Sets the texture being displayed on the sphere
  62731. */
  62732. set texture(newTexture: T);
  62733. /**
  62734. * The skybox material
  62735. */
  62736. protected _material: BackgroundMaterial;
  62737. /**
  62738. * The surface used for the dome
  62739. */
  62740. protected _mesh: Mesh;
  62741. /**
  62742. * Gets the mesh used for the dome.
  62743. */
  62744. get mesh(): Mesh;
  62745. /**
  62746. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  62747. */
  62748. private _halfDomeMask;
  62749. /**
  62750. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  62751. * Also see the options.resolution property.
  62752. */
  62753. get fovMultiplier(): number;
  62754. set fovMultiplier(value: number);
  62755. protected _textureMode: number;
  62756. /**
  62757. * Gets or set 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. get textureMode(): number;
  62763. /**
  62764. * Sets the current texture mode for the texture. It can be:
  62765. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  62766. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  62767. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  62768. */
  62769. set textureMode(value: number);
  62770. /**
  62771. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  62772. */
  62773. get halfDome(): boolean;
  62774. /**
  62775. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  62776. */
  62777. set halfDome(enabled: boolean);
  62778. /**
  62779. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  62780. */
  62781. set crossEye(enabled: boolean);
  62782. /**
  62783. * Is it a cross-eye texture?
  62784. */
  62785. get crossEye(): boolean;
  62786. /**
  62787. * The background material of this dome.
  62788. */
  62789. get material(): BackgroundMaterial;
  62790. /**
  62791. * Oberserver used in Stereoscopic VR Mode.
  62792. */
  62793. private _onBeforeCameraRenderObserver;
  62794. /**
  62795. * Observable raised when an error occurred while loading the texture
  62796. */
  62797. onLoadErrorObservable: Observable<string>;
  62798. /**
  62799. * Observable raised when the texture finished loading
  62800. */
  62801. onLoadObservable: Observable<void>;
  62802. /**
  62803. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  62804. * @param name Element's name, child elements will append suffixes for their own names.
  62805. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  62806. * @param options An object containing optional or exposed sub element properties
  62807. */
  62808. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  62809. resolution?: number;
  62810. clickToPlay?: boolean;
  62811. autoPlay?: boolean;
  62812. loop?: boolean;
  62813. size?: number;
  62814. poster?: string;
  62815. faceForward?: boolean;
  62816. useDirectMapping?: boolean;
  62817. halfDomeMode?: boolean;
  62818. crossEyeMode?: boolean;
  62819. generateMipMaps?: boolean;
  62820. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  62821. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  62822. protected _changeTextureMode(value: number): void;
  62823. /**
  62824. * Releases resources associated with this node.
  62825. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  62826. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  62827. */
  62828. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  62829. }
  62830. }
  62831. declare module BABYLON {
  62832. /**
  62833. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  62834. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  62835. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  62836. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62837. */
  62838. export class PhotoDome extends TextureDome<Texture> {
  62839. /**
  62840. * Define the image as a Monoscopic panoramic 360 image.
  62841. */
  62842. static readonly MODE_MONOSCOPIC: number;
  62843. /**
  62844. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  62845. */
  62846. static readonly MODE_TOPBOTTOM: number;
  62847. /**
  62848. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  62849. */
  62850. static readonly MODE_SIDEBYSIDE: number;
  62851. /**
  62852. * Gets or sets the texture being displayed on the sphere
  62853. */
  62854. get photoTexture(): Texture;
  62855. /**
  62856. * sets the texture being displayed on the sphere
  62857. */
  62858. set photoTexture(value: Texture);
  62859. /**
  62860. * Gets 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. get imageMode(): number;
  62866. /**
  62867. * Sets the current video mode for the video. It can be:
  62868. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  62869. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  62870. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  62871. */
  62872. set imageMode(value: number);
  62873. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  62874. }
  62875. }
  62876. declare module BABYLON {
  62877. /**
  62878. * Direct draw surface info
  62879. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  62880. */
  62881. export interface DDSInfo {
  62882. /**
  62883. * Width of the texture
  62884. */
  62885. width: number;
  62886. /**
  62887. * Width of the texture
  62888. */
  62889. height: number;
  62890. /**
  62891. * Number of Mipmaps for the texture
  62892. * @see https://en.wikipedia.org/wiki/Mipmap
  62893. */
  62894. mipmapCount: number;
  62895. /**
  62896. * If the textures format is a known fourCC format
  62897. * @see https://www.fourcc.org/
  62898. */
  62899. isFourCC: boolean;
  62900. /**
  62901. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  62902. */
  62903. isRGB: boolean;
  62904. /**
  62905. * If the texture is a lumincance format
  62906. */
  62907. isLuminance: boolean;
  62908. /**
  62909. * If this is a cube texture
  62910. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  62911. */
  62912. isCube: boolean;
  62913. /**
  62914. * If the texture is a compressed format eg. FOURCC_DXT1
  62915. */
  62916. isCompressed: boolean;
  62917. /**
  62918. * The dxgiFormat of the texture
  62919. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  62920. */
  62921. dxgiFormat: number;
  62922. /**
  62923. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  62924. */
  62925. textureType: number;
  62926. /**
  62927. * Sphericle polynomial created for the dds texture
  62928. */
  62929. sphericalPolynomial?: SphericalPolynomial;
  62930. }
  62931. /**
  62932. * Class used to provide DDS decompression tools
  62933. */
  62934. export class DDSTools {
  62935. /**
  62936. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  62937. */
  62938. static StoreLODInAlphaChannel: boolean;
  62939. /**
  62940. * Gets DDS information from an array buffer
  62941. * @param data defines the array buffer view to read data from
  62942. * @returns the DDS information
  62943. */
  62944. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  62945. private static _FloatView;
  62946. private static _Int32View;
  62947. private static _ToHalfFloat;
  62948. private static _FromHalfFloat;
  62949. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  62950. private static _GetHalfFloatRGBAArrayBuffer;
  62951. private static _GetFloatRGBAArrayBuffer;
  62952. private static _GetFloatAsUIntRGBAArrayBuffer;
  62953. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  62954. private static _GetRGBAArrayBuffer;
  62955. private static _ExtractLongWordOrder;
  62956. private static _GetRGBArrayBuffer;
  62957. private static _GetLuminanceArrayBuffer;
  62958. /**
  62959. * Uploads DDS Levels to a Babylon Texture
  62960. * @hidden
  62961. */
  62962. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  62963. }
  62964. interface ThinEngine {
  62965. /**
  62966. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  62967. * @param rootUrl defines the url where the file to load is located
  62968. * @param scene defines the current scene
  62969. * @param lodScale defines scale to apply to the mip map selection
  62970. * @param lodOffset defines offset to apply to the mip map selection
  62971. * @param onLoad defines an optional callback raised when the texture is loaded
  62972. * @param onError defines an optional callback raised if there is an issue to load the texture
  62973. * @param format defines the format of the data
  62974. * @param forcedExtension defines the extension to use to pick the right loader
  62975. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  62976. * @returns the cube texture as an InternalTexture
  62977. */
  62978. 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;
  62979. }
  62980. }
  62981. declare module BABYLON {
  62982. /**
  62983. * Implementation of the DDS Texture Loader.
  62984. * @hidden
  62985. */
  62986. export class _DDSTextureLoader implements IInternalTextureLoader {
  62987. /**
  62988. * Defines whether the loader supports cascade loading the different faces.
  62989. */
  62990. readonly supportCascades: boolean;
  62991. /**
  62992. * This returns if the loader support the current file information.
  62993. * @param extension defines the file extension of the file being loaded
  62994. * @returns true if the loader can load the specified file
  62995. */
  62996. canLoad(extension: string): boolean;
  62997. /**
  62998. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62999. * @param data contains the texture data
  63000. * @param texture defines the BabylonJS internal texture
  63001. * @param createPolynomials will be true if polynomials have been requested
  63002. * @param onLoad defines the callback to trigger once the texture is ready
  63003. * @param onError defines the callback to trigger in case of error
  63004. */
  63005. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63006. /**
  63007. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63008. * @param data contains the texture data
  63009. * @param texture defines the BabylonJS internal texture
  63010. * @param callback defines the method to call once ready to upload
  63011. */
  63012. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63013. }
  63014. }
  63015. declare module BABYLON {
  63016. /**
  63017. * Implementation of the ENV Texture Loader.
  63018. * @hidden
  63019. */
  63020. export class _ENVTextureLoader implements IInternalTextureLoader {
  63021. /**
  63022. * Defines whether the loader supports cascade loading the different faces.
  63023. */
  63024. readonly supportCascades: boolean;
  63025. /**
  63026. * This returns if the loader support the current file information.
  63027. * @param extension defines the file extension of the file being loaded
  63028. * @returns true if the loader can load the specified file
  63029. */
  63030. canLoad(extension: string): boolean;
  63031. /**
  63032. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63033. * @param data contains the texture data
  63034. * @param texture defines the BabylonJS internal texture
  63035. * @param createPolynomials will be true if polynomials have been requested
  63036. * @param onLoad defines the callback to trigger once the texture is ready
  63037. * @param onError defines the callback to trigger in case of error
  63038. */
  63039. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63040. /**
  63041. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63042. * @param data contains the texture data
  63043. * @param texture defines the BabylonJS internal texture
  63044. * @param callback defines the method to call once ready to upload
  63045. */
  63046. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63047. }
  63048. }
  63049. declare module BABYLON {
  63050. /**
  63051. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  63052. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  63053. */
  63054. export class KhronosTextureContainer {
  63055. /** contents of the KTX container file */
  63056. data: ArrayBufferView;
  63057. private static HEADER_LEN;
  63058. private static COMPRESSED_2D;
  63059. private static COMPRESSED_3D;
  63060. private static TEX_2D;
  63061. private static TEX_3D;
  63062. /**
  63063. * Gets the openGL type
  63064. */
  63065. glType: number;
  63066. /**
  63067. * Gets the openGL type size
  63068. */
  63069. glTypeSize: number;
  63070. /**
  63071. * Gets the openGL format
  63072. */
  63073. glFormat: number;
  63074. /**
  63075. * Gets the openGL internal format
  63076. */
  63077. glInternalFormat: number;
  63078. /**
  63079. * Gets the base internal format
  63080. */
  63081. glBaseInternalFormat: number;
  63082. /**
  63083. * Gets image width in pixel
  63084. */
  63085. pixelWidth: number;
  63086. /**
  63087. * Gets image height in pixel
  63088. */
  63089. pixelHeight: number;
  63090. /**
  63091. * Gets image depth in pixels
  63092. */
  63093. pixelDepth: number;
  63094. /**
  63095. * Gets the number of array elements
  63096. */
  63097. numberOfArrayElements: number;
  63098. /**
  63099. * Gets the number of faces
  63100. */
  63101. numberOfFaces: number;
  63102. /**
  63103. * Gets the number of mipmap levels
  63104. */
  63105. numberOfMipmapLevels: number;
  63106. /**
  63107. * Gets the bytes of key value data
  63108. */
  63109. bytesOfKeyValueData: number;
  63110. /**
  63111. * Gets the load type
  63112. */
  63113. loadType: number;
  63114. /**
  63115. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  63116. */
  63117. isInvalid: boolean;
  63118. /**
  63119. * Creates a new KhronosTextureContainer
  63120. * @param data contents of the KTX container file
  63121. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  63122. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  63123. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  63124. */
  63125. constructor(
  63126. /** contents of the KTX container file */
  63127. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  63128. /**
  63129. * Uploads KTX content to a Babylon Texture.
  63130. * It is assumed that the texture has already been created & is currently bound
  63131. * @hidden
  63132. */
  63133. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  63134. private _upload2DCompressedLevels;
  63135. /**
  63136. * Checks if the given data starts with a KTX file identifier.
  63137. * @param data the data to check
  63138. * @returns true if the data is a KTX file or false otherwise
  63139. */
  63140. static IsValid(data: ArrayBufferView): boolean;
  63141. }
  63142. }
  63143. declare module BABYLON {
  63144. /**
  63145. * Helper class to push actions to a pool of workers.
  63146. */
  63147. export class WorkerPool implements IDisposable {
  63148. private _workerInfos;
  63149. private _pendingActions;
  63150. /**
  63151. * Constructor
  63152. * @param workers Array of workers to use for actions
  63153. */
  63154. constructor(workers: Array<Worker>);
  63155. /**
  63156. * Terminates all workers and clears any pending actions.
  63157. */
  63158. dispose(): void;
  63159. /**
  63160. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63161. * pended until a worker has completed its action.
  63162. * @param action The action to perform. Call onComplete when the action is complete.
  63163. */
  63164. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63165. private _execute;
  63166. }
  63167. }
  63168. declare module BABYLON {
  63169. /**
  63170. * Class for loading KTX2 files
  63171. */
  63172. export class KhronosTextureContainer2 {
  63173. private static _WorkerPoolPromise?;
  63174. private static _Initialized;
  63175. private static _Ktx2Decoder;
  63176. /**
  63177. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  63178. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  63179. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  63180. * Urls you can change:
  63181. * URLConfig.jsDecoderModule
  63182. * URLConfig.wasmUASTCToASTC
  63183. * URLConfig.wasmUASTCToBC7
  63184. * URLConfig.wasmUASTCToRGBA_UNORM
  63185. * URLConfig.wasmUASTCToRGBA_SRGB
  63186. * URLConfig.jsMSCTranscoder
  63187. * URLConfig.wasmMSCTranscoder
  63188. * URLConfig.wasmZSTDDecoder
  63189. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#29
  63190. */
  63191. static URLConfig: {
  63192. jsDecoderModule: string;
  63193. wasmUASTCToASTC: null;
  63194. wasmUASTCToBC7: null;
  63195. wasmUASTCToRGBA_UNORM: null;
  63196. wasmUASTCToRGBA_SRGB: null;
  63197. jsMSCTranscoder: null;
  63198. wasmMSCTranscoder: null;
  63199. wasmZSTDDecoder: null;
  63200. };
  63201. /**
  63202. * Default number of workers used to handle data decoding
  63203. */
  63204. static DefaultNumWorkers: number;
  63205. private static GetDefaultNumWorkers;
  63206. private _engine;
  63207. private static _CreateWorkerPool;
  63208. /**
  63209. * Constructor
  63210. * @param engine The engine to use
  63211. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63212. */
  63213. constructor(engine: ThinEngine, numWorkers?: number);
  63214. /** @hidden */
  63215. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  63216. /**
  63217. * Stop all async operations and release resources.
  63218. */
  63219. dispose(): void;
  63220. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  63221. /**
  63222. * Checks if the given data starts with a KTX2 file identifier.
  63223. * @param data the data to check
  63224. * @returns true if the data is a KTX2 file or false otherwise
  63225. */
  63226. static IsValid(data: ArrayBufferView): boolean;
  63227. }
  63228. }
  63229. declare module BABYLON {
  63230. /**
  63231. * Implementation of the KTX Texture Loader.
  63232. * @hidden
  63233. */
  63234. export class _KTXTextureLoader implements IInternalTextureLoader {
  63235. /**
  63236. * Defines whether the loader supports cascade loading the different faces.
  63237. */
  63238. readonly supportCascades: boolean;
  63239. /**
  63240. * This returns if the loader support the current file information.
  63241. * @param extension defines the file extension of the file being loaded
  63242. * @param mimeType defines the optional mime type of the file being loaded
  63243. * @returns true if the loader can load the specified file
  63244. */
  63245. canLoad(extension: string, mimeType?: string): boolean;
  63246. /**
  63247. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63248. * @param data contains the texture data
  63249. * @param texture defines the BabylonJS internal texture
  63250. * @param createPolynomials will be true if polynomials have been requested
  63251. * @param onLoad defines the callback to trigger once the texture is ready
  63252. * @param onError defines the callback to trigger in case of error
  63253. */
  63254. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63255. /**
  63256. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63257. * @param data contains the texture data
  63258. * @param texture defines the BabylonJS internal texture
  63259. * @param callback defines the method to call once ready to upload
  63260. */
  63261. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  63262. }
  63263. }
  63264. declare module BABYLON {
  63265. /** @hidden */
  63266. export var _forceSceneHelpersToBundle: boolean;
  63267. interface Scene {
  63268. /**
  63269. * Creates a default light for the scene.
  63270. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  63271. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  63272. */
  63273. createDefaultLight(replace?: boolean): void;
  63274. /**
  63275. * Creates a default camera for the scene.
  63276. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  63277. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  63278. * @param replace has default false, when true replaces the active camera in the scene
  63279. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  63280. */
  63281. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  63282. /**
  63283. * Creates a default camera and a default light.
  63284. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  63285. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  63286. * @param replace has the default false, when true replaces the active camera/light in the scene
  63287. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  63288. */
  63289. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  63290. /**
  63291. * Creates a new sky box
  63292. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  63293. * @param environmentTexture defines the texture to use as environment texture
  63294. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  63295. * @param scale defines the overall scale of the skybox
  63296. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  63297. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  63298. * @returns a new mesh holding the sky box
  63299. */
  63300. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  63301. /**
  63302. * Creates a new environment
  63303. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  63304. * @param options defines the options you can use to configure the environment
  63305. * @returns the new EnvironmentHelper
  63306. */
  63307. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  63308. /**
  63309. * Creates a new VREXperienceHelper
  63310. * @see https://doc.babylonjs.com/how_to/webvr_helper
  63311. * @param webVROptions defines the options used to create the new VREXperienceHelper
  63312. * @returns a new VREXperienceHelper
  63313. */
  63314. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  63315. /**
  63316. * Creates a new WebXRDefaultExperience
  63317. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  63318. * @param options experience options
  63319. * @returns a promise for a new WebXRDefaultExperience
  63320. */
  63321. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  63322. }
  63323. }
  63324. declare module BABYLON {
  63325. /**
  63326. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  63327. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  63328. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  63329. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  63330. */
  63331. export class VideoDome extends TextureDome<VideoTexture> {
  63332. /**
  63333. * Define the video source as a Monoscopic panoramic 360 video.
  63334. */
  63335. static readonly MODE_MONOSCOPIC: number;
  63336. /**
  63337. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  63338. */
  63339. static readonly MODE_TOPBOTTOM: number;
  63340. /**
  63341. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  63342. */
  63343. static readonly MODE_SIDEBYSIDE: number;
  63344. /**
  63345. * Get the video texture associated with this video dome
  63346. */
  63347. get videoTexture(): VideoTexture;
  63348. /**
  63349. * Get the video mode of this dome
  63350. */
  63351. get videoMode(): number;
  63352. /**
  63353. * Set the video mode of this dome.
  63354. * @see textureMode
  63355. */
  63356. set videoMode(value: number);
  63357. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  63358. }
  63359. }
  63360. declare module BABYLON {
  63361. /**
  63362. * This class can be used to get instrumentation data from a Babylon engine
  63363. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  63364. */
  63365. export class EngineInstrumentation implements IDisposable {
  63366. /**
  63367. * Define the instrumented engine.
  63368. */
  63369. engine: Engine;
  63370. private _captureGPUFrameTime;
  63371. private _gpuFrameTimeToken;
  63372. private _gpuFrameTime;
  63373. private _captureShaderCompilationTime;
  63374. private _shaderCompilationTime;
  63375. private _onBeginFrameObserver;
  63376. private _onEndFrameObserver;
  63377. private _onBeforeShaderCompilationObserver;
  63378. private _onAfterShaderCompilationObserver;
  63379. /**
  63380. * Gets the perf counter used for GPU frame time
  63381. */
  63382. get gpuFrameTimeCounter(): PerfCounter;
  63383. /**
  63384. * Gets the GPU frame time capture status
  63385. */
  63386. get captureGPUFrameTime(): boolean;
  63387. /**
  63388. * Enable or disable the GPU frame time capture
  63389. */
  63390. set captureGPUFrameTime(value: boolean);
  63391. /**
  63392. * Gets the perf counter used for shader compilation time
  63393. */
  63394. get shaderCompilationTimeCounter(): PerfCounter;
  63395. /**
  63396. * Gets the shader compilation time capture status
  63397. */
  63398. get captureShaderCompilationTime(): boolean;
  63399. /**
  63400. * Enable or disable the shader compilation time capture
  63401. */
  63402. set captureShaderCompilationTime(value: boolean);
  63403. /**
  63404. * Instantiates a new engine instrumentation.
  63405. * This class can be used to get instrumentation data from a Babylon engine
  63406. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  63407. * @param engine Defines the engine to instrument
  63408. */
  63409. constructor(
  63410. /**
  63411. * Define the instrumented engine.
  63412. */
  63413. engine: Engine);
  63414. /**
  63415. * Dispose and release associated resources.
  63416. */
  63417. dispose(): void;
  63418. }
  63419. }
  63420. declare module BABYLON {
  63421. /**
  63422. * This class can be used to get instrumentation data from a Babylon engine
  63423. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  63424. */
  63425. export class SceneInstrumentation implements IDisposable {
  63426. /**
  63427. * Defines the scene to instrument
  63428. */
  63429. scene: Scene;
  63430. private _captureActiveMeshesEvaluationTime;
  63431. private _activeMeshesEvaluationTime;
  63432. private _captureRenderTargetsRenderTime;
  63433. private _renderTargetsRenderTime;
  63434. private _captureFrameTime;
  63435. private _frameTime;
  63436. private _captureRenderTime;
  63437. private _renderTime;
  63438. private _captureInterFrameTime;
  63439. private _interFrameTime;
  63440. private _captureParticlesRenderTime;
  63441. private _particlesRenderTime;
  63442. private _captureSpritesRenderTime;
  63443. private _spritesRenderTime;
  63444. private _capturePhysicsTime;
  63445. private _physicsTime;
  63446. private _captureAnimationsTime;
  63447. private _animationsTime;
  63448. private _captureCameraRenderTime;
  63449. private _cameraRenderTime;
  63450. private _onBeforeActiveMeshesEvaluationObserver;
  63451. private _onAfterActiveMeshesEvaluationObserver;
  63452. private _onBeforeRenderTargetsRenderObserver;
  63453. private _onAfterRenderTargetsRenderObserver;
  63454. private _onAfterRenderObserver;
  63455. private _onBeforeDrawPhaseObserver;
  63456. private _onAfterDrawPhaseObserver;
  63457. private _onBeforeAnimationsObserver;
  63458. private _onBeforeParticlesRenderingObserver;
  63459. private _onAfterParticlesRenderingObserver;
  63460. private _onBeforeSpritesRenderingObserver;
  63461. private _onAfterSpritesRenderingObserver;
  63462. private _onBeforePhysicsObserver;
  63463. private _onAfterPhysicsObserver;
  63464. private _onAfterAnimationsObserver;
  63465. private _onBeforeCameraRenderObserver;
  63466. private _onAfterCameraRenderObserver;
  63467. /**
  63468. * Gets the perf counter used for active meshes evaluation time
  63469. */
  63470. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  63471. /**
  63472. * Gets the active meshes evaluation time capture status
  63473. */
  63474. get captureActiveMeshesEvaluationTime(): boolean;
  63475. /**
  63476. * Enable or disable the active meshes evaluation time capture
  63477. */
  63478. set captureActiveMeshesEvaluationTime(value: boolean);
  63479. /**
  63480. * Gets the perf counter used for render targets render time
  63481. */
  63482. get renderTargetsRenderTimeCounter(): PerfCounter;
  63483. /**
  63484. * Gets the render targets render time capture status
  63485. */
  63486. get captureRenderTargetsRenderTime(): boolean;
  63487. /**
  63488. * Enable or disable the render targets render time capture
  63489. */
  63490. set captureRenderTargetsRenderTime(value: boolean);
  63491. /**
  63492. * Gets the perf counter used for particles render time
  63493. */
  63494. get particlesRenderTimeCounter(): PerfCounter;
  63495. /**
  63496. * Gets the particles render time capture status
  63497. */
  63498. get captureParticlesRenderTime(): boolean;
  63499. /**
  63500. * Enable or disable the particles render time capture
  63501. */
  63502. set captureParticlesRenderTime(value: boolean);
  63503. /**
  63504. * Gets the perf counter used for sprites render time
  63505. */
  63506. get spritesRenderTimeCounter(): PerfCounter;
  63507. /**
  63508. * Gets the sprites render time capture status
  63509. */
  63510. get captureSpritesRenderTime(): boolean;
  63511. /**
  63512. * Enable or disable the sprites render time capture
  63513. */
  63514. set captureSpritesRenderTime(value: boolean);
  63515. /**
  63516. * Gets the perf counter used for physics time
  63517. */
  63518. get physicsTimeCounter(): PerfCounter;
  63519. /**
  63520. * Gets the physics time capture status
  63521. */
  63522. get capturePhysicsTime(): boolean;
  63523. /**
  63524. * Enable or disable the physics time capture
  63525. */
  63526. set capturePhysicsTime(value: boolean);
  63527. /**
  63528. * Gets the perf counter used for animations time
  63529. */
  63530. get animationsTimeCounter(): PerfCounter;
  63531. /**
  63532. * Gets the animations time capture status
  63533. */
  63534. get captureAnimationsTime(): boolean;
  63535. /**
  63536. * Enable or disable the animations time capture
  63537. */
  63538. set captureAnimationsTime(value: boolean);
  63539. /**
  63540. * Gets the perf counter used for frame time capture
  63541. */
  63542. get frameTimeCounter(): PerfCounter;
  63543. /**
  63544. * Gets the frame time capture status
  63545. */
  63546. get captureFrameTime(): boolean;
  63547. /**
  63548. * Enable or disable the frame time capture
  63549. */
  63550. set captureFrameTime(value: boolean);
  63551. /**
  63552. * Gets the perf counter used for inter-frames time capture
  63553. */
  63554. get interFrameTimeCounter(): PerfCounter;
  63555. /**
  63556. * Gets the inter-frames time capture status
  63557. */
  63558. get captureInterFrameTime(): boolean;
  63559. /**
  63560. * Enable or disable the inter-frames time capture
  63561. */
  63562. set captureInterFrameTime(value: boolean);
  63563. /**
  63564. * Gets the perf counter used for render time capture
  63565. */
  63566. get renderTimeCounter(): PerfCounter;
  63567. /**
  63568. * Gets the render time capture status
  63569. */
  63570. get captureRenderTime(): boolean;
  63571. /**
  63572. * Enable or disable the render time capture
  63573. */
  63574. set captureRenderTime(value: boolean);
  63575. /**
  63576. * Gets the perf counter used for camera render time capture
  63577. */
  63578. get cameraRenderTimeCounter(): PerfCounter;
  63579. /**
  63580. * Gets the camera render time capture status
  63581. */
  63582. get captureCameraRenderTime(): boolean;
  63583. /**
  63584. * Enable or disable the camera render time capture
  63585. */
  63586. set captureCameraRenderTime(value: boolean);
  63587. /**
  63588. * Gets the perf counter used for draw calls
  63589. */
  63590. get drawCallsCounter(): PerfCounter;
  63591. /**
  63592. * Instantiates a new scene instrumentation.
  63593. * This class can be used to get instrumentation data from a Babylon engine
  63594. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  63595. * @param scene Defines the scene to instrument
  63596. */
  63597. constructor(
  63598. /**
  63599. * Defines the scene to instrument
  63600. */
  63601. scene: Scene);
  63602. /**
  63603. * Dispose and release associated resources.
  63604. */
  63605. dispose(): void;
  63606. }
  63607. }
  63608. declare module BABYLON {
  63609. /** @hidden */
  63610. export var glowMapGenerationPixelShader: {
  63611. name: string;
  63612. shader: string;
  63613. };
  63614. }
  63615. declare module BABYLON {
  63616. /** @hidden */
  63617. export var glowMapGenerationVertexShader: {
  63618. name: string;
  63619. shader: string;
  63620. };
  63621. }
  63622. declare module BABYLON {
  63623. /**
  63624. * Effect layer options. This helps customizing the behaviour
  63625. * of the effect layer.
  63626. */
  63627. export interface IEffectLayerOptions {
  63628. /**
  63629. * Multiplication factor apply to the canvas size to compute the render target size
  63630. * used to generated the objects (the smaller the faster).
  63631. */
  63632. mainTextureRatio: number;
  63633. /**
  63634. * Enforces a fixed size texture to ensure effect stability across devices.
  63635. */
  63636. mainTextureFixedSize?: number;
  63637. /**
  63638. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  63639. */
  63640. alphaBlendingMode: number;
  63641. /**
  63642. * The camera attached to the layer.
  63643. */
  63644. camera: Nullable<Camera>;
  63645. /**
  63646. * The rendering group to draw the layer in.
  63647. */
  63648. renderingGroupId: number;
  63649. }
  63650. /**
  63651. * The effect layer Helps adding post process effect blended with the main pass.
  63652. *
  63653. * This can be for instance use to generate glow or highlight effects on the scene.
  63654. *
  63655. * The effect layer class can not be used directly and is intented to inherited from to be
  63656. * customized per effects.
  63657. */
  63658. export abstract class EffectLayer {
  63659. private _vertexBuffers;
  63660. private _indexBuffer;
  63661. private _cachedDefines;
  63662. private _effectLayerMapGenerationEffect;
  63663. private _effectLayerOptions;
  63664. private _mergeEffect;
  63665. protected _scene: Scene;
  63666. protected _engine: Engine;
  63667. protected _maxSize: number;
  63668. protected _mainTextureDesiredSize: ISize;
  63669. protected _mainTexture: RenderTargetTexture;
  63670. protected _shouldRender: boolean;
  63671. protected _postProcesses: PostProcess[];
  63672. protected _textures: BaseTexture[];
  63673. protected _emissiveTextureAndColor: {
  63674. texture: Nullable<BaseTexture>;
  63675. color: Color4;
  63676. };
  63677. /**
  63678. * The name of the layer
  63679. */
  63680. name: string;
  63681. /**
  63682. * The clear color of the texture used to generate the glow map.
  63683. */
  63684. neutralColor: Color4;
  63685. /**
  63686. * Specifies whether the highlight layer is enabled or not.
  63687. */
  63688. isEnabled: boolean;
  63689. /**
  63690. * Gets the camera attached to the layer.
  63691. */
  63692. get camera(): Nullable<Camera>;
  63693. /**
  63694. * Gets the rendering group id the layer should render in.
  63695. */
  63696. get renderingGroupId(): number;
  63697. set renderingGroupId(renderingGroupId: number);
  63698. /**
  63699. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  63700. */
  63701. disableBoundingBoxesFromEffectLayer: boolean;
  63702. /**
  63703. * An event triggered when the effect layer has been disposed.
  63704. */
  63705. onDisposeObservable: Observable<EffectLayer>;
  63706. /**
  63707. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  63708. */
  63709. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  63710. /**
  63711. * An event triggered when the generated texture is being merged in the scene.
  63712. */
  63713. onBeforeComposeObservable: Observable<EffectLayer>;
  63714. /**
  63715. * An event triggered when the mesh is rendered into the effect render target.
  63716. */
  63717. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  63718. /**
  63719. * An event triggered after the mesh has been rendered into the effect render target.
  63720. */
  63721. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  63722. /**
  63723. * An event triggered when the generated texture has been merged in the scene.
  63724. */
  63725. onAfterComposeObservable: Observable<EffectLayer>;
  63726. /**
  63727. * An event triggered when the effect layer changes its size.
  63728. */
  63729. onSizeChangedObservable: Observable<EffectLayer>;
  63730. /** @hidden */
  63731. static _SceneComponentInitialization: (scene: Scene) => void;
  63732. /**
  63733. * Instantiates a new effect Layer and references it in the scene.
  63734. * @param name The name of the layer
  63735. * @param scene The scene to use the layer in
  63736. */
  63737. constructor(
  63738. /** The Friendly of the effect in the scene */
  63739. name: string, scene: Scene);
  63740. /**
  63741. * Get the effect name of the layer.
  63742. * @return The effect name
  63743. */
  63744. abstract getEffectName(): string;
  63745. /**
  63746. * Checks for the readiness of the element composing the layer.
  63747. * @param subMesh the mesh to check for
  63748. * @param useInstances specify whether or not to use instances to render the mesh
  63749. * @return true if ready otherwise, false
  63750. */
  63751. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63752. /**
  63753. * Returns whether or not the layer needs stencil enabled during the mesh rendering.
  63754. * @returns true if the effect requires stencil during the main canvas render pass.
  63755. */
  63756. abstract needStencil(): boolean;
  63757. /**
  63758. * Create the merge effect. This is the shader use to blit the information back
  63759. * to the main canvas at the end of the scene rendering.
  63760. * @returns The effect containing the shader used to merge the effect on the main canvas
  63761. */
  63762. protected abstract _createMergeEffect(): Effect;
  63763. /**
  63764. * Creates the render target textures and post processes used in the effect layer.
  63765. */
  63766. protected abstract _createTextureAndPostProcesses(): void;
  63767. /**
  63768. * Implementation specific of rendering the generating effect on the main canvas.
  63769. * @param effect The effect used to render through
  63770. */
  63771. protected abstract _internalRender(effect: Effect): void;
  63772. /**
  63773. * Sets the required values for both the emissive texture and and the main color.
  63774. */
  63775. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63776. /**
  63777. * Free any resources and references associated to a mesh.
  63778. * Internal use
  63779. * @param mesh The mesh to free.
  63780. */
  63781. abstract _disposeMesh(mesh: Mesh): void;
  63782. /**
  63783. * Serializes this layer (Glow or Highlight for example)
  63784. * @returns a serialized layer object
  63785. */
  63786. abstract serialize?(): any;
  63787. /**
  63788. * Initializes the effect layer with the required options.
  63789. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  63790. */
  63791. protected _init(options: Partial<IEffectLayerOptions>): void;
  63792. /**
  63793. * Generates the index buffer of the full screen quad blending to the main canvas.
  63794. */
  63795. private _generateIndexBuffer;
  63796. /**
  63797. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  63798. */
  63799. private _generateVertexBuffer;
  63800. /**
  63801. * Sets the main texture desired size which is the closest power of two
  63802. * of the engine canvas size.
  63803. */
  63804. private _setMainTextureSize;
  63805. /**
  63806. * Creates the main texture for the effect layer.
  63807. */
  63808. protected _createMainTexture(): void;
  63809. /**
  63810. * Adds specific effects defines.
  63811. * @param defines The defines to add specifics to.
  63812. */
  63813. protected _addCustomEffectDefines(defines: string[]): void;
  63814. /**
  63815. * Checks for the readiness of the element composing the layer.
  63816. * @param subMesh the mesh to check for
  63817. * @param useInstances specify whether or not to use instances to render the mesh
  63818. * @param emissiveTexture the associated emissive texture used to generate the glow
  63819. * @return true if ready otherwise, false
  63820. */
  63821. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  63822. /**
  63823. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  63824. */
  63825. render(): void;
  63826. /**
  63827. * Determine if a given mesh will be used in the current effect.
  63828. * @param mesh mesh to test
  63829. * @returns true if the mesh will be used
  63830. */
  63831. hasMesh(mesh: AbstractMesh): boolean;
  63832. /**
  63833. * Returns true if the layer contains information to display, otherwise false.
  63834. * @returns true if the glow layer should be rendered
  63835. */
  63836. shouldRender(): boolean;
  63837. /**
  63838. * Returns true if the mesh should render, otherwise false.
  63839. * @param mesh The mesh to render
  63840. * @returns true if it should render otherwise false
  63841. */
  63842. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  63843. /**
  63844. * Returns true if the mesh can be rendered, otherwise false.
  63845. * @param mesh The mesh to render
  63846. * @param material The material used on the mesh
  63847. * @returns true if it can be rendered otherwise false
  63848. */
  63849. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63850. /**
  63851. * Returns true if the mesh should render, otherwise false.
  63852. * @param mesh The mesh to render
  63853. * @returns true if it should render otherwise false
  63854. */
  63855. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  63856. /**
  63857. * Renders the submesh passed in parameter to the generation map.
  63858. */
  63859. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  63860. /**
  63861. * Defines whether the current material of the mesh should be use to render the effect.
  63862. * @param mesh defines the current mesh to render
  63863. */
  63864. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  63865. /**
  63866. * Rebuild the required buffers.
  63867. * @hidden Internal use only.
  63868. */
  63869. _rebuild(): void;
  63870. /**
  63871. * Dispose only the render target textures and post process.
  63872. */
  63873. private _disposeTextureAndPostProcesses;
  63874. /**
  63875. * Dispose the highlight layer and free resources.
  63876. */
  63877. dispose(): void;
  63878. /**
  63879. * Gets the class name of the effect layer
  63880. * @returns the string with the class name of the effect layer
  63881. */
  63882. getClassName(): string;
  63883. /**
  63884. * Creates an effect layer from parsed effect layer data
  63885. * @param parsedEffectLayer defines effect layer data
  63886. * @param scene defines the current scene
  63887. * @param rootUrl defines the root URL containing the effect layer information
  63888. * @returns a parsed effect Layer
  63889. */
  63890. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  63891. }
  63892. }
  63893. declare module BABYLON {
  63894. interface AbstractScene {
  63895. /**
  63896. * The list of effect layers (highlights/glow) added to the scene
  63897. * @see https://doc.babylonjs.com/how_to/highlight_layer
  63898. * @see https://doc.babylonjs.com/how_to/glow_layer
  63899. */
  63900. effectLayers: Array<EffectLayer>;
  63901. /**
  63902. * Removes the given effect layer from this scene.
  63903. * @param toRemove defines the effect layer to remove
  63904. * @returns the index of the removed effect layer
  63905. */
  63906. removeEffectLayer(toRemove: EffectLayer): number;
  63907. /**
  63908. * Adds the given effect layer to this scene
  63909. * @param newEffectLayer defines the effect layer to add
  63910. */
  63911. addEffectLayer(newEffectLayer: EffectLayer): void;
  63912. }
  63913. /**
  63914. * Defines the layer scene component responsible to manage any effect layers
  63915. * in a given scene.
  63916. */
  63917. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  63918. /**
  63919. * The component name helpful to identify the component in the list of scene components.
  63920. */
  63921. readonly name: string;
  63922. /**
  63923. * The scene the component belongs to.
  63924. */
  63925. scene: Scene;
  63926. private _engine;
  63927. private _renderEffects;
  63928. private _needStencil;
  63929. private _previousStencilState;
  63930. /**
  63931. * Creates a new instance of the component for the given scene
  63932. * @param scene Defines the scene to register the component in
  63933. */
  63934. constructor(scene: Scene);
  63935. /**
  63936. * Registers the component in a given scene
  63937. */
  63938. register(): void;
  63939. /**
  63940. * Rebuilds the elements related to this component in case of
  63941. * context lost for instance.
  63942. */
  63943. rebuild(): void;
  63944. /**
  63945. * Serializes the component data to the specified json object
  63946. * @param serializationObject The object to serialize to
  63947. */
  63948. serialize(serializationObject: any): void;
  63949. /**
  63950. * Adds all the elements from the container to the scene
  63951. * @param container the container holding the elements
  63952. */
  63953. addFromContainer(container: AbstractScene): void;
  63954. /**
  63955. * Removes all the elements in the container from the scene
  63956. * @param container contains the elements to remove
  63957. * @param dispose if the removed element should be disposed (default: false)
  63958. */
  63959. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63960. /**
  63961. * Disposes the component and the associated resources.
  63962. */
  63963. dispose(): void;
  63964. private _isReadyForMesh;
  63965. private _renderMainTexture;
  63966. private _setStencil;
  63967. private _setStencilBack;
  63968. private _draw;
  63969. private _drawCamera;
  63970. private _drawRenderingGroup;
  63971. }
  63972. }
  63973. declare module BABYLON {
  63974. /** @hidden */
  63975. export var glowMapMergePixelShader: {
  63976. name: string;
  63977. shader: string;
  63978. };
  63979. }
  63980. declare module BABYLON {
  63981. /** @hidden */
  63982. export var glowMapMergeVertexShader: {
  63983. name: string;
  63984. shader: string;
  63985. };
  63986. }
  63987. declare module BABYLON {
  63988. interface AbstractScene {
  63989. /**
  63990. * Return a the first highlight layer of the scene with a given name.
  63991. * @param name The name of the highlight layer to look for.
  63992. * @return The highlight layer if found otherwise null.
  63993. */
  63994. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  63995. }
  63996. /**
  63997. * Glow layer options. This helps customizing the behaviour
  63998. * of the glow layer.
  63999. */
  64000. export interface IGlowLayerOptions {
  64001. /**
  64002. * Multiplication factor apply to the canvas size to compute the render target size
  64003. * used to generated the glowing objects (the smaller the faster).
  64004. */
  64005. mainTextureRatio: number;
  64006. /**
  64007. * Enforces a fixed size texture to ensure resize independent blur.
  64008. */
  64009. mainTextureFixedSize?: number;
  64010. /**
  64011. * How big is the kernel of the blur texture.
  64012. */
  64013. blurKernelSize: number;
  64014. /**
  64015. * The camera attached to the layer.
  64016. */
  64017. camera: Nullable<Camera>;
  64018. /**
  64019. * Enable MSAA by choosing the number of samples.
  64020. */
  64021. mainTextureSamples?: number;
  64022. /**
  64023. * The rendering group to draw the layer in.
  64024. */
  64025. renderingGroupId: number;
  64026. }
  64027. /**
  64028. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  64029. *
  64030. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  64031. *
  64032. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  64033. */
  64034. export class GlowLayer extends EffectLayer {
  64035. /**
  64036. * Effect Name of the layer.
  64037. */
  64038. static readonly EffectName: string;
  64039. /**
  64040. * The default blur kernel size used for the glow.
  64041. */
  64042. static DefaultBlurKernelSize: number;
  64043. /**
  64044. * The default texture size ratio used for the glow.
  64045. */
  64046. static DefaultTextureRatio: number;
  64047. /**
  64048. * Sets the kernel size of the blur.
  64049. */
  64050. set blurKernelSize(value: number);
  64051. /**
  64052. * Gets the kernel size of the blur.
  64053. */
  64054. get blurKernelSize(): number;
  64055. /**
  64056. * Sets the glow intensity.
  64057. */
  64058. set intensity(value: number);
  64059. /**
  64060. * Gets the glow intensity.
  64061. */
  64062. get intensity(): number;
  64063. private _options;
  64064. private _intensity;
  64065. private _horizontalBlurPostprocess1;
  64066. private _verticalBlurPostprocess1;
  64067. private _horizontalBlurPostprocess2;
  64068. private _verticalBlurPostprocess2;
  64069. private _blurTexture1;
  64070. private _blurTexture2;
  64071. private _postProcesses1;
  64072. private _postProcesses2;
  64073. private _includedOnlyMeshes;
  64074. private _excludedMeshes;
  64075. private _meshesUsingTheirOwnMaterials;
  64076. /**
  64077. * Callback used to let the user override the color selection on a per mesh basis
  64078. */
  64079. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  64080. /**
  64081. * Callback used to let the user override the texture selection on a per mesh basis
  64082. */
  64083. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  64084. /**
  64085. * Instantiates a new glow Layer and references it to the scene.
  64086. * @param name The name of the layer
  64087. * @param scene The scene to use the layer in
  64088. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  64089. */
  64090. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  64091. /**
  64092. * Get the effect name of the layer.
  64093. * @return The effect name
  64094. */
  64095. getEffectName(): string;
  64096. /**
  64097. * Create the merge effect. This is the shader use to blit the information back
  64098. * to the main canvas at the end of the scene rendering.
  64099. */
  64100. protected _createMergeEffect(): Effect;
  64101. /**
  64102. * Creates the render target textures and post processes used in the glow layer.
  64103. */
  64104. protected _createTextureAndPostProcesses(): void;
  64105. /**
  64106. * Checks for the readiness of the element composing the layer.
  64107. * @param subMesh the mesh to check for
  64108. * @param useInstances specify whether or not to use instances to render the mesh
  64109. * @param emissiveTexture the associated emissive texture used to generate the glow
  64110. * @return true if ready otherwise, false
  64111. */
  64112. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64113. /**
  64114. * Returns whether or not the layer needs stencil enabled during the mesh rendering.
  64115. */
  64116. needStencil(): boolean;
  64117. /**
  64118. * Returns true if the mesh can be rendered, otherwise false.
  64119. * @param mesh The mesh to render
  64120. * @param material The material used on the mesh
  64121. * @returns true if it can be rendered otherwise false
  64122. */
  64123. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  64124. /**
  64125. * Implementation specific of rendering the generating effect on the main canvas.
  64126. * @param effect The effect used to render through
  64127. */
  64128. protected _internalRender(effect: Effect): void;
  64129. /**
  64130. * Sets the required values for both the emissive texture and and the main color.
  64131. */
  64132. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  64133. /**
  64134. * Returns true if the mesh should render, otherwise false.
  64135. * @param mesh The mesh to render
  64136. * @returns true if it should render otherwise false
  64137. */
  64138. protected _shouldRenderMesh(mesh: Mesh): boolean;
  64139. /**
  64140. * Adds specific effects defines.
  64141. * @param defines The defines to add specifics to.
  64142. */
  64143. protected _addCustomEffectDefines(defines: string[]): void;
  64144. /**
  64145. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  64146. * @param mesh The mesh to exclude from the glow layer
  64147. */
  64148. addExcludedMesh(mesh: Mesh): void;
  64149. /**
  64150. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  64151. * @param mesh The mesh to remove
  64152. */
  64153. removeExcludedMesh(mesh: Mesh): void;
  64154. /**
  64155. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  64156. * @param mesh The mesh to include in the glow layer
  64157. */
  64158. addIncludedOnlyMesh(mesh: Mesh): void;
  64159. /**
  64160. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  64161. * @param mesh The mesh to remove
  64162. */
  64163. removeIncludedOnlyMesh(mesh: Mesh): void;
  64164. /**
  64165. * Determine if a given mesh will be used in the glow layer
  64166. * @param mesh The mesh to test
  64167. * @returns true if the mesh will be highlighted by the current glow layer
  64168. */
  64169. hasMesh(mesh: AbstractMesh): boolean;
  64170. /**
  64171. * Defines whether the current material of the mesh should be use to render the effect.
  64172. * @param mesh defines the current mesh to render
  64173. */
  64174. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  64175. /**
  64176. * Add a mesh to be rendered through its own material and not with emissive only.
  64177. * @param mesh The mesh for which we need to use its material
  64178. */
  64179. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  64180. /**
  64181. * Remove a mesh from being rendered through its own material and not with emissive only.
  64182. * @param mesh The mesh for which we need to not use its material
  64183. */
  64184. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  64185. /**
  64186. * Free any resources and references associated to a mesh.
  64187. * Internal use
  64188. * @param mesh The mesh to free.
  64189. * @hidden
  64190. */
  64191. _disposeMesh(mesh: Mesh): void;
  64192. /**
  64193. * Gets the class name of the effect layer
  64194. * @returns the string with the class name of the effect layer
  64195. */
  64196. getClassName(): string;
  64197. /**
  64198. * Serializes this glow layer
  64199. * @returns a serialized glow layer object
  64200. */
  64201. serialize(): any;
  64202. /**
  64203. * Creates a Glow Layer from parsed glow layer data
  64204. * @param parsedGlowLayer defines glow layer data
  64205. * @param scene defines the current scene
  64206. * @param rootUrl defines the root URL containing the glow layer information
  64207. * @returns a parsed Glow Layer
  64208. */
  64209. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  64210. }
  64211. }
  64212. declare module BABYLON {
  64213. /** @hidden */
  64214. export var glowBlurPostProcessPixelShader: {
  64215. name: string;
  64216. shader: string;
  64217. };
  64218. }
  64219. declare module BABYLON {
  64220. interface AbstractScene {
  64221. /**
  64222. * Return a the first highlight layer of the scene with a given name.
  64223. * @param name The name of the highlight layer to look for.
  64224. * @return The highlight layer if found otherwise null.
  64225. */
  64226. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  64227. }
  64228. /**
  64229. * Highlight layer options. This helps customizing the behaviour
  64230. * of the highlight layer.
  64231. */
  64232. export interface IHighlightLayerOptions {
  64233. /**
  64234. * Multiplication factor apply to the canvas size to compute the render target size
  64235. * used to generated the glowing objects (the smaller the faster).
  64236. */
  64237. mainTextureRatio: number;
  64238. /**
  64239. * Enforces a fixed size texture to ensure resize independent blur.
  64240. */
  64241. mainTextureFixedSize?: number;
  64242. /**
  64243. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  64244. * of the picture to blur (the smaller the faster).
  64245. */
  64246. blurTextureSizeRatio: number;
  64247. /**
  64248. * How big in texel of the blur texture is the vertical blur.
  64249. */
  64250. blurVerticalSize: number;
  64251. /**
  64252. * How big in texel of the blur texture is the horizontal blur.
  64253. */
  64254. blurHorizontalSize: number;
  64255. /**
  64256. * Alpha blending mode used to apply the blur. Default is combine.
  64257. */
  64258. alphaBlendingMode: number;
  64259. /**
  64260. * The camera attached to the layer.
  64261. */
  64262. camera: Nullable<Camera>;
  64263. /**
  64264. * Should we display highlight as a solid stroke?
  64265. */
  64266. isStroke?: boolean;
  64267. /**
  64268. * The rendering group to draw the layer in.
  64269. */
  64270. renderingGroupId: number;
  64271. }
  64272. /**
  64273. * The highlight layer Helps adding a glow effect around a mesh.
  64274. *
  64275. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  64276. * glowy meshes to your scene.
  64277. *
  64278. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  64279. */
  64280. export class HighlightLayer extends EffectLayer {
  64281. name: string;
  64282. /**
  64283. * Effect Name of the highlight layer.
  64284. */
  64285. static readonly EffectName: string;
  64286. /**
  64287. * The neutral color used during the preparation of the glow effect.
  64288. * This is black by default as the blend operation is a blend operation.
  64289. */
  64290. static NeutralColor: Color4;
  64291. /**
  64292. * Stencil value used for glowing meshes.
  64293. */
  64294. static GlowingMeshStencilReference: number;
  64295. /**
  64296. * Stencil value used for the other meshes in the scene.
  64297. */
  64298. static NormalMeshStencilReference: number;
  64299. /**
  64300. * Specifies whether or not the inner glow is ACTIVE in the layer.
  64301. */
  64302. innerGlow: boolean;
  64303. /**
  64304. * Specifies whether or not the outer glow is ACTIVE in the layer.
  64305. */
  64306. outerGlow: boolean;
  64307. /**
  64308. * Specifies the horizontal size of the blur.
  64309. */
  64310. set blurHorizontalSize(value: number);
  64311. /**
  64312. * Specifies the vertical size of the blur.
  64313. */
  64314. set blurVerticalSize(value: number);
  64315. /**
  64316. * Gets the horizontal size of the blur.
  64317. */
  64318. get blurHorizontalSize(): number;
  64319. /**
  64320. * Gets the vertical size of the blur.
  64321. */
  64322. get blurVerticalSize(): number;
  64323. /**
  64324. * An event triggered when the highlight layer is being blurred.
  64325. */
  64326. onBeforeBlurObservable: Observable<HighlightLayer>;
  64327. /**
  64328. * An event triggered when the highlight layer has been blurred.
  64329. */
  64330. onAfterBlurObservable: Observable<HighlightLayer>;
  64331. private _instanceGlowingMeshStencilReference;
  64332. private _options;
  64333. private _downSamplePostprocess;
  64334. private _horizontalBlurPostprocess;
  64335. private _verticalBlurPostprocess;
  64336. private _blurTexture;
  64337. private _meshes;
  64338. private _excludedMeshes;
  64339. /**
  64340. * Instantiates a new highlight Layer and references it to the scene..
  64341. * @param name The name of the layer
  64342. * @param scene The scene to use the layer in
  64343. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  64344. */
  64345. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  64346. /**
  64347. * Get the effect name of the layer.
  64348. * @return The effect name
  64349. */
  64350. getEffectName(): string;
  64351. /**
  64352. * Create the merge effect. This is the shader use to blit the information back
  64353. * to the main canvas at the end of the scene rendering.
  64354. */
  64355. protected _createMergeEffect(): Effect;
  64356. /**
  64357. * Creates the render target textures and post processes used in the highlight layer.
  64358. */
  64359. protected _createTextureAndPostProcesses(): void;
  64360. /**
  64361. * Returns whether or not the layer needs stencil enabled during the mesh rendering.
  64362. */
  64363. needStencil(): boolean;
  64364. /**
  64365. * Checks for the readiness of the element composing the layer.
  64366. * @param subMesh the mesh to check for
  64367. * @param useInstances specify wether or not to use instances to render the mesh
  64368. * @param emissiveTexture the associated emissive texture used to generate the glow
  64369. * @return true if ready otherwise, false
  64370. */
  64371. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64372. /**
  64373. * Implementation specific of rendering the generating effect on the main canvas.
  64374. * @param effect The effect used to render through
  64375. */
  64376. protected _internalRender(effect: Effect): void;
  64377. /**
  64378. * Returns true if the layer contains information to display, otherwise false.
  64379. */
  64380. shouldRender(): boolean;
  64381. /**
  64382. * Returns true if the mesh should render, otherwise false.
  64383. * @param mesh The mesh to render
  64384. * @returns true if it should render otherwise false
  64385. */
  64386. protected _shouldRenderMesh(mesh: Mesh): boolean;
  64387. /**
  64388. * Returns true if the mesh can be rendered, otherwise false.
  64389. * @param mesh The mesh to render
  64390. * @param material The material used on the mesh
  64391. * @returns true if it can be rendered otherwise false
  64392. */
  64393. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  64394. /**
  64395. * Adds specific effects defines.
  64396. * @param defines The defines to add specifics to.
  64397. */
  64398. protected _addCustomEffectDefines(defines: string[]): void;
  64399. /**
  64400. * Sets the required values for both the emissive texture and and the main color.
  64401. */
  64402. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  64403. /**
  64404. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  64405. * @param mesh The mesh to exclude from the highlight layer
  64406. */
  64407. addExcludedMesh(mesh: Mesh): void;
  64408. /**
  64409. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  64410. * @param mesh The mesh to highlight
  64411. */
  64412. removeExcludedMesh(mesh: Mesh): void;
  64413. /**
  64414. * Determine if a given mesh will be highlighted by the current HighlightLayer
  64415. * @param mesh mesh to test
  64416. * @returns true if the mesh will be highlighted by the current HighlightLayer
  64417. */
  64418. hasMesh(mesh: AbstractMesh): boolean;
  64419. /**
  64420. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  64421. * @param mesh The mesh to highlight
  64422. * @param color The color of the highlight
  64423. * @param glowEmissiveOnly Extract the glow from the emissive texture
  64424. */
  64425. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  64426. /**
  64427. * Remove a mesh from the highlight layer in order to make it stop glowing.
  64428. * @param mesh The mesh to highlight
  64429. */
  64430. removeMesh(mesh: Mesh): void;
  64431. /**
  64432. * Remove all the meshes currently referenced in the highlight layer
  64433. */
  64434. removeAllMeshes(): void;
  64435. /**
  64436. * Force the stencil to the normal expected value for none glowing parts
  64437. */
  64438. private _defaultStencilReference;
  64439. /**
  64440. * Free any resources and references associated to a mesh.
  64441. * Internal use
  64442. * @param mesh The mesh to free.
  64443. * @hidden
  64444. */
  64445. _disposeMesh(mesh: Mesh): void;
  64446. /**
  64447. * Dispose the highlight layer and free resources.
  64448. */
  64449. dispose(): void;
  64450. /**
  64451. * Gets the class name of the effect layer
  64452. * @returns the string with the class name of the effect layer
  64453. */
  64454. getClassName(): string;
  64455. /**
  64456. * Serializes this Highlight layer
  64457. * @returns a serialized Highlight layer object
  64458. */
  64459. serialize(): any;
  64460. /**
  64461. * Creates a Highlight layer from parsed Highlight layer data
  64462. * @param parsedHightlightLayer defines the Highlight layer data
  64463. * @param scene defines the current scene
  64464. * @param rootUrl defines the root URL containing the Highlight layer information
  64465. * @returns a parsed Highlight layer
  64466. */
  64467. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  64468. }
  64469. }
  64470. declare module BABYLON {
  64471. interface AbstractScene {
  64472. /**
  64473. * The list of layers (background and foreground) of the scene
  64474. */
  64475. layers: Array<Layer>;
  64476. }
  64477. /**
  64478. * Defines the layer scene component responsible to manage any layers
  64479. * in a given scene.
  64480. */
  64481. export class LayerSceneComponent implements ISceneComponent {
  64482. /**
  64483. * The component name helpful to identify the component in the list of scene components.
  64484. */
  64485. readonly name: string;
  64486. /**
  64487. * The scene the component belongs to.
  64488. */
  64489. scene: Scene;
  64490. private _engine;
  64491. /**
  64492. * Creates a new instance of the component for the given scene
  64493. * @param scene Defines the scene to register the component in
  64494. */
  64495. constructor(scene: Scene);
  64496. /**
  64497. * Registers the component in a given scene
  64498. */
  64499. register(): void;
  64500. /**
  64501. * Rebuilds the elements related to this component in case of
  64502. * context lost for instance.
  64503. */
  64504. rebuild(): void;
  64505. /**
  64506. * Disposes the component and the associated resources.
  64507. */
  64508. dispose(): void;
  64509. private _draw;
  64510. private _drawCameraPredicate;
  64511. private _drawCameraBackground;
  64512. private _drawCameraForeground;
  64513. private _drawRenderTargetPredicate;
  64514. private _drawRenderTargetBackground;
  64515. private _drawRenderTargetForeground;
  64516. /**
  64517. * Adds all the elements from the container to the scene
  64518. * @param container the container holding the elements
  64519. */
  64520. addFromContainer(container: AbstractScene): void;
  64521. /**
  64522. * Removes all the elements in the container from the scene
  64523. * @param container contains the elements to remove
  64524. * @param dispose if the removed element should be disposed (default: false)
  64525. */
  64526. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  64527. }
  64528. }
  64529. declare module BABYLON {
  64530. /** @hidden */
  64531. export var layerPixelShader: {
  64532. name: string;
  64533. shader: string;
  64534. };
  64535. }
  64536. declare module BABYLON {
  64537. /** @hidden */
  64538. export var layerVertexShader: {
  64539. name: string;
  64540. shader: string;
  64541. };
  64542. }
  64543. declare module BABYLON {
  64544. /**
  64545. * This represents a full screen 2d layer.
  64546. * This can be useful to display a picture in the background of your scene for instance.
  64547. * @see https://www.babylonjs-playground.com/#08A2BS#1
  64548. */
  64549. export class Layer {
  64550. /**
  64551. * Define the name of the layer.
  64552. */
  64553. name: string;
  64554. /**
  64555. * Define the texture the layer should display.
  64556. */
  64557. texture: Nullable<Texture>;
  64558. /**
  64559. * Is the layer in background or foreground.
  64560. */
  64561. isBackground: boolean;
  64562. /**
  64563. * Define the color of the layer (instead of texture).
  64564. */
  64565. color: Color4;
  64566. /**
  64567. * Define the scale of the layer in order to zoom in out of the texture.
  64568. */
  64569. scale: Vector2;
  64570. /**
  64571. * Define an offset for the layer in order to shift the texture.
  64572. */
  64573. offset: Vector2;
  64574. /**
  64575. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  64576. */
  64577. alphaBlendingMode: number;
  64578. /**
  64579. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  64580. * Alpha test will not mix with the background color in case of transparency.
  64581. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  64582. */
  64583. alphaTest: boolean;
  64584. /**
  64585. * Define a mask to restrict the layer to only some of the scene cameras.
  64586. */
  64587. layerMask: number;
  64588. /**
  64589. * Define the list of render target the layer is visible into.
  64590. */
  64591. renderTargetTextures: RenderTargetTexture[];
  64592. /**
  64593. * Define if the layer is only used in renderTarget or if it also
  64594. * renders in the main frame buffer of the canvas.
  64595. */
  64596. renderOnlyInRenderTargetTextures: boolean;
  64597. private _scene;
  64598. private _vertexBuffers;
  64599. private _indexBuffer;
  64600. private _effect;
  64601. private _previousDefines;
  64602. /**
  64603. * An event triggered when the layer is disposed.
  64604. */
  64605. onDisposeObservable: Observable<Layer>;
  64606. private _onDisposeObserver;
  64607. /**
  64608. * Back compatibility with callback before the onDisposeObservable existed.
  64609. * The set callback will be triggered when the layer has been disposed.
  64610. */
  64611. set onDispose(callback: () => void);
  64612. /**
  64613. * An event triggered before rendering the scene
  64614. */
  64615. onBeforeRenderObservable: Observable<Layer>;
  64616. private _onBeforeRenderObserver;
  64617. /**
  64618. * Back compatibility with callback before the onBeforeRenderObservable existed.
  64619. * The set callback will be triggered just before rendering the layer.
  64620. */
  64621. set onBeforeRender(callback: () => void);
  64622. /**
  64623. * An event triggered after rendering the scene
  64624. */
  64625. onAfterRenderObservable: Observable<Layer>;
  64626. private _onAfterRenderObserver;
  64627. /**
  64628. * Back compatibility with callback before the onAfterRenderObservable existed.
  64629. * The set callback will be triggered just after rendering the layer.
  64630. */
  64631. set onAfterRender(callback: () => void);
  64632. /**
  64633. * Instantiates a new layer.
  64634. * This represents a full screen 2d layer.
  64635. * This can be useful to display a picture in the background of your scene for instance.
  64636. * @see https://www.babylonjs-playground.com/#08A2BS#1
  64637. * @param name Define the name of the layer in the scene
  64638. * @param imgUrl Define the url of the texture to display in the layer
  64639. * @param scene Define the scene the layer belongs to
  64640. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  64641. * @param color Defines a color for the layer
  64642. */
  64643. constructor(
  64644. /**
  64645. * Define the name of the layer.
  64646. */
  64647. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  64648. private _createIndexBuffer;
  64649. /** @hidden */
  64650. _rebuild(): void;
  64651. /**
  64652. * Renders the layer in the scene.
  64653. */
  64654. render(): void;
  64655. /**
  64656. * Disposes and releases the associated resources.
  64657. */
  64658. dispose(): void;
  64659. }
  64660. }
  64661. declare module BABYLON {
  64662. /** @hidden */
  64663. export var lensFlarePixelShader: {
  64664. name: string;
  64665. shader: string;
  64666. };
  64667. }
  64668. declare module BABYLON {
  64669. /** @hidden */
  64670. export var lensFlareVertexShader: {
  64671. name: string;
  64672. shader: string;
  64673. };
  64674. }
  64675. declare module BABYLON {
  64676. /**
  64677. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  64678. * It is usually composed of several `lensFlare`.
  64679. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64680. */
  64681. export class LensFlareSystem {
  64682. /**
  64683. * Define the name of the lens flare system
  64684. */
  64685. name: string;
  64686. /**
  64687. * List of lens flares used in this system.
  64688. */
  64689. lensFlares: LensFlare[];
  64690. /**
  64691. * Define a limit from the border the lens flare can be visible.
  64692. */
  64693. borderLimit: number;
  64694. /**
  64695. * Define a viewport border we do not want to see the lens flare in.
  64696. */
  64697. viewportBorder: number;
  64698. /**
  64699. * Define a predicate which could limit the list of meshes able to occlude the effect.
  64700. */
  64701. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  64702. /**
  64703. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  64704. */
  64705. layerMask: number;
  64706. /**
  64707. * Define the id of the lens flare system in the scene.
  64708. * (equal to name by default)
  64709. */
  64710. id: string;
  64711. private _scene;
  64712. private _emitter;
  64713. private _vertexBuffers;
  64714. private _indexBuffer;
  64715. private _effect;
  64716. private _positionX;
  64717. private _positionY;
  64718. private _isEnabled;
  64719. /** @hidden */
  64720. static _SceneComponentInitialization: (scene: Scene) => void;
  64721. /**
  64722. * Instantiates a lens flare system.
  64723. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  64724. * It is usually composed of several `lensFlare`.
  64725. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64726. * @param name Define the name of the lens flare system in the scene
  64727. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  64728. * @param scene Define the scene the lens flare system belongs to
  64729. */
  64730. constructor(
  64731. /**
  64732. * Define the name of the lens flare system
  64733. */
  64734. name: string, emitter: any, scene: Scene);
  64735. /**
  64736. * Define if the lens flare system is enabled.
  64737. */
  64738. get isEnabled(): boolean;
  64739. set isEnabled(value: boolean);
  64740. /**
  64741. * Get the scene the effects belongs to.
  64742. * @returns the scene holding the lens flare system
  64743. */
  64744. getScene(): Scene;
  64745. /**
  64746. * Get the emitter of the lens flare system.
  64747. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  64748. * @returns the emitter of the lens flare system
  64749. */
  64750. getEmitter(): any;
  64751. /**
  64752. * Set the emitter of the lens flare system.
  64753. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  64754. * @param newEmitter Define the new emitter of the system
  64755. */
  64756. setEmitter(newEmitter: any): void;
  64757. /**
  64758. * Get the lens flare system emitter position.
  64759. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  64760. * @returns the position
  64761. */
  64762. getEmitterPosition(): Vector3;
  64763. /**
  64764. * @hidden
  64765. */
  64766. computeEffectivePosition(globalViewport: Viewport): boolean;
  64767. /** @hidden */
  64768. _isVisible(): boolean;
  64769. /**
  64770. * @hidden
  64771. */
  64772. render(): boolean;
  64773. /**
  64774. * Dispose and release the lens flare with its associated resources.
  64775. */
  64776. dispose(): void;
  64777. /**
  64778. * Parse a lens flare system from a JSON representation
  64779. * @param parsedLensFlareSystem Define the JSON to parse
  64780. * @param scene Define the scene the parsed system should be instantiated in
  64781. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  64782. * @returns the parsed system
  64783. */
  64784. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  64785. /**
  64786. * Serialize the current Lens Flare System into a JSON representation.
  64787. * @returns the serialized JSON
  64788. */
  64789. serialize(): any;
  64790. }
  64791. }
  64792. declare module BABYLON {
  64793. /**
  64794. * This represents one of the lens effect in a `lensFlareSystem`.
  64795. * It controls one of the individual texture used in the effect.
  64796. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64797. */
  64798. export class LensFlare {
  64799. /**
  64800. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  64801. */
  64802. size: number;
  64803. /**
  64804. * 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.
  64805. */
  64806. position: number;
  64807. /**
  64808. * Define the lens color.
  64809. */
  64810. color: Color3;
  64811. /**
  64812. * Define the lens texture.
  64813. */
  64814. texture: Nullable<Texture>;
  64815. /**
  64816. * Define the alpha mode to render this particular lens.
  64817. */
  64818. alphaMode: number;
  64819. private _system;
  64820. /**
  64821. * Creates a new Lens Flare.
  64822. * This represents one of the lens effect in a `lensFlareSystem`.
  64823. * It controls one of the individual texture used in the effect.
  64824. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64825. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  64826. * @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.
  64827. * @param color Define the lens color
  64828. * @param imgUrl Define the lens texture url
  64829. * @param system Define the `lensFlareSystem` this flare is part of
  64830. * @returns The newly created Lens Flare
  64831. */
  64832. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  64833. /**
  64834. * Instantiates a new Lens Flare.
  64835. * This represents one of the lens effect in a `lensFlareSystem`.
  64836. * It controls one of the individual texture used in the effect.
  64837. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64838. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  64839. * @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.
  64840. * @param color Define the lens color
  64841. * @param imgUrl Define the lens texture url
  64842. * @param system Define the `lensFlareSystem` this flare is part of
  64843. */
  64844. constructor(
  64845. /**
  64846. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  64847. */
  64848. size: number,
  64849. /**
  64850. * 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.
  64851. */
  64852. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  64853. /**
  64854. * Dispose and release the lens flare with its associated resources.
  64855. */
  64856. dispose(): void;
  64857. }
  64858. }
  64859. declare module BABYLON {
  64860. interface AbstractScene {
  64861. /**
  64862. * The list of lens flare system added to the scene
  64863. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64864. */
  64865. lensFlareSystems: Array<LensFlareSystem>;
  64866. /**
  64867. * Removes the given lens flare system from this scene.
  64868. * @param toRemove The lens flare system to remove
  64869. * @returns The index of the removed lens flare system
  64870. */
  64871. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  64872. /**
  64873. * Adds the given lens flare system to this scene
  64874. * @param newLensFlareSystem The lens flare system to add
  64875. */
  64876. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  64877. /**
  64878. * Gets a lens flare system using its name
  64879. * @param name defines the name to look for
  64880. * @returns the lens flare system or null if not found
  64881. */
  64882. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  64883. /**
  64884. * Gets a lens flare system using its id
  64885. * @param id defines the id to look for
  64886. * @returns the lens flare system or null if not found
  64887. */
  64888. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  64889. }
  64890. /**
  64891. * Defines the lens flare scene component responsible to manage any lens flares
  64892. * in a given scene.
  64893. */
  64894. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  64895. /**
  64896. * The component name helpful to identify the component in the list of scene components.
  64897. */
  64898. readonly name: string;
  64899. /**
  64900. * The scene the component belongs to.
  64901. */
  64902. scene: Scene;
  64903. /**
  64904. * Creates a new instance of the component for the given scene
  64905. * @param scene Defines the scene to register the component in
  64906. */
  64907. constructor(scene: Scene);
  64908. /**
  64909. * Registers the component in a given scene
  64910. */
  64911. register(): void;
  64912. /**
  64913. * Rebuilds the elements related to this component in case of
  64914. * context lost for instance.
  64915. */
  64916. rebuild(): void;
  64917. /**
  64918. * Adds all the elements from the container to the scene
  64919. * @param container the container holding the elements
  64920. */
  64921. addFromContainer(container: AbstractScene): void;
  64922. /**
  64923. * Removes all the elements in the container from the scene
  64924. * @param container contains the elements to remove
  64925. * @param dispose if the removed element should be disposed (default: false)
  64926. */
  64927. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  64928. /**
  64929. * Serializes the component data to the specified json object
  64930. * @param serializationObject The object to serialize to
  64931. */
  64932. serialize(serializationObject: any): void;
  64933. /**
  64934. * Disposes the component and the associated resources.
  64935. */
  64936. dispose(): void;
  64937. private _draw;
  64938. }
  64939. }
  64940. declare module BABYLON {
  64941. /** @hidden */
  64942. export var depthPixelShader: {
  64943. name: string;
  64944. shader: string;
  64945. };
  64946. }
  64947. declare module BABYLON {
  64948. /** @hidden */
  64949. export var depthVertexShader: {
  64950. name: string;
  64951. shader: string;
  64952. };
  64953. }
  64954. declare module BABYLON {
  64955. /**
  64956. * This represents a depth renderer in Babylon.
  64957. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  64958. */
  64959. export class DepthRenderer {
  64960. private _scene;
  64961. private _depthMap;
  64962. private _effect;
  64963. private readonly _storeNonLinearDepth;
  64964. private readonly _clearColor;
  64965. /** Get if the depth renderer is using packed depth or not */
  64966. readonly isPacked: boolean;
  64967. private _cachedDefines;
  64968. private _camera;
  64969. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  64970. enabled: boolean;
  64971. /**
  64972. * Specifies that the depth renderer will only be used within
  64973. * the camera it is created for.
  64974. * This can help forcing its rendering during the camera processing.
  64975. */
  64976. useOnlyInActiveCamera: boolean;
  64977. /** @hidden */
  64978. static _SceneComponentInitialization: (scene: Scene) => void;
  64979. /**
  64980. * Instantiates a depth renderer
  64981. * @param scene The scene the renderer belongs to
  64982. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64983. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64984. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64985. */
  64986. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64987. /**
  64988. * Creates the depth rendering effect and checks if the effect is ready.
  64989. * @param subMesh The submesh to be used to render the depth map of
  64990. * @param useInstances If multiple world instances should be used
  64991. * @returns if the depth renderer is ready to render the depth map
  64992. */
  64993. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64994. /**
  64995. * Gets the texture which the depth map will be written to.
  64996. * @returns The depth map texture
  64997. */
  64998. getDepthMap(): RenderTargetTexture;
  64999. /**
  65000. * Disposes of the depth renderer.
  65001. */
  65002. dispose(): void;
  65003. }
  65004. }
  65005. declare module BABYLON {
  65006. /** @hidden */
  65007. export var minmaxReduxPixelShader: {
  65008. name: string;
  65009. shader: string;
  65010. };
  65011. }
  65012. declare module BABYLON {
  65013. /**
  65014. * This class computes a min/max reduction from a texture: it means it computes the minimum
  65015. * and maximum values from all values of the texture.
  65016. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  65017. * The source values are read from the red channel of the texture.
  65018. */
  65019. export class MinMaxReducer {
  65020. /**
  65021. * Observable triggered when the computation has been performed
  65022. */
  65023. onAfterReductionPerformed: Observable<{
  65024. min: number;
  65025. max: number;
  65026. }>;
  65027. protected _camera: Camera;
  65028. protected _sourceTexture: Nullable<RenderTargetTexture>;
  65029. protected _reductionSteps: Nullable<Array<PostProcess>>;
  65030. protected _postProcessManager: PostProcessManager;
  65031. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  65032. protected _forceFullscreenViewport: boolean;
  65033. /**
  65034. * Creates a min/max reducer
  65035. * @param camera The camera to use for the post processes
  65036. */
  65037. constructor(camera: Camera);
  65038. /**
  65039. * Gets the texture used to read the values from.
  65040. */
  65041. get sourceTexture(): Nullable<RenderTargetTexture>;
  65042. /**
  65043. * Sets the source texture to read the values from.
  65044. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  65045. * because in such textures '1' value must not be taken into account to compute the maximum
  65046. * as this value is used to clear the texture.
  65047. * Note that the computation is not activated by calling this function, you must call activate() for that!
  65048. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  65049. * @param depthRedux Indicates if the texture is a depth texture or not
  65050. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  65051. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  65052. */
  65053. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  65054. /**
  65055. * Defines the refresh rate of the computation.
  65056. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  65057. */
  65058. get refreshRate(): number;
  65059. set refreshRate(value: number);
  65060. protected _activated: boolean;
  65061. /**
  65062. * Gets the activation status of the reducer
  65063. */
  65064. get activated(): boolean;
  65065. /**
  65066. * Activates the reduction computation.
  65067. * When activated, the observers registered in onAfterReductionPerformed are
  65068. * called after the computation is performed
  65069. */
  65070. activate(): void;
  65071. /**
  65072. * Deactivates the reduction computation.
  65073. */
  65074. deactivate(): void;
  65075. /**
  65076. * Disposes the min/max reducer
  65077. * @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.
  65078. */
  65079. dispose(disposeAll?: boolean): void;
  65080. }
  65081. }
  65082. declare module BABYLON {
  65083. /**
  65084. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  65085. */
  65086. export class DepthReducer extends MinMaxReducer {
  65087. private _depthRenderer;
  65088. private _depthRendererId;
  65089. /**
  65090. * Gets the depth renderer used for the computation.
  65091. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  65092. */
  65093. get depthRenderer(): Nullable<DepthRenderer>;
  65094. /**
  65095. * Creates a depth reducer
  65096. * @param camera The camera used to render the depth texture
  65097. */
  65098. constructor(camera: Camera);
  65099. /**
  65100. * Sets the depth renderer to use to generate the depth map
  65101. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  65102. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  65103. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  65104. */
  65105. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  65106. /** @hidden */
  65107. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  65108. /**
  65109. * Activates the reduction computation.
  65110. * When activated, the observers registered in onAfterReductionPerformed are
  65111. * called after the computation is performed
  65112. */
  65113. activate(): void;
  65114. /**
  65115. * Deactivates the reduction computation.
  65116. */
  65117. deactivate(): void;
  65118. /**
  65119. * Disposes the depth reducer
  65120. * @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.
  65121. */
  65122. dispose(disposeAll?: boolean): void;
  65123. }
  65124. }
  65125. declare module BABYLON {
  65126. /**
  65127. * A CSM implementation allowing casting shadows on large scenes.
  65128. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  65129. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  65130. */
  65131. export class CascadedShadowGenerator extends ShadowGenerator {
  65132. private static readonly frustumCornersNDCSpace;
  65133. /**
  65134. * Name of the CSM class
  65135. */
  65136. static CLASSNAME: string;
  65137. /**
  65138. * Defines the default number of cascades used by the CSM.
  65139. */
  65140. static readonly DEFAULT_CASCADES_COUNT: number;
  65141. /**
  65142. * Defines the minimum number of cascades used by the CSM.
  65143. */
  65144. static readonly MIN_CASCADES_COUNT: number;
  65145. /**
  65146. * Defines the maximum number of cascades used by the CSM.
  65147. */
  65148. static readonly MAX_CASCADES_COUNT: number;
  65149. protected _validateFilter(filter: number): number;
  65150. /**
  65151. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  65152. */
  65153. penumbraDarkness: number;
  65154. private _numCascades;
  65155. /**
  65156. * Gets or set the number of cascades used by the CSM.
  65157. */
  65158. get numCascades(): number;
  65159. set numCascades(value: number);
  65160. /**
  65161. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  65162. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  65163. */
  65164. stabilizeCascades: boolean;
  65165. private _freezeShadowCastersBoundingInfo;
  65166. private _freezeShadowCastersBoundingInfoObservable;
  65167. /**
  65168. * Enables or disables the shadow casters bounding info computation.
  65169. * If your shadow casters don't move, you can disable this feature.
  65170. * If it is enabled, the bounding box computation is done every frame.
  65171. */
  65172. get freezeShadowCastersBoundingInfo(): boolean;
  65173. set freezeShadowCastersBoundingInfo(freeze: boolean);
  65174. private _scbiMin;
  65175. private _scbiMax;
  65176. protected _computeShadowCastersBoundingInfo(): void;
  65177. protected _shadowCastersBoundingInfo: BoundingInfo;
  65178. /**
  65179. * Gets or sets the shadow casters bounding info.
  65180. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  65181. * so that the system won't overwrite the bounds you provide
  65182. */
  65183. get shadowCastersBoundingInfo(): BoundingInfo;
  65184. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  65185. protected _breaksAreDirty: boolean;
  65186. protected _minDistance: number;
  65187. protected _maxDistance: number;
  65188. /**
  65189. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  65190. *
  65191. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  65192. * If you don't know these values, simply leave them to their defaults and don't call this function.
  65193. * @param min minimal distance for the breaks (default to 0.)
  65194. * @param max maximal distance for the breaks (default to 1.)
  65195. */
  65196. setMinMaxDistance(min: number, max: number): void;
  65197. /** Gets the minimal distance used in the cascade break computation */
  65198. get minDistance(): number;
  65199. /** Gets the maximal distance used in the cascade break computation */
  65200. get maxDistance(): number;
  65201. /**
  65202. * Gets the class name of that object
  65203. * @returns "CascadedShadowGenerator"
  65204. */
  65205. getClassName(): string;
  65206. private _cascadeMinExtents;
  65207. private _cascadeMaxExtents;
  65208. /**
  65209. * Gets a cascade minimum extents
  65210. * @param cascadeIndex index of the cascade
  65211. * @returns the minimum cascade extents
  65212. */
  65213. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  65214. /**
  65215. * Gets a cascade maximum extents
  65216. * @param cascadeIndex index of the cascade
  65217. * @returns the maximum cascade extents
  65218. */
  65219. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  65220. private _cascades;
  65221. private _currentLayer;
  65222. private _viewSpaceFrustumsZ;
  65223. private _viewMatrices;
  65224. private _projectionMatrices;
  65225. private _transformMatrices;
  65226. private _transformMatricesAsArray;
  65227. private _frustumLengths;
  65228. private _lightSizeUVCorrection;
  65229. private _depthCorrection;
  65230. private _frustumCornersWorldSpace;
  65231. private _frustumCenter;
  65232. private _shadowCameraPos;
  65233. private _shadowMaxZ;
  65234. /**
  65235. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  65236. * It defaults to camera.maxZ
  65237. */
  65238. get shadowMaxZ(): number;
  65239. /**
  65240. * Sets the shadow max z distance.
  65241. */
  65242. set shadowMaxZ(value: number);
  65243. protected _debug: boolean;
  65244. /**
  65245. * Gets or sets the debug flag.
  65246. * When enabled, the cascades are materialized by different colors on the screen.
  65247. */
  65248. get debug(): boolean;
  65249. set debug(dbg: boolean);
  65250. private _depthClamp;
  65251. /**
  65252. * Gets or sets the depth clamping value.
  65253. *
  65254. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  65255. * to account for the shadow casters far away.
  65256. *
  65257. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  65258. */
  65259. get depthClamp(): boolean;
  65260. set depthClamp(value: boolean);
  65261. private _cascadeBlendPercentage;
  65262. /**
  65263. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  65264. * It defaults to 0.1 (10% blending).
  65265. */
  65266. get cascadeBlendPercentage(): number;
  65267. set cascadeBlendPercentage(value: number);
  65268. private _lambda;
  65269. /**
  65270. * Gets or set the lambda parameter.
  65271. * This parameter is used to split the camera frustum and create the cascades.
  65272. * 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.
  65273. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  65274. */
  65275. get lambda(): number;
  65276. set lambda(value: number);
  65277. /**
  65278. * Gets the view matrix corresponding to a given cascade
  65279. * @param cascadeNum cascade to retrieve the view matrix from
  65280. * @returns the cascade view matrix
  65281. */
  65282. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  65283. /**
  65284. * Gets the projection matrix corresponding to a given cascade
  65285. * @param cascadeNum cascade to retrieve the projection matrix from
  65286. * @returns the cascade projection matrix
  65287. */
  65288. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  65289. /**
  65290. * Gets the transformation matrix corresponding to a given cascade
  65291. * @param cascadeNum cascade to retrieve the transformation matrix from
  65292. * @returns the cascade transformation matrix
  65293. */
  65294. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  65295. private _depthRenderer;
  65296. /**
  65297. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  65298. *
  65299. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  65300. *
  65301. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  65302. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  65303. * @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
  65304. */
  65305. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  65306. private _depthReducer;
  65307. private _autoCalcDepthBounds;
  65308. /**
  65309. * Gets or sets the autoCalcDepthBounds property.
  65310. *
  65311. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  65312. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  65313. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  65314. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  65315. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  65316. */
  65317. get autoCalcDepthBounds(): boolean;
  65318. set autoCalcDepthBounds(value: boolean);
  65319. /**
  65320. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  65321. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  65322. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  65323. * for setting the refresh rate on the renderer yourself!
  65324. */
  65325. get autoCalcDepthBoundsRefreshRate(): number;
  65326. set autoCalcDepthBoundsRefreshRate(value: number);
  65327. /**
  65328. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  65329. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  65330. * you change the camera near/far planes!
  65331. */
  65332. splitFrustum(): void;
  65333. private _splitFrustum;
  65334. private _computeMatrices;
  65335. private _computeFrustumInWorldSpace;
  65336. private _computeCascadeFrustum;
  65337. /**
  65338. * Support test.
  65339. */
  65340. static get IsSupported(): boolean;
  65341. /** @hidden */
  65342. static _SceneComponentInitialization: (scene: Scene) => void;
  65343. /**
  65344. * Creates a Cascaded Shadow Generator object.
  65345. * A ShadowGenerator is the required tool to use the shadows.
  65346. * Each directional light casting shadows needs to use its own ShadowGenerator.
  65347. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  65348. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  65349. * @param light The directional light object generating the shadows.
  65350. * @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.
  65351. */
  65352. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  65353. protected _initializeGenerator(): void;
  65354. protected _createTargetRenderTexture(): void;
  65355. protected _initializeShadowMap(): void;
  65356. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  65357. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  65358. /**
  65359. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  65360. * @param defines Defines of the material we want to update
  65361. * @param lightIndex Index of the light in the enabled light list of the material
  65362. */
  65363. prepareDefines(defines: any, lightIndex: number): void;
  65364. /**
  65365. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  65366. * defined in the generator but impacting the effect).
  65367. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  65368. * @param effect The effect we are binfing the information for
  65369. */
  65370. bindShadowLight(lightIndex: string, effect: Effect): void;
  65371. /**
  65372. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  65373. * (eq to view projection * shadow projection matrices)
  65374. * @returns The transform matrix used to create the shadow map
  65375. */
  65376. getTransformMatrix(): Matrix;
  65377. /**
  65378. * Disposes the ShadowGenerator.
  65379. * Returns nothing.
  65380. */
  65381. dispose(): void;
  65382. /**
  65383. * Serializes the shadow generator setup to a json object.
  65384. * @returns The serialized JSON object
  65385. */
  65386. serialize(): any;
  65387. /**
  65388. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  65389. * @param parsedShadowGenerator The JSON object to parse
  65390. * @param scene The scene to create the shadow map for
  65391. * @returns The parsed shadow generator
  65392. */
  65393. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  65394. }
  65395. }
  65396. declare module BABYLON {
  65397. /**
  65398. * Defines the shadow generator component responsible to manage any shadow generators
  65399. * in a given scene.
  65400. */
  65401. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  65402. /**
  65403. * The component name helpful to identify the component in the list of scene components.
  65404. */
  65405. readonly name: string;
  65406. /**
  65407. * The scene the component belongs to.
  65408. */
  65409. scene: Scene;
  65410. /**
  65411. * Creates a new instance of the component for the given scene
  65412. * @param scene Defines the scene to register the component in
  65413. */
  65414. constructor(scene: Scene);
  65415. /**
  65416. * Registers the component in a given scene
  65417. */
  65418. register(): void;
  65419. /**
  65420. * Rebuilds the elements related to this component in case of
  65421. * context lost for instance.
  65422. */
  65423. rebuild(): void;
  65424. /**
  65425. * Serializes the component data to the specified json object
  65426. * @param serializationObject The object to serialize to
  65427. */
  65428. serialize(serializationObject: any): void;
  65429. /**
  65430. * Adds all the elements from the container to the scene
  65431. * @param container the container holding the elements
  65432. */
  65433. addFromContainer(container: AbstractScene): void;
  65434. /**
  65435. * Removes all the elements in the container from the scene
  65436. * @param container contains the elements to remove
  65437. * @param dispose if the removed element should be disposed (default: false)
  65438. */
  65439. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  65440. /**
  65441. * Rebuilds the elements related to this component in case of
  65442. * context lost for instance.
  65443. */
  65444. dispose(): void;
  65445. private _gatherRenderTargets;
  65446. }
  65447. }
  65448. declare module BABYLON {
  65449. /**
  65450. * A point light is a light defined by an unique point in world space.
  65451. * The light is emitted in every direction from this point.
  65452. * A good example of a point light is a standard light bulb.
  65453. * Documentation: https://doc.babylonjs.com/babylon101/lights
  65454. */
  65455. export class PointLight extends ShadowLight {
  65456. private _shadowAngle;
  65457. /**
  65458. * Getter: 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. get shadowAngle(): number;
  65464. /**
  65465. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  65466. * This specifies what angle the shadow will use to be created.
  65467. *
  65468. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  65469. */
  65470. set shadowAngle(value: number);
  65471. /**
  65472. * Gets the direction if it has been set.
  65473. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  65474. */
  65475. get direction(): Vector3;
  65476. /**
  65477. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  65478. */
  65479. set direction(value: Vector3);
  65480. /**
  65481. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  65482. * A PointLight emits the light in every direction.
  65483. * It can cast shadows.
  65484. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  65485. * ```javascript
  65486. * var pointLight = new PointLight("pl", camera.position, scene);
  65487. * ```
  65488. * Documentation : https://doc.babylonjs.com/babylon101/lights
  65489. * @param name The light friendly name
  65490. * @param position The position of the point light in the scene
  65491. * @param scene The scene the lights belongs to
  65492. */
  65493. constructor(name: string, position: Vector3, scene: Scene);
  65494. /**
  65495. * Returns the string "PointLight"
  65496. * @returns the class name
  65497. */
  65498. getClassName(): string;
  65499. /**
  65500. * Returns the integer 0.
  65501. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  65502. */
  65503. getTypeID(): number;
  65504. /**
  65505. * Specifies whether or not the shadowmap should be a cube texture.
  65506. * @returns true if the shadowmap needs to be a cube texture.
  65507. */
  65508. needCube(): boolean;
  65509. /**
  65510. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  65511. * @param faceIndex The index of the face we are computed the direction to generate shadow
  65512. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  65513. */
  65514. getShadowDirection(faceIndex?: number): Vector3;
  65515. /**
  65516. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  65517. * - fov = PI / 2
  65518. * - aspect ratio : 1.0
  65519. * - z-near and far equal to the active camera minZ and maxZ.
  65520. * Returns the PointLight.
  65521. */
  65522. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  65523. protected _buildUniformLayout(): void;
  65524. /**
  65525. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  65526. * @param effect The effect to update
  65527. * @param lightIndex The index of the light in the effect to update
  65528. * @returns The point light
  65529. */
  65530. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  65531. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  65532. /**
  65533. * Prepares the list of defines specific to the light type.
  65534. * @param defines the list of defines
  65535. * @param lightIndex defines the index of the light for the effect
  65536. */
  65537. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  65538. }
  65539. }
  65540. declare module BABYLON {
  65541. /**
  65542. * Header information of HDR texture files.
  65543. */
  65544. export interface HDRInfo {
  65545. /**
  65546. * The height of the texture in pixels.
  65547. */
  65548. height: number;
  65549. /**
  65550. * The width of the texture in pixels.
  65551. */
  65552. width: number;
  65553. /**
  65554. * The index of the beginning of the data in the binary file.
  65555. */
  65556. dataPosition: number;
  65557. }
  65558. /**
  65559. * This groups tools to convert HDR texture to native colors array.
  65560. */
  65561. export class HDRTools {
  65562. private static Ldexp;
  65563. private static Rgbe2float;
  65564. private static readStringLine;
  65565. /**
  65566. * Reads header information from an RGBE texture stored in a native array.
  65567. * More information on this format are available here:
  65568. * https://en.wikipedia.org/wiki/RGBE_image_format
  65569. *
  65570. * @param uint8array The binary file stored in native array.
  65571. * @return The header information.
  65572. */
  65573. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  65574. /**
  65575. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  65576. * This RGBE texture needs to store the information as a panorama.
  65577. *
  65578. * More information on this format are available here:
  65579. * https://en.wikipedia.org/wiki/RGBE_image_format
  65580. *
  65581. * @param buffer The binary file stored in an array buffer.
  65582. * @param size The expected size of the extracted cubemap.
  65583. * @return The Cube Map information.
  65584. */
  65585. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  65586. /**
  65587. * Returns the pixels data extracted from an RGBE texture.
  65588. * This pixels will be stored left to right up to down in the R G B order in one array.
  65589. *
  65590. * More information on this format are available here:
  65591. * https://en.wikipedia.org/wiki/RGBE_image_format
  65592. *
  65593. * @param uint8array The binary file stored in an array buffer.
  65594. * @param hdrInfo The header information of the file.
  65595. * @return The pixels data in RGB right to left up to down order.
  65596. */
  65597. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  65598. private static RGBE_ReadPixels_RLE;
  65599. private static RGBE_ReadPixels_NOT_RLE;
  65600. }
  65601. }
  65602. declare module BABYLON {
  65603. /**
  65604. * Effect Render Options
  65605. */
  65606. export interface IEffectRendererOptions {
  65607. /**
  65608. * Defines the vertices positions.
  65609. */
  65610. positions?: number[];
  65611. /**
  65612. * Defines the indices.
  65613. */
  65614. indices?: number[];
  65615. }
  65616. /**
  65617. * Helper class to render one or more effects.
  65618. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  65619. */
  65620. export class EffectRenderer {
  65621. private engine;
  65622. private static _DefaultOptions;
  65623. private _vertexBuffers;
  65624. private _indexBuffer;
  65625. private _fullscreenViewport;
  65626. /**
  65627. * Creates an effect renderer
  65628. * @param engine the engine to use for rendering
  65629. * @param options defines the options of the effect renderer
  65630. */
  65631. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  65632. /**
  65633. * Sets the current viewport in normalized coordinates 0-1
  65634. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  65635. */
  65636. setViewport(viewport?: Viewport): void;
  65637. /**
  65638. * Binds the embedded attributes buffer to the effect.
  65639. * @param effect Defines the effect to bind the attributes for
  65640. */
  65641. bindBuffers(effect: Effect): void;
  65642. /**
  65643. * Sets the current effect wrapper to use during draw.
  65644. * The effect needs to be ready before calling this api.
  65645. * This also sets the default full screen position attribute.
  65646. * @param effectWrapper Defines the effect to draw with
  65647. */
  65648. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  65649. /**
  65650. * Restores engine states
  65651. */
  65652. restoreStates(): void;
  65653. /**
  65654. * Draws a full screen quad.
  65655. */
  65656. draw(): void;
  65657. private isRenderTargetTexture;
  65658. /**
  65659. * renders one or more effects to a specified texture
  65660. * @param effectWrapper the effect to renderer
  65661. * @param outputTexture texture to draw to, if null it will render to the screen.
  65662. */
  65663. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  65664. /**
  65665. * Disposes of the effect renderer
  65666. */
  65667. dispose(): void;
  65668. }
  65669. /**
  65670. * Options to create an EffectWrapper
  65671. */
  65672. interface EffectWrapperCreationOptions {
  65673. /**
  65674. * Engine to use to create the effect
  65675. */
  65676. engine: ThinEngine;
  65677. /**
  65678. * Fragment shader for the effect
  65679. */
  65680. fragmentShader: string;
  65681. /**
  65682. * Use the shader store instead of direct source code
  65683. */
  65684. useShaderStore?: boolean;
  65685. /**
  65686. * Vertex shader for the effect
  65687. */
  65688. vertexShader?: string;
  65689. /**
  65690. * Attributes to use in the shader
  65691. */
  65692. attributeNames?: Array<string>;
  65693. /**
  65694. * Uniforms to use in the shader
  65695. */
  65696. uniformNames?: Array<string>;
  65697. /**
  65698. * Texture sampler names to use in the shader
  65699. */
  65700. samplerNames?: Array<string>;
  65701. /**
  65702. * Defines to use in the shader
  65703. */
  65704. defines?: Array<string>;
  65705. /**
  65706. * Callback when effect is compiled
  65707. */
  65708. onCompiled?: Nullable<(effect: Effect) => void>;
  65709. /**
  65710. * The friendly name of the effect displayed in Spector.
  65711. */
  65712. name?: string;
  65713. }
  65714. /**
  65715. * Wraps an effect to be used for rendering
  65716. */
  65717. export class EffectWrapper {
  65718. /**
  65719. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  65720. */
  65721. onApplyObservable: Observable<{}>;
  65722. /**
  65723. * The underlying effect
  65724. */
  65725. effect: Effect;
  65726. /**
  65727. * Creates an effect to be renderer
  65728. * @param creationOptions options to create the effect
  65729. */
  65730. constructor(creationOptions: EffectWrapperCreationOptions);
  65731. /**
  65732. * Disposes of the effect wrapper
  65733. */
  65734. dispose(): void;
  65735. }
  65736. }
  65737. declare module BABYLON {
  65738. /** @hidden */
  65739. export var hdrFilteringVertexShader: {
  65740. name: string;
  65741. shader: string;
  65742. };
  65743. }
  65744. declare module BABYLON {
  65745. /** @hidden */
  65746. export var hdrFilteringPixelShader: {
  65747. name: string;
  65748. shader: string;
  65749. };
  65750. }
  65751. declare module BABYLON {
  65752. /**
  65753. * Options for texture filtering
  65754. */
  65755. interface IHDRFilteringOptions {
  65756. /**
  65757. * Scales pixel intensity for the input HDR map.
  65758. */
  65759. hdrScale?: number;
  65760. /**
  65761. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  65762. */
  65763. quality?: number;
  65764. }
  65765. /**
  65766. * Filters HDR maps to get correct renderings of PBR reflections
  65767. */
  65768. export class HDRFiltering {
  65769. private _engine;
  65770. private _effectRenderer;
  65771. private _effectWrapper;
  65772. private _lodGenerationOffset;
  65773. private _lodGenerationScale;
  65774. /**
  65775. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  65776. * you care about baking speed.
  65777. */
  65778. quality: number;
  65779. /**
  65780. * Scales pixel intensity for the input HDR map.
  65781. */
  65782. hdrScale: number;
  65783. /**
  65784. * Instantiates HDR filter for reflection maps
  65785. *
  65786. * @param engine Thin engine
  65787. * @param options Options
  65788. */
  65789. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  65790. private _createRenderTarget;
  65791. private _prefilterInternal;
  65792. private _createEffect;
  65793. /**
  65794. * Get a value indicating if the filter is ready to be used
  65795. * @param texture Texture to filter
  65796. * @returns true if the filter is ready
  65797. */
  65798. isReady(texture: BaseTexture): boolean;
  65799. /**
  65800. * Prefilters a cube texture to have mipmap levels representing roughness values.
  65801. * Prefiltering will be invoked at the end of next rendering pass.
  65802. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  65803. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  65804. * @param texture Texture to filter
  65805. * @param onFinished Callback when filtering is done
  65806. * @return Promise called when prefiltering is done
  65807. */
  65808. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<void>;
  65809. }
  65810. }
  65811. declare module BABYLON {
  65812. /**
  65813. * This represents a texture coming from an HDR input.
  65814. *
  65815. * The only supported format is currently panorama picture stored in RGBE format.
  65816. * Example of such files can be found on HDRLib: http://hdrlib.com/
  65817. */
  65818. export class HDRCubeTexture extends BaseTexture {
  65819. private static _facesMapping;
  65820. private _generateHarmonics;
  65821. private _noMipmap;
  65822. private _prefilterOnLoad;
  65823. private _textureMatrix;
  65824. private _size;
  65825. private _onLoad;
  65826. private _onError;
  65827. /**
  65828. * The texture URL.
  65829. */
  65830. url: string;
  65831. protected _isBlocking: boolean;
  65832. /**
  65833. * Sets whether or not the texture is blocking during loading.
  65834. */
  65835. set isBlocking(value: boolean);
  65836. /**
  65837. * Gets whether or not the texture is blocking during loading.
  65838. */
  65839. get isBlocking(): boolean;
  65840. protected _rotationY: number;
  65841. /**
  65842. * Sets texture matrix rotation angle around Y axis in radians.
  65843. */
  65844. set rotationY(value: number);
  65845. /**
  65846. * Gets texture matrix rotation angle around Y axis radians.
  65847. */
  65848. get rotationY(): number;
  65849. /**
  65850. * Gets or sets the center of the bounding box associated with the cube texture
  65851. * It must define where the camera used to render the texture was set
  65852. */
  65853. boundingBoxPosition: Vector3;
  65854. private _boundingBoxSize;
  65855. /**
  65856. * Gets or sets the size of the bounding box associated with the cube texture
  65857. * When defined, the cubemap will switch to local mode
  65858. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  65859. * @example https://www.babylonjs-playground.com/#RNASML
  65860. */
  65861. set boundingBoxSize(value: Vector3);
  65862. get boundingBoxSize(): Vector3;
  65863. /**
  65864. * Instantiates an HDRTexture from the following parameters.
  65865. *
  65866. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  65867. * @param sceneOrEngine The scene or engine the texture will be used in
  65868. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  65869. * @param noMipmap Forces to not generate the mipmap if true
  65870. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  65871. * @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)
  65872. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  65873. */
  65874. 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>);
  65875. /**
  65876. * Get the current class name of the texture useful for serialization or dynamic coding.
  65877. * @returns "HDRCubeTexture"
  65878. */
  65879. getClassName(): string;
  65880. /**
  65881. * Occurs when the file is raw .hdr file.
  65882. */
  65883. private loadTexture;
  65884. clone(): HDRCubeTexture;
  65885. delayLoad(): void;
  65886. /**
  65887. * Get the texture reflection matrix used to rotate/transform the reflection.
  65888. * @returns the reflection matrix
  65889. */
  65890. getReflectionTextureMatrix(): Matrix;
  65891. /**
  65892. * Set the texture reflection matrix used to rotate/transform the reflection.
  65893. * @param value Define the reflection matrix to set
  65894. */
  65895. setReflectionTextureMatrix(value: Matrix): void;
  65896. /**
  65897. * Parses a JSON representation of an HDR Texture in order to create the texture
  65898. * @param parsedTexture Define the JSON representation
  65899. * @param scene Define the scene the texture should be created in
  65900. * @param rootUrl Define the root url in case we need to load relative dependencies
  65901. * @returns the newly created texture after parsing
  65902. */
  65903. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  65904. serialize(): any;
  65905. }
  65906. }
  65907. declare module BABYLON {
  65908. /**
  65909. * Class used to control physics engine
  65910. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  65911. */
  65912. export class PhysicsEngine implements IPhysicsEngine {
  65913. private _physicsPlugin;
  65914. /**
  65915. * Global value used to control the smallest number supported by the simulation
  65916. */
  65917. static Epsilon: number;
  65918. private _impostors;
  65919. private _joints;
  65920. private _subTimeStep;
  65921. /**
  65922. * Gets the gravity vector used by the simulation
  65923. */
  65924. gravity: Vector3;
  65925. /**
  65926. * Factory used to create the default physics plugin.
  65927. * @returns The default physics plugin
  65928. */
  65929. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  65930. /**
  65931. * Creates a new Physics Engine
  65932. * @param gravity defines the gravity vector used by the simulation
  65933. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  65934. */
  65935. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  65936. /**
  65937. * Sets the gravity vector used by the simulation
  65938. * @param gravity defines the gravity vector to use
  65939. */
  65940. setGravity(gravity: Vector3): void;
  65941. /**
  65942. * Set the time step of the physics engine.
  65943. * Default is 1/60.
  65944. * To slow it down, enter 1/600 for example.
  65945. * To speed it up, 1/30
  65946. * @param newTimeStep defines the new timestep to apply to this world.
  65947. */
  65948. setTimeStep(newTimeStep?: number): void;
  65949. /**
  65950. * Get the time step of the physics engine.
  65951. * @returns the current time step
  65952. */
  65953. getTimeStep(): number;
  65954. /**
  65955. * Set the sub time step of the physics engine.
  65956. * Default is 0 meaning there is no sub steps
  65957. * To increase physics resolution precision, set a small value (like 1 ms)
  65958. * @param subTimeStep defines the new sub timestep used for physics resolution.
  65959. */
  65960. setSubTimeStep(subTimeStep?: number): void;
  65961. /**
  65962. * Get the sub time step of the physics engine.
  65963. * @returns the current sub time step
  65964. */
  65965. getSubTimeStep(): number;
  65966. /**
  65967. * Release all resources
  65968. */
  65969. dispose(): void;
  65970. /**
  65971. * Gets the name of the current physics plugin
  65972. * @returns the name of the plugin
  65973. */
  65974. getPhysicsPluginName(): string;
  65975. /**
  65976. * Adding a new impostor for the impostor tracking.
  65977. * This will be done by the impostor itself.
  65978. * @param impostor the impostor to add
  65979. */
  65980. addImpostor(impostor: PhysicsImpostor): void;
  65981. /**
  65982. * Remove an impostor from the engine.
  65983. * This impostor and its mesh will not longer be updated by the physics engine.
  65984. * @param impostor the impostor to remove
  65985. */
  65986. removeImpostor(impostor: PhysicsImpostor): void;
  65987. /**
  65988. * Add a joint to the physics engine
  65989. * @param mainImpostor defines the main impostor to which the joint is added.
  65990. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  65991. * @param joint defines the joint that will connect both impostors.
  65992. */
  65993. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  65994. /**
  65995. * Removes a joint from the simulation
  65996. * @param mainImpostor defines the impostor used with the joint
  65997. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  65998. * @param joint defines the joint to remove
  65999. */
  66000. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  66001. /**
  66002. * Called by the scene. No need to call it.
  66003. * @param delta defines the timespan between frames
  66004. */
  66005. _step(delta: number): void;
  66006. /**
  66007. * Gets the current plugin used to run the simulation
  66008. * @returns current plugin
  66009. */
  66010. getPhysicsPlugin(): IPhysicsEnginePlugin;
  66011. /**
  66012. * Gets the list of physic impostors
  66013. * @returns an array of PhysicsImpostor
  66014. */
  66015. getImpostors(): Array<PhysicsImpostor>;
  66016. /**
  66017. * Gets the impostor for a physics enabled object
  66018. * @param object defines the object impersonated by the impostor
  66019. * @returns the PhysicsImpostor or null if not found
  66020. */
  66021. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  66022. /**
  66023. * Gets the impostor for a physics body object
  66024. * @param body defines physics body used by the impostor
  66025. * @returns the PhysicsImpostor or null if not found
  66026. */
  66027. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  66028. /**
  66029. * Does a raycast in the physics world
  66030. * @param from when should the ray start?
  66031. * @param to when should the ray end?
  66032. * @returns PhysicsRaycastResult
  66033. */
  66034. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  66035. }
  66036. }
  66037. declare module BABYLON {
  66038. /** @hidden */
  66039. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  66040. private _useDeltaForWorldStep;
  66041. world: any;
  66042. name: string;
  66043. private _physicsMaterials;
  66044. private _fixedTimeStep;
  66045. private _cannonRaycastResult;
  66046. private _raycastResult;
  66047. private _physicsBodysToRemoveAfterStep;
  66048. private _firstFrame;
  66049. BJSCANNON: any;
  66050. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  66051. setGravity(gravity: Vector3): void;
  66052. setTimeStep(timeStep: number): void;
  66053. getTimeStep(): number;
  66054. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  66055. private _removeMarkedPhysicsBodiesFromWorld;
  66056. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  66057. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  66058. generatePhysicsBody(impostor: PhysicsImpostor): void;
  66059. private _processChildMeshes;
  66060. removePhysicsBody(impostor: PhysicsImpostor): void;
  66061. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  66062. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  66063. private _addMaterial;
  66064. private _checkWithEpsilon;
  66065. private _createShape;
  66066. private _createHeightmap;
  66067. private _minus90X;
  66068. private _plus90X;
  66069. private _tmpPosition;
  66070. private _tmpDeltaPosition;
  66071. private _tmpUnityRotation;
  66072. private _updatePhysicsBodyTransformation;
  66073. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  66074. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  66075. isSupported(): boolean;
  66076. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  66077. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  66078. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  66079. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  66080. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  66081. getBodyMass(impostor: PhysicsImpostor): number;
  66082. getBodyFriction(impostor: PhysicsImpostor): number;
  66083. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  66084. getBodyRestitution(impostor: PhysicsImpostor): number;
  66085. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  66086. sleepBody(impostor: PhysicsImpostor): void;
  66087. wakeUpBody(impostor: PhysicsImpostor): void;
  66088. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  66089. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  66090. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  66091. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  66092. getRadius(impostor: PhysicsImpostor): number;
  66093. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  66094. dispose(): void;
  66095. private _extendNamespace;
  66096. /**
  66097. * Does a raycast in the physics world
  66098. * @param from when should the ray start?
  66099. * @param to when should the ray end?
  66100. * @returns PhysicsRaycastResult
  66101. */
  66102. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  66103. }
  66104. }
  66105. declare module BABYLON {
  66106. /** @hidden */
  66107. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  66108. private _useDeltaForWorldStep;
  66109. world: any;
  66110. name: string;
  66111. BJSOIMO: any;
  66112. private _raycastResult;
  66113. private _fixedTimeStep;
  66114. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  66115. setGravity(gravity: Vector3): void;
  66116. setTimeStep(timeStep: number): void;
  66117. getTimeStep(): number;
  66118. private _tmpImpostorsArray;
  66119. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  66120. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  66121. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  66122. generatePhysicsBody(impostor: PhysicsImpostor): void;
  66123. private _tmpPositionVector;
  66124. removePhysicsBody(impostor: PhysicsImpostor): void;
  66125. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  66126. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  66127. isSupported(): boolean;
  66128. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  66129. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  66130. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  66131. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  66132. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  66133. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  66134. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  66135. getBodyMass(impostor: PhysicsImpostor): number;
  66136. getBodyFriction(impostor: PhysicsImpostor): number;
  66137. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  66138. getBodyRestitution(impostor: PhysicsImpostor): number;
  66139. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  66140. sleepBody(impostor: PhysicsImpostor): void;
  66141. wakeUpBody(impostor: PhysicsImpostor): void;
  66142. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  66143. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  66144. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  66145. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  66146. getRadius(impostor: PhysicsImpostor): number;
  66147. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  66148. dispose(): void;
  66149. /**
  66150. * Does a raycast in the physics world
  66151. * @param from when should the ray start?
  66152. * @param to when should the ray end?
  66153. * @returns PhysicsRaycastResult
  66154. */
  66155. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  66156. }
  66157. }
  66158. declare module BABYLON {
  66159. /**
  66160. * AmmoJS Physics plugin
  66161. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  66162. * @see https://github.com/kripken/ammo.js/
  66163. */
  66164. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  66165. private _useDeltaForWorldStep;
  66166. /**
  66167. * Reference to the Ammo library
  66168. */
  66169. bjsAMMO: any;
  66170. /**
  66171. * Created ammoJS world which physics bodies are added to
  66172. */
  66173. world: any;
  66174. /**
  66175. * Name of the plugin
  66176. */
  66177. name: string;
  66178. private _timeStep;
  66179. private _fixedTimeStep;
  66180. private _maxSteps;
  66181. private _tmpQuaternion;
  66182. private _tmpAmmoTransform;
  66183. private _tmpAmmoQuaternion;
  66184. private _tmpAmmoConcreteContactResultCallback;
  66185. private _collisionConfiguration;
  66186. private _dispatcher;
  66187. private _overlappingPairCache;
  66188. private _solver;
  66189. private _softBodySolver;
  66190. private _tmpAmmoVectorA;
  66191. private _tmpAmmoVectorB;
  66192. private _tmpAmmoVectorC;
  66193. private _tmpAmmoVectorD;
  66194. private _tmpContactCallbackResult;
  66195. private _tmpAmmoVectorRCA;
  66196. private _tmpAmmoVectorRCB;
  66197. private _raycastResult;
  66198. private _tmpContactPoint;
  66199. private static readonly DISABLE_COLLISION_FLAG;
  66200. private static readonly KINEMATIC_FLAG;
  66201. private static readonly DISABLE_DEACTIVATION_FLAG;
  66202. /**
  66203. * Initializes the ammoJS plugin
  66204. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  66205. * @param ammoInjection can be used to inject your own ammo reference
  66206. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  66207. */
  66208. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  66209. /**
  66210. * Sets the gravity of the physics world (m/(s^2))
  66211. * @param gravity Gravity to set
  66212. */
  66213. setGravity(gravity: Vector3): void;
  66214. /**
  66215. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  66216. * @param timeStep timestep to use in seconds
  66217. */
  66218. setTimeStep(timeStep: number): void;
  66219. /**
  66220. * 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)
  66221. * @param fixedTimeStep fixedTimeStep to use in seconds
  66222. */
  66223. setFixedTimeStep(fixedTimeStep: number): void;
  66224. /**
  66225. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  66226. * @param maxSteps the maximum number of steps by the physics engine per frame
  66227. */
  66228. setMaxSteps(maxSteps: number): void;
  66229. /**
  66230. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  66231. * @returns the current timestep in seconds
  66232. */
  66233. getTimeStep(): number;
  66234. /**
  66235. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  66236. */
  66237. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  66238. private _isImpostorInContact;
  66239. private _isImpostorPairInContact;
  66240. private _stepSimulation;
  66241. /**
  66242. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  66243. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  66244. * After the step the babylon meshes are set to the position of the physics imposters
  66245. * @param delta amount of time to step forward
  66246. * @param impostors array of imposters to update before/after the step
  66247. */
  66248. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  66249. /**
  66250. * Update babylon mesh to match physics world object
  66251. * @param impostor imposter to match
  66252. */
  66253. private _afterSoftStep;
  66254. /**
  66255. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  66256. * @param impostor imposter to match
  66257. */
  66258. private _ropeStep;
  66259. /**
  66260. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  66261. * @param impostor imposter to match
  66262. */
  66263. private _softbodyOrClothStep;
  66264. private _tmpMatrix;
  66265. /**
  66266. * Applies an impulse on the imposter
  66267. * @param impostor imposter to apply impulse to
  66268. * @param force amount of force to be applied to the imposter
  66269. * @param contactPoint the location to apply the impulse on the imposter
  66270. */
  66271. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  66272. /**
  66273. * Applies a force on the imposter
  66274. * @param impostor imposter to apply force
  66275. * @param force amount of force to be applied to the imposter
  66276. * @param contactPoint the location to apply the force on the imposter
  66277. */
  66278. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  66279. /**
  66280. * Creates a physics body using the plugin
  66281. * @param impostor the imposter to create the physics body on
  66282. */
  66283. generatePhysicsBody(impostor: PhysicsImpostor): void;
  66284. /**
  66285. * Removes the physics body from the imposter and disposes of the body's memory
  66286. * @param impostor imposter to remove the physics body from
  66287. */
  66288. removePhysicsBody(impostor: PhysicsImpostor): void;
  66289. /**
  66290. * Generates a joint
  66291. * @param impostorJoint the imposter joint to create the joint with
  66292. */
  66293. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  66294. /**
  66295. * Removes a joint
  66296. * @param impostorJoint the imposter joint to remove the joint from
  66297. */
  66298. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  66299. private _addMeshVerts;
  66300. /**
  66301. * Initialise the soft body vertices to match its object's (mesh) vertices
  66302. * Softbody vertices (nodes) are in world space and to match this
  66303. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  66304. * @param impostor to create the softbody for
  66305. */
  66306. private _softVertexData;
  66307. /**
  66308. * Create an impostor's soft body
  66309. * @param impostor to create the softbody for
  66310. */
  66311. private _createSoftbody;
  66312. /**
  66313. * Create cloth for an impostor
  66314. * @param impostor to create the softbody for
  66315. */
  66316. private _createCloth;
  66317. /**
  66318. * Create rope for an impostor
  66319. * @param impostor to create the softbody for
  66320. */
  66321. private _createRope;
  66322. /**
  66323. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  66324. * @param impostor to create the custom physics shape for
  66325. */
  66326. private _createCustom;
  66327. private _addHullVerts;
  66328. private _createShape;
  66329. /**
  66330. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  66331. * @param impostor imposter containing the physics body and babylon object
  66332. */
  66333. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  66334. /**
  66335. * Sets the babylon object's position/rotation from the physics body's position/rotation
  66336. * @param impostor imposter containing the physics body and babylon object
  66337. * @param newPosition new position
  66338. * @param newRotation new rotation
  66339. */
  66340. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  66341. /**
  66342. * If this plugin is supported
  66343. * @returns true if its supported
  66344. */
  66345. isSupported(): boolean;
  66346. /**
  66347. * Sets the linear velocity of the physics body
  66348. * @param impostor imposter to set the velocity on
  66349. * @param velocity velocity to set
  66350. */
  66351. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  66352. /**
  66353. * Sets the angular velocity of the physics body
  66354. * @param impostor imposter to set the velocity on
  66355. * @param velocity velocity to set
  66356. */
  66357. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  66358. /**
  66359. * gets the linear velocity
  66360. * @param impostor imposter to get linear velocity from
  66361. * @returns linear velocity
  66362. */
  66363. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  66364. /**
  66365. * gets the angular velocity
  66366. * @param impostor imposter to get angular velocity from
  66367. * @returns angular velocity
  66368. */
  66369. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  66370. /**
  66371. * Sets the mass of physics body
  66372. * @param impostor imposter to set the mass on
  66373. * @param mass mass to set
  66374. */
  66375. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  66376. /**
  66377. * Gets the mass of the physics body
  66378. * @param impostor imposter to get the mass from
  66379. * @returns mass
  66380. */
  66381. getBodyMass(impostor: PhysicsImpostor): number;
  66382. /**
  66383. * Gets friction of the impostor
  66384. * @param impostor impostor to get friction from
  66385. * @returns friction value
  66386. */
  66387. getBodyFriction(impostor: PhysicsImpostor): number;
  66388. /**
  66389. * Sets friction of the impostor
  66390. * @param impostor impostor to set friction on
  66391. * @param friction friction value
  66392. */
  66393. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  66394. /**
  66395. * Gets restitution of the impostor
  66396. * @param impostor impostor to get restitution from
  66397. * @returns restitution value
  66398. */
  66399. getBodyRestitution(impostor: PhysicsImpostor): number;
  66400. /**
  66401. * Sets restitution of the impostor
  66402. * @param impostor impostor to set resitution on
  66403. * @param restitution resitution value
  66404. */
  66405. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  66406. /**
  66407. * Gets pressure inside the impostor
  66408. * @param impostor impostor to get pressure from
  66409. * @returns pressure value
  66410. */
  66411. getBodyPressure(impostor: PhysicsImpostor): number;
  66412. /**
  66413. * Sets pressure inside a soft body impostor
  66414. * Cloth and rope must remain 0 pressure
  66415. * @param impostor impostor to set pressure on
  66416. * @param pressure pressure value
  66417. */
  66418. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  66419. /**
  66420. * Gets stiffness of the impostor
  66421. * @param impostor impostor to get stiffness from
  66422. * @returns pressure value
  66423. */
  66424. getBodyStiffness(impostor: PhysicsImpostor): number;
  66425. /**
  66426. * Sets stiffness of the impostor
  66427. * @param impostor impostor to set stiffness on
  66428. * @param stiffness stiffness value from 0 to 1
  66429. */
  66430. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  66431. /**
  66432. * Gets velocityIterations of the impostor
  66433. * @param impostor impostor to get velocity iterations from
  66434. * @returns velocityIterations value
  66435. */
  66436. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  66437. /**
  66438. * Sets velocityIterations of the impostor
  66439. * @param impostor impostor to set velocity iterations on
  66440. * @param velocityIterations velocityIterations value
  66441. */
  66442. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  66443. /**
  66444. * Gets positionIterations of the impostor
  66445. * @param impostor impostor to get position iterations from
  66446. * @returns positionIterations value
  66447. */
  66448. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  66449. /**
  66450. * Sets positionIterations of the impostor
  66451. * @param impostor impostor to set position on
  66452. * @param positionIterations positionIterations value
  66453. */
  66454. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  66455. /**
  66456. * Append an anchor to a cloth object
  66457. * @param impostor is the cloth impostor to add anchor to
  66458. * @param otherImpostor is the rigid impostor to anchor to
  66459. * @param width ratio across width from 0 to 1
  66460. * @param height ratio up height from 0 to 1
  66461. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little stretch
  66462. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  66463. */
  66464. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  66465. /**
  66466. * Append an hook to a rope object
  66467. * @param impostor is the rope impostor to add hook to
  66468. * @param otherImpostor is the rigid impostor to hook to
  66469. * @param length ratio along the rope from 0 to 1
  66470. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little stretch
  66471. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  66472. */
  66473. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  66474. /**
  66475. * Sleeps the physics body and stops it from being active
  66476. * @param impostor impostor to sleep
  66477. */
  66478. sleepBody(impostor: PhysicsImpostor): void;
  66479. /**
  66480. * Activates the physics body
  66481. * @param impostor impostor to activate
  66482. */
  66483. wakeUpBody(impostor: PhysicsImpostor): void;
  66484. /**
  66485. * Updates the distance parameters of the joint
  66486. * @param joint joint to update
  66487. * @param maxDistance maximum distance of the joint
  66488. * @param minDistance minimum distance of the joint
  66489. */
  66490. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  66491. /**
  66492. * Sets a motor on the joint
  66493. * @param joint joint to set motor on
  66494. * @param speed speed of the motor
  66495. * @param maxForce maximum force of the motor
  66496. * @param motorIndex index of the motor
  66497. */
  66498. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  66499. /**
  66500. * Sets the motors limit
  66501. * @param joint joint to set limit on
  66502. * @param upperLimit upper limit
  66503. * @param lowerLimit lower limit
  66504. */
  66505. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  66506. /**
  66507. * Syncs the position and rotation of a mesh with the impostor
  66508. * @param mesh mesh to sync
  66509. * @param impostor impostor to update the mesh with
  66510. */
  66511. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  66512. /**
  66513. * Gets the radius of the impostor
  66514. * @param impostor impostor to get radius from
  66515. * @returns the radius
  66516. */
  66517. getRadius(impostor: PhysicsImpostor): number;
  66518. /**
  66519. * Gets the box size of the impostor
  66520. * @param impostor impostor to get box size from
  66521. * @param result the resulting box size
  66522. */
  66523. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  66524. /**
  66525. * Disposes of the impostor
  66526. */
  66527. dispose(): void;
  66528. /**
  66529. * Does a raycast in the physics world
  66530. * @param from when should the ray start?
  66531. * @param to when should the ray end?
  66532. * @returns PhysicsRaycastResult
  66533. */
  66534. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  66535. }
  66536. }
  66537. declare module BABYLON {
  66538. interface AbstractScene {
  66539. /**
  66540. * The list of reflection probes added to the scene
  66541. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  66542. */
  66543. reflectionProbes: Array<ReflectionProbe>;
  66544. /**
  66545. * Removes the given reflection probe from this scene.
  66546. * @param toRemove The reflection probe to remove
  66547. * @returns The index of the removed reflection probe
  66548. */
  66549. removeReflectionProbe(toRemove: ReflectionProbe): number;
  66550. /**
  66551. * Adds the given reflection probe to this scene.
  66552. * @param newReflectionProbe The reflection probe to add
  66553. */
  66554. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  66555. }
  66556. /**
  66557. * Class used to generate realtime reflection / refraction cube textures
  66558. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  66559. */
  66560. export class ReflectionProbe {
  66561. /** defines the name of the probe */
  66562. name: string;
  66563. private _scene;
  66564. private _renderTargetTexture;
  66565. private _projectionMatrix;
  66566. private _viewMatrix;
  66567. private _target;
  66568. private _add;
  66569. private _attachedMesh;
  66570. private _invertYAxis;
  66571. /** Gets or sets probe position (center of the cube map) */
  66572. position: Vector3;
  66573. /**
  66574. * Creates a new reflection probe
  66575. * @param name defines the name of the probe
  66576. * @param size defines the texture resolution (for each face)
  66577. * @param scene defines the hosting scene
  66578. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  66579. * @param useFloat defines if HDR data (float data) should be used to store colors (false by default)
  66580. * @param linearSpace defines if the probe should be generated in linear space or not (false by default)
  66581. */
  66582. constructor(
  66583. /** defines the name of the probe */
  66584. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean, linearSpace?: boolean);
  66585. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  66586. get samples(): number;
  66587. set samples(value: number);
  66588. /** Gets or sets the refresh rate to use (on every frame by default) */
  66589. get refreshRate(): number;
  66590. set refreshRate(value: number);
  66591. /**
  66592. * Gets the hosting scene
  66593. * @returns a Scene
  66594. */
  66595. getScene(): Scene;
  66596. /** Gets the internal CubeTexture used to render to */
  66597. get cubeTexture(): RenderTargetTexture;
  66598. /** Gets the list of meshes to render */
  66599. get renderList(): Nullable<AbstractMesh[]>;
  66600. /**
  66601. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  66602. * @param mesh defines the mesh to attach to
  66603. */
  66604. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  66605. /**
  66606. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  66607. * @param renderingGroupId The rendering group id corresponding to its index
  66608. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  66609. */
  66610. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  66611. /**
  66612. * Clean all associated resources
  66613. */
  66614. dispose(): void;
  66615. /**
  66616. * Converts the reflection probe information to a readable string for debug purpose.
  66617. * @param fullDetails Supports for multiple levels of logging within scene loading
  66618. * @returns the human readable reflection probe info
  66619. */
  66620. toString(fullDetails?: boolean): string;
  66621. /**
  66622. * Get the class name of the refection probe.
  66623. * @returns "ReflectionProbe"
  66624. */
  66625. getClassName(): string;
  66626. /**
  66627. * Serialize the reflection probe to a JSON representation we can easily use in the respective Parse function.
  66628. * @returns The JSON representation of the texture
  66629. */
  66630. serialize(): any;
  66631. /**
  66632. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  66633. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  66634. * @param scene Define the scene the parsed reflection probe should be instantiated in
  66635. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  66636. * @returns The parsed reflection probe if successful
  66637. */
  66638. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  66639. }
  66640. }
  66641. declare module BABYLON {
  66642. /** @hidden */
  66643. export var _BabylonLoaderRegistered: boolean;
  66644. /**
  66645. * Helps setting up some configuration for the babylon file loader.
  66646. */
  66647. export class BabylonFileLoaderConfiguration {
  66648. /**
  66649. * The loader does not allow injecting custom physics engine into the plugins.
  66650. * Unfortunately in ES6, we need to manually inject them into the plugin.
  66651. * So you could set this variable to your engine import to make it work.
  66652. */
  66653. static LoaderInjectedPhysicsEngine: any;
  66654. }
  66655. }
  66656. declare module BABYLON {
  66657. /**
  66658. * A material to use for fast depth-only rendering.
  66659. */
  66660. export class OcclusionMaterial extends ShaderMaterial {
  66661. constructor(name: string, scene: Scene);
  66662. }
  66663. }
  66664. declare module BABYLON {
  66665. /**
  66666. * The Physically based simple base material of BJS.
  66667. *
  66668. * This enables better naming and convention enforcements on top of the pbrMaterial.
  66669. * It is used as the base class for both the specGloss and metalRough conventions.
  66670. */
  66671. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  66672. /**
  66673. * Number of Simultaneous lights allowed on the material.
  66674. */
  66675. maxSimultaneousLights: number;
  66676. /**
  66677. * If sets to true, disables all the lights affecting the material.
  66678. */
  66679. disableLighting: boolean;
  66680. /**
  66681. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  66682. */
  66683. environmentTexture: BaseTexture;
  66684. /**
  66685. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  66686. */
  66687. invertNormalMapX: boolean;
  66688. /**
  66689. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  66690. */
  66691. invertNormalMapY: boolean;
  66692. /**
  66693. * Normal map used in the model.
  66694. */
  66695. normalTexture: BaseTexture;
  66696. /**
  66697. * Emissivie color used to self-illuminate the model.
  66698. */
  66699. emissiveColor: Color3;
  66700. /**
  66701. * Emissivie texture used to self-illuminate the model.
  66702. */
  66703. emissiveTexture: BaseTexture;
  66704. /**
  66705. * Occlusion Channel Strength.
  66706. */
  66707. occlusionStrength: number;
  66708. /**
  66709. * Occlusion Texture of the material (adding extra occlusion effects).
  66710. */
  66711. occlusionTexture: BaseTexture;
  66712. /**
  66713. * Defines the alpha limits in alpha test mode.
  66714. */
  66715. alphaCutOff: number;
  66716. /**
  66717. * Gets the current double sided mode.
  66718. */
  66719. get doubleSided(): boolean;
  66720. /**
  66721. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  66722. */
  66723. set doubleSided(value: boolean);
  66724. /**
  66725. * Stores the pre-calculated light information of a mesh in a texture.
  66726. */
  66727. lightmapTexture: BaseTexture;
  66728. /**
  66729. * If true, the light map contains occlusion information instead of lighting info.
  66730. */
  66731. useLightmapAsShadowmap: boolean;
  66732. /**
  66733. * Instantiates a new PBRMaterial instance.
  66734. *
  66735. * @param name The material name
  66736. * @param scene The scene the material will be use in.
  66737. */
  66738. constructor(name: string, scene: Scene);
  66739. getClassName(): string;
  66740. }
  66741. }
  66742. declare module BABYLON {
  66743. /**
  66744. * The PBR material of BJS following the metal roughness convention.
  66745. *
  66746. * This fits to the PBR convention in the GLTF definition:
  66747. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  66748. */
  66749. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  66750. /**
  66751. * The base color has two different interpretations depending on the value of metalness.
  66752. * When the material is a metal, the base color is the specific measured reflectance value
  66753. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  66754. * of the material.
  66755. */
  66756. baseColor: Color3;
  66757. /**
  66758. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  66759. * well as opacity information in the alpha channel.
  66760. */
  66761. baseTexture: BaseTexture;
  66762. /**
  66763. * Specifies the metallic scalar value of the material.
  66764. * Can also be used to scale the metalness values of the metallic texture.
  66765. */
  66766. metallic: number;
  66767. /**
  66768. * Specifies the roughness scalar value of the material.
  66769. * Can also be used to scale the roughness values of the metallic texture.
  66770. */
  66771. roughness: number;
  66772. /**
  66773. * Texture containing both the metallic value in the B channel and the
  66774. * roughness value in the G channel to keep better precision.
  66775. */
  66776. metallicRoughnessTexture: BaseTexture;
  66777. /**
  66778. * Instantiates a new PBRMetalRoughnessMaterial instance.
  66779. *
  66780. * @param name The material name
  66781. * @param scene The scene the material will be use in.
  66782. */
  66783. constructor(name: string, scene: Scene);
  66784. /**
  66785. * Return the current class name of the material.
  66786. */
  66787. getClassName(): string;
  66788. /**
  66789. * Makes a duplicate of the current material.
  66790. * @param name - name to use for the new material.
  66791. */
  66792. clone(name: string): PBRMetallicRoughnessMaterial;
  66793. /**
  66794. * Serialize the material to a parsable JSON object.
  66795. */
  66796. serialize(): any;
  66797. /**
  66798. * Parses a JSON object corresponding to the serialize function.
  66799. */
  66800. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  66801. }
  66802. }
  66803. declare module BABYLON {
  66804. /**
  66805. * The PBR material of BJS following the specular glossiness convention.
  66806. *
  66807. * This fits to the PBR convention in the GLTF definition:
  66808. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  66809. */
  66810. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  66811. /**
  66812. * Specifies the diffuse color of the material.
  66813. */
  66814. diffuseColor: Color3;
  66815. /**
  66816. * Specifies the diffuse texture of the material. This can also contains the opacity value in its alpha
  66817. * channel.
  66818. */
  66819. diffuseTexture: BaseTexture;
  66820. /**
  66821. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  66822. */
  66823. specularColor: Color3;
  66824. /**
  66825. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  66826. */
  66827. glossiness: number;
  66828. /**
  66829. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  66830. */
  66831. specularGlossinessTexture: BaseTexture;
  66832. /**
  66833. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  66834. */
  66835. get useMicroSurfaceFromReflectivityMapAlpha(): boolean;
  66836. /**
  66837. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  66838. *
  66839. * @param name The material name
  66840. * @param scene The scene the material will be use in.
  66841. */
  66842. constructor(name: string, scene: Scene);
  66843. /**
  66844. * Return the current class name of the material.
  66845. */
  66846. getClassName(): string;
  66847. /**
  66848. * Makes a duplicate of the current material.
  66849. * @param name - name to use for the new material.
  66850. */
  66851. clone(name: string): PBRSpecularGlossinessMaterial;
  66852. /**
  66853. * Serialize the material to a parsable JSON object.
  66854. */
  66855. serialize(): any;
  66856. /**
  66857. * Parses a JSON object corresponding to the serialize function.
  66858. */
  66859. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  66860. }
  66861. }
  66862. declare module BABYLON {
  66863. /**
  66864. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  66865. * It can help converting any input color in a desired output one. This can then be used to create effects
  66866. * from sepia, black and white to sixties or futuristic rendering...
  66867. *
  66868. * The only supported format is currently 3dl.
  66869. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  66870. */
  66871. export class ColorGradingTexture extends BaseTexture {
  66872. /**
  66873. * The texture URL.
  66874. */
  66875. url: string;
  66876. /**
  66877. * Empty line regex stored for GC.
  66878. */
  66879. private static _noneEmptyLineRegex;
  66880. private _textureMatrix;
  66881. private _onLoad;
  66882. /**
  66883. * Instantiates a ColorGradingTexture from the following parameters.
  66884. *
  66885. * @param url The location of the color grading data (currently only supporting 3dl)
  66886. * @param sceneOrEngine The scene or engine the texture will be used in
  66887. * @param onLoad defines a callback triggered when the texture has been loaded
  66888. */
  66889. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  66890. /**
  66891. * Fires the onload event from the constructor if requested.
  66892. */
  66893. private _triggerOnLoad;
  66894. /**
  66895. * Returns the texture matrix used in most of the material.
  66896. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  66897. */
  66898. getTextureMatrix(): Matrix;
  66899. /**
  66900. * Occurs when the file being loaded is a .3dl LUT file.
  66901. */
  66902. private load3dlTexture;
  66903. /**
  66904. * Starts the loading process of the texture.
  66905. */
  66906. private loadTexture;
  66907. /**
  66908. * Clones the color grading texture.
  66909. */
  66910. clone(): ColorGradingTexture;
  66911. /**
  66912. * Called during delayed load for textures.
  66913. */
  66914. delayLoad(): void;
  66915. /**
  66916. * Parses a color grading texture serialized by Babylon.
  66917. * @param parsedTexture The texture information being parsedTexture
  66918. * @param scene The scene to load the texture in
  66919. * @param rootUrl The root url of the data assets to load
  66920. * @return A color grading texture
  66921. */
  66922. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  66923. /**
  66924. * Serializes the LUT texture to json format.
  66925. */
  66926. serialize(): any;
  66927. }
  66928. }
  66929. declare module BABYLON {
  66930. /**
  66931. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  66932. */
  66933. export class EquiRectangularCubeTexture extends BaseTexture {
  66934. /** The six faces of the cube. */
  66935. private static _FacesMapping;
  66936. private _noMipmap;
  66937. private _onLoad;
  66938. private _onError;
  66939. /** The size of the cubemap. */
  66940. private _size;
  66941. /** The buffer of the image. */
  66942. private _buffer;
  66943. /** The width of the input image. */
  66944. private _width;
  66945. /** The height of the input image. */
  66946. private _height;
  66947. /** The URL to the image. */
  66948. url: string;
  66949. /**
  66950. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  66951. * @param url The location of the image
  66952. * @param scene The scene the texture will be used in
  66953. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  66954. * @param noMipmap Forces to not generate the mipmap if true
  66955. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  66956. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  66957. * @param onLoad — defines a callback called when texture is loaded
  66958. * @param onError — defines a callback called if there is an error
  66959. */
  66960. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  66961. /**
  66962. * Load the image data, by putting the image on a canvas and extracting its buffer.
  66963. */
  66964. private loadImage;
  66965. /**
  66966. * Convert the image buffer into a cubemap and create a CubeTexture.
  66967. */
  66968. private loadTexture;
  66969. /**
  66970. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  66971. * @param buffer The ArrayBuffer that should be converted.
  66972. * @returns The buffer as Float32Array.
  66973. */
  66974. private getFloat32ArrayFromArrayBuffer;
  66975. /**
  66976. * Get the current class name of the texture useful for serialization or dynamic coding.
  66977. * @returns "EquiRectangularCubeTexture"
  66978. */
  66979. getClassName(): string;
  66980. /**
  66981. * Create a clone of the current EquiRectangularCubeTexture and return it.
  66982. * @returns A clone of the current EquiRectangularCubeTexture.
  66983. */
  66984. clone(): EquiRectangularCubeTexture;
  66985. }
  66986. }
  66987. declare module BABYLON {
  66988. /**
  66989. * Defines the options related to the creation of an HtmlElementTexture
  66990. */
  66991. export interface IHtmlElementTextureOptions {
  66992. /**
  66993. * Defines whether mip maps should be created or not.
  66994. */
  66995. generateMipMaps?: boolean;
  66996. /**
  66997. * Defines the sampling mode of the texture.
  66998. */
  66999. samplingMode?: number;
  67000. /**
  67001. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  67002. */
  67003. engine: Nullable<ThinEngine>;
  67004. /**
  67005. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  67006. */
  67007. scene: Nullable<Scene>;
  67008. }
  67009. /**
  67010. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  67011. * To be as efficient as possible depending on your constraints nothing aside the first upload
  67012. * is automatically managed.
  67013. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  67014. * in your application.
  67015. *
  67016. * As the update is not automatic, you need to call them manually.
  67017. */
  67018. export class HtmlElementTexture extends BaseTexture {
  67019. /**
  67020. * The texture URL.
  67021. */
  67022. element: HTMLVideoElement | HTMLCanvasElement;
  67023. private static readonly DefaultOptions;
  67024. private _textureMatrix;
  67025. private _isVideo;
  67026. private _generateMipMaps;
  67027. private _samplingMode;
  67028. /**
  67029. * Instantiates a HtmlElementTexture from the following parameters.
  67030. *
  67031. * @param name Defines the name of the texture
  67032. * @param element Defines the video or canvas the texture is filled with
  67033. * @param options Defines the other none mandatory texture creation options
  67034. */
  67035. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  67036. private _createInternalTexture;
  67037. /**
  67038. * Returns the texture matrix used in most of the material.
  67039. */
  67040. getTextureMatrix(): Matrix;
  67041. /**
  67042. * Updates the content of the texture.
  67043. * @param invertY Defines whether the texture should be inverted on Y (false by default on video and true on canvas)
  67044. */
  67045. update(invertY?: Nullable<boolean>): void;
  67046. }
  67047. }
  67048. declare module BABYLON {
  67049. /**
  67050. * Based on jsTGALoader - Javascript loader for TGA file
  67051. * By Vincent Thibault
  67052. * @see http://blog.robrowser.com/javascript-tga-loader.html
  67053. */
  67054. export class TGATools {
  67055. private static _TYPE_INDEXED;
  67056. private static _TYPE_RGB;
  67057. private static _TYPE_GREY;
  67058. private static _TYPE_RLE_INDEXED;
  67059. private static _TYPE_RLE_RGB;
  67060. private static _TYPE_RLE_GREY;
  67061. private static _ORIGIN_MASK;
  67062. private static _ORIGIN_SHIFT;
  67063. private static _ORIGIN_BL;
  67064. private static _ORIGIN_BR;
  67065. private static _ORIGIN_UL;
  67066. private static _ORIGIN_UR;
  67067. /**
  67068. * Gets the header of a TGA file
  67069. * @param data defines the TGA data
  67070. * @returns the header
  67071. */
  67072. static GetTGAHeader(data: Uint8Array): any;
  67073. /**
  67074. * Uploads TGA content to a Babylon Texture
  67075. * @hidden
  67076. */
  67077. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  67078. /** @hidden */
  67079. 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;
  67080. /** @hidden */
  67081. 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;
  67082. /** @hidden */
  67083. 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;
  67084. /** @hidden */
  67085. 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;
  67086. /** @hidden */
  67087. 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;
  67088. /** @hidden */
  67089. 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;
  67090. }
  67091. }
  67092. declare module BABYLON {
  67093. /**
  67094. * Implementation of the TGA Texture Loader.
  67095. * @hidden
  67096. */
  67097. export class _TGATextureLoader implements IInternalTextureLoader {
  67098. /**
  67099. * Defines whether the loader supports cascade loading the different faces.
  67100. */
  67101. readonly supportCascades: boolean;
  67102. /**
  67103. * This returns if the loader support the current file information.
  67104. * @param extension defines the file extension of the file being loaded
  67105. * @returns true if the loader can load the specified file
  67106. */
  67107. canLoad(extension: string): boolean;
  67108. /**
  67109. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  67110. * @param data contains the texture data
  67111. * @param texture defines the BabylonJS internal texture
  67112. * @param createPolynomials will be true if polynomials have been requested
  67113. * @param onLoad defines the callback to trigger once the texture is ready
  67114. * @param onError defines the callback to trigger in case of error
  67115. */
  67116. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  67117. /**
  67118. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  67119. * @param data contains the texture data
  67120. * @param texture defines the BabylonJS internal texture
  67121. * @param callback defines the method to call once ready to upload
  67122. */
  67123. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  67124. }
  67125. }
  67126. declare module BABYLON {
  67127. /**
  67128. * Implementation of the HDR Texture Loader.
  67129. * @hidden
  67130. */
  67131. export class _HDRTextureLoader implements IInternalTextureLoader {
  67132. /**
  67133. * Defines whether the loader supports cascade loading the different faces.
  67134. */
  67135. readonly supportCascades: boolean;
  67136. /**
  67137. * This returns if the loader support the current file information.
  67138. * @param extension defines the file extension of the file being loaded
  67139. * @returns true if the loader can load the specified file
  67140. */
  67141. canLoad(extension: string): boolean;
  67142. /**
  67143. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  67144. * @param data contains the texture data
  67145. * @param texture defines the BabylonJS internal texture
  67146. * @param createPolynomials will be true if polynomials have been requested
  67147. * @param onLoad defines the callback to trigger once the texture is ready
  67148. * @param onError defines the callback to trigger in case of error
  67149. */
  67150. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  67151. /**
  67152. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  67153. * @param data contains the texture data
  67154. * @param texture defines the BabylonJS internal texture
  67155. * @param callback defines the method to call once ready to upload
  67156. */
  67157. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  67158. }
  67159. }
  67160. declare module BABYLON {
  67161. /**
  67162. * Info about the .basis files
  67163. */
  67164. class BasisFileInfo {
  67165. /**
  67166. * If the file has alpha
  67167. */
  67168. hasAlpha: boolean;
  67169. /**
  67170. * Info about each image of the basis file
  67171. */
  67172. images: Array<{
  67173. levels: Array<{
  67174. width: number;
  67175. height: number;
  67176. transcodedPixels: ArrayBufferView;
  67177. }>;
  67178. }>;
  67179. }
  67180. /**
  67181. * Result of transcoding a basis file
  67182. */
  67183. class TranscodeResult {
  67184. /**
  67185. * Info about the .basis file
  67186. */
  67187. fileInfo: BasisFileInfo;
  67188. /**
  67189. * Format to use when loading the file
  67190. */
  67191. format: number;
  67192. }
  67193. /**
  67194. * Configuration options for the Basis transcoder
  67195. */
  67196. export class BasisTranscodeConfiguration {
  67197. /**
  67198. * Supported compression formats used to determine the supported output format of the transcoder
  67199. */
  67200. supportedCompressionFormats?: {
  67201. /**
  67202. * etc1 compression format
  67203. */
  67204. etc1?: boolean;
  67205. /**
  67206. * s3tc compression format
  67207. */
  67208. s3tc?: boolean;
  67209. /**
  67210. * pvrtc compression format
  67211. */
  67212. pvrtc?: boolean;
  67213. /**
  67214. * etc2 compression format
  67215. */
  67216. etc2?: boolean;
  67217. };
  67218. /**
  67219. * If mipmap levels should be loaded for transcoded images (Default: true)
  67220. */
  67221. loadMipmapLevels?: boolean;
  67222. /**
  67223. * Index of a single image to load (Default: all images)
  67224. */
  67225. loadSingleImage?: number;
  67226. }
  67227. /**
  67228. * Used to load .Basis files
  67229. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  67230. */
  67231. export class BasisTools {
  67232. private static _IgnoreSupportedFormats;
  67233. /**
  67234. * URL to use when loading the basis transcoder
  67235. */
  67236. static JSModuleURL: string;
  67237. /**
  67238. * URL to use when loading the wasm module for the transcoder
  67239. */
  67240. static WasmModuleURL: string;
  67241. /**
  67242. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  67243. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  67244. * @returns internal format corresponding to the Basis format
  67245. */
  67246. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  67247. private static _WorkerPromise;
  67248. private static _Worker;
  67249. private static _actionId;
  67250. private static _CreateWorkerAsync;
  67251. /**
  67252. * Transcodes a loaded image file to compressed pixel data
  67253. * @param data image data to transcode
  67254. * @param config configuration options for the transcoding
  67255. * @returns a promise resulting in the transcoded image
  67256. */
  67257. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  67258. /**
  67259. * Loads a texture from the transcode result
  67260. * @param texture texture load to
  67261. * @param transcodeResult the result of transcoding the basis file to load from
  67262. */
  67263. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  67264. }
  67265. }
  67266. declare module BABYLON {
  67267. /**
  67268. * Loader for .basis file format
  67269. */
  67270. export class _BasisTextureLoader implements IInternalTextureLoader {
  67271. /**
  67272. * Defines whether the loader supports cascade loading the different faces.
  67273. */
  67274. readonly supportCascades: boolean;
  67275. /**
  67276. * This returns if the loader support the current file information.
  67277. * @param extension defines the file extension of the file being loaded
  67278. * @returns true if the loader can load the specified file
  67279. */
  67280. canLoad(extension: string): boolean;
  67281. /**
  67282. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  67283. * @param data contains the texture data
  67284. * @param texture defines the BabylonJS internal texture
  67285. * @param createPolynomials will be true if polynomials have been requested
  67286. * @param onLoad defines the callback to trigger once the texture is ready
  67287. * @param onError defines the callback to trigger in case of error
  67288. */
  67289. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  67290. /**
  67291. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  67292. * @param data contains the texture data
  67293. * @param texture defines the BabylonJS internal texture
  67294. * @param callback defines the method to call once ready to upload
  67295. */
  67296. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  67297. }
  67298. }
  67299. declare module BABYLON {
  67300. /**
  67301. * Defines the basic options interface of a TexturePacker Frame
  67302. */
  67303. export interface ITexturePackerFrame {
  67304. /**
  67305. * The frame ID
  67306. */
  67307. id: number;
  67308. /**
  67309. * The frames Scale
  67310. */
  67311. scale: Vector2;
  67312. /**
  67313. * The Frames offset
  67314. */
  67315. offset: Vector2;
  67316. }
  67317. /**
  67318. * This is a support class for frame Data on texture packer sets.
  67319. */
  67320. export class TexturePackerFrame implements ITexturePackerFrame {
  67321. /**
  67322. * The frame ID
  67323. */
  67324. id: number;
  67325. /**
  67326. * The frames Scale
  67327. */
  67328. scale: Vector2;
  67329. /**
  67330. * The Frames offset
  67331. */
  67332. offset: Vector2;
  67333. /**
  67334. * Initializes a texture package frame.
  67335. * @param id The numerical frame identifier
  67336. * @param scale Scalar Vector2 for UV frame
  67337. * @param offset Vector2 for the frame position in UV units.
  67338. * @returns TexturePackerFrame
  67339. */
  67340. constructor(id: number, scale: Vector2, offset: Vector2);
  67341. }
  67342. }
  67343. declare module BABYLON {
  67344. /**
  67345. * Defines the basic options interface of a TexturePacker
  67346. */
  67347. export interface ITexturePackerOptions {
  67348. /**
  67349. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  67350. */
  67351. map?: string[];
  67352. /**
  67353. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  67354. */
  67355. uvsIn?: string;
  67356. /**
  67357. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  67358. */
  67359. uvsOut?: string;
  67360. /**
  67361. * number representing the layout style. Defaults to LAYOUT_STRIP
  67362. */
  67363. layout?: number;
  67364. /**
  67365. * number of columns if using custom column count layout(2). This defaults to 4.
  67366. */
  67367. colnum?: number;
  67368. /**
  67369. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  67370. */
  67371. updateInputMeshes?: boolean;
  67372. /**
  67373. * boolean flag to dispose all the source textures. Defaults to true.
  67374. */
  67375. disposeSources?: boolean;
  67376. /**
  67377. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  67378. */
  67379. fillBlanks?: boolean;
  67380. /**
  67381. * string value representing the context fill style color. Defaults to 'black'.
  67382. */
  67383. customFillColor?: string;
  67384. /**
  67385. * Width and Height Value of each Frame in the TexturePacker Sets
  67386. */
  67387. frameSize?: number;
  67388. /**
  67389. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  67390. */
  67391. paddingRatio?: number;
  67392. /**
  67393. * Number that declares the fill method for the padding gutter.
  67394. */
  67395. paddingMode?: number;
  67396. /**
  67397. * If in SUBUV_COLOR padding mode what color to use.
  67398. */
  67399. paddingColor?: Color3 | Color4;
  67400. }
  67401. /**
  67402. * Defines the basic interface of a TexturePacker JSON File
  67403. */
  67404. export interface ITexturePackerJSON {
  67405. /**
  67406. * The frame ID
  67407. */
  67408. name: string;
  67409. /**
  67410. * The base64 channel data
  67411. */
  67412. sets: any;
  67413. /**
  67414. * The options of the Packer
  67415. */
  67416. options: ITexturePackerOptions;
  67417. /**
  67418. * The frame data of the Packer
  67419. */
  67420. frames: Array<number>;
  67421. }
  67422. /**
  67423. * This is a support class that generates a series of packed texture sets.
  67424. * @see https://doc.babylonjs.com/babylon101/materials
  67425. */
  67426. export class TexturePacker {
  67427. /** Packer Layout Constant 0 */
  67428. static readonly LAYOUT_STRIP: number;
  67429. /** Packer Layout Constant 1 */
  67430. static readonly LAYOUT_POWER2: number;
  67431. /** Packer Layout Constant 2 */
  67432. static readonly LAYOUT_COLNUM: number;
  67433. /** Packer Layout Constant 0 */
  67434. static readonly SUBUV_WRAP: number;
  67435. /** Packer Layout Constant 1 */
  67436. static readonly SUBUV_EXTEND: number;
  67437. /** Packer Layout Constant 2 */
  67438. static readonly SUBUV_COLOR: number;
  67439. /** The Name of the Texture Package */
  67440. name: string;
  67441. /** The scene scope of the TexturePacker */
  67442. scene: Scene;
  67443. /** The Meshes to target */
  67444. meshes: AbstractMesh[];
  67445. /** Arguments passed with the Constructor */
  67446. options: ITexturePackerOptions;
  67447. /** The promise that is started upon initialization */
  67448. promise: Nullable<Promise<TexturePacker | string>>;
  67449. /** The Container object for the channel sets that are generated */
  67450. sets: object;
  67451. /** The Container array for the frames that are generated */
  67452. frames: TexturePackerFrame[];
  67453. /** The expected number of textures the system is parsing. */
  67454. private _expecting;
  67455. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  67456. private _paddingValue;
  67457. /**
  67458. * Initializes a texture package series from an array of meshes or a single mesh.
  67459. * @param name The name of the package
  67460. * @param meshes The target meshes to compose the package from
  67461. * @param options The arguments that texture packer should follow while building.
  67462. * @param scene The scene which the textures are scoped to.
  67463. * @returns TexturePacker
  67464. */
  67465. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  67466. /**
  67467. * Starts the package process
  67468. * @param resolve The promises resolution function
  67469. * @returns TexturePacker
  67470. */
  67471. private _createFrames;
  67472. /**
  67473. * Calculates the Size of the Channel Sets
  67474. * @returns Vector2
  67475. */
  67476. private _calculateSize;
  67477. /**
  67478. * Calculates the UV data for the frames.
  67479. * @param baseSize the base frameSize
  67480. * @param padding the base frame padding
  67481. * @param dtSize size of the Dynamic Texture for that channel
  67482. * @param dtUnits is 1/dtSize
  67483. * @param update flag to update the input meshes
  67484. */
  67485. private _calculateMeshUVFrames;
  67486. /**
  67487. * Calculates the frames Offset.
  67488. * @param index of the frame
  67489. * @returns Vector2
  67490. */
  67491. private _getFrameOffset;
  67492. /**
  67493. * Updates a Mesh to the frame data
  67494. * @param mesh that is the target
  67495. * @param frameID or the frame index
  67496. */
  67497. private _updateMeshUV;
  67498. /**
  67499. * Updates a Meshes materials to use the texture packer channels
  67500. * @param m is the mesh to target
  67501. * @param force all channels on the packer to be set.
  67502. */
  67503. private _updateTextureReferences;
  67504. /**
  67505. * Public method to set a Mesh to a frame
  67506. * @param m that is the target
  67507. * @param frameID or the frame index
  67508. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  67509. */
  67510. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  67511. /**
  67512. * Starts the async promise to compile the texture packer.
  67513. * @returns Promise<void>
  67514. */
  67515. processAsync(): Promise<void>;
  67516. /**
  67517. * Disposes all textures associated with this packer
  67518. */
  67519. dispose(): void;
  67520. /**
  67521. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  67522. * @param imageType is the image type to use.
  67523. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  67524. */
  67525. download(imageType?: string, quality?: number): void;
  67526. /**
  67527. * Public method to load a texturePacker JSON file.
  67528. * @param data of the JSON file in string format.
  67529. */
  67530. updateFromJSON(data: string): void;
  67531. }
  67532. }
  67533. declare module BABYLON {
  67534. /**
  67535. * 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.
  67536. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  67537. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  67538. */
  67539. export class CustomProceduralTexture extends ProceduralTexture {
  67540. private _animate;
  67541. private _time;
  67542. private _config;
  67543. private _texturePath;
  67544. /**
  67545. * Instantiates a new Custom Procedural Texture.
  67546. * 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.
  67547. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  67548. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  67549. * @param name Define the name of the texture
  67550. * @param texturePath Define the folder path containing all the custom texture related files (config, shaders...)
  67551. * @param size Define the size of the texture to create
  67552. * @param scene Define the scene the texture belongs to
  67553. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  67554. * @param generateMipMaps Define if the texture should creates mip maps or not
  67555. */
  67556. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  67557. private _loadJson;
  67558. /**
  67559. * Is the texture ready to be used ? (rendered at least once)
  67560. * @returns true if ready, otherwise, false.
  67561. */
  67562. isReady(): boolean;
  67563. /**
  67564. * Render the texture to its associated render target.
  67565. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  67566. */
  67567. render(useCameraPostProcess?: boolean): void;
  67568. /**
  67569. * Update the list of dependant textures samplers in the shader.
  67570. */
  67571. updateTextures(): void;
  67572. /**
  67573. * Update the uniform values of the procedural texture in the shader.
  67574. */
  67575. updateShaderUniforms(): void;
  67576. /**
  67577. * Define if the texture animates or not.
  67578. */
  67579. get animate(): boolean;
  67580. set animate(value: boolean);
  67581. }
  67582. }
  67583. declare module BABYLON {
  67584. /** @hidden */
  67585. export var noisePixelShader: {
  67586. name: string;
  67587. shader: string;
  67588. };
  67589. }
  67590. declare module BABYLON {
  67591. /**
  67592. * Class used to generate noise procedural textures
  67593. */
  67594. export class NoiseProceduralTexture extends ProceduralTexture {
  67595. /** Gets or sets the start time (default is 0) */
  67596. time: number;
  67597. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  67598. brightness: number;
  67599. /** Defines the number of octaves to process */
  67600. octaves: number;
  67601. /** Defines the level of persistence (0.8 by default) */
  67602. persistence: number;
  67603. /** Gets or sets animation speed factor (default is 1) */
  67604. animationSpeedFactor: number;
  67605. /**
  67606. * Creates a new NoiseProceduralTexture
  67607. * @param name defines the name fo the texture
  67608. * @param size defines the size of the texture (default is 256)
  67609. * @param scene defines the hosting scene
  67610. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  67611. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  67612. */
  67613. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  67614. private _updateShaderUniforms;
  67615. protected _getDefines(): string;
  67616. /** Generate the current state of the procedural texture */
  67617. render(useCameraPostProcess?: boolean): void;
  67618. /**
  67619. * Serializes this noise procedural texture
  67620. * @returns a serialized noise procedural texture object
  67621. */
  67622. serialize(): any;
  67623. /**
  67624. * Clone the texture.
  67625. * @returns the cloned texture
  67626. */
  67627. clone(): NoiseProceduralTexture;
  67628. /**
  67629. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  67630. * @param parsedTexture defines parsed texture data
  67631. * @param scene defines the current scene
  67632. * @param rootUrl defines the root URL containing noise procedural texture information
  67633. * @returns a parsed NoiseProceduralTexture
  67634. */
  67635. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  67636. }
  67637. }
  67638. declare module BABYLON {
  67639. /**
  67640. * Raw cube texture where the raw buffers are passed in
  67641. */
  67642. export class RawCubeTexture extends CubeTexture {
  67643. /**
  67644. * Creates a cube texture where the raw buffers are passed in.
  67645. * @param scene defines the scene the texture is attached to
  67646. * @param data defines the array of data to use to create each face
  67647. * @param size defines the size of the textures
  67648. * @param format defines the format of the data
  67649. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  67650. * @param generateMipMaps defines if the engine should generate the mip levels
  67651. * @param invertY defines if data must be stored with Y axis inverted
  67652. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  67653. * @param compression defines the compression used (null by default)
  67654. */
  67655. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  67656. /**
  67657. * Updates the raw cube texture.
  67658. * @param data defines the data to store
  67659. * @param format defines the data format
  67660. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  67661. * @param invertY defines if data must be stored with Y axis inverted
  67662. * @param compression defines the compression used (null by default)
  67663. * @param level defines which level of the texture to update
  67664. */
  67665. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  67666. /**
  67667. * Updates a raw cube texture with RGBD encoded data.
  67668. * @param data defines the array of data [mipmap][face] to use to create each face
  67669. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  67670. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  67671. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  67672. * @returns a promise that resolves when the operation is complete
  67673. */
  67674. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  67675. /**
  67676. * Clones the raw cube texture.
  67677. * @return a new cube texture
  67678. */
  67679. clone(): CubeTexture;
  67680. /** @hidden */
  67681. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  67682. }
  67683. }
  67684. declare module BABYLON {
  67685. /**
  67686. * Class used to store 3D textures containing user data
  67687. */
  67688. export class RawTexture3D extends Texture {
  67689. /** Gets or sets the texture format to use */
  67690. format: number;
  67691. /**
  67692. * Create a new RawTexture3D
  67693. * @param data defines the data of the texture
  67694. * @param width defines the width of the texture
  67695. * @param height defines the height of the texture
  67696. * @param depth defines the depth of the texture
  67697. * @param format defines the texture format to use
  67698. * @param scene defines the hosting scene
  67699. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  67700. * @param invertY defines if texture must be stored with Y axis inverted
  67701. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67702. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  67703. */
  67704. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  67705. /** Gets or sets the texture format to use */
  67706. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  67707. /**
  67708. * Update the texture with new data
  67709. * @param data defines the data to store in the texture
  67710. */
  67711. update(data: ArrayBufferView): void;
  67712. }
  67713. }
  67714. declare module BABYLON {
  67715. /**
  67716. * Creates a refraction texture used by refraction channel of the standard material.
  67717. * It is like a mirror but to see through a material.
  67718. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  67719. */
  67720. export class RefractionTexture extends RenderTargetTexture {
  67721. /**
  67722. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  67723. * 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.
  67724. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  67725. */
  67726. refractionPlane: Plane;
  67727. /**
  67728. * Define how deep under the surface we should see.
  67729. */
  67730. depth: number;
  67731. /**
  67732. * Creates a refraction texture used by refraction channel of the standard material.
  67733. * It is like a mirror but to see through a material.
  67734. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  67735. * @param name Define the texture name
  67736. * @param size Define the size of the underlying texture
  67737. * @param scene Define the scene the refraction belongs to
  67738. * @param generateMipMaps Define if we need to generate mips level for the refraction
  67739. */
  67740. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  67741. /**
  67742. * Clone the refraction texture.
  67743. * @returns the cloned texture
  67744. */
  67745. clone(): RefractionTexture;
  67746. /**
  67747. * Serialize the texture to a JSON representation you could use in Parse later on
  67748. * @returns the serialized JSON representation
  67749. */
  67750. serialize(): any;
  67751. }
  67752. }
  67753. declare module BABYLON {
  67754. /**
  67755. * Block used to add support for vertex skinning (bones)
  67756. */
  67757. export class BonesBlock extends NodeMaterialBlock {
  67758. /**
  67759. * Creates a new BonesBlock
  67760. * @param name defines the block name
  67761. */
  67762. constructor(name: string);
  67763. /**
  67764. * Initialize the block and prepare the context for build
  67765. * @param state defines the state that will be used for the build
  67766. */
  67767. initialize(state: NodeMaterialBuildState): void;
  67768. /**
  67769. * Gets the current class name
  67770. * @returns the class name
  67771. */
  67772. getClassName(): string;
  67773. /**
  67774. * Gets the matrix indices input component
  67775. */
  67776. get matricesIndices(): NodeMaterialConnectionPoint;
  67777. /**
  67778. * Gets the matrix weights input component
  67779. */
  67780. get matricesWeights(): NodeMaterialConnectionPoint;
  67781. /**
  67782. * Gets the extra matrix indices input component
  67783. */
  67784. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  67785. /**
  67786. * Gets the extra matrix weights input component
  67787. */
  67788. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  67789. /**
  67790. * Gets the world input component
  67791. */
  67792. get world(): NodeMaterialConnectionPoint;
  67793. /**
  67794. * Gets the output component
  67795. */
  67796. get output(): NodeMaterialConnectionPoint;
  67797. autoConfigure(material: NodeMaterial): void;
  67798. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  67799. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67800. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67801. protected _buildBlock(state: NodeMaterialBuildState): this;
  67802. }
  67803. }
  67804. declare module BABYLON {
  67805. /**
  67806. * Block used to add support for instances
  67807. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  67808. */
  67809. export class InstancesBlock extends NodeMaterialBlock {
  67810. /**
  67811. * Creates a new InstancesBlock
  67812. * @param name defines the block name
  67813. */
  67814. constructor(name: string);
  67815. /**
  67816. * Gets the current class name
  67817. * @returns the class name
  67818. */
  67819. getClassName(): string;
  67820. /**
  67821. * Gets the first world row input component
  67822. */
  67823. get world0(): NodeMaterialConnectionPoint;
  67824. /**
  67825. * Gets the second world row input component
  67826. */
  67827. get world1(): NodeMaterialConnectionPoint;
  67828. /**
  67829. * Gets the third world row input component
  67830. */
  67831. get world2(): NodeMaterialConnectionPoint;
  67832. /**
  67833. * Gets the forth world row input component
  67834. */
  67835. get world3(): NodeMaterialConnectionPoint;
  67836. /**
  67837. * Gets the world input component
  67838. */
  67839. get world(): NodeMaterialConnectionPoint;
  67840. /**
  67841. * Gets the output component
  67842. */
  67843. get output(): NodeMaterialConnectionPoint;
  67844. /**
  67845. * Gets the instanceID component
  67846. */
  67847. get instanceID(): NodeMaterialConnectionPoint;
  67848. autoConfigure(material: NodeMaterial): void;
  67849. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  67850. protected _buildBlock(state: NodeMaterialBuildState): this;
  67851. }
  67852. }
  67853. declare module BABYLON {
  67854. /**
  67855. * Block used to add morph targets support to vertex shader
  67856. */
  67857. export class MorphTargetsBlock extends NodeMaterialBlock {
  67858. private _repeatableContentAnchor;
  67859. /**
  67860. * Create a new MorphTargetsBlock
  67861. * @param name defines the block name
  67862. */
  67863. constructor(name: string);
  67864. /**
  67865. * Gets the current class name
  67866. * @returns the class name
  67867. */
  67868. getClassName(): string;
  67869. /**
  67870. * Gets the position input component
  67871. */
  67872. get position(): NodeMaterialConnectionPoint;
  67873. /**
  67874. * Gets the normal input component
  67875. */
  67876. get normal(): NodeMaterialConnectionPoint;
  67877. /**
  67878. * Gets the tangent input component
  67879. */
  67880. get tangent(): NodeMaterialConnectionPoint;
  67881. /**
  67882. * Gets the tangent input component
  67883. */
  67884. get uv(): NodeMaterialConnectionPoint;
  67885. /**
  67886. * Gets the position output component
  67887. */
  67888. get positionOutput(): NodeMaterialConnectionPoint;
  67889. /**
  67890. * Gets the normal output component
  67891. */
  67892. get normalOutput(): NodeMaterialConnectionPoint;
  67893. /**
  67894. * Gets the tangent output component
  67895. */
  67896. get tangentOutput(): NodeMaterialConnectionPoint;
  67897. /**
  67898. * Gets the tangent output component
  67899. */
  67900. get uvOutput(): NodeMaterialConnectionPoint;
  67901. initialize(state: NodeMaterialBuildState): void;
  67902. autoConfigure(material: NodeMaterial): void;
  67903. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67904. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67905. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  67906. protected _buildBlock(state: NodeMaterialBuildState): this;
  67907. }
  67908. }
  67909. declare module BABYLON {
  67910. /**
  67911. * Block used to get data information from a light
  67912. */
  67913. export class LightInformationBlock extends NodeMaterialBlock {
  67914. private _lightDataUniformName;
  67915. private _lightColorUniformName;
  67916. private _lightTypeDefineName;
  67917. /**
  67918. * Gets or sets the light associated with this block
  67919. */
  67920. light: Nullable<Light>;
  67921. /**
  67922. * Creates a new LightInformationBlock
  67923. * @param name defines the block name
  67924. */
  67925. constructor(name: string);
  67926. /**
  67927. * Gets the current class name
  67928. * @returns the class name
  67929. */
  67930. getClassName(): string;
  67931. /**
  67932. * Gets the world position input component
  67933. */
  67934. get worldPosition(): NodeMaterialConnectionPoint;
  67935. /**
  67936. * Gets the direction output component
  67937. */
  67938. get direction(): NodeMaterialConnectionPoint;
  67939. /**
  67940. * Gets the direction output component
  67941. */
  67942. get color(): NodeMaterialConnectionPoint;
  67943. /**
  67944. * Gets the direction output component
  67945. */
  67946. get intensity(): NodeMaterialConnectionPoint;
  67947. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67948. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67949. protected _buildBlock(state: NodeMaterialBuildState): this;
  67950. serialize(): any;
  67951. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67952. }
  67953. }
  67954. declare module BABYLON {
  67955. /**
  67956. * Block used to add image processing support to fragment shader
  67957. */
  67958. export class ImageProcessingBlock extends NodeMaterialBlock {
  67959. /**
  67960. * Create a new ImageProcessingBlock
  67961. * @param name defines the block name
  67962. */
  67963. constructor(name: string);
  67964. /**
  67965. * Gets the current class name
  67966. * @returns the class name
  67967. */
  67968. getClassName(): string;
  67969. /**
  67970. * Gets the color input component
  67971. */
  67972. get color(): NodeMaterialConnectionPoint;
  67973. /**
  67974. * Gets the output component
  67975. */
  67976. get output(): NodeMaterialConnectionPoint;
  67977. /**
  67978. * Initialize the block and prepare the context for build
  67979. * @param state defines the state that will be used for the build
  67980. */
  67981. initialize(state: NodeMaterialBuildState): void;
  67982. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  67983. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67984. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67985. protected _buildBlock(state: NodeMaterialBuildState): this;
  67986. }
  67987. }
  67988. declare module BABYLON {
  67989. /**
  67990. * Block used to perturb normals based on a normal map
  67991. */
  67992. export class PerturbNormalBlock extends NodeMaterialBlock {
  67993. private _tangentSpaceParameterName;
  67994. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67995. invertX: boolean;
  67996. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  67997. invertY: boolean;
  67998. /**
  67999. * Create a new PerturbNormalBlock
  68000. * @param name defines the block name
  68001. */
  68002. constructor(name: string);
  68003. /**
  68004. * Gets the current class name
  68005. * @returns the class name
  68006. */
  68007. getClassName(): string;
  68008. /**
  68009. * Gets the world position input component
  68010. */
  68011. get worldPosition(): NodeMaterialConnectionPoint;
  68012. /**
  68013. * Gets the world normal input component
  68014. */
  68015. get worldNormal(): NodeMaterialConnectionPoint;
  68016. /**
  68017. * Gets the world tangent input component
  68018. */
  68019. get worldTangent(): NodeMaterialConnectionPoint;
  68020. /**
  68021. * Gets the uv input component
  68022. */
  68023. get uv(): NodeMaterialConnectionPoint;
  68024. /**
  68025. * Gets the normal map color input component
  68026. */
  68027. get normalMapColor(): NodeMaterialConnectionPoint;
  68028. /**
  68029. * Gets the strength input component
  68030. */
  68031. get strength(): NodeMaterialConnectionPoint;
  68032. /**
  68033. * Gets the output component
  68034. */
  68035. get output(): NodeMaterialConnectionPoint;
  68036. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68037. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  68038. autoConfigure(material: NodeMaterial): void;
  68039. protected _buildBlock(state: NodeMaterialBuildState): this;
  68040. protected _dumpPropertiesCode(): string;
  68041. serialize(): any;
  68042. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68043. }
  68044. }
  68045. declare module BABYLON {
  68046. /**
  68047. * Block used to discard a pixel if a value is smaller than a cutoff
  68048. */
  68049. export class DiscardBlock extends NodeMaterialBlock {
  68050. /**
  68051. * Create a new DiscardBlock
  68052. * @param name defines the block name
  68053. */
  68054. constructor(name: string);
  68055. /**
  68056. * Gets the current class name
  68057. * @returns the class name
  68058. */
  68059. getClassName(): string;
  68060. /**
  68061. * Gets the color input component
  68062. */
  68063. get value(): NodeMaterialConnectionPoint;
  68064. /**
  68065. * Gets the cutoff input component
  68066. */
  68067. get cutoff(): NodeMaterialConnectionPoint;
  68068. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68069. }
  68070. }
  68071. declare module BABYLON {
  68072. /**
  68073. * Block used to test if the fragment shader is front facing
  68074. */
  68075. export class FrontFacingBlock extends NodeMaterialBlock {
  68076. /**
  68077. * Creates a new FrontFacingBlock
  68078. * @param name defines the block name
  68079. */
  68080. constructor(name: string);
  68081. /**
  68082. * Gets the current class name
  68083. * @returns the class name
  68084. */
  68085. getClassName(): string;
  68086. /**
  68087. * Gets the output component
  68088. */
  68089. get output(): NodeMaterialConnectionPoint;
  68090. protected _buildBlock(state: NodeMaterialBuildState): this;
  68091. }
  68092. }
  68093. declare module BABYLON {
  68094. /**
  68095. * Block used to get the derivative value on x and y of a given input
  68096. */
  68097. export class DerivativeBlock extends NodeMaterialBlock {
  68098. /**
  68099. * Create a new DerivativeBlock
  68100. * @param name defines the block name
  68101. */
  68102. constructor(name: string);
  68103. /**
  68104. * Gets the current class name
  68105. * @returns the class name
  68106. */
  68107. getClassName(): string;
  68108. /**
  68109. * Gets the input component
  68110. */
  68111. get input(): NodeMaterialConnectionPoint;
  68112. /**
  68113. * Gets the derivative output on x
  68114. */
  68115. get dx(): NodeMaterialConnectionPoint;
  68116. /**
  68117. * Gets the derivative output on y
  68118. */
  68119. get dy(): NodeMaterialConnectionPoint;
  68120. protected _buildBlock(state: NodeMaterialBuildState): this;
  68121. }
  68122. }
  68123. declare module BABYLON {
  68124. /**
  68125. * Block used to make gl_FragCoord available
  68126. */
  68127. export class FragCoordBlock extends NodeMaterialBlock {
  68128. /**
  68129. * Creates a new FragCoordBlock
  68130. * @param name defines the block name
  68131. */
  68132. constructor(name: string);
  68133. /**
  68134. * Gets the current class name
  68135. * @returns the class name
  68136. */
  68137. getClassName(): string;
  68138. /**
  68139. * Gets the xy component
  68140. */
  68141. get xy(): NodeMaterialConnectionPoint;
  68142. /**
  68143. * Gets the xyz component
  68144. */
  68145. get xyz(): NodeMaterialConnectionPoint;
  68146. /**
  68147. * Gets the xyzw component
  68148. */
  68149. get xyzw(): NodeMaterialConnectionPoint;
  68150. /**
  68151. * Gets the x component
  68152. */
  68153. get x(): NodeMaterialConnectionPoint;
  68154. /**
  68155. * Gets the y component
  68156. */
  68157. get y(): NodeMaterialConnectionPoint;
  68158. /**
  68159. * Gets the z component
  68160. */
  68161. get z(): NodeMaterialConnectionPoint;
  68162. /**
  68163. * Gets the w component
  68164. */
  68165. get output(): NodeMaterialConnectionPoint;
  68166. protected writeOutputs(state: NodeMaterialBuildState): string;
  68167. protected _buildBlock(state: NodeMaterialBuildState): this;
  68168. }
  68169. }
  68170. declare module BABYLON {
  68171. /**
  68172. * Block used to get the screen sizes
  68173. */
  68174. export class ScreenSizeBlock extends NodeMaterialBlock {
  68175. private _varName;
  68176. private _scene;
  68177. /**
  68178. * Creates a new ScreenSizeBlock
  68179. * @param name defines the block name
  68180. */
  68181. constructor(name: string);
  68182. /**
  68183. * Gets the current class name
  68184. * @returns the class name
  68185. */
  68186. getClassName(): string;
  68187. /**
  68188. * Gets the xy component
  68189. */
  68190. get xy(): NodeMaterialConnectionPoint;
  68191. /**
  68192. * Gets the x component
  68193. */
  68194. get x(): NodeMaterialConnectionPoint;
  68195. /**
  68196. * Gets the y component
  68197. */
  68198. get y(): NodeMaterialConnectionPoint;
  68199. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  68200. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  68201. protected _buildBlock(state: NodeMaterialBuildState): this;
  68202. }
  68203. }
  68204. declare module BABYLON {
  68205. /**
  68206. * Block used to add support for scene fog
  68207. */
  68208. export class FogBlock extends NodeMaterialBlock {
  68209. private _fogDistanceName;
  68210. private _fogParameters;
  68211. /**
  68212. * Create a new FogBlock
  68213. * @param name defines the block name
  68214. */
  68215. constructor(name: string);
  68216. /**
  68217. * Gets the current class name
  68218. * @returns the class name
  68219. */
  68220. getClassName(): string;
  68221. /**
  68222. * Gets the world position input component
  68223. */
  68224. get worldPosition(): NodeMaterialConnectionPoint;
  68225. /**
  68226. * Gets the view input component
  68227. */
  68228. get view(): NodeMaterialConnectionPoint;
  68229. /**
  68230. * Gets the color input component
  68231. */
  68232. get input(): NodeMaterialConnectionPoint;
  68233. /**
  68234. * Gets the fog color input component
  68235. */
  68236. get fogColor(): NodeMaterialConnectionPoint;
  68237. /**
  68238. * Gets the output component
  68239. */
  68240. get output(): NodeMaterialConnectionPoint;
  68241. autoConfigure(material: NodeMaterial): void;
  68242. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68243. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  68244. protected _buildBlock(state: NodeMaterialBuildState): this;
  68245. }
  68246. }
  68247. declare module BABYLON {
  68248. /**
  68249. * Block used to add light in the fragment shader
  68250. */
  68251. export class LightBlock extends NodeMaterialBlock {
  68252. private _lightId;
  68253. /**
  68254. * Gets or sets the light associated with this block
  68255. */
  68256. light: Nullable<Light>;
  68257. /**
  68258. * Create a new LightBlock
  68259. * @param name defines the block name
  68260. */
  68261. constructor(name: string);
  68262. /**
  68263. * Gets the current class name
  68264. * @returns the class name
  68265. */
  68266. getClassName(): string;
  68267. /**
  68268. * Gets the world position input component
  68269. */
  68270. get worldPosition(): NodeMaterialConnectionPoint;
  68271. /**
  68272. * Gets the world normal input component
  68273. */
  68274. get worldNormal(): NodeMaterialConnectionPoint;
  68275. /**
  68276. * Gets the camera (or eye) position component
  68277. */
  68278. get cameraPosition(): NodeMaterialConnectionPoint;
  68279. /**
  68280. * Gets the glossiness component
  68281. */
  68282. get glossiness(): NodeMaterialConnectionPoint;
  68283. /**
  68284. * Gets the glossiness power component
  68285. */
  68286. get glossPower(): NodeMaterialConnectionPoint;
  68287. /**
  68288. * Gets the diffuse color component
  68289. */
  68290. get diffuseColor(): NodeMaterialConnectionPoint;
  68291. /**
  68292. * Gets the specular color component
  68293. */
  68294. get specularColor(): NodeMaterialConnectionPoint;
  68295. /**
  68296. * Gets the view matrix component
  68297. */
  68298. get view(): NodeMaterialConnectionPoint;
  68299. /**
  68300. * Gets the diffuse output component
  68301. */
  68302. get diffuseOutput(): NodeMaterialConnectionPoint;
  68303. /**
  68304. * Gets the specular output component
  68305. */
  68306. get specularOutput(): NodeMaterialConnectionPoint;
  68307. /**
  68308. * Gets the shadow output component
  68309. */
  68310. get shadow(): NodeMaterialConnectionPoint;
  68311. autoConfigure(material: NodeMaterial): void;
  68312. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68313. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  68314. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  68315. private _injectVertexCode;
  68316. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68317. serialize(): any;
  68318. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68319. }
  68320. }
  68321. declare module BABYLON {
  68322. /**
  68323. * Block used to read a reflection texture from a sampler
  68324. */
  68325. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  68326. /**
  68327. * Create a new ReflectionTextureBlock
  68328. * @param name defines the block name
  68329. */
  68330. constructor(name: string);
  68331. /**
  68332. * Gets the current class name
  68333. * @returns the class name
  68334. */
  68335. getClassName(): string;
  68336. /**
  68337. * Gets the world position input component
  68338. */
  68339. get position(): NodeMaterialConnectionPoint;
  68340. /**
  68341. * Gets the world position input component
  68342. */
  68343. get worldPosition(): NodeMaterialConnectionPoint;
  68344. /**
  68345. * Gets the world normal input component
  68346. */
  68347. get worldNormal(): NodeMaterialConnectionPoint;
  68348. /**
  68349. * Gets the world input component
  68350. */
  68351. get world(): NodeMaterialConnectionPoint;
  68352. /**
  68353. * Gets the camera (or eye) position component
  68354. */
  68355. get cameraPosition(): NodeMaterialConnectionPoint;
  68356. /**
  68357. * Gets the view input component
  68358. */
  68359. get view(): NodeMaterialConnectionPoint;
  68360. /**
  68361. * Gets the rgb output component
  68362. */
  68363. get rgb(): NodeMaterialConnectionPoint;
  68364. /**
  68365. * Gets the rgba output component
  68366. */
  68367. get rgba(): NodeMaterialConnectionPoint;
  68368. /**
  68369. * Gets the r output component
  68370. */
  68371. get r(): NodeMaterialConnectionPoint;
  68372. /**
  68373. * Gets the g output component
  68374. */
  68375. get g(): NodeMaterialConnectionPoint;
  68376. /**
  68377. * Gets the b output component
  68378. */
  68379. get b(): NodeMaterialConnectionPoint;
  68380. /**
  68381. * Gets the a output component
  68382. */
  68383. get a(): NodeMaterialConnectionPoint;
  68384. autoConfigure(material: NodeMaterial): void;
  68385. protected _buildBlock(state: NodeMaterialBuildState): this;
  68386. }
  68387. }
  68388. declare module BABYLON {
  68389. /**
  68390. * Block used to add 2 vectors
  68391. */
  68392. export class AddBlock extends NodeMaterialBlock {
  68393. /**
  68394. * Creates a new AddBlock
  68395. * @param name defines the block name
  68396. */
  68397. constructor(name: string);
  68398. /**
  68399. * Gets the current class name
  68400. * @returns the class name
  68401. */
  68402. getClassName(): string;
  68403. /**
  68404. * Gets the left operand input component
  68405. */
  68406. get left(): NodeMaterialConnectionPoint;
  68407. /**
  68408. * Gets the right operand input component
  68409. */
  68410. get right(): NodeMaterialConnectionPoint;
  68411. /**
  68412. * Gets the output component
  68413. */
  68414. get output(): NodeMaterialConnectionPoint;
  68415. protected _buildBlock(state: NodeMaterialBuildState): this;
  68416. }
  68417. }
  68418. declare module BABYLON {
  68419. /**
  68420. * Block used to scale a vector by a float
  68421. */
  68422. export class ScaleBlock extends NodeMaterialBlock {
  68423. /**
  68424. * Creates a new ScaleBlock
  68425. * @param name defines the block name
  68426. */
  68427. constructor(name: string);
  68428. /**
  68429. * Gets the current class name
  68430. * @returns the class name
  68431. */
  68432. getClassName(): string;
  68433. /**
  68434. * Gets the input component
  68435. */
  68436. get input(): NodeMaterialConnectionPoint;
  68437. /**
  68438. * Gets the factor input component
  68439. */
  68440. get factor(): NodeMaterialConnectionPoint;
  68441. /**
  68442. * Gets the output component
  68443. */
  68444. get output(): NodeMaterialConnectionPoint;
  68445. protected _buildBlock(state: NodeMaterialBuildState): this;
  68446. }
  68447. }
  68448. declare module BABYLON {
  68449. /**
  68450. * Block used to clamp a float
  68451. */
  68452. export class ClampBlock extends NodeMaterialBlock {
  68453. /** Gets or sets the minimum range */
  68454. minimum: number;
  68455. /** Gets or sets the maximum range */
  68456. maximum: number;
  68457. /**
  68458. * Creates a new ClampBlock
  68459. * @param name defines the block name
  68460. */
  68461. constructor(name: string);
  68462. /**
  68463. * Gets the current class name
  68464. * @returns the class name
  68465. */
  68466. getClassName(): string;
  68467. /**
  68468. * Gets the value input component
  68469. */
  68470. get value(): NodeMaterialConnectionPoint;
  68471. /**
  68472. * Gets the output component
  68473. */
  68474. get output(): NodeMaterialConnectionPoint;
  68475. protected _buildBlock(state: NodeMaterialBuildState): this;
  68476. protected _dumpPropertiesCode(): string;
  68477. serialize(): any;
  68478. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68479. }
  68480. }
  68481. declare module BABYLON {
  68482. /**
  68483. * Block used to apply a cross product between 2 vectors
  68484. */
  68485. export class CrossBlock extends NodeMaterialBlock {
  68486. /**
  68487. * Creates a new CrossBlock
  68488. * @param name defines the block name
  68489. */
  68490. constructor(name: string);
  68491. /**
  68492. * Gets the current class name
  68493. * @returns the class name
  68494. */
  68495. getClassName(): string;
  68496. /**
  68497. * Gets the left operand input component
  68498. */
  68499. get left(): NodeMaterialConnectionPoint;
  68500. /**
  68501. * Gets the right operand input component
  68502. */
  68503. get right(): NodeMaterialConnectionPoint;
  68504. /**
  68505. * Gets the output component
  68506. */
  68507. get output(): NodeMaterialConnectionPoint;
  68508. protected _buildBlock(state: NodeMaterialBuildState): this;
  68509. }
  68510. }
  68511. declare module BABYLON {
  68512. /**
  68513. * Block used to apply a dot product between 2 vectors
  68514. */
  68515. export class DotBlock extends NodeMaterialBlock {
  68516. /**
  68517. * Creates a new DotBlock
  68518. * @param name defines the block name
  68519. */
  68520. constructor(name: string);
  68521. /**
  68522. * Gets the current class name
  68523. * @returns the class name
  68524. */
  68525. getClassName(): string;
  68526. /**
  68527. * Gets the left operand input component
  68528. */
  68529. get left(): NodeMaterialConnectionPoint;
  68530. /**
  68531. * Gets the right operand input component
  68532. */
  68533. get right(): NodeMaterialConnectionPoint;
  68534. /**
  68535. * Gets the output component
  68536. */
  68537. get output(): NodeMaterialConnectionPoint;
  68538. protected _buildBlock(state: NodeMaterialBuildState): this;
  68539. }
  68540. }
  68541. declare module BABYLON {
  68542. /**
  68543. * Block used to normalize a vector
  68544. */
  68545. export class NormalizeBlock extends NodeMaterialBlock {
  68546. /**
  68547. * Creates a new NormalizeBlock
  68548. * @param name defines the block name
  68549. */
  68550. constructor(name: string);
  68551. /**
  68552. * Gets the current class name
  68553. * @returns the class name
  68554. */
  68555. getClassName(): string;
  68556. /**
  68557. * Gets the input component
  68558. */
  68559. get input(): NodeMaterialConnectionPoint;
  68560. /**
  68561. * Gets the output component
  68562. */
  68563. get output(): NodeMaterialConnectionPoint;
  68564. protected _buildBlock(state: NodeMaterialBuildState): this;
  68565. }
  68566. }
  68567. declare module BABYLON {
  68568. /**
  68569. * Block used to create a Color3/4 out of individual inputs (one for each component)
  68570. */
  68571. export class ColorMergerBlock extends NodeMaterialBlock {
  68572. /**
  68573. * Create a new ColorMergerBlock
  68574. * @param name defines the block name
  68575. */
  68576. constructor(name: string);
  68577. /**
  68578. * Gets the current class name
  68579. * @returns the class name
  68580. */
  68581. getClassName(): string;
  68582. /**
  68583. * Gets the rgb component (input)
  68584. */
  68585. get rgbIn(): NodeMaterialConnectionPoint;
  68586. /**
  68587. * Gets the r component (input)
  68588. */
  68589. get r(): NodeMaterialConnectionPoint;
  68590. /**
  68591. * Gets the g component (input)
  68592. */
  68593. get g(): NodeMaterialConnectionPoint;
  68594. /**
  68595. * Gets the b component (input)
  68596. */
  68597. get b(): NodeMaterialConnectionPoint;
  68598. /**
  68599. * Gets the a component (input)
  68600. */
  68601. get a(): NodeMaterialConnectionPoint;
  68602. /**
  68603. * Gets the rgba component (output)
  68604. */
  68605. get rgba(): NodeMaterialConnectionPoint;
  68606. /**
  68607. * Gets the rgb component (output)
  68608. */
  68609. get rgbOut(): NodeMaterialConnectionPoint;
  68610. /**
  68611. * Gets the rgb component (output)
  68612. * @deprecated Please use rgbOut instead.
  68613. */
  68614. get rgb(): NodeMaterialConnectionPoint;
  68615. protected _buildBlock(state: NodeMaterialBuildState): this;
  68616. }
  68617. }
  68618. declare module BABYLON {
  68619. /**
  68620. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  68621. */
  68622. export class VectorSplitterBlock extends NodeMaterialBlock {
  68623. /**
  68624. * Create a new VectorSplitterBlock
  68625. * @param name defines the block name
  68626. */
  68627. constructor(name: string);
  68628. /**
  68629. * Gets the current class name
  68630. * @returns the class name
  68631. */
  68632. getClassName(): string;
  68633. /**
  68634. * Gets the xyzw component (input)
  68635. */
  68636. get xyzw(): NodeMaterialConnectionPoint;
  68637. /**
  68638. * Gets the xyz component (input)
  68639. */
  68640. get xyzIn(): NodeMaterialConnectionPoint;
  68641. /**
  68642. * Gets the xy component (input)
  68643. */
  68644. get xyIn(): NodeMaterialConnectionPoint;
  68645. /**
  68646. * Gets the xyz component (output)
  68647. */
  68648. get xyzOut(): NodeMaterialConnectionPoint;
  68649. /**
  68650. * Gets the xy component (output)
  68651. */
  68652. get xyOut(): NodeMaterialConnectionPoint;
  68653. /**
  68654. * Gets the x component (output)
  68655. */
  68656. get x(): NodeMaterialConnectionPoint;
  68657. /**
  68658. * Gets the y component (output)
  68659. */
  68660. get y(): NodeMaterialConnectionPoint;
  68661. /**
  68662. * Gets the z component (output)
  68663. */
  68664. get z(): NodeMaterialConnectionPoint;
  68665. /**
  68666. * Gets the w component (output)
  68667. */
  68668. get w(): NodeMaterialConnectionPoint;
  68669. protected _inputRename(name: string): string;
  68670. protected _outputRename(name: string): string;
  68671. protected _buildBlock(state: NodeMaterialBuildState): this;
  68672. }
  68673. }
  68674. declare module BABYLON {
  68675. /**
  68676. * Block used to lerp between 2 values
  68677. */
  68678. export class LerpBlock extends NodeMaterialBlock {
  68679. /**
  68680. * Creates a new LerpBlock
  68681. * @param name defines the block name
  68682. */
  68683. constructor(name: string);
  68684. /**
  68685. * Gets the current class name
  68686. * @returns the class name
  68687. */
  68688. getClassName(): string;
  68689. /**
  68690. * Gets the left operand input component
  68691. */
  68692. get left(): NodeMaterialConnectionPoint;
  68693. /**
  68694. * Gets the right operand input component
  68695. */
  68696. get right(): NodeMaterialConnectionPoint;
  68697. /**
  68698. * Gets the gradient operand input component
  68699. */
  68700. get gradient(): NodeMaterialConnectionPoint;
  68701. /**
  68702. * Gets the output component
  68703. */
  68704. get output(): NodeMaterialConnectionPoint;
  68705. protected _buildBlock(state: NodeMaterialBuildState): this;
  68706. }
  68707. }
  68708. declare module BABYLON {
  68709. /**
  68710. * Block used to divide 2 vectors
  68711. */
  68712. export class DivideBlock extends NodeMaterialBlock {
  68713. /**
  68714. * Creates a new DivideBlock
  68715. * @param name defines the block name
  68716. */
  68717. constructor(name: string);
  68718. /**
  68719. * Gets the current class name
  68720. * @returns the class name
  68721. */
  68722. getClassName(): string;
  68723. /**
  68724. * Gets the left operand input component
  68725. */
  68726. get left(): NodeMaterialConnectionPoint;
  68727. /**
  68728. * Gets the right operand input component
  68729. */
  68730. get right(): NodeMaterialConnectionPoint;
  68731. /**
  68732. * Gets the output component
  68733. */
  68734. get output(): NodeMaterialConnectionPoint;
  68735. protected _buildBlock(state: NodeMaterialBuildState): this;
  68736. }
  68737. }
  68738. declare module BABYLON {
  68739. /**
  68740. * Block used to subtract 2 vectors
  68741. */
  68742. export class SubtractBlock extends NodeMaterialBlock {
  68743. /**
  68744. * Creates a new SubtractBlock
  68745. * @param name defines the block name
  68746. */
  68747. constructor(name: string);
  68748. /**
  68749. * Gets the current class name
  68750. * @returns the class name
  68751. */
  68752. getClassName(): string;
  68753. /**
  68754. * Gets the left operand input component
  68755. */
  68756. get left(): NodeMaterialConnectionPoint;
  68757. /**
  68758. * Gets the right operand input component
  68759. */
  68760. get right(): NodeMaterialConnectionPoint;
  68761. /**
  68762. * Gets the output component
  68763. */
  68764. get output(): NodeMaterialConnectionPoint;
  68765. protected _buildBlock(state: NodeMaterialBuildState): this;
  68766. }
  68767. }
  68768. declare module BABYLON {
  68769. /**
  68770. * Block used to step a value
  68771. */
  68772. export class StepBlock extends NodeMaterialBlock {
  68773. /**
  68774. * Creates a new StepBlock
  68775. * @param name defines the block name
  68776. */
  68777. constructor(name: string);
  68778. /**
  68779. * Gets the current class name
  68780. * @returns the class name
  68781. */
  68782. getClassName(): string;
  68783. /**
  68784. * Gets the value operand input component
  68785. */
  68786. get value(): NodeMaterialConnectionPoint;
  68787. /**
  68788. * Gets the edge operand input component
  68789. */
  68790. get edge(): NodeMaterialConnectionPoint;
  68791. /**
  68792. * Gets the output component
  68793. */
  68794. get output(): NodeMaterialConnectionPoint;
  68795. protected _buildBlock(state: NodeMaterialBuildState): this;
  68796. }
  68797. }
  68798. declare module BABYLON {
  68799. /**
  68800. * Block used to get the opposite (1 - x) of a value
  68801. */
  68802. export class OneMinusBlock extends NodeMaterialBlock {
  68803. /**
  68804. * Creates a new OneMinusBlock
  68805. * @param name defines the block name
  68806. */
  68807. constructor(name: string);
  68808. /**
  68809. * Gets the current class name
  68810. * @returns the class name
  68811. */
  68812. getClassName(): string;
  68813. /**
  68814. * Gets the input component
  68815. */
  68816. get input(): NodeMaterialConnectionPoint;
  68817. /**
  68818. * Gets the output component
  68819. */
  68820. get output(): NodeMaterialConnectionPoint;
  68821. protected _buildBlock(state: NodeMaterialBuildState): this;
  68822. }
  68823. }
  68824. declare module BABYLON {
  68825. /**
  68826. * Block used to get the view direction
  68827. */
  68828. export class ViewDirectionBlock extends NodeMaterialBlock {
  68829. /**
  68830. * Creates a new ViewDirectionBlock
  68831. * @param name defines the block name
  68832. */
  68833. constructor(name: string);
  68834. /**
  68835. * Gets the current class name
  68836. * @returns the class name
  68837. */
  68838. getClassName(): string;
  68839. /**
  68840. * Gets the world position component
  68841. */
  68842. get worldPosition(): NodeMaterialConnectionPoint;
  68843. /**
  68844. * Gets the camera position component
  68845. */
  68846. get cameraPosition(): NodeMaterialConnectionPoint;
  68847. /**
  68848. * Gets the output component
  68849. */
  68850. get output(): NodeMaterialConnectionPoint;
  68851. autoConfigure(material: NodeMaterial): void;
  68852. protected _buildBlock(state: NodeMaterialBuildState): this;
  68853. }
  68854. }
  68855. declare module BABYLON {
  68856. /**
  68857. * Block used to compute fresnel value
  68858. */
  68859. export class FresnelBlock extends NodeMaterialBlock {
  68860. /**
  68861. * Create a new FresnelBlock
  68862. * @param name defines the block name
  68863. */
  68864. constructor(name: string);
  68865. /**
  68866. * Gets the current class name
  68867. * @returns the class name
  68868. */
  68869. getClassName(): string;
  68870. /**
  68871. * Gets the world normal input component
  68872. */
  68873. get worldNormal(): NodeMaterialConnectionPoint;
  68874. /**
  68875. * Gets the view direction input component
  68876. */
  68877. get viewDirection(): NodeMaterialConnectionPoint;
  68878. /**
  68879. * Gets the bias input component
  68880. */
  68881. get bias(): NodeMaterialConnectionPoint;
  68882. /**
  68883. * Gets the camera (or eye) position component
  68884. */
  68885. get power(): NodeMaterialConnectionPoint;
  68886. /**
  68887. * Gets the fresnel output component
  68888. */
  68889. get fresnel(): NodeMaterialConnectionPoint;
  68890. autoConfigure(material: NodeMaterial): void;
  68891. protected _buildBlock(state: NodeMaterialBuildState): this;
  68892. }
  68893. }
  68894. declare module BABYLON {
  68895. /**
  68896. * Block used to get the max of 2 values
  68897. */
  68898. export class MaxBlock extends NodeMaterialBlock {
  68899. /**
  68900. * Creates a new MaxBlock
  68901. * @param name defines the block name
  68902. */
  68903. constructor(name: string);
  68904. /**
  68905. * Gets the current class name
  68906. * @returns the class name
  68907. */
  68908. getClassName(): string;
  68909. /**
  68910. * Gets the left operand input component
  68911. */
  68912. get left(): NodeMaterialConnectionPoint;
  68913. /**
  68914. * Gets the right operand input component
  68915. */
  68916. get right(): NodeMaterialConnectionPoint;
  68917. /**
  68918. * Gets the output component
  68919. */
  68920. get output(): NodeMaterialConnectionPoint;
  68921. protected _buildBlock(state: NodeMaterialBuildState): this;
  68922. }
  68923. }
  68924. declare module BABYLON {
  68925. /**
  68926. * Block used to get the min of 2 values
  68927. */
  68928. export class MinBlock extends NodeMaterialBlock {
  68929. /**
  68930. * Creates a new MinBlock
  68931. * @param name defines the block name
  68932. */
  68933. constructor(name: string);
  68934. /**
  68935. * Gets the current class name
  68936. * @returns the class name
  68937. */
  68938. getClassName(): string;
  68939. /**
  68940. * Gets the left operand input component
  68941. */
  68942. get left(): NodeMaterialConnectionPoint;
  68943. /**
  68944. * Gets the right operand input component
  68945. */
  68946. get right(): NodeMaterialConnectionPoint;
  68947. /**
  68948. * Gets the output component
  68949. */
  68950. get output(): NodeMaterialConnectionPoint;
  68951. protected _buildBlock(state: NodeMaterialBuildState): this;
  68952. }
  68953. }
  68954. declare module BABYLON {
  68955. /**
  68956. * Block used to get the distance between 2 values
  68957. */
  68958. export class DistanceBlock extends NodeMaterialBlock {
  68959. /**
  68960. * Creates a new DistanceBlock
  68961. * @param name defines the block name
  68962. */
  68963. constructor(name: string);
  68964. /**
  68965. * Gets the current class name
  68966. * @returns the class name
  68967. */
  68968. getClassName(): string;
  68969. /**
  68970. * Gets the left operand input component
  68971. */
  68972. get left(): NodeMaterialConnectionPoint;
  68973. /**
  68974. * Gets the right operand input component
  68975. */
  68976. get right(): NodeMaterialConnectionPoint;
  68977. /**
  68978. * Gets the output component
  68979. */
  68980. get output(): NodeMaterialConnectionPoint;
  68981. protected _buildBlock(state: NodeMaterialBuildState): this;
  68982. }
  68983. }
  68984. declare module BABYLON {
  68985. /**
  68986. * Block used to get the length of a vector
  68987. */
  68988. export class LengthBlock extends NodeMaterialBlock {
  68989. /**
  68990. * Creates a new LengthBlock
  68991. * @param name defines the block name
  68992. */
  68993. constructor(name: string);
  68994. /**
  68995. * Gets the current class name
  68996. * @returns the class name
  68997. */
  68998. getClassName(): string;
  68999. /**
  69000. * Gets the value input component
  69001. */
  69002. get value(): NodeMaterialConnectionPoint;
  69003. /**
  69004. * Gets the output component
  69005. */
  69006. get output(): NodeMaterialConnectionPoint;
  69007. protected _buildBlock(state: NodeMaterialBuildState): this;
  69008. }
  69009. }
  69010. declare module BABYLON {
  69011. /**
  69012. * Block used to get negative version of a value (i.e. x * -1)
  69013. */
  69014. export class NegateBlock extends NodeMaterialBlock {
  69015. /**
  69016. * Creates a new NegateBlock
  69017. * @param name defines the block name
  69018. */
  69019. constructor(name: string);
  69020. /**
  69021. * Gets the current class name
  69022. * @returns the class name
  69023. */
  69024. getClassName(): string;
  69025. /**
  69026. * Gets the value input component
  69027. */
  69028. get value(): NodeMaterialConnectionPoint;
  69029. /**
  69030. * Gets the output component
  69031. */
  69032. get output(): NodeMaterialConnectionPoint;
  69033. protected _buildBlock(state: NodeMaterialBuildState): this;
  69034. }
  69035. }
  69036. declare module BABYLON {
  69037. /**
  69038. * Block used to get the value of the first parameter raised to the power of the second
  69039. */
  69040. export class PowBlock extends NodeMaterialBlock {
  69041. /**
  69042. * Creates a new PowBlock
  69043. * @param name defines the block name
  69044. */
  69045. constructor(name: string);
  69046. /**
  69047. * Gets the current class name
  69048. * @returns the class name
  69049. */
  69050. getClassName(): string;
  69051. /**
  69052. * Gets the value operand input component
  69053. */
  69054. get value(): NodeMaterialConnectionPoint;
  69055. /**
  69056. * Gets the power operand input component
  69057. */
  69058. get power(): NodeMaterialConnectionPoint;
  69059. /**
  69060. * Gets the output component
  69061. */
  69062. get output(): NodeMaterialConnectionPoint;
  69063. protected _buildBlock(state: NodeMaterialBuildState): this;
  69064. }
  69065. }
  69066. declare module BABYLON {
  69067. /**
  69068. * Block used to get a random number
  69069. */
  69070. export class RandomNumberBlock extends NodeMaterialBlock {
  69071. /**
  69072. * Creates a new RandomNumberBlock
  69073. * @param name defines the block name
  69074. */
  69075. constructor(name: string);
  69076. /**
  69077. * Gets the current class name
  69078. * @returns the class name
  69079. */
  69080. getClassName(): string;
  69081. /**
  69082. * Gets the seed input component
  69083. */
  69084. get seed(): NodeMaterialConnectionPoint;
  69085. /**
  69086. * Gets the output component
  69087. */
  69088. get output(): NodeMaterialConnectionPoint;
  69089. protected _buildBlock(state: NodeMaterialBuildState): this;
  69090. }
  69091. }
  69092. declare module BABYLON {
  69093. /**
  69094. * Block used to compute arc tangent of 2 values
  69095. */
  69096. export class ArcTan2Block extends NodeMaterialBlock {
  69097. /**
  69098. * Creates a new ArcTan2Block
  69099. * @param name defines the block name
  69100. */
  69101. constructor(name: string);
  69102. /**
  69103. * Gets the current class name
  69104. * @returns the class name
  69105. */
  69106. getClassName(): string;
  69107. /**
  69108. * Gets the x operand input component
  69109. */
  69110. get x(): NodeMaterialConnectionPoint;
  69111. /**
  69112. * Gets the y operand input component
  69113. */
  69114. get y(): NodeMaterialConnectionPoint;
  69115. /**
  69116. * Gets the output component
  69117. */
  69118. get output(): NodeMaterialConnectionPoint;
  69119. protected _buildBlock(state: NodeMaterialBuildState): this;
  69120. }
  69121. }
  69122. declare module BABYLON {
  69123. /**
  69124. * Block used to smooth step a value
  69125. */
  69126. export class SmoothStepBlock extends NodeMaterialBlock {
  69127. /**
  69128. * Creates a new SmoothStepBlock
  69129. * @param name defines the block name
  69130. */
  69131. constructor(name: string);
  69132. /**
  69133. * Gets the current class name
  69134. * @returns the class name
  69135. */
  69136. getClassName(): string;
  69137. /**
  69138. * Gets the value operand input component
  69139. */
  69140. get value(): NodeMaterialConnectionPoint;
  69141. /**
  69142. * Gets the first edge operand input component
  69143. */
  69144. get edge0(): NodeMaterialConnectionPoint;
  69145. /**
  69146. * Gets the second edge operand input component
  69147. */
  69148. get edge1(): NodeMaterialConnectionPoint;
  69149. /**
  69150. * Gets the output component
  69151. */
  69152. get output(): NodeMaterialConnectionPoint;
  69153. protected _buildBlock(state: NodeMaterialBuildState): this;
  69154. }
  69155. }
  69156. declare module BABYLON {
  69157. /**
  69158. * Block used to get the reciprocal (1 / x) of a value
  69159. */
  69160. export class ReciprocalBlock extends NodeMaterialBlock {
  69161. /**
  69162. * Creates a new ReciprocalBlock
  69163. * @param name defines the block name
  69164. */
  69165. constructor(name: string);
  69166. /**
  69167. * Gets the current class name
  69168. * @returns the class name
  69169. */
  69170. getClassName(): string;
  69171. /**
  69172. * Gets the input component
  69173. */
  69174. get input(): NodeMaterialConnectionPoint;
  69175. /**
  69176. * Gets the output component
  69177. */
  69178. get output(): NodeMaterialConnectionPoint;
  69179. protected _buildBlock(state: NodeMaterialBuildState): this;
  69180. }
  69181. }
  69182. declare module BABYLON {
  69183. /**
  69184. * Block used to replace a color by another one
  69185. */
  69186. export class ReplaceColorBlock extends NodeMaterialBlock {
  69187. /**
  69188. * Creates a new ReplaceColorBlock
  69189. * @param name defines the block name
  69190. */
  69191. constructor(name: string);
  69192. /**
  69193. * Gets the current class name
  69194. * @returns the class name
  69195. */
  69196. getClassName(): string;
  69197. /**
  69198. * Gets the value input component
  69199. */
  69200. get value(): NodeMaterialConnectionPoint;
  69201. /**
  69202. * Gets the reference input component
  69203. */
  69204. get reference(): NodeMaterialConnectionPoint;
  69205. /**
  69206. * Gets the distance input component
  69207. */
  69208. get distance(): NodeMaterialConnectionPoint;
  69209. /**
  69210. * Gets the replacement input component
  69211. */
  69212. get replacement(): NodeMaterialConnectionPoint;
  69213. /**
  69214. * Gets the output component
  69215. */
  69216. get output(): NodeMaterialConnectionPoint;
  69217. protected _buildBlock(state: NodeMaterialBuildState): this;
  69218. }
  69219. }
  69220. declare module BABYLON {
  69221. /**
  69222. * Block used to posterize a value
  69223. * @see https://en.wikipedia.org/wiki/Posterization
  69224. */
  69225. export class PosterizeBlock extends NodeMaterialBlock {
  69226. /**
  69227. * Creates a new PosterizeBlock
  69228. * @param name defines the block name
  69229. */
  69230. constructor(name: string);
  69231. /**
  69232. * Gets the current class name
  69233. * @returns the class name
  69234. */
  69235. getClassName(): string;
  69236. /**
  69237. * Gets the value input component
  69238. */
  69239. get value(): NodeMaterialConnectionPoint;
  69240. /**
  69241. * Gets the steps input component
  69242. */
  69243. get steps(): NodeMaterialConnectionPoint;
  69244. /**
  69245. * Gets the output component
  69246. */
  69247. get output(): NodeMaterialConnectionPoint;
  69248. protected _buildBlock(state: NodeMaterialBuildState): this;
  69249. }
  69250. }
  69251. declare module BABYLON {
  69252. /**
  69253. * Operations supported by the Wave block
  69254. */
  69255. export enum WaveBlockKind {
  69256. /** SawTooth */
  69257. SawTooth = 0,
  69258. /** Square */
  69259. Square = 1,
  69260. /** Triangle */
  69261. Triangle = 2
  69262. }
  69263. /**
  69264. * Block used to apply wave operation to floats
  69265. */
  69266. export class WaveBlock extends NodeMaterialBlock {
  69267. /**
  69268. * Gets or sets the kibnd of wave to be applied by the block
  69269. */
  69270. kind: WaveBlockKind;
  69271. /**
  69272. * Creates a new WaveBlock
  69273. * @param name defines the block name
  69274. */
  69275. constructor(name: string);
  69276. /**
  69277. * Gets the current class name
  69278. * @returns the class name
  69279. */
  69280. getClassName(): string;
  69281. /**
  69282. * Gets the input component
  69283. */
  69284. get input(): NodeMaterialConnectionPoint;
  69285. /**
  69286. * Gets the output component
  69287. */
  69288. get output(): NodeMaterialConnectionPoint;
  69289. protected _buildBlock(state: NodeMaterialBuildState): this;
  69290. serialize(): any;
  69291. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69292. }
  69293. }
  69294. declare module BABYLON {
  69295. /**
  69296. * Class used to store a color step for the GradientBlock
  69297. */
  69298. export class GradientBlockColorStep {
  69299. private _step;
  69300. /**
  69301. * Gets value indicating which step this color is associated with (between 0 and 1)
  69302. */
  69303. get step(): number;
  69304. /**
  69305. * Sets a value indicating which step this color is associated with (between 0 and 1)
  69306. */
  69307. set step(val: number);
  69308. private _color;
  69309. /**
  69310. * Gets the color associated with this step
  69311. */
  69312. get color(): Color3;
  69313. /**
  69314. * Sets the color associated with this step
  69315. */
  69316. set color(val: Color3);
  69317. /**
  69318. * Creates a new GradientBlockColorStep
  69319. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  69320. * @param color defines the color associated with this step
  69321. */
  69322. constructor(step: number, color: Color3);
  69323. }
  69324. /**
  69325. * Block used to return a color from a gradient based on an input value between 0 and 1
  69326. */
  69327. export class GradientBlock extends NodeMaterialBlock {
  69328. /**
  69329. * Gets or sets the list of color steps
  69330. */
  69331. colorSteps: GradientBlockColorStep[];
  69332. /** Gets an observable raised when the value is changed */
  69333. onValueChangedObservable: Observable<GradientBlock>;
  69334. /** calls observable when the value is changed*/
  69335. colorStepsUpdated(): void;
  69336. /**
  69337. * Creates a new GradientBlock
  69338. * @param name defines the block name
  69339. */
  69340. constructor(name: string);
  69341. /**
  69342. * Gets the current class name
  69343. * @returns the class name
  69344. */
  69345. getClassName(): string;
  69346. /**
  69347. * Gets the gradient input component
  69348. */
  69349. get gradient(): NodeMaterialConnectionPoint;
  69350. /**
  69351. * Gets the output component
  69352. */
  69353. get output(): NodeMaterialConnectionPoint;
  69354. private _writeColorConstant;
  69355. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  69356. serialize(): any;
  69357. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69358. protected _dumpPropertiesCode(): string;
  69359. }
  69360. }
  69361. declare module BABYLON {
  69362. /**
  69363. * Block used to normalize lerp between 2 values
  69364. */
  69365. export class NLerpBlock extends NodeMaterialBlock {
  69366. /**
  69367. * Creates a new NLerpBlock
  69368. * @param name defines the block name
  69369. */
  69370. constructor(name: string);
  69371. /**
  69372. * Gets the current class name
  69373. * @returns the class name
  69374. */
  69375. getClassName(): string;
  69376. /**
  69377. * Gets the left operand input component
  69378. */
  69379. get left(): NodeMaterialConnectionPoint;
  69380. /**
  69381. * Gets the right operand input component
  69382. */
  69383. get right(): NodeMaterialConnectionPoint;
  69384. /**
  69385. * Gets the gradient operand input component
  69386. */
  69387. get gradient(): NodeMaterialConnectionPoint;
  69388. /**
  69389. * Gets the output component
  69390. */
  69391. get output(): NodeMaterialConnectionPoint;
  69392. protected _buildBlock(state: NodeMaterialBuildState): this;
  69393. }
  69394. }
  69395. declare module BABYLON {
  69396. /**
  69397. * block used to Generate a Worley Noise 3D Noise Pattern
  69398. */
  69399. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  69400. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  69401. manhattanDistance: boolean;
  69402. /**
  69403. * Creates a new WorleyNoise3DBlock
  69404. * @param name defines the block name
  69405. */
  69406. constructor(name: string);
  69407. /**
  69408. * Gets the current class name
  69409. * @returns the class name
  69410. */
  69411. getClassName(): string;
  69412. /**
  69413. * Gets the seed input component
  69414. */
  69415. get seed(): NodeMaterialConnectionPoint;
  69416. /**
  69417. * Gets the jitter input component
  69418. */
  69419. get jitter(): NodeMaterialConnectionPoint;
  69420. /**
  69421. * Gets the output component
  69422. */
  69423. get output(): NodeMaterialConnectionPoint;
  69424. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  69425. /**
  69426. * Exposes the properties to the UI?
  69427. */
  69428. protected _dumpPropertiesCode(): string;
  69429. /**
  69430. * Exposes the properties to the Serialize?
  69431. */
  69432. serialize(): any;
  69433. /**
  69434. * Exposes the properties to the deserialize?
  69435. */
  69436. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69437. }
  69438. }
  69439. declare module BABYLON {
  69440. /**
  69441. * block used to Generate a Simplex Perlin 3d Noise Pattern
  69442. */
  69443. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  69444. /**
  69445. * Creates a new SimplexPerlin3DBlock
  69446. * @param name defines the block name
  69447. */
  69448. constructor(name: string);
  69449. /**
  69450. * Gets the current class name
  69451. * @returns the class name
  69452. */
  69453. getClassName(): string;
  69454. /**
  69455. * Gets the seed operand input component
  69456. */
  69457. get seed(): NodeMaterialConnectionPoint;
  69458. /**
  69459. * Gets the output component
  69460. */
  69461. get output(): NodeMaterialConnectionPoint;
  69462. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  69463. }
  69464. }
  69465. declare module BABYLON {
  69466. /**
  69467. * Block used to blend normals
  69468. */
  69469. export class NormalBlendBlock extends NodeMaterialBlock {
  69470. /**
  69471. * Creates a new NormalBlendBlock
  69472. * @param name defines the block name
  69473. */
  69474. constructor(name: string);
  69475. /**
  69476. * Gets the current class name
  69477. * @returns the class name
  69478. */
  69479. getClassName(): string;
  69480. /**
  69481. * Gets the first input component
  69482. */
  69483. get normalMap0(): NodeMaterialConnectionPoint;
  69484. /**
  69485. * Gets the second input component
  69486. */
  69487. get normalMap1(): NodeMaterialConnectionPoint;
  69488. /**
  69489. * Gets the output component
  69490. */
  69491. get output(): NodeMaterialConnectionPoint;
  69492. protected _buildBlock(state: NodeMaterialBuildState): this;
  69493. }
  69494. }
  69495. declare module BABYLON {
  69496. /**
  69497. * Block used to rotate a 2d vector by a given angle
  69498. */
  69499. export class Rotate2dBlock extends NodeMaterialBlock {
  69500. /**
  69501. * Creates a new Rotate2dBlock
  69502. * @param name defines the block name
  69503. */
  69504. constructor(name: string);
  69505. /**
  69506. * Gets the current class name
  69507. * @returns the class name
  69508. */
  69509. getClassName(): string;
  69510. /**
  69511. * Gets the input vector
  69512. */
  69513. get input(): NodeMaterialConnectionPoint;
  69514. /**
  69515. * Gets the input angle
  69516. */
  69517. get angle(): NodeMaterialConnectionPoint;
  69518. /**
  69519. * Gets the output component
  69520. */
  69521. get output(): NodeMaterialConnectionPoint;
  69522. autoConfigure(material: NodeMaterial): void;
  69523. protected _buildBlock(state: NodeMaterialBuildState): this;
  69524. }
  69525. }
  69526. declare module BABYLON {
  69527. /**
  69528. * Block used to get the reflected vector from a direction and a normal
  69529. */
  69530. export class ReflectBlock extends NodeMaterialBlock {
  69531. /**
  69532. * Creates a new ReflectBlock
  69533. * @param name defines the block name
  69534. */
  69535. constructor(name: string);
  69536. /**
  69537. * Gets the current class name
  69538. * @returns the class name
  69539. */
  69540. getClassName(): string;
  69541. /**
  69542. * Gets the incident component
  69543. */
  69544. get incident(): NodeMaterialConnectionPoint;
  69545. /**
  69546. * Gets the normal component
  69547. */
  69548. get normal(): NodeMaterialConnectionPoint;
  69549. /**
  69550. * Gets the output component
  69551. */
  69552. get output(): NodeMaterialConnectionPoint;
  69553. protected _buildBlock(state: NodeMaterialBuildState): this;
  69554. }
  69555. }
  69556. declare module BABYLON {
  69557. /**
  69558. * Block used to get the refracted vector from a direction and a normal
  69559. */
  69560. export class RefractBlock extends NodeMaterialBlock {
  69561. /**
  69562. * Creates a new RefractBlock
  69563. * @param name defines the block name
  69564. */
  69565. constructor(name: string);
  69566. /**
  69567. * Gets the current class name
  69568. * @returns the class name
  69569. */
  69570. getClassName(): string;
  69571. /**
  69572. * Gets the incident component
  69573. */
  69574. get incident(): NodeMaterialConnectionPoint;
  69575. /**
  69576. * Gets the normal component
  69577. */
  69578. get normal(): NodeMaterialConnectionPoint;
  69579. /**
  69580. * Gets the index of refraction component
  69581. */
  69582. get ior(): NodeMaterialConnectionPoint;
  69583. /**
  69584. * Gets the output component
  69585. */
  69586. get output(): NodeMaterialConnectionPoint;
  69587. protected _buildBlock(state: NodeMaterialBuildState): this;
  69588. }
  69589. }
  69590. declare module BABYLON {
  69591. /**
  69592. * Block used to desaturate a color
  69593. */
  69594. export class DesaturateBlock extends NodeMaterialBlock {
  69595. /**
  69596. * Creates a new DesaturateBlock
  69597. * @param name defines the block name
  69598. */
  69599. constructor(name: string);
  69600. /**
  69601. * Gets the current class name
  69602. * @returns the class name
  69603. */
  69604. getClassName(): string;
  69605. /**
  69606. * Gets the color operand input component
  69607. */
  69608. get color(): NodeMaterialConnectionPoint;
  69609. /**
  69610. * Gets the level operand input component
  69611. */
  69612. get level(): NodeMaterialConnectionPoint;
  69613. /**
  69614. * Gets the output component
  69615. */
  69616. get output(): NodeMaterialConnectionPoint;
  69617. protected _buildBlock(state: NodeMaterialBuildState): this;
  69618. }
  69619. }
  69620. declare module BABYLON {
  69621. /**
  69622. * Block used to implement the reflection module of the PBR material
  69623. */
  69624. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  69625. /** @hidden */
  69626. _defineLODReflectionAlpha: string;
  69627. /** @hidden */
  69628. _defineLinearSpecularReflection: string;
  69629. private _vEnvironmentIrradianceName;
  69630. /** @hidden */
  69631. _vReflectionMicrosurfaceInfosName: string;
  69632. /** @hidden */
  69633. _vReflectionInfosName: string;
  69634. /** @hidden */
  69635. _vReflectionFilteringInfoName: string;
  69636. private _scene;
  69637. /**
  69638. * The properties below are set by the main PBR block prior to calling methods of this class.
  69639. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  69640. * It's less burden on the user side in the editor part.
  69641. */
  69642. /** @hidden */
  69643. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  69644. /** @hidden */
  69645. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  69646. /** @hidden */
  69647. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  69648. /** @hidden */
  69649. viewConnectionPoint: NodeMaterialConnectionPoint;
  69650. /**
  69651. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  69652. * diffuse part of the IBL.
  69653. */
  69654. useSphericalHarmonics: boolean;
  69655. /**
  69656. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  69657. */
  69658. forceIrradianceInFragment: boolean;
  69659. /**
  69660. * Create a new ReflectionBlock
  69661. * @param name defines the block name
  69662. */
  69663. constructor(name: string);
  69664. /**
  69665. * Gets the current class name
  69666. * @returns the class name
  69667. */
  69668. getClassName(): string;
  69669. /**
  69670. * Gets the position input component
  69671. */
  69672. get position(): NodeMaterialConnectionPoint;
  69673. /**
  69674. * Gets the world position input component
  69675. */
  69676. get worldPosition(): NodeMaterialConnectionPoint;
  69677. /**
  69678. * Gets the world normal input component
  69679. */
  69680. get worldNormal(): NodeMaterialConnectionPoint;
  69681. /**
  69682. * Gets the world input component
  69683. */
  69684. get world(): NodeMaterialConnectionPoint;
  69685. /**
  69686. * Gets the camera (or eye) position component
  69687. */
  69688. get cameraPosition(): NodeMaterialConnectionPoint;
  69689. /**
  69690. * Gets the view input component
  69691. */
  69692. get view(): NodeMaterialConnectionPoint;
  69693. /**
  69694. * Gets the color input component
  69695. */
  69696. get color(): NodeMaterialConnectionPoint;
  69697. /**
  69698. * Gets the reflection object output component
  69699. */
  69700. get reflection(): NodeMaterialConnectionPoint;
  69701. /**
  69702. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  69703. */
  69704. get hasTexture(): boolean;
  69705. /**
  69706. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  69707. */
  69708. get reflectionColor(): string;
  69709. protected _getTexture(): Nullable<BaseTexture>;
  69710. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69711. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69712. /**
  69713. * Gets the code to inject in the vertex shader
  69714. * @param state current state of the node material building
  69715. * @returns the shader code
  69716. */
  69717. handleVertexSide(state: NodeMaterialBuildState): string;
  69718. /**
  69719. * Gets the main code of the block (fragment side)
  69720. * @param state current state of the node material building
  69721. * @param normalVarName name of the existing variable corresponding to the normal
  69722. * @returns the shader code
  69723. */
  69724. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  69725. protected _buildBlock(state: NodeMaterialBuildState): this;
  69726. protected _dumpPropertiesCode(): string;
  69727. serialize(): any;
  69728. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69729. }
  69730. }
  69731. declare module BABYLON {
  69732. /**
  69733. * Block used to implement the sheen module of the PBR material
  69734. */
  69735. export class SheenBlock extends NodeMaterialBlock {
  69736. /**
  69737. * Create a new SheenBlock
  69738. * @param name defines the block name
  69739. */
  69740. constructor(name: string);
  69741. /**
  69742. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  69743. * It allows the strength of the sheen effect to not depend on the base color of the material,
  69744. * making it easier to setup and tweak the effect
  69745. */
  69746. albedoScaling: boolean;
  69747. /**
  69748. * Defines if the sheen is linked to the sheen color.
  69749. */
  69750. linkSheenWithAlbedo: boolean;
  69751. /**
  69752. * Initialize the block and prepare the context for build
  69753. * @param state defines the state that will be used for the build
  69754. */
  69755. initialize(state: NodeMaterialBuildState): void;
  69756. /**
  69757. * Gets the current class name
  69758. * @returns the class name
  69759. */
  69760. getClassName(): string;
  69761. /**
  69762. * Gets the intensity input component
  69763. */
  69764. get intensity(): NodeMaterialConnectionPoint;
  69765. /**
  69766. * Gets the color input component
  69767. */
  69768. get color(): NodeMaterialConnectionPoint;
  69769. /**
  69770. * Gets the roughness input component
  69771. */
  69772. get roughness(): NodeMaterialConnectionPoint;
  69773. /**
  69774. * Gets the sheen object output component
  69775. */
  69776. get sheen(): NodeMaterialConnectionPoint;
  69777. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69778. /**
  69779. * Gets the main code of the block (fragment side)
  69780. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69781. * @returns the shader code
  69782. */
  69783. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  69784. protected _buildBlock(state: NodeMaterialBuildState): this;
  69785. protected _dumpPropertiesCode(): string;
  69786. serialize(): any;
  69787. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69788. }
  69789. }
  69790. declare module BABYLON {
  69791. /**
  69792. * Block used to implement the anisotropy module of the PBR material
  69793. */
  69794. export class AnisotropyBlock extends NodeMaterialBlock {
  69795. /**
  69796. * The two properties below are set by the main PBR block prior to calling methods of this class.
  69797. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  69798. * It's less burden on the user side in the editor part.
  69799. */
  69800. /** @hidden */
  69801. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  69802. /** @hidden */
  69803. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  69804. /**
  69805. * Create a new AnisotropyBlock
  69806. * @param name defines the block name
  69807. */
  69808. constructor(name: string);
  69809. /**
  69810. * Initialize the block and prepare the context for build
  69811. * @param state defines the state that will be used for the build
  69812. */
  69813. initialize(state: NodeMaterialBuildState): void;
  69814. /**
  69815. * Gets the current class name
  69816. * @returns the class name
  69817. */
  69818. getClassName(): string;
  69819. /**
  69820. * Gets the intensity input component
  69821. */
  69822. get intensity(): NodeMaterialConnectionPoint;
  69823. /**
  69824. * Gets the direction input component
  69825. */
  69826. get direction(): NodeMaterialConnectionPoint;
  69827. /**
  69828. * Gets the uv input component
  69829. */
  69830. get uv(): NodeMaterialConnectionPoint;
  69831. /**
  69832. * Gets the worldTangent input component
  69833. */
  69834. get worldTangent(): NodeMaterialConnectionPoint;
  69835. /**
  69836. * Gets the anisotropy object output component
  69837. */
  69838. get anisotropy(): NodeMaterialConnectionPoint;
  69839. private _generateTBNSpace;
  69840. /**
  69841. * Gets the main code of the block (fragment side)
  69842. * @param state current state of the node material building
  69843. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69844. * @returns the shader code
  69845. */
  69846. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  69847. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69848. protected _buildBlock(state: NodeMaterialBuildState): this;
  69849. }
  69850. }
  69851. declare module BABYLON {
  69852. /**
  69853. * Block used to implement the clear coat module of the PBR material
  69854. */
  69855. export class ClearCoatBlock extends NodeMaterialBlock {
  69856. private _scene;
  69857. /**
  69858. * Create a new ClearCoatBlock
  69859. * @param name defines the block name
  69860. */
  69861. constructor(name: string);
  69862. /**
  69863. * Defines if the F0 value should be remapped to account for the interface change in the material.
  69864. */
  69865. remapF0OnInterfaceChange: boolean;
  69866. /**
  69867. * Initialize the block and prepare the context for build
  69868. * @param state defines the state that will be used for the build
  69869. */
  69870. initialize(state: NodeMaterialBuildState): void;
  69871. /**
  69872. * Gets the current class name
  69873. * @returns the class name
  69874. */
  69875. getClassName(): string;
  69876. /**
  69877. * Gets the intensity input component
  69878. */
  69879. get intensity(): NodeMaterialConnectionPoint;
  69880. /**
  69881. * Gets the roughness input component
  69882. */
  69883. get roughness(): NodeMaterialConnectionPoint;
  69884. /**
  69885. * Gets the ior input component
  69886. */
  69887. get indexOfRefraction(): NodeMaterialConnectionPoint;
  69888. /**
  69889. * Gets the bump texture input component
  69890. */
  69891. get normalMapColor(): NodeMaterialConnectionPoint;
  69892. /**
  69893. * Gets the uv input component
  69894. */
  69895. get uv(): NodeMaterialConnectionPoint;
  69896. /**
  69897. * Gets the tint color input component
  69898. */
  69899. get tintColor(): NodeMaterialConnectionPoint;
  69900. /**
  69901. * Gets the tint "at distance" input component
  69902. */
  69903. get tintAtDistance(): NodeMaterialConnectionPoint;
  69904. /**
  69905. * Gets the tint thickness input component
  69906. */
  69907. get tintThickness(): NodeMaterialConnectionPoint;
  69908. /**
  69909. * Gets the world tangent input component
  69910. */
  69911. get worldTangent(): NodeMaterialConnectionPoint;
  69912. /**
  69913. * Gets the clear coat object output component
  69914. */
  69915. get clearcoat(): NodeMaterialConnectionPoint;
  69916. autoConfigure(material: NodeMaterial): void;
  69917. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69918. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69919. private _generateTBNSpace;
  69920. /**
  69921. * Gets the main code of the block (fragment side)
  69922. * @param state current state of the node material building
  69923. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  69924. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69925. * @param worldPosVarName name of the variable holding the world position
  69926. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69927. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  69928. * @param worldNormalVarName name of the variable holding the world normal
  69929. * @returns the shader code
  69930. */
  69931. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  69932. protected _buildBlock(state: NodeMaterialBuildState): this;
  69933. protected _dumpPropertiesCode(): string;
  69934. serialize(): any;
  69935. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69936. }
  69937. }
  69938. declare module BABYLON {
  69939. /**
  69940. * Block used to implement the sub surface module of the PBR material
  69941. */
  69942. export class SubSurfaceBlock extends NodeMaterialBlock {
  69943. /**
  69944. * Create a new SubSurfaceBlock
  69945. * @param name defines the block name
  69946. */
  69947. constructor(name: string);
  69948. /**
  69949. * Initialize the block and prepare the context for build
  69950. * @param state defines the state that will be used for the build
  69951. */
  69952. initialize(state: NodeMaterialBuildState): void;
  69953. /**
  69954. * Gets the current class name
  69955. * @returns the class name
  69956. */
  69957. getClassName(): string;
  69958. /**
  69959. * Gets the thickness component
  69960. */
  69961. get thickness(): NodeMaterialConnectionPoint;
  69962. /**
  69963. * Gets the tint color input component
  69964. */
  69965. get tintColor(): NodeMaterialConnectionPoint;
  69966. /**
  69967. * Gets the translucency intensity input component
  69968. */
  69969. get translucencyIntensity(): NodeMaterialConnectionPoint;
  69970. /**
  69971. * Gets the translucency diffusion distance input component
  69972. */
  69973. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  69974. /**
  69975. * Gets the refraction object parameters
  69976. */
  69977. get refraction(): NodeMaterialConnectionPoint;
  69978. /**
  69979. * Gets the sub surface object output component
  69980. */
  69981. get subsurface(): NodeMaterialConnectionPoint;
  69982. autoConfigure(material: NodeMaterial): void;
  69983. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69984. /**
  69985. * Gets the main code of the block (fragment side)
  69986. * @param state current state of the node material building
  69987. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  69988. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69989. * @param worldPosVarName name of the variable holding the world position
  69990. * @returns the shader code
  69991. */
  69992. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  69993. protected _buildBlock(state: NodeMaterialBuildState): this;
  69994. }
  69995. }
  69996. declare module BABYLON {
  69997. /**
  69998. * Block used to implement the PBR metallic/roughness model
  69999. */
  70000. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  70001. /**
  70002. * Gets or sets the light associated with this block
  70003. */
  70004. light: Nullable<Light>;
  70005. private _lightId;
  70006. private _scene;
  70007. private _environmentBRDFTexture;
  70008. private _environmentBrdfSamplerName;
  70009. private _vNormalWName;
  70010. private _invertNormalName;
  70011. private _metallicReflectanceColor;
  70012. private _metallicF0Factor;
  70013. private _vMetallicReflectanceFactorsName;
  70014. /**
  70015. * Create a new ReflectionBlock
  70016. * @param name defines the block name
  70017. */
  70018. constructor(name: string);
  70019. /**
  70020. * Intensity of the direct lights e.g. the four lights available in your scene.
  70021. * This impacts both the direct diffuse and specular highlights.
  70022. */
  70023. directIntensity: number;
  70024. /**
  70025. * Intensity of the environment e.g. how much the environment will light the object
  70026. * either through harmonics for rough material or through the reflection for shiny ones.
  70027. */
  70028. environmentIntensity: number;
  70029. /**
  70030. * This is a special control allowing the reduction of the specular highlights coming from the
  70031. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  70032. */
  70033. specularIntensity: number;
  70034. /**
  70035. * Defines the falloff type used in this material.
  70036. * It by default is Physical.
  70037. */
  70038. lightFalloff: number;
  70039. /**
  70040. * Specifies that alpha test should be used
  70041. */
  70042. useAlphaTest: boolean;
  70043. /**
  70044. * Defines the alpha limits in alpha test mode.
  70045. */
  70046. alphaTestCutoff: number;
  70047. /**
  70048. * Specifies that alpha blending should be used
  70049. */
  70050. useAlphaBlending: boolean;
  70051. /**
  70052. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  70053. * A car glass is a good example of that. When the street lights reflects on it you can not see what is behind.
  70054. */
  70055. useRadianceOverAlpha: boolean;
  70056. /**
  70057. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  70058. * A car glass is a good example of that. When sun reflects on it you can not see what is behind.
  70059. */
  70060. useSpecularOverAlpha: boolean;
  70061. /**
  70062. * Enables specular anti aliasing in the PBR shader.
  70063. * It will both interacts on the Geometry for analytical and IBL lighting.
  70064. * It also prefilter the roughness map based on the bump values.
  70065. */
  70066. enableSpecularAntiAliasing: boolean;
  70067. /**
  70068. * Enables realtime filtering on the texture.
  70069. */
  70070. realTimeFiltering: boolean;
  70071. /**
  70072. * Quality switch for realtime filtering
  70073. */
  70074. realTimeFilteringQuality: number;
  70075. /**
  70076. * Defines if the material uses energy conservation.
  70077. */
  70078. useEnergyConservation: boolean;
  70079. /**
  70080. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  70081. * too much the area relying on ambient texture to define their ambient occlusion.
  70082. */
  70083. useRadianceOcclusion: boolean;
  70084. /**
  70085. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  70086. * makes the reflect vector face the model (under horizon).
  70087. */
  70088. useHorizonOcclusion: boolean;
  70089. /**
  70090. * If set to true, no lighting calculations will be applied.
  70091. */
  70092. unlit: boolean;
  70093. /**
  70094. * Force normal to face away from face.
  70095. */
  70096. forceNormalForward: boolean;
  70097. /**
  70098. * Defines the material debug mode.
  70099. * It helps seeing only some components of the material while troubleshooting.
  70100. */
  70101. debugMode: number;
  70102. /**
  70103. * Specify from where on screen the debug mode should start.
  70104. * The value goes from -1 (full screen) to 1 (not visible)
  70105. * It helps with side by side comparison against the final render
  70106. * This defaults to 0
  70107. */
  70108. debugLimit: number;
  70109. /**
  70110. * As the default viewing range might not be enough (if the ambient is really small for instance)
  70111. * You can use the factor to better multiply the final value.
  70112. */
  70113. debugFactor: number;
  70114. /**
  70115. * Initialize the block and prepare the context for build
  70116. * @param state defines the state that will be used for the build
  70117. */
  70118. initialize(state: NodeMaterialBuildState): void;
  70119. /**
  70120. * Gets the current class name
  70121. * @returns the class name
  70122. */
  70123. getClassName(): string;
  70124. /**
  70125. * Gets the world position input component
  70126. */
  70127. get worldPosition(): NodeMaterialConnectionPoint;
  70128. /**
  70129. * Gets the world normal input component
  70130. */
  70131. get worldNormal(): NodeMaterialConnectionPoint;
  70132. /**
  70133. * Gets the view matrix parameter
  70134. */
  70135. get view(): NodeMaterialConnectionPoint;
  70136. /**
  70137. * Gets the camera position input component
  70138. */
  70139. get cameraPosition(): NodeMaterialConnectionPoint;
  70140. /**
  70141. * Gets the perturbed normal input component
  70142. */
  70143. get perturbedNormal(): NodeMaterialConnectionPoint;
  70144. /**
  70145. * Gets the base color input component
  70146. */
  70147. get baseColor(): NodeMaterialConnectionPoint;
  70148. /**
  70149. * Gets the metallic input component
  70150. */
  70151. get metallic(): NodeMaterialConnectionPoint;
  70152. /**
  70153. * Gets the roughness input component
  70154. */
  70155. get roughness(): NodeMaterialConnectionPoint;
  70156. /**
  70157. * Gets the ambient occlusion input component
  70158. */
  70159. get ambientOcc(): NodeMaterialConnectionPoint;
  70160. /**
  70161. * Gets the opacity input component
  70162. */
  70163. get opacity(): NodeMaterialConnectionPoint;
  70164. /**
  70165. * Gets the index of refraction input component
  70166. */
  70167. get indexOfRefraction(): NodeMaterialConnectionPoint;
  70168. /**
  70169. * Gets the ambient color input component
  70170. */
  70171. get ambientColor(): NodeMaterialConnectionPoint;
  70172. /**
  70173. * Gets the reflection object parameters
  70174. */
  70175. get reflection(): NodeMaterialConnectionPoint;
  70176. /**
  70177. * Gets the clear coat object parameters
  70178. */
  70179. get clearcoat(): NodeMaterialConnectionPoint;
  70180. /**
  70181. * Gets the sheen object parameters
  70182. */
  70183. get sheen(): NodeMaterialConnectionPoint;
  70184. /**
  70185. * Gets the sub surface object parameters
  70186. */
  70187. get subsurface(): NodeMaterialConnectionPoint;
  70188. /**
  70189. * Gets the anisotropy object parameters
  70190. */
  70191. get anisotropy(): NodeMaterialConnectionPoint;
  70192. /**
  70193. * Gets the ambient output component
  70194. */
  70195. get ambientClr(): NodeMaterialConnectionPoint;
  70196. /**
  70197. * Gets the diffuse output component
  70198. */
  70199. get diffuseDir(): NodeMaterialConnectionPoint;
  70200. /**
  70201. * Gets the specular output component
  70202. */
  70203. get specularDir(): NodeMaterialConnectionPoint;
  70204. /**
  70205. * Gets the clear coat output component
  70206. */
  70207. get clearcoatDir(): NodeMaterialConnectionPoint;
  70208. /**
  70209. * Gets the sheen output component
  70210. */
  70211. get sheenDir(): NodeMaterialConnectionPoint;
  70212. /**
  70213. * Gets the indirect diffuse output component
  70214. */
  70215. get diffuseIndirect(): NodeMaterialConnectionPoint;
  70216. /**
  70217. * Gets the indirect specular output component
  70218. */
  70219. get specularIndirect(): NodeMaterialConnectionPoint;
  70220. /**
  70221. * Gets the indirect clear coat output component
  70222. */
  70223. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  70224. /**
  70225. * Gets the indirect sheen output component
  70226. */
  70227. get sheenIndirect(): NodeMaterialConnectionPoint;
  70228. /**
  70229. * Gets the refraction output component
  70230. */
  70231. get refraction(): NodeMaterialConnectionPoint;
  70232. /**
  70233. * Gets the global lighting output component
  70234. */
  70235. get lighting(): NodeMaterialConnectionPoint;
  70236. /**
  70237. * Gets the shadow output component
  70238. */
  70239. get shadow(): NodeMaterialConnectionPoint;
  70240. /**
  70241. * Gets the alpha output component
  70242. */
  70243. get alpha(): NodeMaterialConnectionPoint;
  70244. autoConfigure(material: NodeMaterial): void;
  70245. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  70246. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  70247. isReady(): boolean;
  70248. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  70249. private _injectVertexCode;
  70250. private _getAlbedoOpacityCode;
  70251. private _getAmbientOcclusionCode;
  70252. private _getReflectivityCode;
  70253. protected _buildBlock(state: NodeMaterialBuildState): this;
  70254. protected _dumpPropertiesCode(): string;
  70255. serialize(): any;
  70256. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  70257. }
  70258. }
  70259. declare module BABYLON {
  70260. /**
  70261. * Block used to compute value of one parameter modulo another
  70262. */
  70263. export class ModBlock extends NodeMaterialBlock {
  70264. /**
  70265. * Creates a new ModBlock
  70266. * @param name defines the block name
  70267. */
  70268. constructor(name: string);
  70269. /**
  70270. * Gets the current class name
  70271. * @returns the class name
  70272. */
  70273. getClassName(): string;
  70274. /**
  70275. * Gets the left operand input component
  70276. */
  70277. get left(): NodeMaterialConnectionPoint;
  70278. /**
  70279. * Gets the right operand input component
  70280. */
  70281. get right(): NodeMaterialConnectionPoint;
  70282. /**
  70283. * Gets the output component
  70284. */
  70285. get output(): NodeMaterialConnectionPoint;
  70286. protected _buildBlock(state: NodeMaterialBuildState): this;
  70287. }
  70288. }
  70289. declare module BABYLON {
  70290. /**
  70291. * Configuration for Draco compression
  70292. */
  70293. export interface IDracoCompressionConfiguration {
  70294. /**
  70295. * Configuration for the decoder.
  70296. */
  70297. decoder: {
  70298. /**
  70299. * The url to the WebAssembly module.
  70300. */
  70301. wasmUrl?: string;
  70302. /**
  70303. * The url to the WebAssembly binary.
  70304. */
  70305. wasmBinaryUrl?: string;
  70306. /**
  70307. * The url to the fallback JavaScript module.
  70308. */
  70309. fallbackUrl?: string;
  70310. };
  70311. }
  70312. /**
  70313. * Draco compression (https://google.github.io/draco/)
  70314. *
  70315. * This class wraps the Draco module.
  70316. *
  70317. * **Encoder**
  70318. *
  70319. * The encoder is not currently implemented.
  70320. *
  70321. * **Decoder**
  70322. *
  70323. * 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.
  70324. *
  70325. * To update the configuration, use the following code:
  70326. * ```javascript
  70327. * DracoCompression.Configuration = {
  70328. * decoder: {
  70329. * wasmUrl: "<url to the WebAssembly library>",
  70330. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  70331. * fallbackUrl: "<url to the fallback JavaScript library>",
  70332. * }
  70333. * };
  70334. * ```
  70335. *
  70336. * 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.
  70337. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  70338. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  70339. *
  70340. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  70341. * ```javascript
  70342. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  70343. * ```
  70344. *
  70345. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  70346. */
  70347. export class DracoCompression implements IDisposable {
  70348. private _workerPoolPromise?;
  70349. private _decoderModulePromise?;
  70350. /**
  70351. * The configuration. Defaults to the following urls:
  70352. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  70353. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  70354. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  70355. */
  70356. static Configuration: IDracoCompressionConfiguration;
  70357. /**
  70358. * Returns true if the decoder configuration is available.
  70359. */
  70360. static get DecoderAvailable(): boolean;
  70361. /**
  70362. * Default number of workers to create when creating the draco compression object.
  70363. */
  70364. static DefaultNumWorkers: number;
  70365. private static GetDefaultNumWorkers;
  70366. private static _Default;
  70367. /**
  70368. * Default instance for the draco compression object.
  70369. */
  70370. static get Default(): DracoCompression;
  70371. /**
  70372. * Constructor
  70373. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  70374. */
  70375. constructor(numWorkers?: number);
  70376. /**
  70377. * Stop all async operations and release resources.
  70378. */
  70379. dispose(): void;
  70380. /**
  70381. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  70382. * @returns a promise that resolves when ready
  70383. */
  70384. whenReadyAsync(): Promise<void>;
  70385. /**
  70386. * Decode Draco compressed mesh data to vertex data.
  70387. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  70388. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  70389. * @returns A promise that resolves with the decoded vertex data
  70390. */
  70391. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  70392. [kind: string]: number;
  70393. }): Promise<VertexData>;
  70394. }
  70395. }
  70396. declare module BABYLON {
  70397. /**
  70398. * Class for building Constructive Solid Geometry
  70399. */
  70400. export class CSG {
  70401. private polygons;
  70402. /**
  70403. * The world matrix
  70404. */
  70405. matrix: Matrix;
  70406. /**
  70407. * Stores the position
  70408. */
  70409. position: Vector3;
  70410. /**
  70411. * Stores the rotation
  70412. */
  70413. rotation: Vector3;
  70414. /**
  70415. * Stores the rotation quaternion
  70416. */
  70417. rotationQuaternion: Nullable<Quaternion>;
  70418. /**
  70419. * Stores the scaling vector
  70420. */
  70421. scaling: Vector3;
  70422. /**
  70423. * Convert the Mesh to CSG
  70424. * @param mesh The Mesh to convert to CSG
  70425. * @returns A new CSG from the Mesh
  70426. */
  70427. static FromMesh(mesh: Mesh): CSG;
  70428. /**
  70429. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  70430. * @param polygons Polygons used to construct a CSG solid
  70431. */
  70432. private static FromPolygons;
  70433. /**
  70434. * Clones, or makes a deep copy, of the CSG
  70435. * @returns A new CSG
  70436. */
  70437. clone(): CSG;
  70438. /**
  70439. * Unions this CSG with another CSG
  70440. * @param csg The CSG to union against this CSG
  70441. * @returns The unioned CSG
  70442. */
  70443. union(csg: CSG): CSG;
  70444. /**
  70445. * Unions this CSG with another CSG in place
  70446. * @param csg The CSG to union against this CSG
  70447. */
  70448. unionInPlace(csg: CSG): void;
  70449. /**
  70450. * Subtracts this CSG with another CSG
  70451. * @param csg The CSG to subtract against this CSG
  70452. * @returns A new CSG
  70453. */
  70454. subtract(csg: CSG): CSG;
  70455. /**
  70456. * Subtracts this CSG with another CSG in place
  70457. * @param csg The CSG to subtract against this CSG
  70458. */
  70459. subtractInPlace(csg: CSG): void;
  70460. /**
  70461. * Intersect this CSG with another CSG
  70462. * @param csg The CSG to intersect against this CSG
  70463. * @returns A new CSG
  70464. */
  70465. intersect(csg: CSG): CSG;
  70466. /**
  70467. * Intersects this CSG with another CSG in place
  70468. * @param csg The CSG to intersect against this CSG
  70469. */
  70470. intersectInPlace(csg: CSG): void;
  70471. /**
  70472. * Return a new CSG solid with solid and empty space switched. This solid is
  70473. * not modified.
  70474. * @returns A new CSG solid with solid and empty space switched
  70475. */
  70476. inverse(): CSG;
  70477. /**
  70478. * Inverses the CSG in place
  70479. */
  70480. inverseInPlace(): void;
  70481. /**
  70482. * This is used to keep meshes transformations so they can be restored
  70483. * when we build back a Babylon Mesh
  70484. * NB : All CSG operations are performed in world coordinates
  70485. * @param csg The CSG to copy the transform attributes from
  70486. * @returns This CSG
  70487. */
  70488. copyTransformAttributes(csg: CSG): CSG;
  70489. /**
  70490. * Build Raw mesh from CSG
  70491. * Coordinates here are in world space
  70492. * @param name The name of the mesh geometry
  70493. * @param scene The Scene
  70494. * @param keepSubMeshes Specifies if the submeshes should be kept
  70495. * @returns A new Mesh
  70496. */
  70497. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  70498. /**
  70499. * Build Mesh from CSG taking material and transforms into account
  70500. * @param name The name of the Mesh
  70501. * @param material The material of the Mesh
  70502. * @param scene The Scene
  70503. * @param keepSubMeshes Specifies if submeshes should be kept
  70504. * @returns The new Mesh
  70505. */
  70506. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  70507. }
  70508. }
  70509. declare module BABYLON {
  70510. /**
  70511. * Class used to create a trail following a mesh
  70512. */
  70513. export class TrailMesh extends Mesh {
  70514. private _generator;
  70515. private _autoStart;
  70516. private _running;
  70517. private _diameter;
  70518. private _length;
  70519. private _sectionPolygonPointsCount;
  70520. private _sectionVectors;
  70521. private _sectionNormalVectors;
  70522. private _beforeRenderObserver;
  70523. /**
  70524. * @constructor
  70525. * @param name The value used by scene.getMeshByName() to do a lookup.
  70526. * @param generator The mesh or transform node to generate a trail.
  70527. * @param scene The scene to add this mesh to.
  70528. * @param diameter Diameter of trailing mesh. Default is 1.
  70529. * @param length Length of trailing mesh. Default is 60.
  70530. * @param autoStart Automatically start trailing mesh. Default true.
  70531. */
  70532. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  70533. /**
  70534. * "TrailMesh"
  70535. * @returns "TrailMesh"
  70536. */
  70537. getClassName(): string;
  70538. private _createMesh;
  70539. /**
  70540. * Start trailing mesh.
  70541. */
  70542. start(): void;
  70543. /**
  70544. * Stop trailing mesh.
  70545. */
  70546. stop(): void;
  70547. /**
  70548. * Update trailing mesh geometry.
  70549. */
  70550. update(): void;
  70551. /**
  70552. * Returns a new TrailMesh object.
  70553. * @param name is a string, the name given to the new mesh
  70554. * @param newGenerator use new generator object for cloned trail mesh
  70555. * @returns a new mesh
  70556. */
  70557. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  70558. /**
  70559. * Serializes this trail mesh
  70560. * @param serializationObject object to write serialization to
  70561. */
  70562. serialize(serializationObject: any): void;
  70563. /**
  70564. * Parses a serialized trail mesh
  70565. * @param parsedMesh the serialized mesh
  70566. * @param scene the scene to create the trail mesh in
  70567. * @returns the created trail mesh
  70568. */
  70569. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  70570. }
  70571. }
  70572. declare module BABYLON {
  70573. /**
  70574. * Class containing static functions to help procedurally build meshes
  70575. */
  70576. export class TiledBoxBuilder {
  70577. /**
  70578. * Creates a box mesh
  70579. * 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)
  70580. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70581. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70582. * * 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
  70583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70584. * @param name defines the name of the mesh
  70585. * @param options defines the options used to create the mesh
  70586. * @param scene defines the hosting scene
  70587. * @returns the box mesh
  70588. */
  70589. static CreateTiledBox(name: string, options: {
  70590. pattern?: number;
  70591. width?: number;
  70592. height?: number;
  70593. depth?: number;
  70594. tileSize?: number;
  70595. tileWidth?: number;
  70596. tileHeight?: number;
  70597. alignHorizontal?: number;
  70598. alignVertical?: number;
  70599. faceUV?: Vector4[];
  70600. faceColors?: Color4[];
  70601. sideOrientation?: number;
  70602. updatable?: boolean;
  70603. }, scene?: Nullable<Scene>): Mesh;
  70604. }
  70605. }
  70606. declare module BABYLON {
  70607. /**
  70608. * Class containing static functions to help procedurally build meshes
  70609. */
  70610. export class TorusKnotBuilder {
  70611. /**
  70612. * Creates a torus knot mesh
  70613. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70614. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70615. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70616. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70617. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70618. * * 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
  70619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70620. * @param name defines the name of the mesh
  70621. * @param options defines the options used to create the mesh
  70622. * @param scene defines the hosting scene
  70623. * @returns the torus knot mesh
  70624. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70625. */
  70626. static CreateTorusKnot(name: string, options: {
  70627. radius?: number;
  70628. tube?: number;
  70629. radialSegments?: number;
  70630. tubularSegments?: number;
  70631. p?: number;
  70632. q?: number;
  70633. updatable?: boolean;
  70634. sideOrientation?: number;
  70635. frontUVs?: Vector4;
  70636. backUVs?: Vector4;
  70637. }, scene: any): Mesh;
  70638. }
  70639. }
  70640. declare module BABYLON {
  70641. /**
  70642. * Polygon
  70643. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  70644. */
  70645. export class Polygon {
  70646. /**
  70647. * Creates a rectangle
  70648. * @param xmin bottom X coord
  70649. * @param ymin bottom Y coord
  70650. * @param xmax top X coord
  70651. * @param ymax top Y coord
  70652. * @returns points that make the resulting rectangle
  70653. */
  70654. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  70655. /**
  70656. * Creates a circle
  70657. * @param radius radius of circle
  70658. * @param cx scale in x
  70659. * @param cy scale in y
  70660. * @param numberOfSides number of sides that make up the circle
  70661. * @returns points that make the resulting circle
  70662. */
  70663. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  70664. /**
  70665. * Creates a polygon from input string
  70666. * @param input Input polygon data
  70667. * @returns the parsed points
  70668. */
  70669. static Parse(input: string): Vector2[];
  70670. /**
  70671. * Starts building a polygon from x and y coordinates
  70672. * @param x x coordinate
  70673. * @param y y coordinate
  70674. * @returns the started path2
  70675. */
  70676. static StartingAt(x: number, y: number): Path2;
  70677. }
  70678. /**
  70679. * Builds a polygon
  70680. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  70681. */
  70682. export class PolygonMeshBuilder {
  70683. private _points;
  70684. private _outlinepoints;
  70685. private _holes;
  70686. private _name;
  70687. private _scene;
  70688. private _epoints;
  70689. private _eholes;
  70690. private _addToepoint;
  70691. /**
  70692. * Babylon reference to the earcut plugin.
  70693. */
  70694. bjsEarcut: any;
  70695. /**
  70696. * Creates a PolygonMeshBuilder
  70697. * @param name name of the builder
  70698. * @param contours Path of the polygon
  70699. * @param scene scene to add to when creating the mesh
  70700. * @param earcutInjection can be used to inject your own earcut reference
  70701. */
  70702. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  70703. /**
  70704. * Adds a hole within the polygon
  70705. * @param hole Array of points defining the hole
  70706. * @returns this
  70707. */
  70708. addHole(hole: Vector2[]): PolygonMeshBuilder;
  70709. /**
  70710. * Creates the polygon
  70711. * @param updatable If the mesh should be updatable
  70712. * @param depth The depth of the mesh created
  70713. * @param smoothingThreshold Dot product threshold for smoothed normals
  70714. * @returns the created mesh
  70715. */
  70716. build(updatable?: boolean, depth?: number, smoothingThreshold?: number): Mesh;
  70717. /**
  70718. * Creates the polygon
  70719. * @param depth The depth of the mesh created
  70720. * @param smoothingThreshold Dot product threshold for smoothed normals
  70721. * @returns the created VertexData
  70722. */
  70723. buildVertexData(depth?: number, smoothingThreshold?: number): VertexData;
  70724. /**
  70725. * Adds a side to the polygon
  70726. * @param positions points that make the polygon
  70727. * @param normals normals of the polygon
  70728. * @param uvs uvs of the polygon
  70729. * @param indices indices of the polygon
  70730. * @param bounds bounds of the polygon
  70731. * @param points points of the polygon
  70732. * @param depth depth of the polygon
  70733. * @param flip flip of the polygon
  70734. */
  70735. private addSide;
  70736. }
  70737. }
  70738. declare module BABYLON {
  70739. /**
  70740. * Class containing static functions to help procedurally build meshes
  70741. */
  70742. export class PolygonBuilder {
  70743. /**
  70744. * Creates a polygon mesh
  70745. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70746. * * 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
  70747. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70748. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70749. * * 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)
  70750. * * Remember you can only change the shape positions, not their number when updating a polygon
  70751. * @param name defines the name of the mesh
  70752. * @param options defines the options used to create the mesh
  70753. * @param scene defines the hosting scene
  70754. * @param earcutInjection can be used to inject your own earcut reference
  70755. * @returns the polygon mesh
  70756. */
  70757. static CreatePolygon(name: string, options: {
  70758. shape: Vector3[];
  70759. holes?: Vector3[][];
  70760. depth?: number;
  70761. smoothingThreshold?: number;
  70762. faceUV?: Vector4[];
  70763. faceColors?: Color4[];
  70764. updatable?: boolean;
  70765. sideOrientation?: number;
  70766. frontUVs?: Vector4;
  70767. backUVs?: Vector4;
  70768. wrap?: boolean;
  70769. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70770. /**
  70771. * Creates an extruded polygon mesh, with depth in the Y direction.
  70772. * * 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)
  70773. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70774. * @param name defines the name of the mesh
  70775. * @param options defines the options used to create the mesh
  70776. * @param scene defines the hosting scene
  70777. * @param earcutInjection can be used to inject your own earcut reference
  70778. * @returns the polygon mesh
  70779. */
  70780. static ExtrudePolygon(name: string, options: {
  70781. shape: Vector3[];
  70782. holes?: Vector3[][];
  70783. depth?: number;
  70784. faceUV?: Vector4[];
  70785. faceColors?: Color4[];
  70786. updatable?: boolean;
  70787. sideOrientation?: number;
  70788. frontUVs?: Vector4;
  70789. backUVs?: Vector4;
  70790. wrap?: boolean;
  70791. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70792. }
  70793. }
  70794. declare module BABYLON {
  70795. /**
  70796. * Class containing static functions to help procedurally build meshes
  70797. */
  70798. export class LatheBuilder {
  70799. /**
  70800. * Creates lathe mesh.
  70801. * The lathe is a shape with a symmetry axis : a 2D model shape is rotated around this axis to design the lathe
  70802. * * 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
  70803. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70804. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70805. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70806. * * 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
  70807. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70808. * * 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
  70809. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70810. * * 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
  70811. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70813. * @param name defines the name of the mesh
  70814. * @param options defines the options used to create the mesh
  70815. * @param scene defines the hosting scene
  70816. * @returns the lathe mesh
  70817. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70818. */
  70819. static CreateLathe(name: string, options: {
  70820. shape: Vector3[];
  70821. radius?: number;
  70822. tessellation?: number;
  70823. clip?: number;
  70824. arc?: number;
  70825. closed?: boolean;
  70826. updatable?: boolean;
  70827. sideOrientation?: number;
  70828. frontUVs?: Vector4;
  70829. backUVs?: Vector4;
  70830. cap?: number;
  70831. invertUV?: boolean;
  70832. }, scene?: Nullable<Scene>): Mesh;
  70833. }
  70834. }
  70835. declare module BABYLON {
  70836. /**
  70837. * Class containing static functions to help procedurally build meshes
  70838. */
  70839. export class TiledPlaneBuilder {
  70840. /**
  70841. * Creates a tiled plane mesh
  70842. * * The parameter `pattern` will, depending on value, do nothing or
  70843. * * * flip (reflect about central vertical) alternate tiles across and up
  70844. * * * flip every tile on alternate rows
  70845. * * * rotate (180 degs) alternate tiles across and up
  70846. * * * rotate every tile on alternate rows
  70847. * * * flip and rotate alternate tiles across and up
  70848. * * * flip and rotate every tile on alternate rows
  70849. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  70850. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  70851. * * 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
  70852. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70853. * * 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)
  70854. * * 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)
  70855. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70856. * @param name defines the name of the mesh
  70857. * @param options defines the options used to create the mesh
  70858. * @param scene defines the hosting scene
  70859. * @returns the box mesh
  70860. */
  70861. static CreateTiledPlane(name: string, options: {
  70862. pattern?: number;
  70863. tileSize?: number;
  70864. tileWidth?: number;
  70865. tileHeight?: number;
  70866. size?: number;
  70867. width?: number;
  70868. height?: number;
  70869. alignHorizontal?: number;
  70870. alignVertical?: number;
  70871. sideOrientation?: number;
  70872. frontUVs?: Vector4;
  70873. backUVs?: Vector4;
  70874. updatable?: boolean;
  70875. }, scene?: Nullable<Scene>): Mesh;
  70876. }
  70877. }
  70878. declare module BABYLON {
  70879. /**
  70880. * Class containing static functions to help procedurally build meshes
  70881. */
  70882. export class TubeBuilder {
  70883. /**
  70884. * Creates a tube mesh.
  70885. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70886. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70887. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70888. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70889. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overrides the parameter `radius`
  70890. * * 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)
  70891. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70892. * * 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
  70893. * * 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
  70894. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70895. * * 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
  70896. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70898. * @param name defines the name of the mesh
  70899. * @param options defines the options used to create the mesh
  70900. * @param scene defines the hosting scene
  70901. * @returns the tube mesh
  70902. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70903. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70904. */
  70905. static CreateTube(name: string, options: {
  70906. path: Vector3[];
  70907. radius?: number;
  70908. tessellation?: number;
  70909. radiusFunction?: {
  70910. (i: number, distance: number): number;
  70911. };
  70912. cap?: number;
  70913. arc?: number;
  70914. updatable?: boolean;
  70915. sideOrientation?: number;
  70916. frontUVs?: Vector4;
  70917. backUVs?: Vector4;
  70918. instance?: Mesh;
  70919. invertUV?: boolean;
  70920. }, scene?: Nullable<Scene>): Mesh;
  70921. }
  70922. }
  70923. declare module BABYLON {
  70924. /**
  70925. * Class containing static functions to help procedurally build meshes
  70926. */
  70927. export class IcoSphereBuilder {
  70928. /**
  70929. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70930. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70931. * * 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`)
  70932. * * The parameter `subdivisions` sets the number of subdivisions (positive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70933. * * 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
  70934. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70935. * * 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
  70936. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70937. * @param name defines the name of the mesh
  70938. * @param options defines the options used to create the mesh
  70939. * @param scene defines the hosting scene
  70940. * @returns the icosahedron mesh
  70941. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70942. */
  70943. static CreateIcoSphere(name: string, options: {
  70944. radius?: number;
  70945. radiusX?: number;
  70946. radiusY?: number;
  70947. radiusZ?: number;
  70948. flat?: boolean;
  70949. subdivisions?: number;
  70950. sideOrientation?: number;
  70951. frontUVs?: Vector4;
  70952. backUVs?: Vector4;
  70953. updatable?: boolean;
  70954. }, scene?: Nullable<Scene>): Mesh;
  70955. }
  70956. }
  70957. declare module BABYLON {
  70958. /**
  70959. * Class containing static functions to help procedurally build meshes
  70960. */
  70961. export class DecalBuilder {
  70962. /**
  70963. * Creates a decal mesh.
  70964. * 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
  70965. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70966. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70967. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70968. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70969. * * The parameter `captureUVS` defines if we need to capture the uvs or compute them
  70970. * @param name defines the name of the mesh
  70971. * @param sourceMesh defines the mesh where the decal must be applied
  70972. * @param options defines the options used to create the mesh
  70973. * @param scene defines the hosting scene
  70974. * @returns the decal mesh
  70975. * @see https://doc.babylonjs.com/how_to/decals
  70976. */
  70977. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70978. position?: Vector3;
  70979. normal?: Vector3;
  70980. size?: Vector3;
  70981. angle?: number;
  70982. captureUVS?: boolean;
  70983. }): Mesh;
  70984. }
  70985. }
  70986. declare module BABYLON {
  70987. /**
  70988. * Class containing static functions to help procedurally build meshes
  70989. */
  70990. export class MeshBuilder {
  70991. /**
  70992. * Creates a box mesh
  70993. * * The parameter `size` sets the size (float) of each box side (default 1)
  70994. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  70995. * * 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)
  70996. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70997. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70998. * * 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
  70999. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71000. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  71001. * @param name defines the name of the mesh
  71002. * @param options defines the options used to create the mesh
  71003. * @param scene defines the hosting scene
  71004. * @returns the box mesh
  71005. */
  71006. static CreateBox(name: string, options: {
  71007. size?: number;
  71008. width?: number;
  71009. height?: number;
  71010. depth?: number;
  71011. faceUV?: Vector4[];
  71012. faceColors?: Color4[];
  71013. sideOrientation?: number;
  71014. frontUVs?: Vector4;
  71015. backUVs?: Vector4;
  71016. wrap?: boolean;
  71017. topBaseAt?: number;
  71018. bottomBaseAt?: number;
  71019. updatable?: boolean;
  71020. }, scene?: Nullable<Scene>): Mesh;
  71021. /**
  71022. * Creates a tiled box mesh
  71023. * * faceTiles sets the pattern, tile size and number of tiles for a face
  71024. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71025. * @param name defines the name of the mesh
  71026. * @param options defines the options used to create the mesh
  71027. * @param scene defines the hosting scene
  71028. * @returns the tiled box mesh
  71029. */
  71030. static CreateTiledBox(name: string, options: {
  71031. pattern?: number;
  71032. size?: number;
  71033. width?: number;
  71034. height?: number;
  71035. depth: number;
  71036. tileSize?: number;
  71037. tileWidth?: number;
  71038. tileHeight?: number;
  71039. faceUV?: Vector4[];
  71040. faceColors?: Color4[];
  71041. alignHorizontal?: number;
  71042. alignVertical?: number;
  71043. sideOrientation?: number;
  71044. updatable?: boolean;
  71045. }, scene?: Nullable<Scene>): Mesh;
  71046. /**
  71047. * Creates a sphere mesh
  71048. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  71049. * * 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`)
  71050. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  71051. * * 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
  71052. * * 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)
  71053. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71054. * * 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
  71055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71056. * @param name defines the name of the mesh
  71057. * @param options defines the options used to create the mesh
  71058. * @param scene defines the hosting scene
  71059. * @returns the sphere mesh
  71060. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  71061. */
  71062. static CreateSphere(name: string, options: {
  71063. segments?: number;
  71064. diameter?: number;
  71065. diameterX?: number;
  71066. diameterY?: number;
  71067. diameterZ?: number;
  71068. arc?: number;
  71069. slice?: number;
  71070. sideOrientation?: number;
  71071. frontUVs?: Vector4;
  71072. backUVs?: Vector4;
  71073. updatable?: boolean;
  71074. }, scene?: Nullable<Scene>): Mesh;
  71075. /**
  71076. * Creates a plane polygonal mesh. By default, this is a disc
  71077. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  71078. * * 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
  71079. * * 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
  71080. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71081. * * 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
  71082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71083. * @param name defines the name of the mesh
  71084. * @param options defines the options used to create the mesh
  71085. * @param scene defines the hosting scene
  71086. * @returns the plane polygonal mesh
  71087. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  71088. */
  71089. static CreateDisc(name: string, options: {
  71090. radius?: number;
  71091. tessellation?: number;
  71092. arc?: number;
  71093. updatable?: boolean;
  71094. sideOrientation?: number;
  71095. frontUVs?: Vector4;
  71096. backUVs?: Vector4;
  71097. }, scene?: Nullable<Scene>): Mesh;
  71098. /**
  71099. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  71100. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  71101. * * 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`)
  71102. * * The parameter `subdivisions` sets the number of subdivisions (positive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  71103. * * 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
  71104. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71105. * * 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
  71106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71107. * @param name defines the name of the mesh
  71108. * @param options defines the options used to create the mesh
  71109. * @param scene defines the hosting scene
  71110. * @returns the icosahedron mesh
  71111. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  71112. */
  71113. static CreateIcoSphere(name: string, options: {
  71114. radius?: number;
  71115. radiusX?: number;
  71116. radiusY?: number;
  71117. radiusZ?: number;
  71118. flat?: boolean;
  71119. subdivisions?: number;
  71120. sideOrientation?: number;
  71121. frontUVs?: Vector4;
  71122. backUVs?: Vector4;
  71123. updatable?: boolean;
  71124. }, scene?: Nullable<Scene>): Mesh;
  71125. /**
  71126. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  71127. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  71128. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  71129. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  71130. * * 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
  71131. * * 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
  71132. * * 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
  71133. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71134. * * 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
  71135. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  71136. * * 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
  71137. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  71138. * * 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
  71139. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  71140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71141. * @param name defines the name of the mesh
  71142. * @param options defines the options used to create the mesh
  71143. * @param scene defines the hosting scene
  71144. * @returns the ribbon mesh
  71145. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  71146. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  71147. */
  71148. static CreateRibbon(name: string, options: {
  71149. pathArray: Vector3[][];
  71150. closeArray?: boolean;
  71151. closePath?: boolean;
  71152. offset?: number;
  71153. updatable?: boolean;
  71154. sideOrientation?: number;
  71155. frontUVs?: Vector4;
  71156. backUVs?: Vector4;
  71157. instance?: Mesh;
  71158. invertUV?: boolean;
  71159. uvs?: Vector2[];
  71160. colors?: Color4[];
  71161. }, scene?: Nullable<Scene>): Mesh;
  71162. /**
  71163. * Creates a cylinder or a cone mesh
  71164. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  71165. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  71166. * * 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.
  71167. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  71168. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  71169. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  71170. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  71171. * * 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).
  71172. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  71173. * * 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).
  71174. * * 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
  71175. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  71176. * * 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
  71177. * * 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.
  71178. * * If `enclose` is false, a ring surface is one element.
  71179. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  71180. * * 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
  71181. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71182. * * 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
  71183. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71184. * @param name defines the name of the mesh
  71185. * @param options defines the options used to create the mesh
  71186. * @param scene defines the hosting scene
  71187. * @returns the cylinder mesh
  71188. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  71189. */
  71190. static CreateCylinder(name: string, options: {
  71191. height?: number;
  71192. diameterTop?: number;
  71193. diameterBottom?: number;
  71194. diameter?: number;
  71195. tessellation?: number;
  71196. subdivisions?: number;
  71197. arc?: number;
  71198. faceColors?: Color4[];
  71199. faceUV?: Vector4[];
  71200. updatable?: boolean;
  71201. hasRings?: boolean;
  71202. enclose?: boolean;
  71203. cap?: number;
  71204. sideOrientation?: number;
  71205. frontUVs?: Vector4;
  71206. backUVs?: Vector4;
  71207. }, scene?: Nullable<Scene>): Mesh;
  71208. /**
  71209. * Creates a torus mesh
  71210. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  71211. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  71212. * * The parameter `tessellation` sets the number of torus sides (positive integer, default 16)
  71213. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71214. * * 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
  71215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71216. * @param name defines the name of the mesh
  71217. * @param options defines the options used to create the mesh
  71218. * @param scene defines the hosting scene
  71219. * @returns the torus mesh
  71220. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  71221. */
  71222. static CreateTorus(name: string, options: {
  71223. diameter?: number;
  71224. thickness?: number;
  71225. tessellation?: number;
  71226. updatable?: boolean;
  71227. sideOrientation?: number;
  71228. frontUVs?: Vector4;
  71229. backUVs?: Vector4;
  71230. }, scene?: Nullable<Scene>): Mesh;
  71231. /**
  71232. * Creates a torus knot mesh
  71233. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  71234. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  71235. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  71236. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  71237. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71238. * * 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
  71239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71240. * @param name defines the name of the mesh
  71241. * @param options defines the options used to create the mesh
  71242. * @param scene defines the hosting scene
  71243. * @returns the torus knot mesh
  71244. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  71245. */
  71246. static CreateTorusKnot(name: string, options: {
  71247. radius?: number;
  71248. tube?: number;
  71249. radialSegments?: number;
  71250. tubularSegments?: number;
  71251. p?: number;
  71252. q?: number;
  71253. updatable?: boolean;
  71254. sideOrientation?: number;
  71255. frontUVs?: Vector4;
  71256. backUVs?: Vector4;
  71257. }, scene?: Nullable<Scene>): Mesh;
  71258. /**
  71259. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  71260. * * 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
  71261. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  71262. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  71263. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  71264. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  71265. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  71266. * * 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
  71267. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  71268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71269. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  71270. * @param name defines the name of the new line system
  71271. * @param options defines the options used to create the line system
  71272. * @param scene defines the hosting scene
  71273. * @returns a new line system mesh
  71274. */
  71275. static CreateLineSystem(name: string, options: {
  71276. lines: Vector3[][];
  71277. updatable?: boolean;
  71278. instance?: Nullable<LinesMesh>;
  71279. colors?: Nullable<Color4[][]>;
  71280. useVertexAlpha?: boolean;
  71281. }, scene: Nullable<Scene>): LinesMesh;
  71282. /**
  71283. * Creates a line mesh
  71284. * 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
  71285. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  71286. * * The parameter `points` is an array successive Vector3
  71287. * * 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
  71288. * * The optional parameter `colors` is an array of successive Color4, one per line point
  71289. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  71290. * * When updating an instance, remember that only point positions can change, not the number of points
  71291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71292. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  71293. * @param name defines the name of the new line system
  71294. * @param options defines the options used to create the line system
  71295. * @param scene defines the hosting scene
  71296. * @returns a new line mesh
  71297. */
  71298. static CreateLines(name: string, options: {
  71299. points: Vector3[];
  71300. updatable?: boolean;
  71301. instance?: Nullable<LinesMesh>;
  71302. colors?: Color4[];
  71303. useVertexAlpha?: boolean;
  71304. }, scene?: Nullable<Scene>): LinesMesh;
  71305. /**
  71306. * Creates a dashed line mesh
  71307. * * 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
  71308. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  71309. * * The parameter `points` is an array successive Vector3
  71310. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  71311. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  71312. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  71313. * * 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
  71314. * * When updating an instance, remember that only point positions can change, not the number of points
  71315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71316. * @param name defines the name of the mesh
  71317. * @param options defines the options used to create the mesh
  71318. * @param scene defines the hosting scene
  71319. * @returns the dashed line mesh
  71320. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  71321. */
  71322. static CreateDashedLines(name: string, options: {
  71323. points: Vector3[];
  71324. dashSize?: number;
  71325. gapSize?: number;
  71326. dashNb?: number;
  71327. updatable?: boolean;
  71328. instance?: LinesMesh;
  71329. }, scene?: Nullable<Scene>): LinesMesh;
  71330. /**
  71331. * 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.
  71332. * * 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.
  71333. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  71334. * * 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.
  71335. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  71336. * * 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
  71337. * * 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
  71338. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  71339. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71340. * * 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
  71341. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  71342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71343. * @param name defines the name of the mesh
  71344. * @param options defines the options used to create the mesh
  71345. * @param scene defines the hosting scene
  71346. * @returns the extruded shape mesh
  71347. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  71348. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  71349. */
  71350. static ExtrudeShape(name: string, options: {
  71351. shape: Vector3[];
  71352. path: Vector3[];
  71353. scale?: number;
  71354. rotation?: number;
  71355. cap?: number;
  71356. updatable?: boolean;
  71357. sideOrientation?: number;
  71358. frontUVs?: Vector4;
  71359. backUVs?: Vector4;
  71360. instance?: Mesh;
  71361. invertUV?: boolean;
  71362. }, scene?: Nullable<Scene>): Mesh;
  71363. /**
  71364. * Creates an custom extruded shape mesh.
  71365. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  71366. * * 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.
  71367. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  71368. * * 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
  71369. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  71370. * * 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
  71371. * * It must returns a float value that will be the scale value applied to the shape on each path point
  71372. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  71373. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  71374. * * 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
  71375. * * 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
  71376. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  71377. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71378. * * 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
  71379. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  71380. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71381. * @param name defines the name of the mesh
  71382. * @param options defines the options used to create the mesh
  71383. * @param scene defines the hosting scene
  71384. * @returns the custom extruded shape mesh
  71385. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  71386. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  71387. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  71388. */
  71389. static ExtrudeShapeCustom(name: string, options: {
  71390. shape: Vector3[];
  71391. path: Vector3[];
  71392. scaleFunction?: any;
  71393. rotationFunction?: any;
  71394. ribbonCloseArray?: boolean;
  71395. ribbonClosePath?: boolean;
  71396. cap?: number;
  71397. updatable?: boolean;
  71398. sideOrientation?: number;
  71399. frontUVs?: Vector4;
  71400. backUVs?: Vector4;
  71401. instance?: Mesh;
  71402. invertUV?: boolean;
  71403. }, scene?: Nullable<Scene>): Mesh;
  71404. /**
  71405. * Creates lathe mesh.
  71406. * The lathe is a shape with a symmetry axis : a 2D model shape is rotated around this axis to design the lathe
  71407. * * 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
  71408. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  71409. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  71410. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  71411. * * 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
  71412. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  71413. * * 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
  71414. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71415. * * 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
  71416. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  71417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71418. * @param name defines the name of the mesh
  71419. * @param options defines the options used to create the mesh
  71420. * @param scene defines the hosting scene
  71421. * @returns the lathe mesh
  71422. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  71423. */
  71424. static CreateLathe(name: string, options: {
  71425. shape: Vector3[];
  71426. radius?: number;
  71427. tessellation?: number;
  71428. clip?: number;
  71429. arc?: number;
  71430. closed?: boolean;
  71431. updatable?: boolean;
  71432. sideOrientation?: number;
  71433. frontUVs?: Vector4;
  71434. backUVs?: Vector4;
  71435. cap?: number;
  71436. invertUV?: boolean;
  71437. }, scene?: Nullable<Scene>): Mesh;
  71438. /**
  71439. * Creates a tiled plane mesh
  71440. * * You can set a limited pattern arrangement with the tiles
  71441. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71442. * * 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
  71443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71444. * @param name defines the name of the mesh
  71445. * @param options defines the options used to create the mesh
  71446. * @param scene defines the hosting scene
  71447. * @returns the plane mesh
  71448. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  71449. */
  71450. static CreateTiledPlane(name: string, options: {
  71451. pattern?: number;
  71452. tileSize?: number;
  71453. tileWidth?: number;
  71454. tileHeight?: number;
  71455. size?: number;
  71456. width?: number;
  71457. height?: number;
  71458. alignHorizontal?: number;
  71459. alignVertical?: number;
  71460. sideOrientation?: number;
  71461. frontUVs?: Vector4;
  71462. backUVs?: Vector4;
  71463. updatable?: boolean;
  71464. }, scene?: Nullable<Scene>): Mesh;
  71465. /**
  71466. * Creates a plane mesh
  71467. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  71468. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  71469. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  71470. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71471. * * 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
  71472. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71473. * @param name defines the name of the mesh
  71474. * @param options defines the options used to create the mesh
  71475. * @param scene defines the hosting scene
  71476. * @returns the plane mesh
  71477. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  71478. */
  71479. static CreatePlane(name: string, options: {
  71480. size?: number;
  71481. width?: number;
  71482. height?: number;
  71483. sideOrientation?: number;
  71484. frontUVs?: Vector4;
  71485. backUVs?: Vector4;
  71486. updatable?: boolean;
  71487. sourcePlane?: Plane;
  71488. }, scene?: Nullable<Scene>): Mesh;
  71489. /**
  71490. * Creates a ground mesh
  71491. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  71492. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  71493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71494. * @param name defines the name of the mesh
  71495. * @param options defines the options used to create the mesh
  71496. * @param scene defines the hosting scene
  71497. * @returns the ground mesh
  71498. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  71499. */
  71500. static CreateGround(name: string, options: {
  71501. width?: number;
  71502. height?: number;
  71503. subdivisions?: number;
  71504. subdivisionsX?: number;
  71505. subdivisionsY?: number;
  71506. updatable?: boolean;
  71507. }, scene?: Nullable<Scene>): Mesh;
  71508. /**
  71509. * Creates a tiled ground mesh
  71510. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  71511. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  71512. * * 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
  71513. * * 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
  71514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71515. * @param name defines the name of the mesh
  71516. * @param options defines the options used to create the mesh
  71517. * @param scene defines the hosting scene
  71518. * @returns the tiled ground mesh
  71519. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  71520. */
  71521. static CreateTiledGround(name: string, options: {
  71522. xmin: number;
  71523. zmin: number;
  71524. xmax: number;
  71525. zmax: number;
  71526. subdivisions?: {
  71527. w: number;
  71528. h: number;
  71529. };
  71530. precision?: {
  71531. w: number;
  71532. h: number;
  71533. };
  71534. updatable?: boolean;
  71535. }, scene?: Nullable<Scene>): Mesh;
  71536. /**
  71537. * Creates a ground mesh from a height map
  71538. * * The parameter `url` sets the URL of the height map image resource.
  71539. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  71540. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  71541. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  71542. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  71543. * * 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.
  71544. * * 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).
  71545. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  71546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71547. * @param name defines the name of the mesh
  71548. * @param url defines the url to the height map
  71549. * @param options defines the options used to create the mesh
  71550. * @param scene defines the hosting scene
  71551. * @returns the ground mesh
  71552. * @see https://doc.babylonjs.com/babylon101/height_map
  71553. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  71554. */
  71555. static CreateGroundFromHeightMap(name: string, url: string, options: {
  71556. width?: number;
  71557. height?: number;
  71558. subdivisions?: number;
  71559. minHeight?: number;
  71560. maxHeight?: number;
  71561. colorFilter?: Color3;
  71562. alphaFilter?: number;
  71563. updatable?: boolean;
  71564. onReady?: (mesh: GroundMesh) => void;
  71565. }, scene?: Nullable<Scene>): GroundMesh;
  71566. /**
  71567. * Creates a polygon mesh
  71568. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  71569. * * 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
  71570. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  71571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71572. * * 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)
  71573. * * Remember you can only change the shape positions, not their number when updating a polygon
  71574. * @param name defines the name of the mesh
  71575. * @param options defines the options used to create the mesh
  71576. * @param scene defines the hosting scene
  71577. * @param earcutInjection can be used to inject your own earcut reference
  71578. * @returns the polygon mesh
  71579. */
  71580. static CreatePolygon(name: string, options: {
  71581. shape: Vector3[];
  71582. holes?: Vector3[][];
  71583. depth?: number;
  71584. faceUV?: Vector4[];
  71585. faceColors?: Color4[];
  71586. updatable?: boolean;
  71587. sideOrientation?: number;
  71588. frontUVs?: Vector4;
  71589. backUVs?: Vector4;
  71590. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  71591. /**
  71592. * Creates an extruded polygon mesh, with depth in the Y direction.
  71593. * * 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)
  71594. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  71595. * @param name defines the name of the mesh
  71596. * @param options defines the options used to create the mesh
  71597. * @param scene defines the hosting scene
  71598. * @param earcutInjection can be used to inject your own earcut reference
  71599. * @returns the polygon mesh
  71600. */
  71601. static ExtrudePolygon(name: string, options: {
  71602. shape: Vector3[];
  71603. holes?: Vector3[][];
  71604. depth?: number;
  71605. faceUV?: Vector4[];
  71606. faceColors?: Color4[];
  71607. updatable?: boolean;
  71608. sideOrientation?: number;
  71609. frontUVs?: Vector4;
  71610. backUVs?: Vector4;
  71611. wrap?: boolean;
  71612. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  71613. /**
  71614. * Creates a tube mesh.
  71615. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  71616. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  71617. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  71618. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  71619. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overrides the parameter `radius`
  71620. * * 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)
  71621. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  71622. * * 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
  71623. * * 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
  71624. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71625. * * 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
  71626. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  71627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71628. * @param name defines the name of the mesh
  71629. * @param options defines the options used to create the mesh
  71630. * @param scene defines the hosting scene
  71631. * @returns the tube mesh
  71632. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  71633. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  71634. */
  71635. static CreateTube(name: string, options: {
  71636. path: Vector3[];
  71637. radius?: number;
  71638. tessellation?: number;
  71639. radiusFunction?: {
  71640. (i: number, distance: number): number;
  71641. };
  71642. cap?: number;
  71643. arc?: number;
  71644. updatable?: boolean;
  71645. sideOrientation?: number;
  71646. frontUVs?: Vector4;
  71647. backUVs?: Vector4;
  71648. instance?: Mesh;
  71649. invertUV?: boolean;
  71650. }, scene?: Nullable<Scene>): Mesh;
  71651. /**
  71652. * Creates a polyhedron mesh
  71653. * * 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
  71654. * * The parameter `size` (positive float, default 1) sets the polygon size
  71655. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  71656. * * 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`
  71657. * * 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
  71658. * * 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)`)
  71659. * * 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
  71660. * * 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
  71661. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71662. * * 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
  71663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71664. * @param name defines the name of the mesh
  71665. * @param options defines the options used to create the mesh
  71666. * @param scene defines the hosting scene
  71667. * @returns the polyhedron mesh
  71668. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  71669. */
  71670. static CreatePolyhedron(name: string, options: {
  71671. type?: number;
  71672. size?: number;
  71673. sizeX?: number;
  71674. sizeY?: number;
  71675. sizeZ?: number;
  71676. custom?: any;
  71677. faceUV?: Vector4[];
  71678. faceColors?: Color4[];
  71679. flat?: boolean;
  71680. updatable?: boolean;
  71681. sideOrientation?: number;
  71682. frontUVs?: Vector4;
  71683. backUVs?: Vector4;
  71684. }, scene?: Nullable<Scene>): Mesh;
  71685. /**
  71686. * Creates a decal mesh.
  71687. * 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
  71688. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  71689. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  71690. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  71691. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  71692. * @param name defines the name of the mesh
  71693. * @param sourceMesh defines the mesh where the decal must be applied
  71694. * @param options defines the options used to create the mesh
  71695. * @param scene defines the hosting scene
  71696. * @returns the decal mesh
  71697. * @see https://doc.babylonjs.com/how_to/decals
  71698. */
  71699. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  71700. position?: Vector3;
  71701. normal?: Vector3;
  71702. size?: Vector3;
  71703. angle?: number;
  71704. }): Mesh;
  71705. /**
  71706. * Creates a Capsule Mesh
  71707. * @param name defines the name of the mesh.
  71708. * @param options the constructors options used to shape the mesh.
  71709. * @param scene defines the scene the mesh is scoped to.
  71710. * @returns the capsule mesh
  71711. * @see https://doc.babylonjs.com/how_to/capsule_shape
  71712. */
  71713. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  71714. }
  71715. }
  71716. declare module BABYLON {
  71717. /**
  71718. * A simplifier interface for future simplification implementations
  71719. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71720. */
  71721. export interface ISimplifier {
  71722. /**
  71723. * Simplification of a given mesh according to the given settings.
  71724. * Since this requires computation, it is assumed that the function runs async.
  71725. * @param settings The settings of the simplification, including quality and distance
  71726. * @param successCallback A callback that will be called after the mesh was simplified.
  71727. * @param errorCallback in case of an error, this callback will be called. optional.
  71728. */
  71729. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  71730. }
  71731. /**
  71732. * Expected simplification settings.
  71733. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  71734. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71735. */
  71736. export interface ISimplificationSettings {
  71737. /**
  71738. * Gets or sets the expected quality
  71739. */
  71740. quality: number;
  71741. /**
  71742. * Gets or sets the distance when this optimized version should be used
  71743. */
  71744. distance: number;
  71745. /**
  71746. * Gets an already optimized mesh
  71747. */
  71748. optimizeMesh?: boolean;
  71749. }
  71750. /**
  71751. * Class used to specify simplification options
  71752. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71753. */
  71754. export class SimplificationSettings implements ISimplificationSettings {
  71755. /** expected quality */
  71756. quality: number;
  71757. /** distance when this optimized version should be used */
  71758. distance: number;
  71759. /** already optimized mesh */
  71760. optimizeMesh?: boolean | undefined;
  71761. /**
  71762. * Creates a SimplificationSettings
  71763. * @param quality expected quality
  71764. * @param distance distance when this optimized version should be used
  71765. * @param optimizeMesh already optimized mesh
  71766. */
  71767. constructor(
  71768. /** expected quality */
  71769. quality: number,
  71770. /** distance when this optimized version should be used */
  71771. distance: number,
  71772. /** already optimized mesh */
  71773. optimizeMesh?: boolean | undefined);
  71774. }
  71775. /**
  71776. * Interface used to define a simplification task
  71777. */
  71778. export interface ISimplificationTask {
  71779. /**
  71780. * Array of settings
  71781. */
  71782. settings: Array<ISimplificationSettings>;
  71783. /**
  71784. * Simplification type
  71785. */
  71786. simplificationType: SimplificationType;
  71787. /**
  71788. * Mesh to simplify
  71789. */
  71790. mesh: Mesh;
  71791. /**
  71792. * Callback called on success
  71793. */
  71794. successCallback?: () => void;
  71795. /**
  71796. * Defines if parallel processing can be used
  71797. */
  71798. parallelProcessing: boolean;
  71799. }
  71800. /**
  71801. * Queue used to order the simplification tasks
  71802. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71803. */
  71804. export class SimplificationQueue {
  71805. private _simplificationArray;
  71806. /**
  71807. * Gets a boolean indicating that the process is still running
  71808. */
  71809. running: boolean;
  71810. /**
  71811. * Creates a new queue
  71812. */
  71813. constructor();
  71814. /**
  71815. * Adds a new simplification task
  71816. * @param task defines a task to add
  71817. */
  71818. addTask(task: ISimplificationTask): void;
  71819. /**
  71820. * Execute next task
  71821. */
  71822. executeNext(): void;
  71823. /**
  71824. * Execute a simplification task
  71825. * @param task defines the task to run
  71826. */
  71827. runSimplification(task: ISimplificationTask): void;
  71828. private getSimplifier;
  71829. }
  71830. /**
  71831. * The implemented types of simplification
  71832. * At the moment only Quadratic Error Decimation is implemented
  71833. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71834. */
  71835. export enum SimplificationType {
  71836. /** Quadratic error decimation */
  71837. QUADRATIC = 0
  71838. }
  71839. /**
  71840. * An implementation of the Quadratic Error simplification algorithm.
  71841. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  71842. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  71843. * @author RaananW
  71844. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71845. */
  71846. export class QuadraticErrorSimplification implements ISimplifier {
  71847. private _mesh;
  71848. private triangles;
  71849. private vertices;
  71850. private references;
  71851. private _reconstructedMesh;
  71852. /** Gets or sets the number pf sync iterations */
  71853. syncIterations: number;
  71854. /** Gets or sets the aggressiveness of the simplifier */
  71855. aggressiveness: number;
  71856. /** Gets or sets the number of allowed iterations for decimation */
  71857. decimationIterations: number;
  71858. /** Gets or sets the espilon to use for bounding box computation */
  71859. boundingBoxEpsilon: number;
  71860. /**
  71861. * Creates a new QuadraticErrorSimplification
  71862. * @param _mesh defines the target mesh
  71863. */
  71864. constructor(_mesh: Mesh);
  71865. /**
  71866. * Simplification of a given mesh according to the given settings.
  71867. * Since this requires computation, it is assumed that the function runs async.
  71868. * @param settings The settings of the simplification, including quality and distance
  71869. * @param successCallback A callback that will be called after the mesh was simplified.
  71870. */
  71871. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  71872. private runDecimation;
  71873. private initWithMesh;
  71874. private init;
  71875. private reconstructMesh;
  71876. private initDecimatedMesh;
  71877. private isFlipped;
  71878. private updateTriangles;
  71879. private identifyBorder;
  71880. private updateMesh;
  71881. private vertexError;
  71882. private calculateError;
  71883. }
  71884. }
  71885. declare module BABYLON {
  71886. interface Scene {
  71887. /** @hidden (Backing field) */
  71888. _simplificationQueue: SimplificationQueue;
  71889. /**
  71890. * Gets or sets the simplification queue attached to the scene
  71891. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71892. */
  71893. simplificationQueue: SimplificationQueue;
  71894. }
  71895. interface Mesh {
  71896. /**
  71897. * Simplify the mesh according to the given array of settings.
  71898. * Function will return immediately and will simplify async
  71899. * @param settings a collection of simplification settings
  71900. * @param parallelProcessing should all levels calculate parallel or one after the other
  71901. * @param simplificationType the type of simplification to run
  71902. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  71903. * @returns the current mesh
  71904. */
  71905. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  71906. }
  71907. /**
  71908. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  71909. * created in a scene
  71910. */
  71911. export class SimplicationQueueSceneComponent implements ISceneComponent {
  71912. /**
  71913. * The component name helpfull to identify the component in the list of scene components.
  71914. */
  71915. readonly name: string;
  71916. /**
  71917. * The scene the component belongs to.
  71918. */
  71919. scene: Scene;
  71920. /**
  71921. * Creates a new instance of the component for the given scene
  71922. * @param scene Defines the scene to register the component in
  71923. */
  71924. constructor(scene: Scene);
  71925. /**
  71926. * Registers the component in a given scene
  71927. */
  71928. register(): void;
  71929. /**
  71930. * Rebuilds the elements related to this component in case of
  71931. * context lost for instance.
  71932. */
  71933. rebuild(): void;
  71934. /**
  71935. * Disposes the component and the associated resources
  71936. */
  71937. dispose(): void;
  71938. private _beforeCameraUpdate;
  71939. }
  71940. }
  71941. declare module BABYLON {
  71942. interface Mesh {
  71943. /**
  71944. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  71945. */
  71946. thinInstanceEnablePicking: boolean;
  71947. /**
  71948. * Creates a new thin instance
  71949. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  71950. * @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
  71951. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  71952. */
  71953. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh?: boolean): number;
  71954. /**
  71955. * Adds the transformation (matrix) of the current mesh as a thin instance
  71956. * @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
  71957. * @returns the thin instance index number
  71958. */
  71959. thinInstanceAddSelf(refresh?: boolean): number;
  71960. /**
  71961. * Registers a custom attribute to be used with thin instances
  71962. * @param kind name of the attribute
  71963. * @param stride size in floats of the attribute
  71964. */
  71965. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  71966. /**
  71967. * Sets the matrix of a thin instance
  71968. * @param index index of the thin instance
  71969. * @param matrix matrix to set
  71970. * @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
  71971. */
  71972. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh?: boolean): void;
  71973. /**
  71974. * Sets the value of a custom attribute for a thin instance
  71975. * @param kind name of the attribute
  71976. * @param index index of the thin instance
  71977. * @param value value to set
  71978. * @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
  71979. */
  71980. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh?: boolean): void;
  71981. /**
  71982. * 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.
  71983. */
  71984. thinInstanceCount: number;
  71985. /**
  71986. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  71987. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  71988. * @param buffer buffer to set
  71989. * @param stride size in floats of each value of the buffer
  71990. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  71991. */
  71992. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride?: number, staticBuffer?: boolean): void;
  71993. /**
  71994. * Gets the list of world matrices
  71995. * @return an array containing all the world matrices from the thin instances
  71996. */
  71997. thinInstanceGetWorldMatrices(): Matrix[];
  71998. /**
  71999. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  72000. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  72001. */
  72002. thinInstanceBufferUpdated(kind: string): void;
  72003. /**
  72004. * Applies a partial update to a buffer directly on the GPU
  72005. * 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
  72006. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  72007. * @param data the data to set in the GPU buffer
  72008. * @param offset the offset in the GPU buffer where to update the data
  72009. */
  72010. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  72011. /**
  72012. * Refreshes the bounding info, taking into account all the thin instances defined
  72013. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  72014. */
  72015. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo?: boolean): void;
  72016. /** @hidden */
  72017. _thinInstanceInitializeUserStorage(): void;
  72018. /** @hidden */
  72019. _thinInstanceUpdateBufferSize(kind: string, numInstances?: number): void;
  72020. /** @hidden */
  72021. _userThinInstanceBuffersStorage: {
  72022. data: {
  72023. [key: string]: Float32Array;
  72024. };
  72025. sizes: {
  72026. [key: string]: number;
  72027. };
  72028. vertexBuffers: {
  72029. [key: string]: Nullable<VertexBuffer>;
  72030. };
  72031. strides: {
  72032. [key: string]: number;
  72033. };
  72034. };
  72035. }
  72036. }
  72037. declare module BABYLON {
  72038. /**
  72039. * Navigation plugin interface to add navigation constrained by a navigation mesh
  72040. */
  72041. export interface INavigationEnginePlugin {
  72042. /**
  72043. * plugin name
  72044. */
  72045. name: string;
  72046. /**
  72047. * Creates a navigation mesh
  72048. * @param meshes array of all the geometry used to compute the navigation mesh
  72049. * @param parameters bunch of parameters used to filter geometry
  72050. */
  72051. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  72052. /**
  72053. * Create a navigation mesh debug mesh
  72054. * @param scene is where the mesh will be added
  72055. * @returns debug display mesh
  72056. */
  72057. createDebugNavMesh(scene: Scene): Mesh;
  72058. /**
  72059. * Get a navigation mesh constrained position, closest to the parameter position
  72060. * @param position world position
  72061. * @returns the closest point to position constrained by the navigation mesh
  72062. */
  72063. getClosestPoint(position: Vector3): Vector3;
  72064. /**
  72065. * Get a navigation mesh constrained position, closest to the parameter position
  72066. * @param position world position
  72067. * @param result output the closest point to position constrained by the navigation mesh
  72068. */
  72069. getClosestPointToRef(position: Vector3, result: Vector3): void;
  72070. /**
  72071. * Get a navigation mesh constrained position, within a particular radius
  72072. * @param position world position
  72073. * @param maxRadius the maximum distance to the constrained world position
  72074. * @returns the closest point to position constrained by the navigation mesh
  72075. */
  72076. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  72077. /**
  72078. * Get a navigation mesh constrained position, within a particular radius
  72079. * @param position world position
  72080. * @param maxRadius the maximum distance to the constrained world position
  72081. * @param result output the closest point to position constrained by the navigation mesh
  72082. */
  72083. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  72084. /**
  72085. * Compute the final position from a segment made of destination-position
  72086. * @param position world position
  72087. * @param destination world position
  72088. * @returns the resulting point along the navmesh
  72089. */
  72090. moveAlong(position: Vector3, destination: Vector3): Vector3;
  72091. /**
  72092. * Compute the final position from a segment made of destination-position
  72093. * @param position world position
  72094. * @param destination world position
  72095. * @param result output the resulting point along the navmesh
  72096. */
  72097. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  72098. /**
  72099. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  72100. * @param start world position
  72101. * @param end world position
  72102. * @returns array containing world position composing the path
  72103. */
  72104. computePath(start: Vector3, end: Vector3): Vector3[];
  72105. /**
  72106. * If this plugin is supported
  72107. * @returns true if plugin is supported
  72108. */
  72109. isSupported(): boolean;
  72110. /**
  72111. * Create a new Crowd so you can add agents
  72112. * @param maxAgents the maximum agent count in the crowd
  72113. * @param maxAgentRadius the maximum radius an agent can have
  72114. * @param scene to attach the crowd to
  72115. * @returns the crowd you can add agents to
  72116. */
  72117. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  72118. /**
  72119. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  72120. * The queries will try to find a solution within those bounds
  72121. * default is (1,1,1)
  72122. * @param extent x,y,z value that define the extent around the queries point of reference
  72123. */
  72124. setDefaultQueryExtent(extent: Vector3): void;
  72125. /**
  72126. * Get the Bounding box extent specified by setDefaultQueryExtent
  72127. * @returns the box extent values
  72128. */
  72129. getDefaultQueryExtent(): Vector3;
  72130. /**
  72131. * build the navmesh from a previously saved state using getNavmeshData
  72132. * @param data the Uint8Array returned by getNavmeshData
  72133. */
  72134. buildFromNavmeshData(data: Uint8Array): void;
  72135. /**
  72136. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  72137. * @returns data the Uint8Array that can be saved and reused
  72138. */
  72139. getNavmeshData(): Uint8Array;
  72140. /**
  72141. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72142. * @param result output the box extent values
  72143. */
  72144. getDefaultQueryExtentToRef(result: Vector3): void;
  72145. /**
  72146. * Set the time step of the navigation tick update.
  72147. * Default is 1/60.
  72148. * A value of 0 will disable fixed time update
  72149. * @param newTimeStep the new timestep to apply to this world.
  72150. */
  72151. setTimeStep(newTimeStep: number): void;
  72152. /**
  72153. * Get the time step of the navigation tick update.
  72154. * @returns the current time step
  72155. */
  72156. getTimeStep(): number;
  72157. /**
  72158. * If delta time in navigation tick update is greater than the time step
  72159. * a number of sub iterations are done. If more iterations are need to reach deltatime
  72160. * they will be discarded.
  72161. * A value of 0 will set to no maximum and update will use as many substeps as needed
  72162. * @param newStepCount the maximum number of iterations
  72163. */
  72164. setMaximumSubStepCount(newStepCount: number): void;
  72165. /**
  72166. * Get the maximum number of iterations per navigation tick update
  72167. * @returns the maximum number of iterations
  72168. */
  72169. getMaximumSubStepCount(): number;
  72170. /**
  72171. * Creates a cylinder obstacle and add it to the navigation
  72172. * @param position world position
  72173. * @param radius cylinder radius
  72174. * @param height cylinder height
  72175. * @returns the obstacle freshly created
  72176. */
  72177. addCylinderObstacle(position: Vector3, radius: number, height: number): IObstacle;
  72178. /**
  72179. * Creates an oriented box obstacle and add it to the navigation
  72180. * @param position world position
  72181. * @param extent box size
  72182. * @param angle angle in radians of the box orientation on Y axis
  72183. * @returns the obstacle freshly created
  72184. */
  72185. addBoxObstacle(position: Vector3, extent: Vector3, angle: number): IObstacle;
  72186. /**
  72187. * Removes an obstacle created by addCylinderObstacle or addBoxObstacle
  72188. * @param obstacle obstacle to remove from the navigation
  72189. */
  72190. removeObstacle(obstacle: IObstacle): void;
  72191. /**
  72192. * Release all resources
  72193. */
  72194. dispose(): void;
  72195. }
  72196. /**
  72197. * Obstacle interface
  72198. */
  72199. export interface IObstacle {
  72200. }
  72201. /**
  72202. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  72203. */
  72204. export interface ICrowd {
  72205. /**
  72206. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  72207. * You can attach anything to that node. The node position is updated in the scene update tick.
  72208. * @param pos world position that will be constrained by the navigation mesh
  72209. * @param parameters agent parameters
  72210. * @param transform hooked to the agent that will be update by the scene
  72211. * @returns agent index
  72212. */
  72213. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  72214. /**
  72215. * Returns the agent position in world space
  72216. * @param index agent index returned by addAgent
  72217. * @returns world space position
  72218. */
  72219. getAgentPosition(index: number): Vector3;
  72220. /**
  72221. * Gets the agent position result in world space
  72222. * @param index agent index returned by addAgent
  72223. * @param result output world space position
  72224. */
  72225. getAgentPositionToRef(index: number, result: Vector3): void;
  72226. /**
  72227. * Gets the agent velocity in world space
  72228. * @param index agent index returned by addAgent
  72229. * @returns world space velocity
  72230. */
  72231. getAgentVelocity(index: number): Vector3;
  72232. /**
  72233. * Gets the agent velocity result in world space
  72234. * @param index agent index returned by addAgent
  72235. * @param result output world space velocity
  72236. */
  72237. getAgentVelocityToRef(index: number, result: Vector3): void;
  72238. /**
  72239. * Gets the agent next target point on the path
  72240. * @param index agent index returned by addAgent
  72241. * @returns world space position
  72242. */
  72243. getAgentNextTargetPath(index: number): Vector3;
  72244. /**
  72245. * Gets the agent state
  72246. * @param index agent index returned by addAgent
  72247. * @returns agent state
  72248. */
  72249. getAgentState(index: number): number;
  72250. /**
  72251. * returns true if the agent in over an off mesh link connection
  72252. * @param index agent index returned by addAgent
  72253. * @returns true if over an off mesh link connection
  72254. */
  72255. overOffmeshConnection(index: number): boolean;
  72256. /**
  72257. * Gets the agent next target point on the path
  72258. * @param index agent index returned by addAgent
  72259. * @param result output world space position
  72260. */
  72261. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  72262. /**
  72263. * remove a particular agent previously created
  72264. * @param index agent index returned by addAgent
  72265. */
  72266. removeAgent(index: number): void;
  72267. /**
  72268. * get the list of all agents attached to this crowd
  72269. * @returns list of agent indices
  72270. */
  72271. getAgents(): number[];
  72272. /**
  72273. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  72274. * @param deltaTime in seconds
  72275. */
  72276. update(deltaTime: number): void;
  72277. /**
  72278. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  72279. * @param index agent index returned by addAgent
  72280. * @param destination targeted world position
  72281. */
  72282. agentGoto(index: number, destination: Vector3): void;
  72283. /**
  72284. * Teleport the agent to a new position
  72285. * @param index agent index returned by addAgent
  72286. * @param destination targeted world position
  72287. */
  72288. agentTeleport(index: number, destination: Vector3): void;
  72289. /**
  72290. * Update agent parameters
  72291. * @param index agent index returned by addAgent
  72292. * @param parameters agent parameters
  72293. */
  72294. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  72295. /**
  72296. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  72297. * The queries will try to find a solution within those bounds
  72298. * default is (1,1,1)
  72299. * @param extent x,y,z value that define the extent around the queries point of reference
  72300. */
  72301. setDefaultQueryExtent(extent: Vector3): void;
  72302. /**
  72303. * Get the Bounding box extent specified by setDefaultQueryExtent
  72304. * @returns the box extent values
  72305. */
  72306. getDefaultQueryExtent(): Vector3;
  72307. /**
  72308. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72309. * @param result output the box extent values
  72310. */
  72311. getDefaultQueryExtentToRef(result: Vector3): void;
  72312. /**
  72313. * Get the next corner points composing the path (max 4 points)
  72314. * @param index agent index returned by addAgent
  72315. * @returns array containing world position composing the path
  72316. */
  72317. getCorners(index: number): Vector3[];
  72318. /**
  72319. * Release all resources
  72320. */
  72321. dispose(): void;
  72322. }
  72323. /**
  72324. * Configures an agent
  72325. */
  72326. export interface IAgentParameters {
  72327. /**
  72328. * Agent radius. [Limit: >= 0]
  72329. */
  72330. radius: number;
  72331. /**
  72332. * Agent height. [Limit: > 0]
  72333. */
  72334. height: number;
  72335. /**
  72336. * Maximum allowed acceleration. [Limit: >= 0]
  72337. */
  72338. maxAcceleration: number;
  72339. /**
  72340. * Maximum allowed speed. [Limit: >= 0]
  72341. */
  72342. maxSpeed: number;
  72343. /**
  72344. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  72345. */
  72346. collisionQueryRange: number;
  72347. /**
  72348. * The path visibility optimization range. [Limit: > 0]
  72349. */
  72350. pathOptimizationRange: number;
  72351. /**
  72352. * How aggressive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  72353. */
  72354. separationWeight: number;
  72355. }
  72356. /**
  72357. * Configures the navigation mesh creation
  72358. */
  72359. export interface INavMeshParameters {
  72360. /**
  72361. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  72362. */
  72363. cs: number;
  72364. /**
  72365. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  72366. */
  72367. ch: number;
  72368. /**
  72369. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  72370. */
  72371. walkableSlopeAngle: number;
  72372. /**
  72373. * Minimum floor to 'ceiling' height that will still allow the floor area to
  72374. * be considered walkable. [Limit: >= 3] [Units: vx]
  72375. */
  72376. walkableHeight: number;
  72377. /**
  72378. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  72379. */
  72380. walkableClimb: number;
  72381. /**
  72382. * The distance to erode/shrink the walkable area of the heightfield away from
  72383. * obstructions. [Limit: >=0] [Units: vx]
  72384. */
  72385. walkableRadius: number;
  72386. /**
  72387. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  72388. */
  72389. maxEdgeLen: number;
  72390. /**
  72391. * The maximum distance a simplified contour's border edges should deviate
  72392. * the original raw contour. [Limit: >=0] [Units: vx]
  72393. */
  72394. maxSimplificationError: number;
  72395. /**
  72396. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  72397. */
  72398. minRegionArea: number;
  72399. /**
  72400. * Any regions with a span count smaller than this value will, if possible,
  72401. * be merged with larger regions. [Limit: >=0] [Units: vx]
  72402. */
  72403. mergeRegionArea: number;
  72404. /**
  72405. * The maximum number of vertices allowed for polygons generated during the
  72406. * contour to polygon conversion process. [Limit: >= 3]
  72407. */
  72408. maxVertsPerPoly: number;
  72409. /**
  72410. * Sets the sampling distance to use when generating the detail mesh.
  72411. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  72412. */
  72413. detailSampleDist: number;
  72414. /**
  72415. * The maximum distance the detail mesh surface should deviate from heightfield
  72416. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  72417. */
  72418. detailSampleMaxError: number;
  72419. /**
  72420. * If using obstacles, the navmesh must be subdivided internaly by tiles.
  72421. * This member defines the tile cube side length in world units.
  72422. * If no obstacles are needed, leave it undefined or 0.
  72423. */
  72424. tileSize: number;
  72425. /**
  72426. * The size of the non-navigable border around the heightfield.
  72427. */
  72428. borderSize: number;
  72429. }
  72430. }
  72431. declare module BABYLON {
  72432. /**
  72433. * RecastJS navigation plugin
  72434. */
  72435. export class RecastJSPlugin implements INavigationEnginePlugin {
  72436. /**
  72437. * Reference to the Recast library
  72438. */
  72439. bjsRECAST: any;
  72440. /**
  72441. * plugin name
  72442. */
  72443. name: string;
  72444. /**
  72445. * the first navmesh created. We might extend this to support multiple navmeshes
  72446. */
  72447. navMesh: any;
  72448. private _maximumSubStepCount;
  72449. private _timeStep;
  72450. /**
  72451. * Initializes the recastJS plugin
  72452. * @param recastInjection can be used to inject your own recast reference
  72453. */
  72454. constructor(recastInjection?: any);
  72455. /**
  72456. * Set the time step of the navigation tick update.
  72457. * Default is 1/60.
  72458. * A value of 0 will disable fixed time update
  72459. * @param newTimeStep the new timestep to apply to this world.
  72460. */
  72461. setTimeStep(newTimeStep?: number): void;
  72462. /**
  72463. * Get the time step of the navigation tick update.
  72464. * @returns the current time step
  72465. */
  72466. getTimeStep(): number;
  72467. /**
  72468. * If delta time in navigation tick update is greater than the time step
  72469. * a number of sub iterations are done. If more iterations are need to reach deltatime
  72470. * they will be discarded.
  72471. * A value of 0 will set to no maximum and update will use as many substeps as needed
  72472. * @param newStepCount the maximum number of iterations
  72473. */
  72474. setMaximumSubStepCount(newStepCount?: number): void;
  72475. /**
  72476. * Get the maximum number of iterations per navigation tick update
  72477. * @returns the maximum number of iterations
  72478. */
  72479. getMaximumSubStepCount(): number;
  72480. /**
  72481. * Creates a navigation mesh
  72482. * @param meshes array of all the geometry used to compute the navigation mesh
  72483. * @param parameters bunch of parameters used to filter geometry
  72484. */
  72485. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  72486. /**
  72487. * Create a navigation mesh debug mesh
  72488. * @param scene is where the mesh will be added
  72489. * @returns debug display mesh
  72490. */
  72491. createDebugNavMesh(scene: Scene): Mesh;
  72492. /**
  72493. * Get a navigation mesh constrained position, closest to the parameter position
  72494. * @param position world position
  72495. * @returns the closest point to position constrained by the navigation mesh
  72496. */
  72497. getClosestPoint(position: Vector3): Vector3;
  72498. /**
  72499. * Get a navigation mesh constrained position, closest to the parameter position
  72500. * @param position world position
  72501. * @param result output the closest point to position constrained by the navigation mesh
  72502. */
  72503. getClosestPointToRef(position: Vector3, result: Vector3): void;
  72504. /**
  72505. * Get a navigation mesh constrained position, within a particular radius
  72506. * @param position world position
  72507. * @param maxRadius the maximum distance to the constrained world position
  72508. * @returns the closest point to position constrained by the navigation mesh
  72509. */
  72510. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  72511. /**
  72512. * Get a navigation mesh constrained position, within a particular radius
  72513. * @param position world position
  72514. * @param maxRadius the maximum distance to the constrained world position
  72515. * @param result output the closest point to position constrained by the navigation mesh
  72516. */
  72517. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  72518. /**
  72519. * Compute the final position from a segment made of destination-position
  72520. * @param position world position
  72521. * @param destination world position
  72522. * @returns the resulting point along the navmesh
  72523. */
  72524. moveAlong(position: Vector3, destination: Vector3): Vector3;
  72525. /**
  72526. * Compute the final position from a segment made of destination-position
  72527. * @param position world position
  72528. * @param destination world position
  72529. * @param result output the resulting point along the navmesh
  72530. */
  72531. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  72532. /**
  72533. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  72534. * @param start world position
  72535. * @param end world position
  72536. * @returns array containing world position composing the path
  72537. */
  72538. computePath(start: Vector3, end: Vector3): Vector3[];
  72539. /**
  72540. * Create a new Crowd so you can add agents
  72541. * @param maxAgents the maximum agent count in the crowd
  72542. * @param maxAgentRadius the maximum radius an agent can have
  72543. * @param scene to attach the crowd to
  72544. * @returns the crowd you can add agents to
  72545. */
  72546. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  72547. /**
  72548. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  72549. * The queries will try to find a solution within those bounds
  72550. * default is (1,1,1)
  72551. * @param extent x,y,z value that define the extent around the queries point of reference
  72552. */
  72553. setDefaultQueryExtent(extent: Vector3): void;
  72554. /**
  72555. * Get the Bounding box extent specified by setDefaultQueryExtent
  72556. * @returns the box extent values
  72557. */
  72558. getDefaultQueryExtent(): Vector3;
  72559. /**
  72560. * build the navmesh from a previously saved state using getNavmeshData
  72561. * @param data the Uint8Array returned by getNavmeshData
  72562. */
  72563. buildFromNavmeshData(data: Uint8Array): void;
  72564. /**
  72565. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  72566. * @returns data the Uint8Array that can be saved and reused
  72567. */
  72568. getNavmeshData(): Uint8Array;
  72569. /**
  72570. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72571. * @param result output the box extent values
  72572. */
  72573. getDefaultQueryExtentToRef(result: Vector3): void;
  72574. /**
  72575. * Disposes
  72576. */
  72577. dispose(): void;
  72578. /**
  72579. * Creates a cylinder obstacle and add it to the navigation
  72580. * @param position world position
  72581. * @param radius cylinder radius
  72582. * @param height cylinder height
  72583. * @returns the obstacle freshly created
  72584. */
  72585. addCylinderObstacle(position: Vector3, radius: number, height: number): IObstacle;
  72586. /**
  72587. * Creates an oriented box obstacle and add it to the navigation
  72588. * @param position world position
  72589. * @param extent box size
  72590. * @param angle angle in radians of the box orientation on Y axis
  72591. * @returns the obstacle freshly created
  72592. */
  72593. addBoxObstacle(position: Vector3, extent: Vector3, angle: number): IObstacle;
  72594. /**
  72595. * Removes an obstacle created by addCylinderObstacle or addBoxObstacle
  72596. * @param obstacle obstacle to remove from the navigation
  72597. */
  72598. removeObstacle(obstacle: IObstacle): void;
  72599. /**
  72600. * If this plugin is supported
  72601. * @returns true if plugin is supported
  72602. */
  72603. isSupported(): boolean;
  72604. }
  72605. /**
  72606. * Recast detour crowd implementation
  72607. */
  72608. export class RecastJSCrowd implements ICrowd {
  72609. /**
  72610. * Recast/detour plugin
  72611. */
  72612. bjsRECASTPlugin: RecastJSPlugin;
  72613. /**
  72614. * Link to the detour crowd
  72615. */
  72616. recastCrowd: any;
  72617. /**
  72618. * One transform per agent
  72619. */
  72620. transforms: TransformNode[];
  72621. /**
  72622. * All agents created
  72623. */
  72624. agents: number[];
  72625. /**
  72626. * Link to the scene is kept to unregister the crowd from the scene
  72627. */
  72628. private _scene;
  72629. /**
  72630. * Observer for crowd updates
  72631. */
  72632. private _onBeforeAnimationsObserver;
  72633. /**
  72634. * Constructor
  72635. * @param plugin recastJS plugin
  72636. * @param maxAgents the maximum agent count in the crowd
  72637. * @param maxAgentRadius the maximum radius an agent can have
  72638. * @param scene to attach the crowd to
  72639. * @returns the crowd you can add agents to
  72640. */
  72641. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  72642. /**
  72643. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  72644. * You can attach anything to that node. The node position is updated in the scene update tick.
  72645. * @param pos world position that will be constrained by the navigation mesh
  72646. * @param parameters agent parameters
  72647. * @param transform hooked to the agent that will be update by the scene
  72648. * @returns agent index
  72649. */
  72650. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  72651. /**
  72652. * Returns the agent position in world space
  72653. * @param index agent index returned by addAgent
  72654. * @returns world space position
  72655. */
  72656. getAgentPosition(index: number): Vector3;
  72657. /**
  72658. * Returns the agent position result in world space
  72659. * @param index agent index returned by addAgent
  72660. * @param result output world space position
  72661. */
  72662. getAgentPositionToRef(index: number, result: Vector3): void;
  72663. /**
  72664. * Returns the agent velocity in world space
  72665. * @param index agent index returned by addAgent
  72666. * @returns world space velocity
  72667. */
  72668. getAgentVelocity(index: number): Vector3;
  72669. /**
  72670. * Returns the agent velocity result in world space
  72671. * @param index agent index returned by addAgent
  72672. * @param result output world space velocity
  72673. */
  72674. getAgentVelocityToRef(index: number, result: Vector3): void;
  72675. /**
  72676. * Returns the agent next target point on the path
  72677. * @param index agent index returned by addAgent
  72678. * @returns world space position
  72679. */
  72680. getAgentNextTargetPath(index: number): Vector3;
  72681. /**
  72682. * Returns the agent next target point on the path
  72683. * @param index agent index returned by addAgent
  72684. * @param result output world space position
  72685. */
  72686. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  72687. /**
  72688. * Gets the agent state
  72689. * @param index agent index returned by addAgent
  72690. * @returns agent state
  72691. */
  72692. getAgentState(index: number): number;
  72693. /**
  72694. * returns true if the agent in over an off mesh link connection
  72695. * @param index agent index returned by addAgent
  72696. * @returns true if over an off mesh link connection
  72697. */
  72698. overOffmeshConnection(index: number): boolean;
  72699. /**
  72700. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  72701. * @param index agent index returned by addAgent
  72702. * @param destination targeted world position
  72703. */
  72704. agentGoto(index: number, destination: Vector3): void;
  72705. /**
  72706. * Teleport the agent to a new position
  72707. * @param index agent index returned by addAgent
  72708. * @param destination targeted world position
  72709. */
  72710. agentTeleport(index: number, destination: Vector3): void;
  72711. /**
  72712. * Update agent parameters
  72713. * @param index agent index returned by addAgent
  72714. * @param parameters agent parameters
  72715. */
  72716. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  72717. /**
  72718. * remove a particular agent previously created
  72719. * @param index agent index returned by addAgent
  72720. */
  72721. removeAgent(index: number): void;
  72722. /**
  72723. * get the list of all agents attached to this crowd
  72724. * @returns list of agent indices
  72725. */
  72726. getAgents(): number[];
  72727. /**
  72728. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  72729. * @param deltaTime in seconds
  72730. */
  72731. update(deltaTime: number): void;
  72732. /**
  72733. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  72734. * The queries will try to find a solution within those bounds
  72735. * default is (1,1,1)
  72736. * @param extent x,y,z value that define the extent around the queries point of reference
  72737. */
  72738. setDefaultQueryExtent(extent: Vector3): void;
  72739. /**
  72740. * Get the Bounding box extent specified by setDefaultQueryExtent
  72741. * @returns the box extent values
  72742. */
  72743. getDefaultQueryExtent(): Vector3;
  72744. /**
  72745. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72746. * @param result output the box extent values
  72747. */
  72748. getDefaultQueryExtentToRef(result: Vector3): void;
  72749. /**
  72750. * Get the next corner points composing the path (max 4 points)
  72751. * @param index agent index returned by addAgent
  72752. * @returns array containing world position composing the path
  72753. */
  72754. getCorners(index: number): Vector3[];
  72755. /**
  72756. * Release all resources
  72757. */
  72758. dispose(): void;
  72759. }
  72760. }
  72761. declare module BABYLON {
  72762. /**
  72763. * Class used to enable access to IndexedDB
  72764. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  72765. */
  72766. export class Database implements IOfflineProvider {
  72767. private _callbackManifestChecked;
  72768. private _currentSceneUrl;
  72769. private _db;
  72770. private _enableSceneOffline;
  72771. private _enableTexturesOffline;
  72772. private _manifestVersionFound;
  72773. private _mustUpdateRessources;
  72774. private _hasReachedQuota;
  72775. private _isSupported;
  72776. private _idbFactory;
  72777. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  72778. private static IsUASupportingBlobStorage;
  72779. /**
  72780. * Gets a boolean indicating if Database storage is enabled (off by default)
  72781. */
  72782. static IDBStorageEnabled: boolean;
  72783. /**
  72784. * Gets a boolean indicating if scene must be saved in the database
  72785. */
  72786. get enableSceneOffline(): boolean;
  72787. /**
  72788. * Gets a boolean indicating if textures must be saved in the database
  72789. */
  72790. get enableTexturesOffline(): boolean;
  72791. /**
  72792. * Creates a new Database
  72793. * @param urlToScene defines the url to load the scene
  72794. * @param callbackManifestChecked defines the callback to use when manifest is checked
  72795. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  72796. */
  72797. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  72798. private static _ParseURL;
  72799. private static _ReturnFullUrlLocation;
  72800. private _checkManifestFile;
  72801. /**
  72802. * Open the database and make it available
  72803. * @param successCallback defines the callback to call on success
  72804. * @param errorCallback defines the callback to call on error
  72805. */
  72806. open(successCallback: () => void, errorCallback: () => void): void;
  72807. /**
  72808. * Loads an image from the database
  72809. * @param url defines the url to load from
  72810. * @param image defines the target DOM image
  72811. */
  72812. loadImage(url: string, image: HTMLImageElement): void;
  72813. private _loadImageFromDBAsync;
  72814. private _saveImageIntoDBAsync;
  72815. private _checkVersionFromDB;
  72816. private _loadVersionFromDBAsync;
  72817. private _saveVersionIntoDBAsync;
  72818. /**
  72819. * Loads a file from database
  72820. * @param url defines the URL to load from
  72821. * @param sceneLoaded defines a callback to call on success
  72822. * @param progressCallBack defines a callback to call when progress changed
  72823. * @param errorCallback defines a callback to call on error
  72824. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  72825. */
  72826. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  72827. private _loadFileAsync;
  72828. private _saveFileAsync;
  72829. /**
  72830. * Validates if xhr data is correct
  72831. * @param xhr defines the request to validate
  72832. * @param dataType defines the expected data type
  72833. * @returns true if data is correct
  72834. */
  72835. private static _ValidateXHRData;
  72836. }
  72837. }
  72838. declare module BABYLON {
  72839. /** @hidden */
  72840. export var gpuUpdateParticlesPixelShader: {
  72841. name: string;
  72842. shader: string;
  72843. };
  72844. }
  72845. declare module BABYLON {
  72846. /** @hidden */
  72847. export var gpuUpdateParticlesVertexShader: {
  72848. name: string;
  72849. shader: string;
  72850. };
  72851. }
  72852. declare module BABYLON {
  72853. /** @hidden */
  72854. export var clipPlaneFragmentDeclaration2: {
  72855. name: string;
  72856. shader: string;
  72857. };
  72858. }
  72859. declare module BABYLON {
  72860. /** @hidden */
  72861. export var gpuRenderParticlesPixelShader: {
  72862. name: string;
  72863. shader: string;
  72864. };
  72865. }
  72866. declare module BABYLON {
  72867. /** @hidden */
  72868. export var clipPlaneVertexDeclaration2: {
  72869. name: string;
  72870. shader: string;
  72871. };
  72872. }
  72873. declare module BABYLON {
  72874. /** @hidden */
  72875. export var gpuRenderParticlesVertexShader: {
  72876. name: string;
  72877. shader: string;
  72878. };
  72879. }
  72880. declare module BABYLON {
  72881. /**
  72882. * This represents a GPU particle system in Babylon
  72883. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  72884. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  72885. */
  72886. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  72887. /**
  72888. * The layer mask we are rendering the particles through.
  72889. */
  72890. layerMask: number;
  72891. private _capacity;
  72892. private _activeCount;
  72893. private _currentActiveCount;
  72894. private _accumulatedCount;
  72895. private _renderEffect;
  72896. private _updateEffect;
  72897. private _buffer0;
  72898. private _buffer1;
  72899. private _spriteBuffer;
  72900. private _updateVAO;
  72901. private _renderVAO;
  72902. private _targetIndex;
  72903. private _sourceBuffer;
  72904. private _targetBuffer;
  72905. private _currentRenderId;
  72906. private _started;
  72907. private _stopped;
  72908. private _timeDelta;
  72909. private _randomTexture;
  72910. private _randomTexture2;
  72911. private _attributesStrideSize;
  72912. private _updateEffectOptions;
  72913. private _randomTextureSize;
  72914. private _actualFrame;
  72915. private _customEffect;
  72916. private readonly _rawTextureWidth;
  72917. /**
  72918. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  72919. */
  72920. static get IsSupported(): boolean;
  72921. /**
  72922. * An event triggered when the system is disposed.
  72923. */
  72924. onDisposeObservable: Observable<IParticleSystem>;
  72925. /**
  72926. * An event triggered when the system is stopped
  72927. */
  72928. onStoppedObservable: Observable<IParticleSystem>;
  72929. /**
  72930. * Gets the maximum number of particles active at the same time.
  72931. * @returns The max number of active particles.
  72932. */
  72933. getCapacity(): number;
  72934. /**
  72935. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  72936. * to override the particles.
  72937. */
  72938. forceDepthWrite: boolean;
  72939. /**
  72940. * Gets or set the number of active particles
  72941. */
  72942. get activeParticleCount(): number;
  72943. set activeParticleCount(value: number);
  72944. private _preWarmDone;
  72945. /**
  72946. * Specifies if the particles are updated in emitter local space or world space.
  72947. */
  72948. isLocal: boolean;
  72949. /** Gets or sets a matrix to use to compute projection */
  72950. defaultProjectionMatrix: Matrix;
  72951. /**
  72952. * Is this system ready to be used/rendered
  72953. * @return true if the system is ready
  72954. */
  72955. isReady(): boolean;
  72956. /**
  72957. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72958. * @returns True if it has been started, otherwise false.
  72959. */
  72960. isStarted(): boolean;
  72961. /**
  72962. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  72963. * @returns True if it has been stopped, otherwise false.
  72964. */
  72965. isStopped(): boolean;
  72966. /**
  72967. * Gets a boolean indicating that the system is stopping
  72968. * @returns true if the system is currently stopping
  72969. */
  72970. isStopping(): boolean;
  72971. /**
  72972. * Gets the number of particles active at the same time.
  72973. * @returns The number of active particles.
  72974. */
  72975. getActiveCount(): number;
  72976. /**
  72977. * Starts the particle system and begins to emit
  72978. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  72979. */
  72980. start(delay?: number): void;
  72981. /**
  72982. * Stops the particle system.
  72983. */
  72984. stop(): void;
  72985. /**
  72986. * Remove all active particles
  72987. */
  72988. reset(): void;
  72989. /**
  72990. * Returns the string "GPUParticleSystem"
  72991. * @returns a string containing the class name
  72992. */
  72993. getClassName(): string;
  72994. /**
  72995. * Gets the custom effect used to render the particles
  72996. * @param blendMode Blend mode for which the effect should be retrieved
  72997. * @returns The effect
  72998. */
  72999. getCustomEffect(blendMode?: number): Nullable<Effect>;
  73000. /**
  73001. * Sets the custom effect used to render the particles
  73002. * @param effect The effect to set
  73003. * @param blendMode Blend mode for which the effect should be set
  73004. */
  73005. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  73006. /** @hidden */
  73007. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  73008. /**
  73009. * Observable that will be called just before the particles are drawn
  73010. */
  73011. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  73012. /**
  73013. * Gets the name of the particle vertex shader
  73014. */
  73015. get vertexShaderName(): string;
  73016. private _colorGradientsTexture;
  73017. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  73018. /**
  73019. * Adds a new color gradient
  73020. * @param gradient defines the gradient to use (between 0 and 1)
  73021. * @param color1 defines the color to affect to the specified gradient
  73022. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  73023. * @returns the current particle system
  73024. */
  73025. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  73026. private _refreshColorGradient;
  73027. /** Force the system to rebuild all gradients that need to be resync */
  73028. forceRefreshGradients(): void;
  73029. /**
  73030. * Remove a specific color gradient
  73031. * @param gradient defines the gradient to remove
  73032. * @returns the current particle system
  73033. */
  73034. removeColorGradient(gradient: number): GPUParticleSystem;
  73035. private _angularSpeedGradientsTexture;
  73036. private _sizeGradientsTexture;
  73037. private _velocityGradientsTexture;
  73038. private _limitVelocityGradientsTexture;
  73039. private _dragGradientsTexture;
  73040. private _addFactorGradient;
  73041. /**
  73042. * Adds a new size gradient
  73043. * @param gradient defines the gradient to use (between 0 and 1)
  73044. * @param factor defines the size factor to affect to the specified gradient
  73045. * @returns the current particle system
  73046. */
  73047. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  73048. /**
  73049. * Remove a specific size gradient
  73050. * @param gradient defines the gradient to remove
  73051. * @returns the current particle system
  73052. */
  73053. removeSizeGradient(gradient: number): GPUParticleSystem;
  73054. private _refreshFactorGradient;
  73055. /**
  73056. * Adds a new angular speed gradient
  73057. * @param gradient defines the gradient to use (between 0 and 1)
  73058. * @param factor defines the angular speed to affect to the specified gradient
  73059. * @returns the current particle system
  73060. */
  73061. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  73062. /**
  73063. * Remove a specific angular speed gradient
  73064. * @param gradient defines the gradient to remove
  73065. * @returns the current particle system
  73066. */
  73067. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  73068. /**
  73069. * Adds a new velocity gradient
  73070. * @param gradient defines the gradient to use (between 0 and 1)
  73071. * @param factor defines the velocity to affect to the specified gradient
  73072. * @returns the current particle system
  73073. */
  73074. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  73075. /**
  73076. * Remove a specific velocity gradient
  73077. * @param gradient defines the gradient to remove
  73078. * @returns the current particle system
  73079. */
  73080. removeVelocityGradient(gradient: number): GPUParticleSystem;
  73081. /**
  73082. * Adds a new limit velocity gradient
  73083. * @param gradient defines the gradient to use (between 0 and 1)
  73084. * @param factor defines the limit velocity value to affect to the specified gradient
  73085. * @returns the current particle system
  73086. */
  73087. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  73088. /**
  73089. * Remove a specific limit velocity gradient
  73090. * @param gradient defines the gradient to remove
  73091. * @returns the current particle system
  73092. */
  73093. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  73094. /**
  73095. * Adds a new drag gradient
  73096. * @param gradient defines the gradient to use (between 0 and 1)
  73097. * @param factor defines the drag value to affect to the specified gradient
  73098. * @returns the current particle system
  73099. */
  73100. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  73101. /**
  73102. * Remove a specific drag gradient
  73103. * @param gradient defines the gradient to remove
  73104. * @returns the current particle system
  73105. */
  73106. removeDragGradient(gradient: number): GPUParticleSystem;
  73107. /**
  73108. * Not supported by GPUParticleSystem
  73109. * @param gradient defines the gradient to use (between 0 and 1)
  73110. * @param factor defines the emit rate value to affect to the specified gradient
  73111. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73112. * @returns the current particle system
  73113. */
  73114. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73115. /**
  73116. * Not supported by GPUParticleSystem
  73117. * @param gradient defines the gradient to remove
  73118. * @returns the current particle system
  73119. */
  73120. removeEmitRateGradient(gradient: number): IParticleSystem;
  73121. /**
  73122. * Not supported by GPUParticleSystem
  73123. * @param gradient defines the gradient to use (between 0 and 1)
  73124. * @param factor defines the start size value to affect to the specified gradient
  73125. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73126. * @returns the current particle system
  73127. */
  73128. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73129. /**
  73130. * Not supported by GPUParticleSystem
  73131. * @param gradient defines the gradient to remove
  73132. * @returns the current particle system
  73133. */
  73134. removeStartSizeGradient(gradient: number): IParticleSystem;
  73135. /**
  73136. * Not supported by GPUParticleSystem
  73137. * @param gradient defines the gradient to use (between 0 and 1)
  73138. * @param min defines the color remap minimal range
  73139. * @param max defines the color remap maximal range
  73140. * @returns the current particle system
  73141. */
  73142. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73143. /**
  73144. * Not supported by GPUParticleSystem
  73145. * @param gradient defines the gradient to remove
  73146. * @returns the current particle system
  73147. */
  73148. removeColorRemapGradient(): IParticleSystem;
  73149. /**
  73150. * Not supported by GPUParticleSystem
  73151. * @param gradient defines the gradient to use (between 0 and 1)
  73152. * @param min defines the alpha remap minimal range
  73153. * @param max defines the alpha remap maximal range
  73154. * @returns the current particle system
  73155. */
  73156. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73157. /**
  73158. * Not supported by GPUParticleSystem
  73159. * @param gradient defines the gradient to remove
  73160. * @returns the current particle system
  73161. */
  73162. removeAlphaRemapGradient(): IParticleSystem;
  73163. /**
  73164. * Not supported by GPUParticleSystem
  73165. * @param gradient defines the gradient to use (between 0 and 1)
  73166. * @param color defines the color to affect to the specified gradient
  73167. * @returns the current particle system
  73168. */
  73169. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  73170. /**
  73171. * Not supported by GPUParticleSystem
  73172. * @param gradient defines the gradient to remove
  73173. * @returns the current particle system
  73174. */
  73175. removeRampGradient(): IParticleSystem;
  73176. /**
  73177. * Not supported by GPUParticleSystem
  73178. * @returns the list of ramp gradients
  73179. */
  73180. getRampGradients(): Nullable<Array<Color3Gradient>>;
  73181. /**
  73182. * Not supported by GPUParticleSystem
  73183. * Gets or sets a boolean indicating that ramp gradients must be used
  73184. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  73185. */
  73186. get useRampGradients(): boolean;
  73187. set useRampGradients(value: boolean);
  73188. /**
  73189. * Not supported by GPUParticleSystem
  73190. * @param gradient defines the gradient to use (between 0 and 1)
  73191. * @param factor defines the life time factor to affect to the specified gradient
  73192. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73193. * @returns the current particle system
  73194. */
  73195. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73196. /**
  73197. * Not supported by GPUParticleSystem
  73198. * @param gradient defines the gradient to remove
  73199. * @returns the current particle system
  73200. */
  73201. removeLifeTimeGradient(gradient: number): IParticleSystem;
  73202. /**
  73203. * Instantiates a GPU particle system.
  73204. * 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.
  73205. * @param name The name of the particle system
  73206. * @param options The options used to create the system
  73207. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  73208. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  73209. * @param customEffect a custom effect used to change the way particles are rendered by default
  73210. */
  73211. constructor(name: string, options: Partial<{
  73212. capacity: number;
  73213. randomTextureSize: number;
  73214. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  73215. protected _reset(): void;
  73216. private _createUpdateVAO;
  73217. private _createRenderVAO;
  73218. private _initialize;
  73219. /** @hidden */
  73220. _recreateUpdateEffect(): void;
  73221. private _getEffect;
  73222. /**
  73223. * Fill the defines array according to the current settings of the particle system
  73224. * @param defines Array to be updated
  73225. * @param blendMode blend mode to take into account when updating the array
  73226. */
  73227. fillDefines(defines: Array<string>, blendMode?: number): void;
  73228. /**
  73229. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  73230. * @param uniforms Uniforms array to fill
  73231. * @param attributes Attributes array to fill
  73232. * @param samplers Samplers array to fill
  73233. */
  73234. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  73235. /** @hidden */
  73236. _recreateRenderEffect(): Effect;
  73237. /**
  73238. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  73239. * @param preWarm defines if we are in the pre-warmimg phase
  73240. */
  73241. animate(preWarm?: boolean): void;
  73242. private _createFactorGradientTexture;
  73243. private _createSizeGradientTexture;
  73244. private _createAngularSpeedGradientTexture;
  73245. private _createVelocityGradientTexture;
  73246. private _createLimitVelocityGradientTexture;
  73247. private _createDragGradientTexture;
  73248. private _createColorGradientTexture;
  73249. /**
  73250. * Renders the particle system in its current state
  73251. * @param preWarm defines if the system should only update the particles but not render them
  73252. * @returns the current number of particles
  73253. */
  73254. render(preWarm?: boolean): number;
  73255. /**
  73256. * Rebuilds the particle system
  73257. */
  73258. rebuild(): void;
  73259. private _releaseBuffers;
  73260. private _releaseVAOs;
  73261. /**
  73262. * Disposes the particle system and free the associated resources
  73263. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  73264. */
  73265. dispose(disposeTexture?: boolean): void;
  73266. /**
  73267. * Clones the particle system.
  73268. * @param name The name of the cloned object
  73269. * @param newEmitter The new emitter to use
  73270. * @returns the cloned particle system
  73271. */
  73272. clone(name: string, newEmitter: any): GPUParticleSystem;
  73273. /**
  73274. * Serializes the particle system to a JSON object
  73275. * @param serializeTexture defines if the texture must be serialized as well
  73276. * @returns the JSON object
  73277. */
  73278. serialize(serializeTexture?: boolean): any;
  73279. /**
  73280. * Parses a JSON object to create a GPU particle system.
  73281. * @param parsedParticleSystem The JSON object to parse
  73282. * @param sceneOrEngine The scene or the engine to create the particle system in
  73283. * @param rootUrl The root url to use to load external dependencies like texture
  73284. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  73285. * @returns the parsed GPU particle system
  73286. */
  73287. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  73288. }
  73289. }
  73290. declare module BABYLON {
  73291. /**
  73292. * Represents a set of particle systems working together to create a specific effect
  73293. */
  73294. export class ParticleSystemSet implements IDisposable {
  73295. /**
  73296. * Gets or sets base Assets URL
  73297. */
  73298. static BaseAssetsUrl: string;
  73299. private _emitterCreationOptions;
  73300. private _emitterNode;
  73301. /**
  73302. * Gets the particle system list
  73303. */
  73304. systems: IParticleSystem[];
  73305. /**
  73306. * Gets the emitter node used with this set
  73307. */
  73308. get emitterNode(): Nullable<TransformNode>;
  73309. /**
  73310. * Creates a new emitter mesh as a sphere
  73311. * @param options defines the options used to create the sphere
  73312. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  73313. * @param scene defines the hosting scene
  73314. */
  73315. setEmitterAsSphere(options: {
  73316. diameter: number;
  73317. segments: number;
  73318. color: Color3;
  73319. }, renderingGroupId: number, scene: Scene): void;
  73320. /**
  73321. * Starts all particle systems of the set
  73322. * @param emitter defines an optional mesh to use as emitter for the particle systems
  73323. */
  73324. start(emitter?: AbstractMesh): void;
  73325. /**
  73326. * Release all associated resources
  73327. */
  73328. dispose(): void;
  73329. /**
  73330. * Serialize the set into a JSON compatible object
  73331. * @param serializeTexture defines if the texture must be serialized as well
  73332. * @returns a JSON compatible representation of the set
  73333. */
  73334. serialize(serializeTexture?: boolean): any;
  73335. /**
  73336. * Parse a new ParticleSystemSet from a serialized source
  73337. * @param data defines a JSON compatible representation of the set
  73338. * @param scene defines the hosting scene
  73339. * @param gpu defines if we want GPU particles or CPU particles
  73340. * @returns a new ParticleSystemSet
  73341. */
  73342. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  73343. }
  73344. }
  73345. declare module BABYLON {
  73346. /**
  73347. * This class is made for on one-liner static method to help creating particle system set.
  73348. */
  73349. export class ParticleHelper {
  73350. /**
  73351. * Gets or sets base Assets URL
  73352. */
  73353. static BaseAssetsUrl: string;
  73354. /** Define the Url to load snippets */
  73355. static SnippetUrl: string;
  73356. /**
  73357. * Create a default particle system that you can tweak
  73358. * @param emitter defines the emitter to use
  73359. * @param capacity defines the system capacity (default is 500 particles)
  73360. * @param scene defines the hosting scene
  73361. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  73362. * @returns the new Particle system
  73363. */
  73364. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  73365. /**
  73366. * This is the main static method (one-liner) of this helper to create different particle systems
  73367. * @param type This string represents the type to the particle system to create
  73368. * @param scene The scene where the particle system should live
  73369. * @param gpu If the system will use gpu
  73370. * @returns the ParticleSystemSet created
  73371. */
  73372. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  73373. /**
  73374. * Static function used to export a particle system to a ParticleSystemSet variable.
  73375. * Please note that the emitter shape is not exported
  73376. * @param systems defines the particle systems to export
  73377. * @returns the created particle system set
  73378. */
  73379. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  73380. /**
  73381. * Creates a particle system from a snippet saved in a remote file
  73382. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  73383. * @param url defines the url to load from
  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 ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  73390. /**
  73391. * Creates a particle system from a snippet saved by the particle system editor
  73392. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  73393. * @param scene defines the hosting scene
  73394. * @param gpu If the system will use gpu
  73395. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  73396. * @returns a promise that will resolve to the new particle system
  73397. */
  73398. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  73399. }
  73400. }
  73401. declare module BABYLON {
  73402. interface Engine {
  73403. /**
  73404. * Create an effect to use with particle systems.
  73405. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  73406. * the particle system for which you want to create a custom effect in the last parameter
  73407. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  73408. * @param uniformsNames defines a list of attribute names
  73409. * @param samplers defines an array of string used to represent textures
  73410. * @param defines defines the string containing the defines to use to compile the shaders
  73411. * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails
  73412. * @param onCompiled defines a function to call when the effect creation is successful
  73413. * @param onError defines a function to call when the effect creation has failed
  73414. * @param particleSystem the particle system you want to create the effect for
  73415. * @returns the new Effect
  73416. */
  73417. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  73418. }
  73419. interface Mesh {
  73420. /**
  73421. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  73422. * @returns an array of IParticleSystem
  73423. */
  73424. getEmittedParticleSystems(): IParticleSystem[];
  73425. /**
  73426. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  73427. * @returns an array of IParticleSystem
  73428. */
  73429. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  73430. }
  73431. }
  73432. declare module BABYLON {
  73433. /** Defines the 4 color options */
  73434. export enum PointColor {
  73435. /** color value */
  73436. Color = 2,
  73437. /** uv value */
  73438. UV = 1,
  73439. /** random value */
  73440. Random = 0,
  73441. /** stated value */
  73442. Stated = 3
  73443. }
  73444. /**
  73445. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  73446. * 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.
  73447. * The PointCloudSystem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  73448. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  73449. *
  73450. * Full documentation here : TO BE ENTERED
  73451. */
  73452. export class PointsCloudSystem implements IDisposable {
  73453. /**
  73454. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  73455. * Example : var p = SPS.particles[i];
  73456. */
  73457. particles: CloudPoint[];
  73458. /**
  73459. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  73460. */
  73461. nbParticles: number;
  73462. /**
  73463. * This a counter for your own usage. It's not set by any SPS functions.
  73464. */
  73465. counter: number;
  73466. /**
  73467. * The PCS name. This name is also given to the underlying mesh.
  73468. */
  73469. name: string;
  73470. /**
  73471. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are available.
  73472. */
  73473. mesh: Mesh;
  73474. /**
  73475. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  73476. * Please read :
  73477. */
  73478. vars: any;
  73479. /**
  73480. * @hidden
  73481. */
  73482. _size: number;
  73483. private _scene;
  73484. private _promises;
  73485. private _positions;
  73486. private _indices;
  73487. private _normals;
  73488. private _colors;
  73489. private _uvs;
  73490. private _indices32;
  73491. private _positions32;
  73492. private _colors32;
  73493. private _uvs32;
  73494. private _updatable;
  73495. private _isVisibilityBoxLocked;
  73496. private _alwaysVisible;
  73497. private _groups;
  73498. private _groupCounter;
  73499. private _computeParticleColor;
  73500. private _computeParticleTexture;
  73501. private _computeParticleRotation;
  73502. private _computeBoundingBox;
  73503. private _isReady;
  73504. /**
  73505. * Creates a PCS (Points Cloud System) object
  73506. * @param name (String) is the PCS name, this will be the underlying mesh name
  73507. * @param pointSize (number) is the size for each point
  73508. * @param scene (Scene) is the scene in which the PCS is added
  73509. * @param options defines the options of the PCS e.g.
  73510. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  73511. */
  73512. constructor(name: string, pointSize: number, scene: Scene, options?: {
  73513. updatable?: boolean;
  73514. });
  73515. /**
  73516. * Builds the PCS underlying mesh. Returns a standard Mesh.
  73517. * If no points were added to the PCS, the returned mesh is just a single point.
  73518. * @returns a promise for the created mesh
  73519. */
  73520. buildMeshAsync(): Promise<Mesh>;
  73521. /**
  73522. * @hidden
  73523. */
  73524. private _buildMesh;
  73525. private _addParticle;
  73526. private _randomUnitVector;
  73527. private _getColorIndicesForCoord;
  73528. private _setPointsColorOrUV;
  73529. private _colorFromTexture;
  73530. private _calculateDensity;
  73531. /**
  73532. * Adds points to the PCS in random positions within a unit sphere
  73533. * @param nb (positive integer) the number of particles to be created from this model
  73534. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  73535. * @returns the number of groups in the system
  73536. */
  73537. addPoints(nb: number, pointFunction?: any): number;
  73538. /**
  73539. * Adds points to the PCS from the surface of the model shape
  73540. * @param mesh is any Mesh object that will be used as a surface model for the points
  73541. * @param nb (positive integer) the number of particles to be created from this model
  73542. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  73543. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  73544. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  73545. * @returns the number of groups in the system
  73546. */
  73547. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  73548. /**
  73549. * Adds points to the PCS inside the model shape
  73550. * @param mesh is any Mesh object that will be used as a surface model for the points
  73551. * @param nb (positive integer) the number of particles to be created from this model
  73552. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  73553. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  73554. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  73555. * @returns the number of groups in the system
  73556. */
  73557. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  73558. /**
  73559. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  73560. * This method calls `updateParticle()` for each particle of the SPS.
  73561. * For an animated SPS, it is usually called within the render loop.
  73562. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  73563. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  73564. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  73565. * @returns the PCS.
  73566. */
  73567. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  73568. /**
  73569. * Disposes the PCS.
  73570. */
  73571. dispose(): void;
  73572. /**
  73573. * Visibility helper : Recomputes the visible size according to the mesh bounding box
  73574. * doc :
  73575. * @returns the PCS.
  73576. */
  73577. refreshVisibleSize(): PointsCloudSystem;
  73578. /**
  73579. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  73580. * @param size the size (float) of the visibility box
  73581. * note : this doesn't lock the PCS mesh bounding box.
  73582. * doc :
  73583. */
  73584. setVisibilityBox(size: number): void;
  73585. /**
  73586. * Gets whether the PCS is always visible or not
  73587. * doc :
  73588. */
  73589. get isAlwaysVisible(): boolean;
  73590. /**
  73591. * Sets the PCS as always visible or not
  73592. * doc :
  73593. */
  73594. set isAlwaysVisible(val: boolean);
  73595. /**
  73596. * Tells to `setParticles()` to compute the particle rotations or not
  73597. * Default value : false. The PCS is faster when it's set to false
  73598. * Note : particle rotations are only applied to parent particles
  73599. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  73600. */
  73601. set computeParticleRotation(val: boolean);
  73602. /**
  73603. * Tells to `setParticles()` to compute the particle colors or not.
  73604. * Default value : true. The PCS is faster when it's set to false.
  73605. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  73606. */
  73607. set computeParticleColor(val: boolean);
  73608. set computeParticleTexture(val: boolean);
  73609. /**
  73610. * Gets if `setParticles()` computes the particle colors or not.
  73611. * Default value : false. The PCS is faster when it's set to false.
  73612. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  73613. */
  73614. get computeParticleColor(): boolean;
  73615. /**
  73616. * Gets if `setParticles()` computes the particle textures or not.
  73617. * Default value : false. The PCS is faster when it's set to false.
  73618. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  73619. */
  73620. get computeParticleTexture(): boolean;
  73621. /**
  73622. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  73623. */
  73624. set computeBoundingBox(val: boolean);
  73625. /**
  73626. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  73627. */
  73628. get computeBoundingBox(): boolean;
  73629. /**
  73630. * This function does nothing. It may be overwritten to set all the particle first values.
  73631. * The PCS doesn't call this function, you may have to call it by your own.
  73632. * doc :
  73633. */
  73634. initParticles(): void;
  73635. /**
  73636. * This function does nothing. It may be overwritten to recycle a particle
  73637. * The PCS doesn't call this function, you can to call it
  73638. * doc :
  73639. * @param particle The particle to recycle
  73640. * @returns the recycled particle
  73641. */
  73642. recycleParticle(particle: CloudPoint): CloudPoint;
  73643. /**
  73644. * Updates a particle : this function should be overwritten by the user.
  73645. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  73646. * doc :
  73647. * @example : just set a particle position or velocity and recycle conditions
  73648. * @param particle The particle to update
  73649. * @returns the updated particle
  73650. */
  73651. updateParticle(particle: CloudPoint): CloudPoint;
  73652. /**
  73653. * This will be called before any other treatment by `setParticles()` and 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. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  73660. /**
  73661. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  73662. * This will be passed three parameters.
  73663. * This does nothing and may be overwritten by the user.
  73664. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  73665. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  73666. * @param update the boolean update value actually passed to setParticles()
  73667. */
  73668. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  73669. }
  73670. }
  73671. declare module BABYLON {
  73672. /**
  73673. * Represents one particle of a points cloud system.
  73674. */
  73675. export class CloudPoint {
  73676. /**
  73677. * particle global index
  73678. */
  73679. idx: number;
  73680. /**
  73681. * The color of the particle
  73682. */
  73683. color: Nullable<Color4>;
  73684. /**
  73685. * The world space position of the particle.
  73686. */
  73687. position: Vector3;
  73688. /**
  73689. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  73690. */
  73691. rotation: Vector3;
  73692. /**
  73693. * The world space rotation quaternion of the particle.
  73694. */
  73695. rotationQuaternion: Nullable<Quaternion>;
  73696. /**
  73697. * The uv of the particle.
  73698. */
  73699. uv: Nullable<Vector2>;
  73700. /**
  73701. * The current speed of the particle.
  73702. */
  73703. velocity: Vector3;
  73704. /**
  73705. * The pivot point in the particle local space.
  73706. */
  73707. pivot: Vector3;
  73708. /**
  73709. * Must the particle be translated from its pivot point in its local space ?
  73710. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  73711. * Default : false
  73712. */
  73713. translateFromPivot: boolean;
  73714. /**
  73715. * Index of this particle in the global "positions" array (Internal use)
  73716. * @hidden
  73717. */
  73718. _pos: number;
  73719. /**
  73720. * @hidden Index of this particle in the global "indices" array (Internal use)
  73721. */
  73722. _ind: number;
  73723. /**
  73724. * Group this particle belongs to
  73725. */
  73726. _group: PointsGroup;
  73727. /**
  73728. * Group id of this particle
  73729. */
  73730. groupId: number;
  73731. /**
  73732. * Index of the particle in its group id (Internal use)
  73733. */
  73734. idxInGroup: number;
  73735. /**
  73736. * @hidden Particle BoundingInfo object (Internal use)
  73737. */
  73738. _boundingInfo: BoundingInfo;
  73739. /**
  73740. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  73741. */
  73742. _pcs: PointsCloudSystem;
  73743. /**
  73744. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  73745. */
  73746. _stillInvisible: boolean;
  73747. /**
  73748. * @hidden Last computed particle rotation matrix
  73749. */
  73750. _rotationMatrix: number[];
  73751. /**
  73752. * Parent particle Id, if any.
  73753. * Default null.
  73754. */
  73755. parentId: Nullable<number>;
  73756. /**
  73757. * @hidden Internal global position in the PCS.
  73758. */
  73759. _globalPosition: Vector3;
  73760. /**
  73761. * Creates a Point Cloud object.
  73762. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  73763. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  73764. * @param group (PointsGroup) is the group the particle belongs to
  73765. * @param groupId (integer) is the group identifier in the PCS.
  73766. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  73767. * @param pcs defines the PCS it is associated to
  73768. */
  73769. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  73770. /**
  73771. * get point size
  73772. */
  73773. get size(): Vector3;
  73774. /**
  73775. * Set point size
  73776. */
  73777. set size(scale: Vector3);
  73778. /**
  73779. * Legacy support, changed quaternion to rotationQuaternion
  73780. */
  73781. get quaternion(): Nullable<Quaternion>;
  73782. /**
  73783. * Legacy support, changed quaternion to rotationQuaternion
  73784. */
  73785. set quaternion(q: Nullable<Quaternion>);
  73786. /**
  73787. * Returns a boolean. True if the particle intersects a mesh, else false
  73788. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  73789. * @param target is the object (point or mesh) what the intersection is computed against
  73790. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bounding sphere is used
  73791. * @returns true if it intersects
  73792. */
  73793. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  73794. /**
  73795. * get the rotation matrix of the particle
  73796. * @hidden
  73797. */
  73798. getRotationMatrix(m: Matrix): void;
  73799. }
  73800. /**
  73801. * Represents a group of points in a points cloud system
  73802. * * PCS internal tool, don't use it manually.
  73803. */
  73804. export class PointsGroup {
  73805. /**
  73806. * The group id
  73807. * @hidden
  73808. */
  73809. groupID: number;
  73810. /**
  73811. * image data for group (internal use)
  73812. * @hidden
  73813. */
  73814. _groupImageData: Nullable<ArrayBufferView>;
  73815. /**
  73816. * Image Width (internal use)
  73817. * @hidden
  73818. */
  73819. _groupImgWidth: number;
  73820. /**
  73821. * Image Height (internal use)
  73822. * @hidden
  73823. */
  73824. _groupImgHeight: number;
  73825. /**
  73826. * Custom position function (internal use)
  73827. * @hidden
  73828. */
  73829. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  73830. /**
  73831. * density per facet for surface points
  73832. * @hidden
  73833. */
  73834. _groupDensity: number[];
  73835. /**
  73836. * Only when points are colored by texture carries pointer to texture list array
  73837. * @hidden
  73838. */
  73839. _textureNb: number;
  73840. /**
  73841. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  73842. * PCS internal tool, don't use it manually.
  73843. * @hidden
  73844. */
  73845. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  73846. }
  73847. }
  73848. declare module BABYLON {
  73849. interface Scene {
  73850. /** @hidden (Backing field) */
  73851. _physicsEngine: Nullable<IPhysicsEngine>;
  73852. /** @hidden */
  73853. _physicsTimeAccumulator: number;
  73854. /**
  73855. * Gets the current physics engine
  73856. * @returns a IPhysicsEngine or null if none attached
  73857. */
  73858. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  73859. /**
  73860. * Enables physics to the current scene
  73861. * @param gravity defines the scene's gravity for the physics engine
  73862. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  73863. * @return a boolean indicating if the physics engine was initialized
  73864. */
  73865. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  73866. /**
  73867. * Disables and disposes the physics engine associated with the scene
  73868. */
  73869. disablePhysicsEngine(): void;
  73870. /**
  73871. * Gets a boolean indicating if there is an active physics engine
  73872. * @returns a boolean indicating if there is an active physics engine
  73873. */
  73874. isPhysicsEnabled(): boolean;
  73875. /**
  73876. * Deletes a physics compound impostor
  73877. * @param compound defines the compound to delete
  73878. */
  73879. deleteCompoundImpostor(compound: any): void;
  73880. /**
  73881. * An event triggered when physic simulation is about to be run
  73882. */
  73883. onBeforePhysicsObservable: Observable<Scene>;
  73884. /**
  73885. * An event triggered when physic simulation has been done
  73886. */
  73887. onAfterPhysicsObservable: Observable<Scene>;
  73888. }
  73889. interface AbstractMesh {
  73890. /** @hidden */
  73891. _physicsImpostor: Nullable<PhysicsImpostor>;
  73892. /**
  73893. * Gets or sets impostor used for physic simulation
  73894. * @see https://doc.babylonjs.com/features/physics_engine
  73895. */
  73896. physicsImpostor: Nullable<PhysicsImpostor>;
  73897. /**
  73898. * Gets the current physics impostor
  73899. * @see https://doc.babylonjs.com/features/physics_engine
  73900. * @returns a physics impostor or null
  73901. */
  73902. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  73903. /** Apply a physic impulse to the mesh
  73904. * @param force defines the force to apply
  73905. * @param contactPoint defines where to apply the force
  73906. * @returns the current mesh
  73907. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  73908. */
  73909. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  73910. /**
  73911. * Creates a physic joint between two meshes
  73912. * @param otherMesh defines the other mesh to use
  73913. * @param pivot1 defines the pivot to use on this mesh
  73914. * @param pivot2 defines the pivot to use on the other mesh
  73915. * @param options defines additional options (can be plugin dependent)
  73916. * @returns the current mesh
  73917. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  73918. */
  73919. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  73920. /** @hidden */
  73921. _disposePhysicsObserver: Nullable<Observer<Node>>;
  73922. }
  73923. /**
  73924. * Defines the physics engine scene component responsible to manage a physics engine
  73925. */
  73926. export class PhysicsEngineSceneComponent implements ISceneComponent {
  73927. /**
  73928. * The component name helpful to identify the component in the list of scene components.
  73929. */
  73930. readonly name: string;
  73931. /**
  73932. * The scene the component belongs to.
  73933. */
  73934. scene: Scene;
  73935. /**
  73936. * Creates a new instance of the component for the given scene
  73937. * @param scene Defines the scene to register the component in
  73938. */
  73939. constructor(scene: Scene);
  73940. /**
  73941. * Registers the component in a given scene
  73942. */
  73943. register(): void;
  73944. /**
  73945. * Rebuilds the elements related to this component in case of
  73946. * context lost for instance.
  73947. */
  73948. rebuild(): void;
  73949. /**
  73950. * Disposes the component and the associated resources
  73951. */
  73952. dispose(): void;
  73953. }
  73954. }
  73955. declare module BABYLON {
  73956. /**
  73957. * A helper for physics simulations
  73958. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73959. */
  73960. export class PhysicsHelper {
  73961. private _scene;
  73962. private _physicsEngine;
  73963. /**
  73964. * Initializes the Physics helper
  73965. * @param scene Babylon.js scene
  73966. */
  73967. constructor(scene: Scene);
  73968. /**
  73969. * Applies a radial explosion impulse
  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. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73977. /**
  73978. * Applies a radial explosion force
  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 radial explosion event, or null
  73984. */
  73985. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73986. /**
  73987. * Creates a gravitational field
  73988. * @param origin the origin of the explosion
  73989. * @param radiusOrEventOptions the radius or the options of radial explosion
  73990. * @param strength the explosion strength
  73991. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73992. * @returns A physics gravitational field event, or null
  73993. */
  73994. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  73995. /**
  73996. * Creates a physics updraft event
  73997. * @param origin the origin of the updraft
  73998. * @param radiusOrEventOptions the radius or the options of the updraft
  73999. * @param strength the strength of the updraft
  74000. * @param height the height of the updraft
  74001. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  74002. * @returns A physics updraft event, or null
  74003. */
  74004. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  74005. /**
  74006. * Creates a physics vortex event
  74007. * @param origin the of the vortex
  74008. * @param radiusOrEventOptions the radius or the options of the vortex
  74009. * @param strength the strength of the vortex
  74010. * @param height the height of the vortex
  74011. * @returns a Physics vortex event, or null
  74012. * A physics vortex event or null
  74013. */
  74014. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  74015. }
  74016. /**
  74017. * Represents a physics radial explosion event
  74018. */
  74019. class PhysicsRadialExplosionEvent {
  74020. private _scene;
  74021. private _options;
  74022. private _sphere;
  74023. private _dataFetched;
  74024. /**
  74025. * Initializes a radial explosion event
  74026. * @param _scene BabylonJS scene
  74027. * @param _options The options for the vortex event
  74028. */
  74029. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  74030. /**
  74031. * Returns the data related to the radial explosion event (sphere).
  74032. * @returns The radial explosion event data
  74033. */
  74034. getData(): PhysicsRadialExplosionEventData;
  74035. /**
  74036. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  74037. * @param impostor A physics imposter
  74038. * @param origin the origin of the explosion
  74039. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  74040. */
  74041. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  74042. /**
  74043. * Triggers affected impostors callbacks
  74044. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  74045. */
  74046. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  74047. /**
  74048. * Disposes the sphere.
  74049. * @param force Specifies if the sphere should be disposed by force
  74050. */
  74051. dispose(force?: boolean): void;
  74052. /*** Helpers ***/
  74053. private _prepareSphere;
  74054. private _intersectsWithSphere;
  74055. }
  74056. /**
  74057. * Represents a gravitational field event
  74058. */
  74059. class PhysicsGravitationalFieldEvent {
  74060. private _physicsHelper;
  74061. private _scene;
  74062. private _origin;
  74063. private _options;
  74064. private _tickCallback;
  74065. private _sphere;
  74066. private _dataFetched;
  74067. /**
  74068. * Initializes the physics gravitational field event
  74069. * @param _physicsHelper A physics helper
  74070. * @param _scene BabylonJS scene
  74071. * @param _origin The origin position of the gravitational field event
  74072. * @param _options The options for the vortex event
  74073. */
  74074. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  74075. /**
  74076. * Returns the data related to the gravitational field event (sphere).
  74077. * @returns A gravitational field event
  74078. */
  74079. getData(): PhysicsGravitationalFieldEventData;
  74080. /**
  74081. * Enables the gravitational field.
  74082. */
  74083. enable(): void;
  74084. /**
  74085. * Disables the gravitational field.
  74086. */
  74087. disable(): void;
  74088. /**
  74089. * Disposes the sphere.
  74090. * @param force The force to dispose from the gravitational field event
  74091. */
  74092. dispose(force?: boolean): void;
  74093. private _tick;
  74094. }
  74095. /**
  74096. * Represents a physics updraft event
  74097. */
  74098. class PhysicsUpdraftEvent {
  74099. private _scene;
  74100. private _origin;
  74101. private _options;
  74102. private _physicsEngine;
  74103. private _originTop;
  74104. private _originDirection;
  74105. private _tickCallback;
  74106. private _cylinder;
  74107. private _cylinderPosition;
  74108. private _dataFetched;
  74109. /**
  74110. * Initializes the physics updraft event
  74111. * @param _scene BabylonJS scene
  74112. * @param _origin The origin position of the updraft
  74113. * @param _options The options for the updraft event
  74114. */
  74115. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  74116. /**
  74117. * Returns the data related to the updraft event (cylinder).
  74118. * @returns A physics updraft event
  74119. */
  74120. getData(): PhysicsUpdraftEventData;
  74121. /**
  74122. * Enables the updraft.
  74123. */
  74124. enable(): void;
  74125. /**
  74126. * Disables the updraft.
  74127. */
  74128. disable(): void;
  74129. /**
  74130. * Disposes the cylinder.
  74131. * @param force Specifies if the updraft should be disposed by force
  74132. */
  74133. dispose(force?: boolean): void;
  74134. private getImpostorHitData;
  74135. private _tick;
  74136. /*** Helpers ***/
  74137. private _prepareCylinder;
  74138. private _intersectsWithCylinder;
  74139. }
  74140. /**
  74141. * Represents a physics vortex event
  74142. */
  74143. class PhysicsVortexEvent {
  74144. private _scene;
  74145. private _origin;
  74146. private _options;
  74147. private _physicsEngine;
  74148. private _originTop;
  74149. private _tickCallback;
  74150. private _cylinder;
  74151. private _cylinderPosition;
  74152. private _dataFetched;
  74153. /**
  74154. * Initializes the physics vortex event
  74155. * @param _scene The BabylonJS scene
  74156. * @param _origin The origin position of the vortex
  74157. * @param _options The options for the vortex event
  74158. */
  74159. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  74160. /**
  74161. * Returns the data related to the vortex event (cylinder).
  74162. * @returns The physics vortex event data
  74163. */
  74164. getData(): PhysicsVortexEventData;
  74165. /**
  74166. * Enables the vortex.
  74167. */
  74168. enable(): void;
  74169. /**
  74170. * Disables the cortex.
  74171. */
  74172. disable(): void;
  74173. /**
  74174. * Disposes the sphere.
  74175. * @param force
  74176. */
  74177. dispose(force?: boolean): void;
  74178. private getImpostorHitData;
  74179. private _tick;
  74180. /*** Helpers ***/
  74181. private _prepareCylinder;
  74182. private _intersectsWithCylinder;
  74183. }
  74184. /**
  74185. * Options fot the radial explosion event
  74186. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74187. */
  74188. export class PhysicsRadialExplosionEventOptions {
  74189. /**
  74190. * The radius of the sphere for the radial explosion.
  74191. */
  74192. radius: number;
  74193. /**
  74194. * The strength of the explosion.
  74195. */
  74196. strength: number;
  74197. /**
  74198. * The strength of the force in correspondence to the distance of the affected object
  74199. */
  74200. falloff: PhysicsRadialImpulseFalloff;
  74201. /**
  74202. * Sphere options for the radial explosion.
  74203. */
  74204. sphere: {
  74205. segments: number;
  74206. diameter: number;
  74207. };
  74208. /**
  74209. * Sphere options for the radial explosion.
  74210. */
  74211. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  74212. }
  74213. /**
  74214. * Options fot the updraft event
  74215. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74216. */
  74217. export class PhysicsUpdraftEventOptions {
  74218. /**
  74219. * The radius of the cylinder for the vortex
  74220. */
  74221. radius: number;
  74222. /**
  74223. * The strength of the updraft.
  74224. */
  74225. strength: number;
  74226. /**
  74227. * The height of the cylinder for the updraft.
  74228. */
  74229. height: number;
  74230. /**
  74231. * The mode for the the updraft.
  74232. */
  74233. updraftMode: PhysicsUpdraftMode;
  74234. }
  74235. /**
  74236. * Options fot the vortex event
  74237. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74238. */
  74239. export class PhysicsVortexEventOptions {
  74240. /**
  74241. * The radius of the cylinder for the vortex
  74242. */
  74243. radius: number;
  74244. /**
  74245. * The strength of the vortex.
  74246. */
  74247. strength: number;
  74248. /**
  74249. * The height of the cylinder for the vortex.
  74250. */
  74251. height: number;
  74252. /**
  74253. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  74254. */
  74255. centripetalForceThreshold: number;
  74256. /**
  74257. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the threshold.
  74258. */
  74259. centripetalForceMultiplier: number;
  74260. /**
  74261. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the threshold.
  74262. */
  74263. centrifugalForceMultiplier: number;
  74264. /**
  74265. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  74266. */
  74267. updraftForceMultiplier: number;
  74268. }
  74269. /**
  74270. * The strength of the force in correspondence to the distance of the affected object
  74271. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74272. */
  74273. export enum PhysicsRadialImpulseFalloff {
  74274. /** Defines that impulse is constant in strength across it's whole radius */
  74275. Constant = 0,
  74276. /** Defines that impulse gets weaker if it's further from the origin */
  74277. Linear = 1
  74278. }
  74279. /**
  74280. * The strength of the force in correspondence to the distance of the affected object
  74281. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74282. */
  74283. export enum PhysicsUpdraftMode {
  74284. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  74285. Center = 0,
  74286. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  74287. Perpendicular = 1
  74288. }
  74289. /**
  74290. * Interface for a physics hit data
  74291. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74292. */
  74293. export interface PhysicsHitData {
  74294. /**
  74295. * The force applied at the contact point
  74296. */
  74297. force: Vector3;
  74298. /**
  74299. * The contact point
  74300. */
  74301. contactPoint: Vector3;
  74302. /**
  74303. * The distance from the origin to the contact point
  74304. */
  74305. distanceFromOrigin: number;
  74306. }
  74307. /**
  74308. * Interface for radial explosion event data
  74309. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74310. */
  74311. export interface PhysicsRadialExplosionEventData {
  74312. /**
  74313. * A sphere used for the radial explosion event
  74314. */
  74315. sphere: Mesh;
  74316. }
  74317. /**
  74318. * Interface for gravitational field event data
  74319. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74320. */
  74321. export interface PhysicsGravitationalFieldEventData {
  74322. /**
  74323. * A sphere mesh used for the gravitational field event
  74324. */
  74325. sphere: Mesh;
  74326. }
  74327. /**
  74328. * Interface for updraft event data
  74329. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74330. */
  74331. export interface PhysicsUpdraftEventData {
  74332. /**
  74333. * A cylinder used for the updraft event
  74334. */
  74335. cylinder: Mesh;
  74336. }
  74337. /**
  74338. * Interface for vortex event data
  74339. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74340. */
  74341. export interface PhysicsVortexEventData {
  74342. /**
  74343. * A cylinder used for the vortex event
  74344. */
  74345. cylinder: Mesh;
  74346. }
  74347. /**
  74348. * Interface for an affected physics impostor
  74349. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74350. */
  74351. export interface PhysicsAffectedImpostorWithData {
  74352. /**
  74353. * The impostor affected by the effect
  74354. */
  74355. impostor: PhysicsImpostor;
  74356. /**
  74357. * The data about the hit/force from the explosion
  74358. */
  74359. hitData: PhysicsHitData;
  74360. }
  74361. }
  74362. declare module BABYLON {
  74363. /** @hidden */
  74364. export var blackAndWhitePixelShader: {
  74365. name: string;
  74366. shader: string;
  74367. };
  74368. }
  74369. declare module BABYLON {
  74370. /**
  74371. * Post process used to render in black and white
  74372. */
  74373. export class BlackAndWhitePostProcess extends PostProcess {
  74374. /**
  74375. * Linear about to convert he result to black and white (default: 1)
  74376. */
  74377. degree: number;
  74378. /**
  74379. * Gets a string identifying the name of the class
  74380. * @returns "BlackAndWhitePostProcess" string
  74381. */
  74382. getClassName(): string;
  74383. /**
  74384. * Creates a black and white post process
  74385. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  74386. * @param name The name of the effect.
  74387. * @param options The required width/height ratio to downsize to before computing the render pass.
  74388. * @param camera The camera to apply the render pass to.
  74389. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74390. * @param engine The engine which the post process will be applied. (default: current engine)
  74391. * @param reusable If the post process can be reused on the same frame. (default: false)
  74392. */
  74393. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74394. /** @hidden */
  74395. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  74396. }
  74397. }
  74398. declare module BABYLON {
  74399. /**
  74400. * This represents a set of one or more post processes in Babylon.
  74401. * A post process can be used to apply a shader to a texture after it is rendered.
  74402. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74403. */
  74404. export class PostProcessRenderEffect {
  74405. private _postProcesses;
  74406. private _getPostProcesses;
  74407. private _singleInstance;
  74408. private _cameras;
  74409. private _indicesForCamera;
  74410. /**
  74411. * Name of the effect
  74412. * @hidden
  74413. */
  74414. _name: string;
  74415. /**
  74416. * Instantiates a post process render effect.
  74417. * A post process can be used to apply a shader to a texture after it is rendered.
  74418. * @param engine The engine the effect is tied to
  74419. * @param name The name of the effect
  74420. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  74421. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  74422. */
  74423. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  74424. /**
  74425. * Checks if all the post processes in the effect are supported.
  74426. */
  74427. get isSupported(): boolean;
  74428. /**
  74429. * Updates the current state of the effect
  74430. * @hidden
  74431. */
  74432. _update(): void;
  74433. /**
  74434. * Attaches the effect on cameras
  74435. * @param cameras The camera to attach to.
  74436. * @hidden
  74437. */
  74438. _attachCameras(cameras: Camera): void;
  74439. /**
  74440. * Attaches the effect on cameras
  74441. * @param cameras The camera to attach to.
  74442. * @hidden
  74443. */
  74444. _attachCameras(cameras: Camera[]): void;
  74445. /**
  74446. * Detaches the effect on cameras
  74447. * @param cameras The camera to detach from.
  74448. * @hidden
  74449. */
  74450. _detachCameras(cameras: Camera): void;
  74451. /**
  74452. * Detaches the effect on cameras
  74453. * @param cameras The camera to detach from.
  74454. * @hidden
  74455. */
  74456. _detachCameras(cameras: Camera[]): void;
  74457. /**
  74458. * Enables the effect on given cameras
  74459. * @param cameras The camera to enable.
  74460. * @hidden
  74461. */
  74462. _enable(cameras: Camera): void;
  74463. /**
  74464. * Enables the effect on given cameras
  74465. * @param cameras The camera to enable.
  74466. * @hidden
  74467. */
  74468. _enable(cameras: Nullable<Camera[]>): void;
  74469. /**
  74470. * Disables the effect on the given cameras
  74471. * @param cameras The camera to disable.
  74472. * @hidden
  74473. */
  74474. _disable(cameras: Camera): void;
  74475. /**
  74476. * Disables the effect on the given cameras
  74477. * @param cameras The camera to disable.
  74478. * @hidden
  74479. */
  74480. _disable(cameras: Nullable<Camera[]>): void;
  74481. /**
  74482. * Gets a list of the post processes contained in the effect.
  74483. * @param camera The camera to get the post processes on.
  74484. * @returns The list of the post processes in the effect.
  74485. */
  74486. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  74487. }
  74488. }
  74489. declare module BABYLON {
  74490. /** @hidden */
  74491. export var extractHighlightsPixelShader: {
  74492. name: string;
  74493. shader: string;
  74494. };
  74495. }
  74496. declare module BABYLON {
  74497. /**
  74498. * 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.
  74499. */
  74500. export class ExtractHighlightsPostProcess extends PostProcess {
  74501. /**
  74502. * The luminance threshold, pixels below this value will be set to black.
  74503. */
  74504. threshold: number;
  74505. /** @hidden */
  74506. _exposure: number;
  74507. /**
  74508. * Post process which has the input texture to be used when performing highlight extraction
  74509. * @hidden
  74510. */
  74511. _inputPostProcess: Nullable<PostProcess>;
  74512. /**
  74513. * Gets a string identifying the name of the class
  74514. * @returns "ExtractHighlightsPostProcess" string
  74515. */
  74516. getClassName(): string;
  74517. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74518. }
  74519. }
  74520. declare module BABYLON {
  74521. /** @hidden */
  74522. export var bloomMergePixelShader: {
  74523. name: string;
  74524. shader: string;
  74525. };
  74526. }
  74527. declare module BABYLON {
  74528. /**
  74529. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  74530. */
  74531. export class BloomMergePostProcess extends PostProcess {
  74532. /** Weight of the bloom to be added to the original input. */
  74533. weight: number;
  74534. /**
  74535. * Gets a string identifying the name of the class
  74536. * @returns "BloomMergePostProcess" string
  74537. */
  74538. getClassName(): string;
  74539. /**
  74540. * Creates a new instance of @see BloomMergePostProcess
  74541. * @param name The name of the effect.
  74542. * @param originalFromInput Post process which's input will be used for the merge.
  74543. * @param blurred Blurred highlights post process which's output will be used.
  74544. * @param weight Weight of the bloom to be added to the original input.
  74545. * @param options The required width/height ratio to downsize to before computing the render pass.
  74546. * @param camera The camera to apply the render pass to.
  74547. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74548. * @param engine The engine which the post process will be applied. (default: current engine)
  74549. * @param reusable If the post process can be reused on the same frame. (default: false)
  74550. * @param textureType Type of textures used when performing the post process. (default: 0)
  74551. * @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)
  74552. */
  74553. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  74554. /** Weight of the bloom to be added to the original input. */
  74555. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74556. }
  74557. }
  74558. declare module BABYLON {
  74559. /**
  74560. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  74561. */
  74562. export class BloomEffect extends PostProcessRenderEffect {
  74563. private bloomScale;
  74564. /**
  74565. * @hidden Internal
  74566. */
  74567. _effects: Array<PostProcess>;
  74568. /**
  74569. * @hidden Internal
  74570. */
  74571. _downscale: ExtractHighlightsPostProcess;
  74572. private _blurX;
  74573. private _blurY;
  74574. private _merge;
  74575. /**
  74576. * The luminance threshold to find bright areas of the image to bloom.
  74577. */
  74578. get threshold(): number;
  74579. set threshold(value: number);
  74580. /**
  74581. * The strength of the bloom.
  74582. */
  74583. get weight(): number;
  74584. set weight(value: number);
  74585. /**
  74586. * Specifies the size of the bloom blur kernel, relative to the final output size
  74587. */
  74588. get kernel(): number;
  74589. set kernel(value: number);
  74590. /**
  74591. * Creates a new instance of @see BloomEffect
  74592. * @param scene The scene the effect belongs to.
  74593. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  74594. * @param bloomKernel The size of the kernel to be used when applying the blur.
  74595. * @param bloomWeight The the strength of bloom.
  74596. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74597. * @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)
  74598. */
  74599. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  74600. /**
  74601. * Disposes each of the internal effects for a given camera.
  74602. * @param camera The camera to dispose the effect on.
  74603. */
  74604. disposeEffects(camera: Camera): void;
  74605. /**
  74606. * @hidden Internal
  74607. */
  74608. _updateEffects(): void;
  74609. /**
  74610. * Internal
  74611. * @returns if all the contained post processes are ready.
  74612. * @hidden
  74613. */
  74614. _isReady(): boolean;
  74615. }
  74616. }
  74617. declare module BABYLON {
  74618. /** @hidden */
  74619. export var chromaticAberrationPixelShader: {
  74620. name: string;
  74621. shader: string;
  74622. };
  74623. }
  74624. declare module BABYLON {
  74625. /**
  74626. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  74627. */
  74628. export class ChromaticAberrationPostProcess extends PostProcess {
  74629. /**
  74630. * The amount of separation of rgb channels (default: 30)
  74631. */
  74632. aberrationAmount: number;
  74633. /**
  74634. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  74635. */
  74636. radialIntensity: number;
  74637. /**
  74638. * 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))
  74639. */
  74640. direction: Vector2;
  74641. /**
  74642. * 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))
  74643. */
  74644. centerPosition: Vector2;
  74645. /** The width of the screen to apply the effect on */
  74646. screenWidth: number;
  74647. /** The height of the screen to apply the effect on */
  74648. screenHeight: number;
  74649. /**
  74650. * Gets a string identifying the name of the class
  74651. * @returns "ChromaticAberrationPostProcess" string
  74652. */
  74653. getClassName(): string;
  74654. /**
  74655. * Creates a new instance ChromaticAberrationPostProcess
  74656. * @param name The name of the effect.
  74657. * @param screenWidth The width of the screen to apply the effect on.
  74658. * @param screenHeight The height of the screen to apply the effect on.
  74659. * @param options The required width/height ratio to downsize to before computing the render pass.
  74660. * @param camera The camera to apply the render pass to.
  74661. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74662. * @param engine The engine which the post process will be applied. (default: current engine)
  74663. * @param reusable If the post process can be reused on the same frame. (default: false)
  74664. * @param textureType Type of textures used when performing the post process. (default: 0)
  74665. * @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)
  74666. */
  74667. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74668. /** @hidden */
  74669. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  74670. }
  74671. }
  74672. declare module BABYLON {
  74673. /** @hidden */
  74674. export var circleOfConfusionPixelShader: {
  74675. name: string;
  74676. shader: string;
  74677. };
  74678. }
  74679. declare module BABYLON {
  74680. /**
  74681. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  74682. */
  74683. export class CircleOfConfusionPostProcess extends PostProcess {
  74684. /**
  74685. * 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.
  74686. */
  74687. lensSize: number;
  74688. /**
  74689. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74690. */
  74691. fStop: number;
  74692. /**
  74693. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74694. */
  74695. focusDistance: number;
  74696. /**
  74697. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  74698. */
  74699. focalLength: number;
  74700. /**
  74701. * Gets a string identifying the name of the class
  74702. * @returns "CircleOfConfusionPostProcess" string
  74703. */
  74704. getClassName(): string;
  74705. private _depthTexture;
  74706. /**
  74707. * Creates a new instance CircleOfConfusionPostProcess
  74708. * @param name The name of the effect.
  74709. * @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.
  74710. * @param options The required width/height ratio to downsize to before computing the render pass.
  74711. * @param camera The camera to apply the render pass to.
  74712. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74713. * @param engine The engine which the post process will be applied. (default: current engine)
  74714. * @param reusable If the post process can be reused on the same frame. (default: false)
  74715. * @param textureType Type of textures used when performing the post process. (default: 0)
  74716. * @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)
  74717. */
  74718. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74719. /**
  74720. * 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.
  74721. */
  74722. set depthTexture(value: RenderTargetTexture);
  74723. }
  74724. }
  74725. declare module BABYLON {
  74726. /** @hidden */
  74727. export var colorCorrectionPixelShader: {
  74728. name: string;
  74729. shader: string;
  74730. };
  74731. }
  74732. declare module BABYLON {
  74733. /**
  74734. *
  74735. * This post-process allows the modification of rendered colors by using
  74736. * a 'look-up table' (LUT). This effect is also called Color Grading.
  74737. *
  74738. * The object needs to be provided an url to a texture containing the color
  74739. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  74740. * Use an image editing software to tweak the LUT to match your needs.
  74741. *
  74742. * For an example of a color LUT, see here:
  74743. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  74744. * For explanations on color grading, see here:
  74745. * @see http://udn.epicgames.com/Three/ColorGrading.html
  74746. *
  74747. */
  74748. export class ColorCorrectionPostProcess extends PostProcess {
  74749. private _colorTableTexture;
  74750. /**
  74751. * Gets the color table url used to create the LUT texture
  74752. */
  74753. colorTableUrl: string;
  74754. /**
  74755. * Gets a string identifying the name of the class
  74756. * @returns "ColorCorrectionPostProcess" string
  74757. */
  74758. getClassName(): string;
  74759. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74760. /** @hidden */
  74761. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  74762. }
  74763. }
  74764. declare module BABYLON {
  74765. /** @hidden */
  74766. export var convolutionPixelShader: {
  74767. name: string;
  74768. shader: string;
  74769. };
  74770. }
  74771. declare module BABYLON {
  74772. /**
  74773. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  74774. * input texture to perform effects such as edge detection or sharpening
  74775. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74776. */
  74777. export class ConvolutionPostProcess extends PostProcess {
  74778. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  74779. kernel: number[];
  74780. /**
  74781. * Gets a string identifying the name of the class
  74782. * @returns "ConvolutionPostProcess" string
  74783. */
  74784. getClassName(): string;
  74785. /**
  74786. * Creates a new instance ConvolutionPostProcess
  74787. * @param name The name of the effect.
  74788. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  74789. * @param options The required width/height ratio to downsize to before computing the render pass.
  74790. * @param camera The camera to apply the render pass to.
  74791. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74792. * @param engine The engine which the post process will be applied. (default: current engine)
  74793. * @param reusable If the post process can be reused on the same frame. (default: false)
  74794. * @param textureType Type of textures used when performing the post process. (default: 0)
  74795. */
  74796. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74797. /** @hidden */
  74798. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  74799. /**
  74800. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74801. */
  74802. static EdgeDetect0Kernel: number[];
  74803. /**
  74804. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74805. */
  74806. static EdgeDetect1Kernel: number[];
  74807. /**
  74808. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74809. */
  74810. static EdgeDetect2Kernel: number[];
  74811. /**
  74812. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74813. */
  74814. static SharpenKernel: number[];
  74815. /**
  74816. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74817. */
  74818. static EmbossKernel: number[];
  74819. /**
  74820. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74821. */
  74822. static GaussianKernel: number[];
  74823. }
  74824. }
  74825. declare module BABYLON {
  74826. /**
  74827. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  74828. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  74829. * based on samples that have a large difference in distance than the center pixel.
  74830. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  74831. */
  74832. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  74833. /**
  74834. * The direction the blur should be applied
  74835. */
  74836. direction: Vector2;
  74837. /**
  74838. * Gets a string identifying the name of the class
  74839. * @returns "DepthOfFieldBlurPostProcess" string
  74840. */
  74841. getClassName(): string;
  74842. /**
  74843. * Creates a new instance CircleOfConfusionPostProcess
  74844. * @param name The name of the effect.
  74845. * @param scene The scene the effect belongs to.
  74846. * @param direction The direction the blur should be applied.
  74847. * @param kernel The size of the kernel used to blur.
  74848. * @param options The required width/height ratio to downsize to before computing the render pass.
  74849. * @param camera The camera to apply the render pass to.
  74850. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring across edges
  74851. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  74852. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74853. * @param engine The engine which the post process will be applied. (default: current engine)
  74854. * @param reusable If the post process can be reused on the same frame. (default: false)
  74855. * @param textureType Type of textures used when performing the post process. (default: 0)
  74856. * @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)
  74857. */
  74858. 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);
  74859. }
  74860. }
  74861. declare module BABYLON {
  74862. /** @hidden */
  74863. export var depthOfFieldMergePixelShader: {
  74864. name: string;
  74865. shader: string;
  74866. };
  74867. }
  74868. declare module BABYLON {
  74869. /**
  74870. * Options to be set when merging outputs from the default pipeline.
  74871. */
  74872. export class DepthOfFieldMergePostProcessOptions {
  74873. /**
  74874. * The original image to merge on top of
  74875. */
  74876. originalFromInput: PostProcess;
  74877. /**
  74878. * Parameters to perform the merge of the depth of field effect
  74879. */
  74880. depthOfField?: {
  74881. circleOfConfusion: PostProcess;
  74882. blurSteps: Array<PostProcess>;
  74883. };
  74884. /**
  74885. * Parameters to perform the merge of bloom effect
  74886. */
  74887. bloom?: {
  74888. blurred: PostProcess;
  74889. weight: number;
  74890. };
  74891. }
  74892. /**
  74893. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  74894. */
  74895. export class DepthOfFieldMergePostProcess extends PostProcess {
  74896. private blurSteps;
  74897. /**
  74898. * Gets a string identifying the name of the class
  74899. * @returns "DepthOfFieldMergePostProcess" string
  74900. */
  74901. getClassName(): string;
  74902. /**
  74903. * Creates a new instance of DepthOfFieldMergePostProcess
  74904. * @param name The name of the effect.
  74905. * @param originalFromInput Post process which's input will be used for the merge.
  74906. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  74907. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  74908. * @param options The required width/height ratio to downsize to before computing the render pass.
  74909. * @param camera The camera to apply the render pass to.
  74910. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74911. * @param engine The engine which the post process will be applied. (default: current engine)
  74912. * @param reusable If the post process can be reused on the same frame. (default: false)
  74913. * @param textureType Type of textures used when performing the post process. (default: 0)
  74914. * @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)
  74915. */
  74916. 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);
  74917. /**
  74918. * Updates the effect with the current post process compile time values and recompiles the shader.
  74919. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  74920. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  74921. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  74922. * @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
  74923. * @param onCompiled Called when the shader has been compiled.
  74924. * @param onError Called if there is an error when compiling a shader.
  74925. */
  74926. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  74927. }
  74928. }
  74929. declare module BABYLON {
  74930. /**
  74931. * Specifies the level of max blur that should be applied when using the depth of field effect
  74932. */
  74933. export enum DepthOfFieldEffectBlurLevel {
  74934. /**
  74935. * Subtle blur
  74936. */
  74937. Low = 0,
  74938. /**
  74939. * Medium blur
  74940. */
  74941. Medium = 1,
  74942. /**
  74943. * Large blur
  74944. */
  74945. High = 2
  74946. }
  74947. /**
  74948. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  74949. */
  74950. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  74951. private _circleOfConfusion;
  74952. /**
  74953. * @hidden Internal, blurs from high to low
  74954. */
  74955. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  74956. private _depthOfFieldBlurY;
  74957. private _dofMerge;
  74958. /**
  74959. * @hidden Internal post processes in depth of field effect
  74960. */
  74961. _effects: Array<PostProcess>;
  74962. /**
  74963. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  74964. */
  74965. set focalLength(value: number);
  74966. get focalLength(): number;
  74967. /**
  74968. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74969. */
  74970. set fStop(value: number);
  74971. get fStop(): number;
  74972. /**
  74973. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74974. */
  74975. set focusDistance(value: number);
  74976. get focusDistance(): number;
  74977. /**
  74978. * 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.
  74979. */
  74980. set lensSize(value: number);
  74981. get lensSize(): number;
  74982. /**
  74983. * Creates a new instance DepthOfFieldEffect
  74984. * @param scene The scene the effect belongs to.
  74985. * @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.
  74986. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74987. * @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)
  74988. */
  74989. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  74990. /**
  74991. * Get the current class name of the current effect
  74992. * @returns "DepthOfFieldEffect"
  74993. */
  74994. getClassName(): string;
  74995. /**
  74996. * 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.
  74997. */
  74998. set depthTexture(value: RenderTargetTexture);
  74999. /**
  75000. * Disposes each of the internal effects for a given camera.
  75001. * @param camera The camera to dispose the effect on.
  75002. */
  75003. disposeEffects(camera: Camera): void;
  75004. /**
  75005. * @hidden Internal
  75006. */
  75007. _updateEffects(): void;
  75008. /**
  75009. * Internal
  75010. * @returns if all the contained post processes are ready.
  75011. * @hidden
  75012. */
  75013. _isReady(): boolean;
  75014. }
  75015. }
  75016. declare module BABYLON {
  75017. /** @hidden */
  75018. export var displayPassPixelShader: {
  75019. name: string;
  75020. shader: string;
  75021. };
  75022. }
  75023. declare module BABYLON {
  75024. /**
  75025. * DisplayPassPostProcess which produces an output the same as it's input
  75026. */
  75027. export class DisplayPassPostProcess extends PostProcess {
  75028. /**
  75029. * Gets a string identifying the name of the class
  75030. * @returns "DisplayPassPostProcess" string
  75031. */
  75032. getClassName(): string;
  75033. /**
  75034. * Creates the DisplayPassPostProcess
  75035. * @param name The name of the effect.
  75036. * @param options The required width/height ratio to downsize to before computing the render pass.
  75037. * @param camera The camera to apply the render pass to.
  75038. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75039. * @param engine The engine which the post process will be applied. (default: current engine)
  75040. * @param reusable If the post process can be reused on the same frame. (default: false)
  75041. */
  75042. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75043. /** @hidden */
  75044. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  75045. }
  75046. }
  75047. declare module BABYLON {
  75048. /** @hidden */
  75049. export var filterPixelShader: {
  75050. name: string;
  75051. shader: string;
  75052. };
  75053. }
  75054. declare module BABYLON {
  75055. /**
  75056. * Applies a kernel filter to the image
  75057. */
  75058. export class FilterPostProcess extends PostProcess {
  75059. /** The matrix to be applied to the image */
  75060. kernelMatrix: Matrix;
  75061. /**
  75062. * Gets a string identifying the name of the class
  75063. * @returns "FilterPostProcess" string
  75064. */
  75065. getClassName(): string;
  75066. /**
  75067. *
  75068. * @param name The name of the effect.
  75069. * @param kernelMatrix The matrix to be applied to the image
  75070. * @param options The required width/height ratio to downsize to before computing the render pass.
  75071. * @param camera The camera to apply the render pass to.
  75072. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75073. * @param engine The engine which the post process will be applied. (default: current engine)
  75074. * @param reusable If the post process can be reused on the same frame. (default: false)
  75075. */
  75076. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75077. /** @hidden */
  75078. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  75079. }
  75080. }
  75081. declare module BABYLON {
  75082. /** @hidden */
  75083. export var fxaaPixelShader: {
  75084. name: string;
  75085. shader: string;
  75086. };
  75087. }
  75088. declare module BABYLON {
  75089. /** @hidden */
  75090. export var fxaaVertexShader: {
  75091. name: string;
  75092. shader: string;
  75093. };
  75094. }
  75095. declare module BABYLON {
  75096. /**
  75097. * Fxaa post process
  75098. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  75099. */
  75100. export class FxaaPostProcess extends PostProcess {
  75101. /**
  75102. * Gets a string identifying the name of the class
  75103. * @returns "FxaaPostProcess" string
  75104. */
  75105. getClassName(): string;
  75106. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  75107. private _getDefines;
  75108. /** @hidden */
  75109. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  75110. }
  75111. }
  75112. declare module BABYLON {
  75113. /** @hidden */
  75114. export var grainPixelShader: {
  75115. name: string;
  75116. shader: string;
  75117. };
  75118. }
  75119. declare module BABYLON {
  75120. /**
  75121. * The GrainPostProcess adds noise to the image at mid luminance levels
  75122. */
  75123. export class GrainPostProcess extends PostProcess {
  75124. /**
  75125. * The intensity of the grain added (default: 30)
  75126. */
  75127. intensity: number;
  75128. /**
  75129. * If the grain should be randomized on every frame
  75130. */
  75131. animated: boolean;
  75132. /**
  75133. * Gets a string identifying the name of the class
  75134. * @returns "GrainPostProcess" string
  75135. */
  75136. getClassName(): string;
  75137. /**
  75138. * Creates a new instance of @see GrainPostProcess
  75139. * @param name The name of the effect.
  75140. * @param options The required width/height ratio to downsize to before computing the render pass.
  75141. * @param camera The camera to apply the render pass to.
  75142. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75143. * @param engine The engine which the post process will be applied. (default: current engine)
  75144. * @param reusable If the post process can be reused on the same frame. (default: false)
  75145. * @param textureType Type of textures used when performing the post process. (default: 0)
  75146. * @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)
  75147. */
  75148. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75149. /** @hidden */
  75150. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  75151. }
  75152. }
  75153. declare module BABYLON {
  75154. /** @hidden */
  75155. export var highlightsPixelShader: {
  75156. name: string;
  75157. shader: string;
  75158. };
  75159. }
  75160. declare module BABYLON {
  75161. /**
  75162. * Extracts highlights from the image
  75163. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  75164. */
  75165. export class HighlightsPostProcess extends PostProcess {
  75166. /**
  75167. * Gets a string identifying the name of the class
  75168. * @returns "HighlightsPostProcess" string
  75169. */
  75170. getClassName(): string;
  75171. /**
  75172. * Extracts highlights from the image
  75173. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  75174. * @param name The name of the effect.
  75175. * @param options The required width/height ratio to downsize to before computing the render pass.
  75176. * @param camera The camera to apply the render pass to.
  75177. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75178. * @param engine The engine which the post process will be applied. (default: current engine)
  75179. * @param reusable If the post process can be reused on the same frame. (default: false)
  75180. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  75181. */
  75182. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  75183. }
  75184. }
  75185. declare module BABYLON {
  75186. /**
  75187. * Contains all parameters needed for the prepass to perform
  75188. * motion blur
  75189. */
  75190. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  75191. /**
  75192. * Is motion blur enabled
  75193. */
  75194. enabled: boolean;
  75195. /**
  75196. * Name of the configuration
  75197. */
  75198. name: string;
  75199. /**
  75200. * Textures that should be present in the MRT for this effect to work
  75201. */
  75202. readonly texturesRequired: number[];
  75203. }
  75204. }
  75205. declare module BABYLON {
  75206. interface Scene {
  75207. /** @hidden (Backing field) */
  75208. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  75209. /**
  75210. * Gets or Sets the current geometry buffer associated to the scene.
  75211. */
  75212. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  75213. /**
  75214. * Enables a GeometryBufferRender and associates it with the scene
  75215. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  75216. * @returns the GeometryBufferRenderer
  75217. */
  75218. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  75219. /**
  75220. * Disables the GeometryBufferRender associated with the scene
  75221. */
  75222. disableGeometryBufferRenderer(): void;
  75223. }
  75224. /**
  75225. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  75226. * in several rendering techniques.
  75227. */
  75228. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  75229. /**
  75230. * The component name helpful to identify the component in the list of scene components.
  75231. */
  75232. readonly name: string;
  75233. /**
  75234. * The scene the component belongs to.
  75235. */
  75236. scene: Scene;
  75237. /**
  75238. * Creates a new instance of the component for the given scene
  75239. * @param scene Defines the scene to register the component in
  75240. */
  75241. constructor(scene: Scene);
  75242. /**
  75243. * Registers the component in a given scene
  75244. */
  75245. register(): void;
  75246. /**
  75247. * Rebuilds the elements related to this component in case of
  75248. * context lost for instance.
  75249. */
  75250. rebuild(): void;
  75251. /**
  75252. * Disposes the component and the associated resources
  75253. */
  75254. dispose(): void;
  75255. private _gatherRenderTargets;
  75256. }
  75257. }
  75258. declare module BABYLON {
  75259. /** @hidden */
  75260. export var motionBlurPixelShader: {
  75261. name: string;
  75262. shader: string;
  75263. };
  75264. }
  75265. declare module BABYLON {
  75266. /**
  75267. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  75268. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  75269. * As an example, all you have to do is to create the post-process:
  75270. * var mb = new BABYLON.MotionBlurPostProcess(
  75271. * 'mb', // The name of the effect.
  75272. * scene, // The scene containing the objects to blur according to their velocity.
  75273. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  75274. * camera // The camera to apply the render pass to.
  75275. * );
  75276. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  75277. */
  75278. export class MotionBlurPostProcess extends PostProcess {
  75279. /**
  75280. * Defines how much the image is blurred by the movement. Default value is equal to 1
  75281. */
  75282. motionStrength: number;
  75283. /**
  75284. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  75285. */
  75286. get motionBlurSamples(): number;
  75287. /**
  75288. * Sets the number of iterations to be used for motion blur quality
  75289. */
  75290. set motionBlurSamples(samples: number);
  75291. private _motionBlurSamples;
  75292. /**
  75293. * Gets whether or not the motion blur post-process is in object based mode.
  75294. */
  75295. get isObjectBased(): boolean;
  75296. /**
  75297. * Sets whether or not the motion blur post-process is in object based mode.
  75298. */
  75299. set isObjectBased(value: boolean);
  75300. private _isObjectBased;
  75301. private _forceGeometryBuffer;
  75302. private _geometryBufferRenderer;
  75303. private _prePassRenderer;
  75304. private _invViewProjection;
  75305. private _previousViewProjection;
  75306. /**
  75307. * Gets a string identifying the name of the class
  75308. * @returns "MotionBlurPostProcess" string
  75309. */
  75310. getClassName(): string;
  75311. /**
  75312. * Creates a new instance MotionBlurPostProcess
  75313. * @param name The name of the effect.
  75314. * @param scene The scene containing the objects to blur according to their velocity.
  75315. * @param options The required width/height ratio to downsize to before computing the render pass.
  75316. * @param camera The camera to apply the render pass to.
  75317. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75318. * @param engine The engine which the post process will be applied. (default: current engine)
  75319. * @param reusable If the post process can be reused on the same frame. (default: false)
  75320. * @param textureType Type of textures used when performing the post process. (default: 0)
  75321. * @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)
  75322. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  75323. */
  75324. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  75325. /**
  75326. * Excludes the given skinned mesh from computing bones velocities.
  75327. * 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.
  75328. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  75329. */
  75330. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  75331. /**
  75332. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  75333. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  75334. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  75335. */
  75336. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  75337. /**
  75338. * Disposes the post process.
  75339. * @param camera The camera to dispose the post process on.
  75340. */
  75341. dispose(camera?: Camera): void;
  75342. /**
  75343. * Called on the mode changed (object based or screen based).
  75344. */
  75345. private _applyMode;
  75346. /**
  75347. * Called on the effect is applied when the motion blur post-process is in object based mode.
  75348. */
  75349. private _onApplyObjectBased;
  75350. /**
  75351. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  75352. */
  75353. private _onApplyScreenBased;
  75354. /**
  75355. * Called on the effect must be updated (changed mode, samples count, etc.).
  75356. */
  75357. private _updateEffect;
  75358. /** @hidden */
  75359. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  75360. }
  75361. }
  75362. declare module BABYLON {
  75363. /** @hidden */
  75364. export var refractionPixelShader: {
  75365. name: string;
  75366. shader: string;
  75367. };
  75368. }
  75369. declare module BABYLON {
  75370. /**
  75371. * Post process which applies a refraction texture
  75372. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  75373. */
  75374. export class RefractionPostProcess extends PostProcess {
  75375. private _refTexture;
  75376. private _ownRefractionTexture;
  75377. /** the base color of the refraction (used to taint the rendering) */
  75378. color: Color3;
  75379. /** simulated refraction depth */
  75380. depth: number;
  75381. /** the coefficient of the base color (0 to remove base color tainting) */
  75382. colorLevel: number;
  75383. /** Gets the url used to load the refraction texture */
  75384. refractionTextureUrl: string;
  75385. /**
  75386. * Gets or sets the refraction texture
  75387. * Please note that you are responsible for disposing the texture if you set it manually
  75388. */
  75389. get refractionTexture(): Texture;
  75390. set refractionTexture(value: Texture);
  75391. /**
  75392. * Gets a string identifying the name of the class
  75393. * @returns "RefractionPostProcess" string
  75394. */
  75395. getClassName(): string;
  75396. /**
  75397. * Initializes the RefractionPostProcess
  75398. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  75399. * @param name The name of the effect.
  75400. * @param refractionTextureUrl Url of the refraction texture to use
  75401. * @param color the base color of the refraction (used to taint the rendering)
  75402. * @param depth simulated refraction depth
  75403. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  75404. * @param camera The camera to apply the render pass to.
  75405. * @param options The required width/height ratio to downsize to before computing the render pass.
  75406. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75407. * @param engine The engine which the post process will be applied. (default: current engine)
  75408. * @param reusable If the post process can be reused on the same frame. (default: false)
  75409. */
  75410. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75411. /**
  75412. * Disposes of the post process
  75413. * @param camera Camera to dispose post process on
  75414. */
  75415. dispose(camera: Camera): void;
  75416. /** @hidden */
  75417. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  75418. }
  75419. }
  75420. declare module BABYLON {
  75421. /** @hidden */
  75422. export var sharpenPixelShader: {
  75423. name: string;
  75424. shader: string;
  75425. };
  75426. }
  75427. declare module BABYLON {
  75428. /**
  75429. * The SharpenPostProcess applies a sharpen kernel to every pixel
  75430. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  75431. */
  75432. export class SharpenPostProcess extends PostProcess {
  75433. /**
  75434. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  75435. */
  75436. colorAmount: number;
  75437. /**
  75438. * How much sharpness should be applied (default: 0.3)
  75439. */
  75440. edgeAmount: number;
  75441. /**
  75442. * Gets a string identifying the name of the class
  75443. * @returns "SharpenPostProcess" string
  75444. */
  75445. getClassName(): string;
  75446. /**
  75447. * Creates a new instance ConvolutionPostProcess
  75448. * @param name The name of the effect.
  75449. * @param options The required width/height ratio to downsize to before computing the render pass.
  75450. * @param camera The camera to apply the render pass to.
  75451. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75452. * @param engine The engine which the post process will be applied. (default: current engine)
  75453. * @param reusable If the post process can be reused on the same frame. (default: false)
  75454. * @param textureType Type of textures used when performing the post process. (default: 0)
  75455. * @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)
  75456. */
  75457. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75458. /** @hidden */
  75459. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  75460. }
  75461. }
  75462. declare module BABYLON {
  75463. /**
  75464. * PostProcessRenderPipeline
  75465. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75466. */
  75467. export class PostProcessRenderPipeline {
  75468. private engine;
  75469. private _renderEffects;
  75470. private _renderEffectsForIsolatedPass;
  75471. /**
  75472. * List of inspectable custom properties (used by the Inspector)
  75473. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  75474. */
  75475. inspectableCustomProperties: IInspectable[];
  75476. /**
  75477. * @hidden
  75478. */
  75479. protected _cameras: Camera[];
  75480. /** @hidden */
  75481. _name: string;
  75482. /**
  75483. * Gets pipeline name
  75484. */
  75485. get name(): string;
  75486. /** Gets the list of attached cameras */
  75487. get cameras(): Camera[];
  75488. /**
  75489. * Initializes a PostProcessRenderPipeline
  75490. * @param engine engine to add the pipeline to
  75491. * @param name name of the pipeline
  75492. */
  75493. constructor(engine: Engine, name: string);
  75494. /**
  75495. * Gets the class name
  75496. * @returns "PostProcessRenderPipeline"
  75497. */
  75498. getClassName(): string;
  75499. /**
  75500. * If all the render effects in the pipeline are supported
  75501. */
  75502. get isSupported(): boolean;
  75503. /**
  75504. * Adds an effect to the pipeline
  75505. * @param renderEffect the effect to add
  75506. */
  75507. addEffect(renderEffect: PostProcessRenderEffect): void;
  75508. /** @hidden */
  75509. _rebuild(): void;
  75510. /** @hidden */
  75511. _enableEffect(renderEffectName: string, cameras: Camera): void;
  75512. /** @hidden */
  75513. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  75514. /** @hidden */
  75515. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  75516. /** @hidden */
  75517. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  75518. /** @hidden */
  75519. _attachCameras(cameras: Camera, unique: boolean): void;
  75520. /** @hidden */
  75521. _attachCameras(cameras: Camera[], unique: boolean): void;
  75522. /** @hidden */
  75523. _detachCameras(cameras: Camera): void;
  75524. /** @hidden */
  75525. _detachCameras(cameras: Nullable<Camera[]>): void;
  75526. /** @hidden */
  75527. _update(): void;
  75528. /** @hidden */
  75529. _reset(): void;
  75530. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  75531. /**
  75532. * Sets the required values to the prepass renderer.
  75533. * @param prePassRenderer defines the prepass renderer to setup.
  75534. * @returns true if the pre pass is needed.
  75535. */
  75536. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  75537. /**
  75538. * Disposes of the pipeline
  75539. */
  75540. dispose(): void;
  75541. }
  75542. }
  75543. declare module BABYLON {
  75544. /**
  75545. * PostProcessRenderPipelineManager class
  75546. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75547. */
  75548. export class PostProcessRenderPipelineManager {
  75549. private _renderPipelines;
  75550. /**
  75551. * Initializes a PostProcessRenderPipelineManager
  75552. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75553. */
  75554. constructor();
  75555. /**
  75556. * Gets the list of supported render pipelines
  75557. */
  75558. get supportedPipelines(): PostProcessRenderPipeline[];
  75559. /**
  75560. * Adds a pipeline to the manager
  75561. * @param renderPipeline The pipeline to add
  75562. */
  75563. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  75564. /**
  75565. * Attaches a camera to the pipeline
  75566. * @param renderPipelineName The name of the pipeline to attach to
  75567. * @param cameras the camera to attach
  75568. * @param unique if the camera can be attached multiple times to the pipeline
  75569. */
  75570. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  75571. /**
  75572. * Detaches a camera from the pipeline
  75573. * @param renderPipelineName The name of the pipeline to detach from
  75574. * @param cameras the camera to detach
  75575. */
  75576. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  75577. /**
  75578. * Enables an effect by name on a pipeline
  75579. * @param renderPipelineName the name of the pipeline to enable the effect in
  75580. * @param renderEffectName the name of the effect to enable
  75581. * @param cameras the cameras that the effect should be enabled on
  75582. */
  75583. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  75584. /**
  75585. * Disables an effect by name on a pipeline
  75586. * @param renderPipelineName the name of the pipeline to disable the effect in
  75587. * @param renderEffectName the name of the effect to disable
  75588. * @param cameras the cameras that the effect should be disabled on
  75589. */
  75590. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  75591. /**
  75592. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  75593. */
  75594. update(): void;
  75595. /** @hidden */
  75596. _rebuild(): void;
  75597. /**
  75598. * Disposes of the manager and pipelines
  75599. */
  75600. dispose(): void;
  75601. }
  75602. }
  75603. declare module BABYLON {
  75604. interface Scene {
  75605. /** @hidden (Backing field) */
  75606. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  75607. /**
  75608. * Gets the postprocess render pipeline manager
  75609. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75610. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  75611. */
  75612. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  75613. }
  75614. /**
  75615. * Defines the Render Pipeline scene component responsible to rendering pipelines
  75616. */
  75617. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  75618. /**
  75619. * The component name helpful to identify the component in the list of scene components.
  75620. */
  75621. readonly name: string;
  75622. /**
  75623. * The scene the component belongs to.
  75624. */
  75625. scene: Scene;
  75626. /**
  75627. * Creates a new instance of the component for the given scene
  75628. * @param scene Defines the scene to register the component in
  75629. */
  75630. constructor(scene: Scene);
  75631. /**
  75632. * Registers the component in a given scene
  75633. */
  75634. register(): void;
  75635. /**
  75636. * Rebuilds the elements related to this component in case of
  75637. * context lost for instance.
  75638. */
  75639. rebuild(): void;
  75640. /**
  75641. * Disposes the component and the associated resources
  75642. */
  75643. dispose(): void;
  75644. private _gatherRenderTargets;
  75645. }
  75646. }
  75647. declare module BABYLON {
  75648. /**
  75649. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  75650. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  75651. */
  75652. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75653. private _scene;
  75654. private _camerasToBeAttached;
  75655. /**
  75656. * ID of the sharpen post process,
  75657. */
  75658. private readonly SharpenPostProcessId;
  75659. /**
  75660. * @ignore
  75661. * ID of the image processing post process;
  75662. */
  75663. readonly ImageProcessingPostProcessId: string;
  75664. /**
  75665. * @ignore
  75666. * ID of the Fast Approximate Anti-Aliasing post process;
  75667. */
  75668. readonly FxaaPostProcessId: string;
  75669. /**
  75670. * ID of the chromatic aberration post process,
  75671. */
  75672. private readonly ChromaticAberrationPostProcessId;
  75673. /**
  75674. * ID of the grain post process
  75675. */
  75676. private readonly GrainPostProcessId;
  75677. /**
  75678. * Sharpen post process which will apply a sharpen convolution to enhance edges
  75679. */
  75680. sharpen: SharpenPostProcess;
  75681. private _sharpenEffect;
  75682. private bloom;
  75683. /**
  75684. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  75685. */
  75686. depthOfField: DepthOfFieldEffect;
  75687. /**
  75688. * The Fast Approximate Anti-Aliasing post process which attempts to remove aliasing from an image.
  75689. */
  75690. fxaa: FxaaPostProcess;
  75691. /**
  75692. * Image post processing pass used to perform operations such as tone mapping or color grading.
  75693. */
  75694. imageProcessing: ImageProcessingPostProcess;
  75695. /**
  75696. * Chromatic aberration post process which will shift rgb colors in the image
  75697. */
  75698. chromaticAberration: ChromaticAberrationPostProcess;
  75699. private _chromaticAberrationEffect;
  75700. /**
  75701. * Grain post process which add noise to the image
  75702. */
  75703. grain: GrainPostProcess;
  75704. private _grainEffect;
  75705. /**
  75706. * Glow post process which adds a glow to emissive areas of the image
  75707. */
  75708. private _glowLayer;
  75709. /**
  75710. * Animations which can be used to tweak settings over a period of time
  75711. */
  75712. animations: Animation[];
  75713. private _imageProcessingConfigurationObserver;
  75714. private _sharpenEnabled;
  75715. private _bloomEnabled;
  75716. private _depthOfFieldEnabled;
  75717. private _depthOfFieldBlurLevel;
  75718. private _fxaaEnabled;
  75719. private _imageProcessingEnabled;
  75720. private _defaultPipelineTextureType;
  75721. private _bloomScale;
  75722. private _chromaticAberrationEnabled;
  75723. private _grainEnabled;
  75724. private _buildAllowed;
  75725. /**
  75726. * This is triggered each time the pipeline has been built.
  75727. */
  75728. onBuildObservable: Observable<DefaultRenderingPipeline>;
  75729. /**
  75730. * Gets active scene
  75731. */
  75732. get scene(): Scene;
  75733. /**
  75734. * Enable or disable the sharpen process from the pipeline
  75735. */
  75736. set sharpenEnabled(enabled: boolean);
  75737. get sharpenEnabled(): boolean;
  75738. private _resizeObserver;
  75739. private _hardwareScaleLevel;
  75740. private _bloomKernel;
  75741. /**
  75742. * Specifies the size of the bloom blur kernel, relative to the final output size
  75743. */
  75744. get bloomKernel(): number;
  75745. set bloomKernel(value: number);
  75746. /**
  75747. * Specifies the weight of the bloom in the final rendering
  75748. */
  75749. private _bloomWeight;
  75750. /**
  75751. * Specifies the luma threshold for the area that will be blurred by the bloom
  75752. */
  75753. private _bloomThreshold;
  75754. private _hdr;
  75755. /**
  75756. * The strength of the bloom.
  75757. */
  75758. set bloomWeight(value: number);
  75759. get bloomWeight(): number;
  75760. /**
  75761. * The strength of the bloom.
  75762. */
  75763. set bloomThreshold(value: number);
  75764. get bloomThreshold(): number;
  75765. /**
  75766. * The scale of the bloom, lower value will provide better performance.
  75767. */
  75768. set bloomScale(value: number);
  75769. get bloomScale(): number;
  75770. /**
  75771. * Enable or disable the bloom from the pipeline
  75772. */
  75773. set bloomEnabled(enabled: boolean);
  75774. get bloomEnabled(): boolean;
  75775. private _rebuildBloom;
  75776. /**
  75777. * If the depth of field is enabled.
  75778. */
  75779. get depthOfFieldEnabled(): boolean;
  75780. set depthOfFieldEnabled(enabled: boolean);
  75781. /**
  75782. * Blur level of the depth of field effect. (Higher blur will effect performance)
  75783. */
  75784. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  75785. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  75786. /**
  75787. * If the anti aliasing is enabled.
  75788. */
  75789. set fxaaEnabled(enabled: boolean);
  75790. get fxaaEnabled(): boolean;
  75791. private _samples;
  75792. /**
  75793. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75794. */
  75795. set samples(sampleCount: number);
  75796. get samples(): number;
  75797. /**
  75798. * If image processing is enabled.
  75799. */
  75800. set imageProcessingEnabled(enabled: boolean);
  75801. get imageProcessingEnabled(): boolean;
  75802. /**
  75803. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  75804. */
  75805. set glowLayerEnabled(enabled: boolean);
  75806. get glowLayerEnabled(): boolean;
  75807. /**
  75808. * Gets the glow layer (or null if not defined)
  75809. */
  75810. get glowLayer(): Nullable<GlowLayer>;
  75811. /**
  75812. * Enable or disable the chromaticAberration process from the pipeline
  75813. */
  75814. set chromaticAberrationEnabled(enabled: boolean);
  75815. get chromaticAberrationEnabled(): boolean;
  75816. /**
  75817. * Enable or disable the grain process from the pipeline
  75818. */
  75819. set grainEnabled(enabled: boolean);
  75820. get grainEnabled(): boolean;
  75821. /**
  75822. * @constructor
  75823. * @param name - The rendering pipeline name (default: "")
  75824. * @param hdr - If high dynamic range textures should be used (default: true)
  75825. * @param scene - The scene linked to this pipeline (default: the last created scene)
  75826. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  75827. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  75828. */
  75829. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  75830. /**
  75831. * Get the class name
  75832. * @returns "DefaultRenderingPipeline"
  75833. */
  75834. getClassName(): string;
  75835. /**
  75836. * Force the compilation of the entire pipeline.
  75837. */
  75838. prepare(): void;
  75839. private _hasCleared;
  75840. private _prevPostProcess;
  75841. private _prevPrevPostProcess;
  75842. private _setAutoClearAndTextureSharing;
  75843. private _depthOfFieldSceneObserver;
  75844. private _buildPipeline;
  75845. private _disposePostProcesses;
  75846. /**
  75847. * Adds a camera to the pipeline
  75848. * @param camera the camera to be added
  75849. */
  75850. addCamera(camera: Camera): void;
  75851. /**
  75852. * Removes a camera from the pipeline
  75853. * @param camera the camera to remove
  75854. */
  75855. removeCamera(camera: Camera): void;
  75856. /**
  75857. * Dispose of the pipeline and stop all post processes
  75858. */
  75859. dispose(): void;
  75860. /**
  75861. * Serialize the rendering pipeline (Used when exporting)
  75862. * @returns the serialized object
  75863. */
  75864. serialize(): any;
  75865. /**
  75866. * Parse the serialized pipeline
  75867. * @param source Source pipeline.
  75868. * @param scene The scene to load the pipeline to.
  75869. * @param rootUrl The URL of the serialized pipeline.
  75870. * @returns An instantiated pipeline from the serialized object.
  75871. */
  75872. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  75873. }
  75874. }
  75875. declare module BABYLON {
  75876. /** @hidden */
  75877. export var lensHighlightsPixelShader: {
  75878. name: string;
  75879. shader: string;
  75880. };
  75881. }
  75882. declare module BABYLON {
  75883. /** @hidden */
  75884. export var depthOfFieldPixelShader: {
  75885. name: string;
  75886. shader: string;
  75887. };
  75888. }
  75889. declare module BABYLON {
  75890. /**
  75891. * BABYLON.JS Chromatic Aberration GLSL Shader
  75892. * Author: Olivier Guyot
  75893. * Separates very slightly R, G and B colors on the edges of the screen
  75894. * Inspired by Francois Tarlier & Martins Upitis
  75895. */
  75896. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  75897. /**
  75898. * @ignore
  75899. * The chromatic aberration PostProcess id in the pipeline
  75900. */
  75901. LensChromaticAberrationEffect: string;
  75902. /**
  75903. * @ignore
  75904. * The highlights enhancing PostProcess id in the pipeline
  75905. */
  75906. HighlightsEnhancingEffect: string;
  75907. /**
  75908. * @ignore
  75909. * The depth-of-field PostProcess id in the pipeline
  75910. */
  75911. LensDepthOfFieldEffect: string;
  75912. private _scene;
  75913. private _depthTexture;
  75914. private _grainTexture;
  75915. private _chromaticAberrationPostProcess;
  75916. private _highlightsPostProcess;
  75917. private _depthOfFieldPostProcess;
  75918. private _edgeBlur;
  75919. private _grainAmount;
  75920. private _chromaticAberration;
  75921. private _distortion;
  75922. private _highlightsGain;
  75923. private _highlightsThreshold;
  75924. private _dofDistance;
  75925. private _dofAperture;
  75926. private _dofDarken;
  75927. private _dofPentagon;
  75928. private _blurNoise;
  75929. /**
  75930. * @constructor
  75931. *
  75932. * Effect parameters are as follow:
  75933. * {
  75934. * chromatic_aberration: number; // from 0 to x (1 for realism)
  75935. * edge_blur: number; // from 0 to x (1 for realism)
  75936. * distortion: number; // from 0 to x (1 for realism)
  75937. * grain_amount: number; // from 0 to 1
  75938. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  75939. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  75940. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  75941. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  75942. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  75943. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  75944. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  75945. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  75946. * }
  75947. * Note: if an effect parameter is unset, effect is disabled
  75948. *
  75949. * @param name The rendering pipeline name
  75950. * @param parameters - An object containing all parameters (see above)
  75951. * @param scene The scene linked to this pipeline
  75952. * @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)
  75953. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75954. */
  75955. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  75956. /**
  75957. * Get the class name
  75958. * @returns "LensRenderingPipeline"
  75959. */
  75960. getClassName(): string;
  75961. /**
  75962. * Gets associated scene
  75963. */
  75964. get scene(): Scene;
  75965. /**
  75966. * Gets or sets the edge blur
  75967. */
  75968. get edgeBlur(): number;
  75969. set edgeBlur(value: number);
  75970. /**
  75971. * Gets or sets the grain amount
  75972. */
  75973. get grainAmount(): number;
  75974. set grainAmount(value: number);
  75975. /**
  75976. * Gets or sets the chromatic aberration amount
  75977. */
  75978. get chromaticAberration(): number;
  75979. set chromaticAberration(value: number);
  75980. /**
  75981. * Gets or sets the depth of field aperture
  75982. */
  75983. get dofAperture(): number;
  75984. set dofAperture(value: number);
  75985. /**
  75986. * Gets or sets the edge distortion
  75987. */
  75988. get edgeDistortion(): number;
  75989. set edgeDistortion(value: number);
  75990. /**
  75991. * Gets or sets the depth of field distortion
  75992. */
  75993. get dofDistortion(): number;
  75994. set dofDistortion(value: number);
  75995. /**
  75996. * Gets or sets the darken out of focus amount
  75997. */
  75998. get darkenOutOfFocus(): number;
  75999. set darkenOutOfFocus(value: number);
  76000. /**
  76001. * Gets or sets a boolean indicating if blur noise is enabled
  76002. */
  76003. get blurNoise(): boolean;
  76004. set blurNoise(value: boolean);
  76005. /**
  76006. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  76007. */
  76008. get pentagonBokeh(): boolean;
  76009. set pentagonBokeh(value: boolean);
  76010. /**
  76011. * Gets or sets the highlight grain amount
  76012. */
  76013. get highlightsGain(): number;
  76014. set highlightsGain(value: number);
  76015. /**
  76016. * Gets or sets the highlight threshold
  76017. */
  76018. get highlightsThreshold(): number;
  76019. set highlightsThreshold(value: number);
  76020. /**
  76021. * Sets the amount of blur at the edges
  76022. * @param amount blur amount
  76023. */
  76024. setEdgeBlur(amount: number): void;
  76025. /**
  76026. * Sets edge blur to 0
  76027. */
  76028. disableEdgeBlur(): void;
  76029. /**
  76030. * Sets the amount of grain
  76031. * @param amount Amount of grain
  76032. */
  76033. setGrainAmount(amount: number): void;
  76034. /**
  76035. * Set grain amount to 0
  76036. */
  76037. disableGrain(): void;
  76038. /**
  76039. * Sets the chromatic aberration amount
  76040. * @param amount amount of chromatic aberration
  76041. */
  76042. setChromaticAberration(amount: number): void;
  76043. /**
  76044. * Sets chromatic aberration amount to 0
  76045. */
  76046. disableChromaticAberration(): void;
  76047. /**
  76048. * Sets the EdgeDistortion amount
  76049. * @param amount amount of EdgeDistortion
  76050. */
  76051. setEdgeDistortion(amount: number): void;
  76052. /**
  76053. * Sets edge distortion to 0
  76054. */
  76055. disableEdgeDistortion(): void;
  76056. /**
  76057. * Sets the FocusDistance amount
  76058. * @param amount amount of FocusDistance
  76059. */
  76060. setFocusDistance(amount: number): void;
  76061. /**
  76062. * Disables depth of field
  76063. */
  76064. disableDepthOfField(): void;
  76065. /**
  76066. * Sets the Aperture amount
  76067. * @param amount amount of Aperture
  76068. */
  76069. setAperture(amount: number): void;
  76070. /**
  76071. * Sets the DarkenOutOfFocus amount
  76072. * @param amount amount of DarkenOutOfFocus
  76073. */
  76074. setDarkenOutOfFocus(amount: number): void;
  76075. private _pentagonBokehIsEnabled;
  76076. /**
  76077. * Creates a pentagon bokeh effect
  76078. */
  76079. enablePentagonBokeh(): void;
  76080. /**
  76081. * Disables the pentagon bokeh effect
  76082. */
  76083. disablePentagonBokeh(): void;
  76084. /**
  76085. * Enables noise blur
  76086. */
  76087. enableNoiseBlur(): void;
  76088. /**
  76089. * Disables noise blur
  76090. */
  76091. disableNoiseBlur(): void;
  76092. /**
  76093. * Sets the HighlightsGain amount
  76094. * @param amount amount of HighlightsGain
  76095. */
  76096. setHighlightsGain(amount: number): void;
  76097. /**
  76098. * Sets the HighlightsThreshold amount
  76099. * @param amount amount of HighlightsThreshold
  76100. */
  76101. setHighlightsThreshold(amount: number): void;
  76102. /**
  76103. * Disables highlights
  76104. */
  76105. disableHighlights(): void;
  76106. /**
  76107. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  76108. * @param disableDepthRender If the scene's depth rendering should be disabled (default: false)
  76109. */
  76110. dispose(disableDepthRender?: boolean): void;
  76111. private _createChromaticAberrationPostProcess;
  76112. private _createHighlightsPostProcess;
  76113. private _createDepthOfFieldPostProcess;
  76114. private _createGrainTexture;
  76115. }
  76116. }
  76117. declare module BABYLON {
  76118. /**
  76119. * Contains all parameters needed for the prepass to perform
  76120. * screen space subsurface scattering
  76121. */
  76122. export class SSAO2Configuration implements PrePassEffectConfiguration {
  76123. /**
  76124. * Is subsurface enabled
  76125. */
  76126. enabled: boolean;
  76127. /**
  76128. * Name of the configuration
  76129. */
  76130. name: string;
  76131. /**
  76132. * Textures that should be present in the MRT for this effect to work
  76133. */
  76134. readonly texturesRequired: number[];
  76135. }
  76136. }
  76137. declare module BABYLON {
  76138. /** @hidden */
  76139. export var ssao2PixelShader: {
  76140. name: string;
  76141. shader: string;
  76142. };
  76143. }
  76144. declare module BABYLON {
  76145. /** @hidden */
  76146. export var ssaoCombinePixelShader: {
  76147. name: string;
  76148. shader: string;
  76149. };
  76150. }
  76151. declare module BABYLON {
  76152. /**
  76153. * Render pipeline to produce ssao effect
  76154. */
  76155. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  76156. /**
  76157. * @ignore
  76158. * The PassPostProcess id in the pipeline that contains the original scene color
  76159. */
  76160. SSAOOriginalSceneColorEffect: string;
  76161. /**
  76162. * @ignore
  76163. * The SSAO PostProcess id in the pipeline
  76164. */
  76165. SSAORenderEffect: string;
  76166. /**
  76167. * @ignore
  76168. * The horizontal blur PostProcess id in the pipeline
  76169. */
  76170. SSAOBlurHRenderEffect: string;
  76171. /**
  76172. * @ignore
  76173. * The vertical blur PostProcess id in the pipeline
  76174. */
  76175. SSAOBlurVRenderEffect: string;
  76176. /**
  76177. * @ignore
  76178. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  76179. */
  76180. SSAOCombineRenderEffect: string;
  76181. /**
  76182. * The output strength of the SSAO post-process. Default value is 1.0.
  76183. */
  76184. totalStrength: number;
  76185. /**
  76186. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  76187. */
  76188. maxZ: number;
  76189. /**
  76190. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  76191. */
  76192. minZAspect: number;
  76193. private _samples;
  76194. /**
  76195. * Number of samples used for the SSAO calculations. Default value is 8
  76196. */
  76197. set samples(n: number);
  76198. get samples(): number;
  76199. private _textureSamples;
  76200. /**
  76201. * Number of samples to use for antialiasing
  76202. */
  76203. set textureSamples(n: number);
  76204. get textureSamples(): number;
  76205. /**
  76206. * Force rendering the geometry through geometry buffer
  76207. */
  76208. private _forceGeometryBuffer;
  76209. /**
  76210. * Ratio object used for SSAO ratio and blur ratio
  76211. */
  76212. private _ratio;
  76213. /**
  76214. * Dynamically generated sphere sampler.
  76215. */
  76216. private _sampleSphere;
  76217. /**
  76218. * Blur filter offsets
  76219. */
  76220. private _samplerOffsets;
  76221. private _expensiveBlur;
  76222. /**
  76223. * If bilateral blur should be used
  76224. */
  76225. set expensiveBlur(b: boolean);
  76226. get expensiveBlur(): boolean;
  76227. /**
  76228. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  76229. */
  76230. radius: number;
  76231. /**
  76232. * The base color of the SSAO post-process
  76233. * The final result is "base + ssao" between [0, 1]
  76234. */
  76235. base: number;
  76236. /**
  76237. * Support test.
  76238. */
  76239. static get IsSupported(): boolean;
  76240. private _scene;
  76241. private _randomTexture;
  76242. private _originalColorPostProcess;
  76243. private _ssaoPostProcess;
  76244. private _blurHPostProcess;
  76245. private _blurVPostProcess;
  76246. private _ssaoCombinePostProcess;
  76247. private _prePassRenderer;
  76248. /**
  76249. * Gets active scene
  76250. */
  76251. get scene(): Scene;
  76252. /**
  76253. * @constructor
  76254. * @param name The rendering pipeline name
  76255. * @param scene The scene linked to this pipeline
  76256. * @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 }
  76257. * @param cameras The array of cameras that the rendering pipeline will be attached to
  76258. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  76259. */
  76260. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  76261. /**
  76262. * Get the class name
  76263. * @returns "SSAO2RenderingPipeline"
  76264. */
  76265. getClassName(): string;
  76266. /**
  76267. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  76268. */
  76269. dispose(disableGeometryBufferRenderer?: boolean): void;
  76270. private _createBlurPostProcess;
  76271. /** @hidden */
  76272. _rebuild(): void;
  76273. private _bits;
  76274. private _radicalInverse_VdC;
  76275. private _hammersley;
  76276. private _hemisphereSample_uniform;
  76277. private _generateHemisphere;
  76278. private _getDefinesForSSAO;
  76279. private static readonly ORTHO_DEPTH_PROJECTION;
  76280. private static readonly PERSPECTIVE_DEPTH_PROJECTION;
  76281. private _createSSAOPostProcess;
  76282. private _createSSAOCombinePostProcess;
  76283. private _createRandomTexture;
  76284. /**
  76285. * Serialize the rendering pipeline (Used when exporting)
  76286. * @returns the serialized object
  76287. */
  76288. serialize(): any;
  76289. /**
  76290. * Parse the serialized pipeline
  76291. * @param source Source pipeline.
  76292. * @param scene The scene to load the pipeline to.
  76293. * @param rootUrl The URL of the serialized pipeline.
  76294. * @returns An instantiated pipeline from the serialized object.
  76295. */
  76296. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  76297. }
  76298. }
  76299. declare module BABYLON {
  76300. /** @hidden */
  76301. export var ssaoPixelShader: {
  76302. name: string;
  76303. shader: string;
  76304. };
  76305. }
  76306. declare module BABYLON {
  76307. /**
  76308. * Render pipeline to produce ssao effect
  76309. */
  76310. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  76311. /**
  76312. * @ignore
  76313. * The PassPostProcess id in the pipeline that contains the original scene color
  76314. */
  76315. SSAOOriginalSceneColorEffect: string;
  76316. /**
  76317. * @ignore
  76318. * The SSAO PostProcess id in the pipeline
  76319. */
  76320. SSAORenderEffect: string;
  76321. /**
  76322. * @ignore
  76323. * The horizontal blur PostProcess id in the pipeline
  76324. */
  76325. SSAOBlurHRenderEffect: string;
  76326. /**
  76327. * @ignore
  76328. * The vertical blur PostProcess id in the pipeline
  76329. */
  76330. SSAOBlurVRenderEffect: string;
  76331. /**
  76332. * @ignore
  76333. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  76334. */
  76335. SSAOCombineRenderEffect: string;
  76336. /**
  76337. * The output strength of the SSAO post-process. Default value is 1.0.
  76338. */
  76339. totalStrength: number;
  76340. /**
  76341. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  76342. */
  76343. radius: number;
  76344. /**
  76345. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  76346. * Must not be equal to fallOff and superior to fallOff.
  76347. * Default value is 0.0075
  76348. */
  76349. area: number;
  76350. /**
  76351. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  76352. * Must not be equal to area and inferior to area.
  76353. * Default value is 0.000001
  76354. */
  76355. fallOff: number;
  76356. /**
  76357. * The base color of the SSAO post-process
  76358. * The final result is "base + ssao" between [0, 1]
  76359. */
  76360. base: number;
  76361. private _scene;
  76362. private _depthTexture;
  76363. private _randomTexture;
  76364. private _originalColorPostProcess;
  76365. private _ssaoPostProcess;
  76366. private _blurHPostProcess;
  76367. private _blurVPostProcess;
  76368. private _ssaoCombinePostProcess;
  76369. private _firstUpdate;
  76370. /**
  76371. * Gets active scene
  76372. */
  76373. get scene(): Scene;
  76374. /**
  76375. * @constructor
  76376. * @param name - The rendering pipeline name
  76377. * @param scene - The scene linked to this pipeline
  76378. * @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 }
  76379. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  76380. */
  76381. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  76382. /**
  76383. * Get the class name
  76384. * @returns "SSAORenderingPipeline"
  76385. */
  76386. getClassName(): string;
  76387. /**
  76388. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  76389. */
  76390. dispose(disableDepthRender?: boolean): void;
  76391. private _createBlurPostProcess;
  76392. /** @hidden */
  76393. _rebuild(): void;
  76394. private _createSSAOPostProcess;
  76395. private _createSSAOCombinePostProcess;
  76396. private _createRandomTexture;
  76397. }
  76398. }
  76399. declare module BABYLON {
  76400. /**
  76401. * Contains all parameters needed for the prepass to perform
  76402. * screen space reflections
  76403. */
  76404. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  76405. /**
  76406. * Is ssr enabled
  76407. */
  76408. enabled: boolean;
  76409. /**
  76410. * Name of the configuration
  76411. */
  76412. name: string;
  76413. /**
  76414. * Textures that should be present in the MRT for this effect to work
  76415. */
  76416. readonly texturesRequired: number[];
  76417. }
  76418. }
  76419. declare module BABYLON {
  76420. /** @hidden */
  76421. export var screenSpaceReflectionPixelShader: {
  76422. name: string;
  76423. shader: string;
  76424. };
  76425. }
  76426. declare module BABYLON {
  76427. /**
  76428. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  76429. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  76430. */
  76431. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  76432. /**
  76433. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  76434. */
  76435. threshold: number;
  76436. /**
  76437. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  76438. */
  76439. strength: number;
  76440. /**
  76441. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  76442. */
  76443. reflectionSpecularFalloffExponent: number;
  76444. /**
  76445. * 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]
  76446. */
  76447. step: number;
  76448. /**
  76449. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  76450. */
  76451. roughnessFactor: number;
  76452. private _forceGeometryBuffer;
  76453. private _geometryBufferRenderer;
  76454. private _prePassRenderer;
  76455. private _enableSmoothReflections;
  76456. private _reflectionSamples;
  76457. private _smoothSteps;
  76458. /**
  76459. * Gets a string identifying the name of the class
  76460. * @returns "ScreenSpaceReflectionPostProcess" string
  76461. */
  76462. getClassName(): string;
  76463. /**
  76464. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  76465. * @param name The name of the effect.
  76466. * @param scene The scene containing the objects to calculate reflections.
  76467. * @param options The required width/height ratio to downsize to before computing the render pass.
  76468. * @param camera The camera to apply the render pass to.
  76469. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76470. * @param engine The engine which the post process will be applied. (default: current engine)
  76471. * @param reusable If the post process can be reused on the same frame. (default: false)
  76472. * @param textureType Type of textures used when performing the post process. (default: 0)
  76473. * @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)
  76474. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  76475. */
  76476. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  76477. /**
  76478. * Gets whether or not smoothing reflections is enabled.
  76479. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  76480. */
  76481. get enableSmoothReflections(): boolean;
  76482. /**
  76483. * Sets whether or not smoothing reflections is enabled.
  76484. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  76485. */
  76486. set enableSmoothReflections(enabled: boolean);
  76487. /**
  76488. * Gets the number of samples taken while computing reflections. More samples count is high,
  76489. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  76490. */
  76491. get reflectionSamples(): number;
  76492. /**
  76493. * Sets the number of samples taken while computing reflections. More samples count is high,
  76494. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  76495. */
  76496. set reflectionSamples(samples: number);
  76497. /**
  76498. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  76499. * more the post-process will require GPU power and can generate a drop in FPS.
  76500. * Default value (5.0) work pretty well in all cases but can be adjusted.
  76501. */
  76502. get smoothSteps(): number;
  76503. set smoothSteps(steps: number);
  76504. private _updateEffectDefines;
  76505. /** @hidden */
  76506. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  76507. }
  76508. }
  76509. declare module BABYLON {
  76510. /** @hidden */
  76511. export var standardPixelShader: {
  76512. name: string;
  76513. shader: string;
  76514. };
  76515. }
  76516. declare module BABYLON {
  76517. /**
  76518. * Standard rendering pipeline
  76519. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76520. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  76521. */
  76522. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  76523. /**
  76524. * Public members
  76525. */
  76526. /**
  76527. * Post-process which contains the original scene color before the pipeline applies all the effects
  76528. */
  76529. originalPostProcess: Nullable<PostProcess>;
  76530. /**
  76531. * Post-process used to down scale an image x4
  76532. */
  76533. downSampleX4PostProcess: Nullable<PostProcess>;
  76534. /**
  76535. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  76536. */
  76537. brightPassPostProcess: Nullable<PostProcess>;
  76538. /**
  76539. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  76540. */
  76541. blurHPostProcesses: PostProcess[];
  76542. /**
  76543. * Post-process array storing all the vertical blur post-processes used by the pipeline
  76544. */
  76545. blurVPostProcesses: PostProcess[];
  76546. /**
  76547. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  76548. */
  76549. textureAdderPostProcess: Nullable<PostProcess>;
  76550. /**
  76551. * Post-process used to create volumetric lighting effect
  76552. */
  76553. volumetricLightPostProcess: Nullable<PostProcess>;
  76554. /**
  76555. * Post-process used to smooth the previous volumetric light post-process on the X axis
  76556. */
  76557. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  76558. /**
  76559. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  76560. */
  76561. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  76562. /**
  76563. * Post-process used to merge the volumetric light effect and the real scene color
  76564. */
  76565. volumetricLightMergePostProces: Nullable<PostProcess>;
  76566. /**
  76567. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  76568. */
  76569. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  76570. /**
  76571. * Base post-process used to calculate the average luminance of the final image for HDR
  76572. */
  76573. luminancePostProcess: Nullable<PostProcess>;
  76574. /**
  76575. * Post-processes used to create down sample post-processes in order to get
  76576. * the average luminance of the final image for HDR
  76577. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  76578. */
  76579. luminanceDownSamplePostProcesses: PostProcess[];
  76580. /**
  76581. * Post-process used to create a HDR effect (light adaptation)
  76582. */
  76583. hdrPostProcess: Nullable<PostProcess>;
  76584. /**
  76585. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  76586. */
  76587. textureAdderFinalPostProcess: Nullable<PostProcess>;
  76588. /**
  76589. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  76590. */
  76591. lensFlareFinalPostProcess: Nullable<PostProcess>;
  76592. /**
  76593. * Post-process used to merge the final HDR post-process and the real scene color
  76594. */
  76595. hdrFinalPostProcess: Nullable<PostProcess>;
  76596. /**
  76597. * Post-process used to create a lens flare effect
  76598. */
  76599. lensFlarePostProcess: Nullable<PostProcess>;
  76600. /**
  76601. * Post-process that merges the result of the lens flare post-process and the real scene color
  76602. */
  76603. lensFlareComposePostProcess: Nullable<PostProcess>;
  76604. /**
  76605. * Post-process used to create a motion blur effect
  76606. */
  76607. motionBlurPostProcess: Nullable<PostProcess>;
  76608. /**
  76609. * Post-process used to create a depth of field effect
  76610. */
  76611. depthOfFieldPostProcess: Nullable<PostProcess>;
  76612. /**
  76613. * The Fast Approximate Anti-Aliasing post process which attempts to remove aliasing from an image.
  76614. */
  76615. fxaaPostProcess: Nullable<FxaaPostProcess>;
  76616. /**
  76617. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  76618. */
  76619. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  76620. /**
  76621. * Represents the brightness threshold in order to configure the illuminated surfaces
  76622. */
  76623. brightThreshold: number;
  76624. /**
  76625. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  76626. */
  76627. blurWidth: number;
  76628. /**
  76629. * Sets if the blur for highlighted surfaces must be only horizontal
  76630. */
  76631. horizontalBlur: boolean;
  76632. /**
  76633. * Gets the overall exposure used by the pipeline
  76634. */
  76635. get exposure(): number;
  76636. /**
  76637. * Sets the overall exposure used by the pipeline
  76638. */
  76639. set exposure(value: number);
  76640. /**
  76641. * Texture used typically to simulate "dirty" on camera lens
  76642. */
  76643. lensTexture: Nullable<Texture>;
  76644. /**
  76645. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  76646. */
  76647. volumetricLightCoefficient: number;
  76648. /**
  76649. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  76650. */
  76651. volumetricLightPower: number;
  76652. /**
  76653. * Used the set the blur intensity to smooth the volumetric lights
  76654. */
  76655. volumetricLightBlurScale: number;
  76656. /**
  76657. * Light (spot or directional) used to generate the volumetric lights rays
  76658. * The source light must have a shadow generate so the pipeline can get its
  76659. * depth map
  76660. */
  76661. sourceLight: Nullable<SpotLight | DirectionalLight>;
  76662. /**
  76663. * For eye adaptation, represents the minimum luminance the eye can see
  76664. */
  76665. hdrMinimumLuminance: number;
  76666. /**
  76667. * For eye adaptation, represents the decrease luminance speed
  76668. */
  76669. hdrDecreaseRate: number;
  76670. /**
  76671. * For eye adaptation, represents the increase luminance speed
  76672. */
  76673. hdrIncreaseRate: number;
  76674. /**
  76675. * Gets whether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  76676. */
  76677. get hdrAutoExposure(): boolean;
  76678. /**
  76679. * Sets whether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  76680. */
  76681. set hdrAutoExposure(value: boolean);
  76682. /**
  76683. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  76684. */
  76685. lensColorTexture: Nullable<Texture>;
  76686. /**
  76687. * The overall strengh for the lens flare effect
  76688. */
  76689. lensFlareStrength: number;
  76690. /**
  76691. * Dispersion coefficient for lens flare ghosts
  76692. */
  76693. lensFlareGhostDispersal: number;
  76694. /**
  76695. * Main lens flare halo width
  76696. */
  76697. lensFlareHaloWidth: number;
  76698. /**
  76699. * Based on the lens distortion effect, defines how much the lens flare result
  76700. * is distorted
  76701. */
  76702. lensFlareDistortionStrength: number;
  76703. /**
  76704. * Configures the blur intensity used for for lens flare (halo)
  76705. */
  76706. lensFlareBlurWidth: number;
  76707. /**
  76708. * Lens star texture must be used to simulate rays on the flares and is available
  76709. * in the documentation
  76710. */
  76711. lensStarTexture: Nullable<Texture>;
  76712. /**
  76713. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  76714. * flare effect by taking account of the dirt texture
  76715. */
  76716. lensFlareDirtTexture: Nullable<Texture>;
  76717. /**
  76718. * Represents the focal length for the depth of field effect
  76719. */
  76720. depthOfFieldDistance: number;
  76721. /**
  76722. * Represents the blur intensity for the blurred part of the depth of field effect
  76723. */
  76724. depthOfFieldBlurWidth: number;
  76725. /**
  76726. * Gets how much the image is blurred by the movement while using the motion blur post-process
  76727. */
  76728. get motionStrength(): number;
  76729. /**
  76730. * Sets how much the image is blurred by the movement while using the motion blur post-process
  76731. */
  76732. set motionStrength(strength: number);
  76733. /**
  76734. * Gets whether or not the motion blur post-process is object based or screen based.
  76735. */
  76736. get objectBasedMotionBlur(): boolean;
  76737. /**
  76738. * Sets whether or not the motion blur post-process should be object based or screen based
  76739. */
  76740. set objectBasedMotionBlur(value: boolean);
  76741. /**
  76742. * List of animations for the pipeline (IAnimatable implementation)
  76743. */
  76744. animations: Animation[];
  76745. /**
  76746. * Private members
  76747. */
  76748. private _scene;
  76749. private _currentDepthOfFieldSource;
  76750. private _basePostProcess;
  76751. private _fixedExposure;
  76752. private _currentExposure;
  76753. private _hdrAutoExposure;
  76754. private _hdrCurrentLuminance;
  76755. private _motionStrength;
  76756. private _isObjectBasedMotionBlur;
  76757. private _floatTextureType;
  76758. private _camerasToBeAttached;
  76759. private _ratio;
  76760. private _bloomEnabled;
  76761. private _depthOfFieldEnabled;
  76762. private _vlsEnabled;
  76763. private _lensFlareEnabled;
  76764. private _hdrEnabled;
  76765. private _motionBlurEnabled;
  76766. private _fxaaEnabled;
  76767. private _screenSpaceReflectionsEnabled;
  76768. private _motionBlurSamples;
  76769. private _volumetricLightStepsCount;
  76770. private _samples;
  76771. /**
  76772. * @ignore
  76773. * Specifies if the bloom pipeline is enabled
  76774. */
  76775. get BloomEnabled(): boolean;
  76776. set BloomEnabled(enabled: boolean);
  76777. /**
  76778. * @ignore
  76779. * Specifies if the depth of field pipeline is enabled
  76780. */
  76781. get DepthOfFieldEnabled(): boolean;
  76782. set DepthOfFieldEnabled(enabled: boolean);
  76783. /**
  76784. * @ignore
  76785. * Specifies if the lens flare pipeline is enabled
  76786. */
  76787. get LensFlareEnabled(): boolean;
  76788. set LensFlareEnabled(enabled: boolean);
  76789. /**
  76790. * @ignore
  76791. * Specifies if the HDR pipeline is enabled
  76792. */
  76793. get HDREnabled(): boolean;
  76794. set HDREnabled(enabled: boolean);
  76795. /**
  76796. * @ignore
  76797. * Specifies if the volumetric lights scattering effect is enabled
  76798. */
  76799. get VLSEnabled(): boolean;
  76800. set VLSEnabled(enabled: boolean);
  76801. /**
  76802. * @ignore
  76803. * Specifies if the motion blur effect is enabled
  76804. */
  76805. get MotionBlurEnabled(): boolean;
  76806. set MotionBlurEnabled(enabled: boolean);
  76807. /**
  76808. * Specifies if anti-aliasing is enabled
  76809. */
  76810. get fxaaEnabled(): boolean;
  76811. set fxaaEnabled(enabled: boolean);
  76812. /**
  76813. * Specifies if screen space reflections are enabled.
  76814. */
  76815. get screenSpaceReflectionsEnabled(): boolean;
  76816. set screenSpaceReflectionsEnabled(enabled: boolean);
  76817. /**
  76818. * Specifies the number of steps used to calculate the volumetric lights
  76819. * Typically in interval [50, 200]
  76820. */
  76821. get volumetricLightStepsCount(): number;
  76822. set volumetricLightStepsCount(count: number);
  76823. /**
  76824. * Specifies the number of samples used for the motion blur effect
  76825. * Typically in interval [16, 64]
  76826. */
  76827. get motionBlurSamples(): number;
  76828. set motionBlurSamples(samples: number);
  76829. /**
  76830. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  76831. */
  76832. get samples(): number;
  76833. set samples(sampleCount: number);
  76834. /**
  76835. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76836. * @constructor
  76837. * @param name The rendering pipeline name
  76838. * @param scene The scene linked to this pipeline
  76839. * @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)
  76840. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  76841. * @param cameras The array of cameras that the rendering pipeline will be attached to
  76842. */
  76843. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  76844. private _buildPipeline;
  76845. private _createDownSampleX4PostProcess;
  76846. private _createBrightPassPostProcess;
  76847. private _createBlurPostProcesses;
  76848. private _createTextureAdderPostProcess;
  76849. private _createVolumetricLightPostProcess;
  76850. private _createLuminancePostProcesses;
  76851. private _createHdrPostProcess;
  76852. private _createLensFlarePostProcess;
  76853. private _createDepthOfFieldPostProcess;
  76854. private _createMotionBlurPostProcess;
  76855. private _getDepthTexture;
  76856. private _disposePostProcesses;
  76857. /**
  76858. * Dispose of the pipeline and stop all post processes
  76859. */
  76860. dispose(): void;
  76861. /**
  76862. * Serialize the rendering pipeline (Used when exporting)
  76863. * @returns the serialized object
  76864. */
  76865. serialize(): any;
  76866. /**
  76867. * Parse the serialized pipeline
  76868. * @param source Source pipeline.
  76869. * @param scene The scene to load the pipeline to.
  76870. * @param rootUrl The URL of the serialized pipeline.
  76871. * @returns An instantiated pipeline from the serialized object.
  76872. */
  76873. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  76874. /**
  76875. * Luminance steps
  76876. */
  76877. static LuminanceSteps: number;
  76878. }
  76879. }
  76880. declare module BABYLON {
  76881. /** @hidden */
  76882. export var tonemapPixelShader: {
  76883. name: string;
  76884. shader: string;
  76885. };
  76886. }
  76887. declare module BABYLON {
  76888. /** Defines operator used for tonemapping */
  76889. export enum TonemappingOperator {
  76890. /** Hable */
  76891. Hable = 0,
  76892. /** Reinhard */
  76893. Reinhard = 1,
  76894. /** HejiDawson */
  76895. HejiDawson = 2,
  76896. /** Photographic */
  76897. Photographic = 3
  76898. }
  76899. /**
  76900. * Defines a post process to apply tone mapping
  76901. */
  76902. export class TonemapPostProcess extends PostProcess {
  76903. private _operator;
  76904. /** Defines the required exposure adjustment */
  76905. exposureAdjustment: number;
  76906. /**
  76907. * Gets a string identifying the name of the class
  76908. * @returns "TonemapPostProcess" string
  76909. */
  76910. getClassName(): string;
  76911. /**
  76912. * Creates a new TonemapPostProcess
  76913. * @param name defines the name of the postprocess
  76914. * @param _operator defines the operator to use
  76915. * @param exposureAdjustment defines the required exposure adjustement
  76916. * @param camera defines the camera to use (can be null)
  76917. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  76918. * @param engine defines the hosting engine (can be ignore if camera is set)
  76919. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76920. */
  76921. constructor(name: string, _operator: TonemappingOperator,
  76922. /** Defines the required exposure adjustment */
  76923. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  76924. }
  76925. }
  76926. declare module BABYLON {
  76927. /** @hidden */
  76928. export var volumetricLightScatteringPixelShader: {
  76929. name: string;
  76930. shader: string;
  76931. };
  76932. }
  76933. declare module BABYLON {
  76934. /** @hidden */
  76935. export var volumetricLightScatteringPassVertexShader: {
  76936. name: string;
  76937. shader: string;
  76938. };
  76939. }
  76940. declare module BABYLON {
  76941. /** @hidden */
  76942. export var volumetricLightScatteringPassPixelShader: {
  76943. name: string;
  76944. shader: string;
  76945. };
  76946. }
  76947. declare module BABYLON {
  76948. /**
  76949. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  76950. */
  76951. export class VolumetricLightScatteringPostProcess extends PostProcess {
  76952. private _volumetricLightScatteringPass;
  76953. private _volumetricLightScatteringRTT;
  76954. private _viewPort;
  76955. private _screenCoordinates;
  76956. private _cachedDefines;
  76957. /**
  76958. * If not undefined, the mesh position is computed from the attached node position
  76959. */
  76960. attachedNode: {
  76961. position: Vector3;
  76962. };
  76963. /**
  76964. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  76965. */
  76966. customMeshPosition: Vector3;
  76967. /**
  76968. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  76969. */
  76970. useCustomMeshPosition: boolean;
  76971. /**
  76972. * If the post-process should inverse the light scattering direction
  76973. */
  76974. invert: boolean;
  76975. /**
  76976. * The internal mesh used by the post-process
  76977. */
  76978. mesh: Mesh;
  76979. /**
  76980. * @hidden
  76981. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  76982. */
  76983. get useDiffuseColor(): boolean;
  76984. set useDiffuseColor(useDiffuseColor: boolean);
  76985. /**
  76986. * Array containing the excluded meshes not rendered in the internal pass
  76987. */
  76988. excludedMeshes: AbstractMesh[];
  76989. /**
  76990. * Controls the overall intensity of the post-process
  76991. */
  76992. exposure: number;
  76993. /**
  76994. * Dissipates each sample's contribution in range [0, 1]
  76995. */
  76996. decay: number;
  76997. /**
  76998. * Controls the overall intensity of each sample
  76999. */
  77000. weight: number;
  77001. /**
  77002. * Controls the density of each sample
  77003. */
  77004. density: number;
  77005. /**
  77006. * @constructor
  77007. * @param name The post-process name
  77008. * @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)
  77009. * @param camera The camera that the post-process will be attached to
  77010. * @param mesh The mesh used to create the light scattering
  77011. * @param samples The post-process quality, default 100
  77012. * @param samplingModeThe post-process filtering mode
  77013. * @param engine The babylon engine
  77014. * @param reusable If the post-process is reusable
  77015. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  77016. */
  77017. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  77018. /**
  77019. * Returns the string "VolumetricLightScatteringPostProcess"
  77020. * @returns "VolumetricLightScatteringPostProcess"
  77021. */
  77022. getClassName(): string;
  77023. private _isReady;
  77024. /**
  77025. * Sets the new light position for light scattering effect
  77026. * @param position The new custom light position
  77027. */
  77028. setCustomMeshPosition(position: Vector3): void;
  77029. /**
  77030. * Returns the light position for light scattering effect
  77031. * @return Vector3 The custom light position
  77032. */
  77033. getCustomMeshPosition(): Vector3;
  77034. /**
  77035. * Disposes the internal assets and detaches the post-process from the camera
  77036. */
  77037. dispose(camera: Camera): void;
  77038. /**
  77039. * Returns the render target texture used by the post-process
  77040. * @return the render target texture used by the post-process
  77041. */
  77042. getPass(): RenderTargetTexture;
  77043. private _meshExcluded;
  77044. private _createPass;
  77045. private _updateMeshScreenCoordinates;
  77046. /**
  77047. * Creates a default mesh for the Volumeric Light Scattering post-process
  77048. * @param name The mesh name
  77049. * @param scene The scene where to create the mesh
  77050. * @return the default mesh
  77051. */
  77052. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  77053. }
  77054. }
  77055. declare module BABYLON {
  77056. /** @hidden */
  77057. export var screenSpaceCurvaturePixelShader: {
  77058. name: string;
  77059. shader: string;
  77060. };
  77061. }
  77062. declare module BABYLON {
  77063. /**
  77064. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  77065. */
  77066. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  77067. /**
  77068. * Defines how much ridge the curvature effect displays.
  77069. */
  77070. ridge: number;
  77071. /**
  77072. * Defines how much valley the curvature effect displays.
  77073. */
  77074. valley: number;
  77075. private _geometryBufferRenderer;
  77076. /**
  77077. * Gets a string identifying the name of the class
  77078. * @returns "ScreenSpaceCurvaturePostProcess" string
  77079. */
  77080. getClassName(): string;
  77081. /**
  77082. * Creates a new instance ScreenSpaceCurvaturePostProcess
  77083. * @param name The name of the effect.
  77084. * @param scene The scene containing the objects to blur according to their velocity.
  77085. * @param options The required width/height ratio to downsize to before computing the render pass.
  77086. * @param camera The camera to apply the render pass to.
  77087. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77088. * @param engine The engine which the post process will be applied. (default: current engine)
  77089. * @param reusable If the post process can be reused on the same frame. (default: false)
  77090. * @param textureType Type of textures used when performing the post process. (default: 0)
  77091. * @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)
  77092. */
  77093. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  77094. /**
  77095. * Support test.
  77096. */
  77097. static get IsSupported(): boolean;
  77098. /** @hidden */
  77099. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  77100. }
  77101. }
  77102. declare module BABYLON {
  77103. interface Scene {
  77104. /** @hidden (Backing field) */
  77105. _boundingBoxRenderer: BoundingBoxRenderer;
  77106. /** @hidden (Backing field) */
  77107. _forceShowBoundingBoxes: boolean;
  77108. /**
  77109. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  77110. */
  77111. forceShowBoundingBoxes: boolean;
  77112. /**
  77113. * Gets the bounding box renderer associated with the scene
  77114. * @returns a BoundingBoxRenderer
  77115. */
  77116. getBoundingBoxRenderer(): BoundingBoxRenderer;
  77117. }
  77118. interface AbstractMesh {
  77119. /** @hidden (Backing field) */
  77120. _showBoundingBox: boolean;
  77121. /**
  77122. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  77123. */
  77124. showBoundingBox: boolean;
  77125. }
  77126. /**
  77127. * Component responsible of rendering the bounding box of the meshes in a scene.
  77128. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  77129. */
  77130. export class BoundingBoxRenderer implements ISceneComponent {
  77131. /**
  77132. * The component name helpful to identify the component in the list of scene components.
  77133. */
  77134. readonly name: string;
  77135. /**
  77136. * The scene the component belongs to.
  77137. */
  77138. scene: Scene;
  77139. /**
  77140. * Color of the bounding box lines placed in front of an object
  77141. */
  77142. frontColor: Color3;
  77143. /**
  77144. * Color of the bounding box lines placed behind an object
  77145. */
  77146. backColor: Color3;
  77147. /**
  77148. * Defines if the renderer should show the back lines or not
  77149. */
  77150. showBackLines: boolean;
  77151. /**
  77152. * Observable raised before rendering a bounding box
  77153. */
  77154. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  77155. /**
  77156. * Observable raised after rendering a bounding box
  77157. */
  77158. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  77159. /**
  77160. * Observable raised after resources are created
  77161. */
  77162. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  77163. /**
  77164. * When false, no bounding boxes will be rendered
  77165. */
  77166. enabled: boolean;
  77167. /**
  77168. * @hidden
  77169. */
  77170. renderList: SmartArray<BoundingBox>;
  77171. private _colorShader;
  77172. private _vertexBuffers;
  77173. private _indexBuffer;
  77174. private _fillIndexBuffer;
  77175. private _fillIndexData;
  77176. /**
  77177. * Instantiates a new bounding box renderer in a scene.
  77178. * @param scene the scene the renderer renders in
  77179. */
  77180. constructor(scene: Scene);
  77181. /**
  77182. * Registers the component in a given scene
  77183. */
  77184. register(): void;
  77185. private _evaluateSubMesh;
  77186. private _preActiveMesh;
  77187. private _prepareResources;
  77188. private _createIndexBuffer;
  77189. /**
  77190. * Rebuilds the elements related to this component in case of
  77191. * context lost for instance.
  77192. */
  77193. rebuild(): void;
  77194. /**
  77195. * @hidden
  77196. */
  77197. reset(): void;
  77198. /**
  77199. * Render the bounding boxes of a specific rendering group
  77200. * @param renderingGroupId defines the rendering group to render
  77201. */
  77202. render(renderingGroupId: number): void;
  77203. /**
  77204. * In case of occlusion queries, we can render the occlusion bounding box through this method
  77205. * @param mesh Define the mesh to render the occlusion bounding box for
  77206. */
  77207. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  77208. /**
  77209. * Dispose and release the resources attached to this renderer.
  77210. */
  77211. dispose(): void;
  77212. }
  77213. }
  77214. declare module BABYLON {
  77215. interface Scene {
  77216. /** @hidden (Backing field) */
  77217. _depthRenderer: {
  77218. [id: string]: DepthRenderer;
  77219. };
  77220. /**
  77221. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  77222. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  77223. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  77224. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  77225. * @returns the created depth renderer
  77226. */
  77227. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  77228. /**
  77229. * Disables a depth renderer for a given camera
  77230. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  77231. */
  77232. disableDepthRenderer(camera?: Nullable<Camera>): void;
  77233. }
  77234. /**
  77235. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  77236. * in several rendering techniques.
  77237. */
  77238. export class DepthRendererSceneComponent implements ISceneComponent {
  77239. /**
  77240. * The component name helpful to identify the component in the list of scene components.
  77241. */
  77242. readonly name: string;
  77243. /**
  77244. * The scene the component belongs to.
  77245. */
  77246. scene: Scene;
  77247. /**
  77248. * Creates a new instance of the component for the given scene
  77249. * @param scene Defines the scene to register the component in
  77250. */
  77251. constructor(scene: Scene);
  77252. /**
  77253. * Registers the component in a given scene
  77254. */
  77255. register(): void;
  77256. /**
  77257. * Rebuilds the elements related to this component in case of
  77258. * context lost for instance.
  77259. */
  77260. rebuild(): void;
  77261. /**
  77262. * Disposes the component and the associated resources
  77263. */
  77264. dispose(): void;
  77265. private _gatherRenderTargets;
  77266. private _gatherActiveCameraRenderTargets;
  77267. }
  77268. }
  77269. declare module BABYLON {
  77270. interface AbstractScene {
  77271. /** @hidden (Backing field) */
  77272. _prePassRenderer: Nullable<PrePassRenderer>;
  77273. /**
  77274. * Gets or Sets the current prepass renderer associated to the scene.
  77275. */
  77276. prePassRenderer: Nullable<PrePassRenderer>;
  77277. /**
  77278. * Enables the prepass and associates it with the scene
  77279. * @returns the PrePassRenderer
  77280. */
  77281. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  77282. /**
  77283. * Disables the prepass associated with the scene
  77284. */
  77285. disablePrePassRenderer(): void;
  77286. }
  77287. interface RenderTargetTexture {
  77288. /** @hidden */
  77289. _prePassRenderTarget: PrePassRenderTarget;
  77290. }
  77291. /**
  77292. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  77293. * in several rendering techniques.
  77294. */
  77295. export class PrePassRendererSceneComponent implements ISceneComponent {
  77296. /**
  77297. * The component name helpful to identify the component in the list of scene components.
  77298. */
  77299. readonly name: string;
  77300. /**
  77301. * The scene the component belongs to.
  77302. */
  77303. scene: Scene;
  77304. /**
  77305. * Creates a new instance of the component for the given scene
  77306. * @param scene Defines the scene to register the component in
  77307. */
  77308. constructor(scene: Scene);
  77309. /**
  77310. * Registers the component in a given scene
  77311. */
  77312. register(): void;
  77313. private _beforeRenderTargetDraw;
  77314. private _afterRenderTargetDraw;
  77315. private _beforeRenderTargetClearStage;
  77316. private _beforeCameraDraw;
  77317. private _afterCameraDraw;
  77318. private _beforeClearStage;
  77319. private _beforeRenderingMeshStage;
  77320. private _afterRenderingMeshStage;
  77321. /**
  77322. * Rebuilds the elements related to this component in case of
  77323. * context lost for instance.
  77324. */
  77325. rebuild(): void;
  77326. /**
  77327. * Disposes the component and the associated resources
  77328. */
  77329. dispose(): void;
  77330. }
  77331. }
  77332. declare module BABYLON {
  77333. /** @hidden */
  77334. export var fibonacci: {
  77335. name: string;
  77336. shader: string;
  77337. };
  77338. }
  77339. declare module BABYLON {
  77340. /** @hidden */
  77341. export var diffusionProfile: {
  77342. name: string;
  77343. shader: string;
  77344. };
  77345. }
  77346. declare module BABYLON {
  77347. /** @hidden */
  77348. export var subSurfaceScatteringPixelShader: {
  77349. name: string;
  77350. shader: string;
  77351. };
  77352. }
  77353. declare module BABYLON {
  77354. /**
  77355. * Sub surface scattering post process
  77356. */
  77357. export class SubSurfaceScatteringPostProcess extends PostProcess {
  77358. /**
  77359. * Gets a string identifying the name of the class
  77360. * @returns "SubSurfaceScatteringPostProcess" string
  77361. */
  77362. getClassName(): string;
  77363. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  77364. }
  77365. }
  77366. declare module BABYLON {
  77367. /**
  77368. * Contains all parameters needed for the prepass to perform
  77369. * screen space subsurface scattering
  77370. */
  77371. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  77372. /** @hidden */
  77373. static _SceneComponentInitialization: (scene: Scene) => void;
  77374. private _ssDiffusionS;
  77375. private _ssFilterRadii;
  77376. private _ssDiffusionD;
  77377. /**
  77378. * Post process to attach for screen space subsurface scattering
  77379. */
  77380. postProcess: SubSurfaceScatteringPostProcess;
  77381. /**
  77382. * Diffusion profile color for subsurface scattering
  77383. */
  77384. get ssDiffusionS(): number[];
  77385. /**
  77386. * Diffusion profile max color channel value for subsurface scattering
  77387. */
  77388. get ssDiffusionD(): number[];
  77389. /**
  77390. * Diffusion profile filter radius for subsurface scattering
  77391. */
  77392. get ssFilterRadii(): number[];
  77393. /**
  77394. * Is subsurface enabled
  77395. */
  77396. enabled: boolean;
  77397. /**
  77398. * Does the output of this prepass need to go through imageprocessing
  77399. */
  77400. needsImageProcessing: boolean;
  77401. /**
  77402. * Name of the configuration
  77403. */
  77404. name: string;
  77405. /**
  77406. * Diffusion profile colors for subsurface scattering
  77407. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  77408. * See ...
  77409. * Note that you can only store up to 5 of them
  77410. */
  77411. ssDiffusionProfileColors: Color3[];
  77412. /**
  77413. * Defines the ratio real world => scene units.
  77414. * Used for subsurface scattering
  77415. */
  77416. metersPerUnit: number;
  77417. /**
  77418. * Textures that should be present in the MRT for this effect to work
  77419. */
  77420. readonly texturesRequired: number[];
  77421. private _scene;
  77422. /**
  77423. * Builds a subsurface configuration object
  77424. * @param scene The scene
  77425. */
  77426. constructor(scene: Scene);
  77427. /**
  77428. * Adds a new diffusion profile.
  77429. * Useful for more realistic subsurface scattering on diverse materials.
  77430. * @param color The color of the diffusion profile. Should be the average color of the material.
  77431. * @return The index of the diffusion profile for the material subsurface configuration
  77432. */
  77433. addDiffusionProfile(color: Color3): number;
  77434. /**
  77435. * Creates the sss post process
  77436. * @return The created post process
  77437. */
  77438. createPostProcess(): SubSurfaceScatteringPostProcess;
  77439. /**
  77440. * Deletes all diffusion profiles.
  77441. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  77442. */
  77443. clearAllDiffusionProfiles(): void;
  77444. /**
  77445. * Disposes this object
  77446. */
  77447. dispose(): void;
  77448. /**
  77449. * @hidden
  77450. * https://zero-radiance.github.io/post/sampling-diffusion/
  77451. *
  77452. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  77453. * ------------------------------------------------------------------------------------
  77454. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  77455. * PDF[r, phi, s] = r * R[r, phi, s]
  77456. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  77457. * ------------------------------------------------------------------------------------
  77458. * We importance sample the color channel with the widest scattering distance.
  77459. */
  77460. getDiffusionProfileParameters(color: Color3): number;
  77461. /**
  77462. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  77463. * 'u' is the random number (the value of the CDF): [0, 1).
  77464. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  77465. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  77466. */
  77467. private _sampleBurleyDiffusionProfile;
  77468. }
  77469. }
  77470. declare module BABYLON {
  77471. interface AbstractScene {
  77472. /** @hidden (Backing field) */
  77473. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  77474. /**
  77475. * Gets or Sets the current prepass renderer associated to the scene.
  77476. */
  77477. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  77478. /**
  77479. * Enables the subsurface effect for prepass
  77480. * @returns the SubSurfaceConfiguration
  77481. */
  77482. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  77483. /**
  77484. * Disables the subsurface effect for prepass
  77485. */
  77486. disableSubSurfaceForPrePass(): void;
  77487. }
  77488. /**
  77489. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  77490. * in several rendering techniques.
  77491. */
  77492. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  77493. /**
  77494. * The component name helpful to identify the component in the list of scene components.
  77495. */
  77496. readonly name: string;
  77497. /**
  77498. * The scene the component belongs to.
  77499. */
  77500. scene: Scene;
  77501. /**
  77502. * Creates a new instance of the component for the given scene
  77503. * @param scene Defines the scene to register the component in
  77504. */
  77505. constructor(scene: Scene);
  77506. /**
  77507. * Registers the component in a given scene
  77508. */
  77509. register(): void;
  77510. /**
  77511. * Serializes the component data to the specified json object
  77512. * @param serializationObject The object to serialize to
  77513. */
  77514. serialize(serializationObject: any): void;
  77515. /**
  77516. * Adds all the elements from the container to the scene
  77517. * @param container the container holding the elements
  77518. */
  77519. addFromContainer(container: AbstractScene): void;
  77520. /**
  77521. * Removes all the elements in the container from the scene
  77522. * @param container contains the elements to remove
  77523. * @param dispose if the removed element should be disposed (default: false)
  77524. */
  77525. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  77526. /**
  77527. * Rebuilds the elements related to this component in case of
  77528. * context lost for instance.
  77529. */
  77530. rebuild(): void;
  77531. /**
  77532. * Disposes the component and the associated resources
  77533. */
  77534. dispose(): void;
  77535. }
  77536. }
  77537. declare module BABYLON {
  77538. /** @hidden */
  77539. export var outlinePixelShader: {
  77540. name: string;
  77541. shader: string;
  77542. };
  77543. }
  77544. declare module BABYLON {
  77545. /** @hidden */
  77546. export var outlineVertexShader: {
  77547. name: string;
  77548. shader: string;
  77549. };
  77550. }
  77551. declare module BABYLON {
  77552. interface Scene {
  77553. /** @hidden */
  77554. _outlineRenderer: OutlineRenderer;
  77555. /**
  77556. * Gets the outline renderer associated with the scene
  77557. * @returns a OutlineRenderer
  77558. */
  77559. getOutlineRenderer(): OutlineRenderer;
  77560. }
  77561. interface AbstractMesh {
  77562. /** @hidden (Backing field) */
  77563. _renderOutline: boolean;
  77564. /**
  77565. * Gets or sets a boolean indicating if the outline must be rendered as well
  77566. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  77567. */
  77568. renderOutline: boolean;
  77569. /** @hidden (Backing field) */
  77570. _renderOverlay: boolean;
  77571. /**
  77572. * Gets or sets a boolean indicating if the overlay must be rendered as well
  77573. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  77574. */
  77575. renderOverlay: boolean;
  77576. }
  77577. /**
  77578. * This class is responsible to draw the outline/overlay of meshes.
  77579. * It should not be used directly but through the available method on mesh.
  77580. */
  77581. export class OutlineRenderer implements ISceneComponent {
  77582. /**
  77583. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  77584. */
  77585. private static _StencilReference;
  77586. /**
  77587. * The name of the component. Each component must have a unique name.
  77588. */
  77589. name: string;
  77590. /**
  77591. * The scene the component belongs to.
  77592. */
  77593. scene: Scene;
  77594. /**
  77595. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  77596. */
  77597. zOffset: number;
  77598. private _engine;
  77599. private _effect;
  77600. private _cachedDefines;
  77601. private _savedDepthWrite;
  77602. /**
  77603. * Instantiates a new outline renderer. (There could be only one per scene).
  77604. * @param scene Defines the scene it belongs to
  77605. */
  77606. constructor(scene: Scene);
  77607. /**
  77608. * Register the component to one instance of a scene.
  77609. */
  77610. register(): void;
  77611. /**
  77612. * Rebuilds the elements related to this component in case of
  77613. * context lost for instance.
  77614. */
  77615. rebuild(): void;
  77616. /**
  77617. * Disposes the component and the associated resources.
  77618. */
  77619. dispose(): void;
  77620. /**
  77621. * Renders the outline in the canvas.
  77622. * @param subMesh Defines the sumesh to render
  77623. * @param batch Defines the batch of meshes in case of instances
  77624. * @param useOverlay Defines if the rendering is for the overlay or the outline
  77625. */
  77626. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  77627. /**
  77628. * Returns whether or not the outline renderer is ready for a given submesh.
  77629. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  77630. * @param subMesh Defines the submesh to check readiness for
  77631. * @param useInstances Defines whether wee are trying to render instances or not
  77632. * @returns true if ready otherwise false
  77633. */
  77634. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77635. private _beforeRenderingMesh;
  77636. private _afterRenderingMesh;
  77637. }
  77638. }
  77639. declare module BABYLON {
  77640. /**
  77641. * Defines the basic options interface of a Sprite Frame Source Size.
  77642. */
  77643. export interface ISpriteJSONSpriteSourceSize {
  77644. /**
  77645. * number of the original width of the Frame
  77646. */
  77647. w: number;
  77648. /**
  77649. * number of the original height of the Frame
  77650. */
  77651. h: number;
  77652. }
  77653. /**
  77654. * Defines the basic options interface of a Sprite Frame Data.
  77655. */
  77656. export interface ISpriteJSONSpriteFrameData {
  77657. /**
  77658. * number of the x offset of the Frame
  77659. */
  77660. x: number;
  77661. /**
  77662. * number of the y offset of the Frame
  77663. */
  77664. y: number;
  77665. /**
  77666. * number of the width of the Frame
  77667. */
  77668. w: number;
  77669. /**
  77670. * number of the height of the Frame
  77671. */
  77672. h: number;
  77673. }
  77674. /**
  77675. * Defines the basic options interface of a JSON Sprite.
  77676. */
  77677. export interface ISpriteJSONSprite {
  77678. /**
  77679. * string name of the Frame
  77680. */
  77681. filename: string;
  77682. /**
  77683. * ISpriteJSONSpriteFrame basic object of the frame data
  77684. */
  77685. frame: ISpriteJSONSpriteFrameData;
  77686. /**
  77687. * boolean to flag is the frame was rotated.
  77688. */
  77689. rotated: boolean;
  77690. /**
  77691. * boolean to flag is the frame was trimmed.
  77692. */
  77693. trimmed: boolean;
  77694. /**
  77695. * ISpriteJSONSpriteFrame basic object of the source data
  77696. */
  77697. spriteSourceSize: ISpriteJSONSpriteFrameData;
  77698. /**
  77699. * ISpriteJSONSpriteFrame basic object of the source data
  77700. */
  77701. sourceSize: ISpriteJSONSpriteSourceSize;
  77702. }
  77703. /**
  77704. * Defines the basic options interface of a JSON atlas.
  77705. */
  77706. export interface ISpriteJSONAtlas {
  77707. /**
  77708. * Array of objects that contain the frame data.
  77709. */
  77710. frames: Array<ISpriteJSONSprite>;
  77711. /**
  77712. * object basic object containing the sprite meta data.
  77713. */
  77714. meta?: object;
  77715. }
  77716. }
  77717. declare module BABYLON {
  77718. /** @hidden */
  77719. export var spriteMapPixelShader: {
  77720. name: string;
  77721. shader: string;
  77722. };
  77723. }
  77724. declare module BABYLON {
  77725. /** @hidden */
  77726. export var spriteMapVertexShader: {
  77727. name: string;
  77728. shader: string;
  77729. };
  77730. }
  77731. declare module BABYLON {
  77732. /**
  77733. * Defines the basic options interface of a SpriteMap
  77734. */
  77735. export interface ISpriteMapOptions {
  77736. /**
  77737. * Vector2 of the number of cells in the grid.
  77738. */
  77739. stageSize?: Vector2;
  77740. /**
  77741. * Vector2 of the size of the output plane in World Units.
  77742. */
  77743. outputSize?: Vector2;
  77744. /**
  77745. * Vector3 of the position of the output plane in World Units.
  77746. */
  77747. outputPosition?: Vector3;
  77748. /**
  77749. * Vector3 of the rotation of the output plane.
  77750. */
  77751. outputRotation?: Vector3;
  77752. /**
  77753. * number of layers that the system will reserve in resources.
  77754. */
  77755. layerCount?: number;
  77756. /**
  77757. * number of max animation frames a single cell will reserve in resources.
  77758. */
  77759. maxAnimationFrames?: number;
  77760. /**
  77761. * number cell index of the base tile when the system compiles.
  77762. */
  77763. baseTile?: number;
  77764. /**
  77765. * boolean flip the sprite after its been repositioned by the framing data.
  77766. */
  77767. flipU?: boolean;
  77768. /**
  77769. * Vector3 scalar of the global RGB values of the SpriteMap.
  77770. */
  77771. colorMultiply?: Vector3;
  77772. }
  77773. /**
  77774. * Defines the IDisposable interface in order to be cleanable from resources.
  77775. */
  77776. export interface ISpriteMap extends IDisposable {
  77777. /**
  77778. * String name of the SpriteMap.
  77779. */
  77780. name: string;
  77781. /**
  77782. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  77783. */
  77784. atlasJSON: ISpriteJSONAtlas;
  77785. /**
  77786. * Texture of the SpriteMap.
  77787. */
  77788. spriteSheet: Texture;
  77789. /**
  77790. * The parameters to initialize the SpriteMap with.
  77791. */
  77792. options: ISpriteMapOptions;
  77793. }
  77794. /**
  77795. * Class used to manage a grid restricted sprite deployment on an Output plane.
  77796. */
  77797. export class SpriteMap implements ISpriteMap {
  77798. /** The Name of the spriteMap */
  77799. name: string;
  77800. /** The JSON file with the frame and meta data */
  77801. atlasJSON: ISpriteJSONAtlas;
  77802. /** The systems Sprite Sheet Texture */
  77803. spriteSheet: Texture;
  77804. /** Arguments passed with the Constructor */
  77805. options: ISpriteMapOptions;
  77806. /** Public Sprite Storage array, parsed from atlasJSON */
  77807. sprites: Array<ISpriteJSONSprite>;
  77808. /** Returns the Number of Sprites in the System */
  77809. get spriteCount(): number;
  77810. /** Returns the Position of Output Plane*/
  77811. get position(): Vector3;
  77812. /** Returns the Position of Output Plane*/
  77813. set position(v: Vector3);
  77814. /** Returns the Rotation of Output Plane*/
  77815. get rotation(): Vector3;
  77816. /** Returns the Rotation of Output Plane*/
  77817. set rotation(v: Vector3);
  77818. /** Sets the AnimationMap*/
  77819. get animationMap(): RawTexture;
  77820. /** Sets the AnimationMap*/
  77821. set animationMap(v: RawTexture);
  77822. /** Scene that the SpriteMap was created in */
  77823. private _scene;
  77824. /** Texture Buffer of Float32 that holds tile frame data*/
  77825. private _frameMap;
  77826. /** Texture Buffers of Float32 that holds tileMap data*/
  77827. private _tileMaps;
  77828. /** Texture Buffer of Float32 that holds Animation Data*/
  77829. private _animationMap;
  77830. /** Custom ShaderMaterial Central to the System*/
  77831. private _material;
  77832. /** Custom ShaderMaterial Central to the System*/
  77833. private _output;
  77834. /** Systems Time Ticker*/
  77835. private _time;
  77836. /**
  77837. * Creates a new SpriteMap
  77838. * @param name defines the SpriteMaps Name
  77839. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  77840. * @param spriteSheet is the Texture that the Sprites are on.
  77841. * @param options a basic deployment configuration
  77842. * @param scene The Scene that the map is deployed on
  77843. */
  77844. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  77845. /**
  77846. * Returns tileID location
  77847. * @returns Vector2 the cell position ID
  77848. */
  77849. getTileID(): Vector2;
  77850. /**
  77851. * Gets the UV location of the mouse over the SpriteMap.
  77852. * @returns Vector2 the UV position of the mouse interaction
  77853. */
  77854. getMousePosition(): Vector2;
  77855. /**
  77856. * Creates the "frame" texture Buffer
  77857. * -------------------------------------
  77858. * Structure of frames
  77859. * "filename": "Falling-Water-2.png",
  77860. * "frame": {"x":69,"y":103,"w":24,"h":32},
  77861. * "rotated": true,
  77862. * "trimmed": true,
  77863. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  77864. * "sourceSize": {"w":32,"h":32}
  77865. * @returns RawTexture of the frameMap
  77866. */
  77867. private _createFrameBuffer;
  77868. /**
  77869. * Creates the tileMap texture Buffer
  77870. * @param buffer normally and array of numbers, or a false to generate from scratch
  77871. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  77872. * @returns RawTexture of the tileMap
  77873. */
  77874. private _createTileBuffer;
  77875. /**
  77876. * Modifies the data of the tileMaps
  77877. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  77878. * @param pos is the iVector2 Coordinates of the Tile
  77879. * @param tile The SpriteIndex of the new Tile
  77880. */
  77881. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  77882. /**
  77883. * Creates the animationMap texture Buffer
  77884. * @param buffer normally and array of numbers, or a false to generate from scratch
  77885. * @returns RawTexture of the animationMap
  77886. */
  77887. private _createTileAnimationBuffer;
  77888. /**
  77889. * Modifies the data of the animationMap
  77890. * @param cellID is the Index of the Sprite
  77891. * @param _frame is the target Animation frame
  77892. * @param toCell is the Target Index of the next frame of the animation
  77893. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  77894. * @param speed is a global scalar of the time variable on the map.
  77895. */
  77896. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  77897. /**
  77898. * Exports the .tilemaps file
  77899. */
  77900. saveTileMaps(): void;
  77901. /**
  77902. * Imports the .tilemaps file
  77903. * @param url of the .tilemaps file
  77904. */
  77905. loadTileMaps(url: string): void;
  77906. /**
  77907. * Release associated resources
  77908. */
  77909. dispose(): void;
  77910. }
  77911. }
  77912. declare module BABYLON {
  77913. /**
  77914. * Class used to manage multiple sprites of different sizes on the same spritesheet
  77915. * @see https://doc.babylonjs.com/babylon101/sprites
  77916. */
  77917. export class SpritePackedManager extends SpriteManager {
  77918. /** defines the packed manager's name */
  77919. name: string;
  77920. /**
  77921. * Creates a new sprite manager from a packed sprite sheet
  77922. * @param name defines the manager's name
  77923. * @param imgUrl defines the sprite sheet url
  77924. * @param capacity defines the maximum allowed number of sprites
  77925. * @param scene defines the hosting scene
  77926. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  77927. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77928. * @param samplingMode defines the sampling mode to use with spritesheet
  77929. * @param fromPacked set to true; do not alter
  77930. */
  77931. constructor(
  77932. /** defines the packed manager's name */
  77933. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  77934. }
  77935. }
  77936. declare module BABYLON {
  77937. /**
  77938. * Defines the list of states available for a task inside a AssetsManager
  77939. */
  77940. export enum AssetTaskState {
  77941. /**
  77942. * Initialization
  77943. */
  77944. INIT = 0,
  77945. /**
  77946. * Running
  77947. */
  77948. RUNNING = 1,
  77949. /**
  77950. * Done
  77951. */
  77952. DONE = 2,
  77953. /**
  77954. * Error
  77955. */
  77956. ERROR = 3
  77957. }
  77958. /**
  77959. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  77960. */
  77961. export abstract class AbstractAssetTask {
  77962. /**
  77963. * Task name
  77964. */ name: string;
  77965. /**
  77966. * Callback called when the task is successful
  77967. */
  77968. onSuccess: (task: any) => void;
  77969. /**
  77970. * Callback called when the task is not successful
  77971. */
  77972. onError: (task: any, message?: string, exception?: any) => void;
  77973. /**
  77974. * Creates a new AssetsManager
  77975. * @param name defines the name of the task
  77976. */
  77977. constructor(
  77978. /**
  77979. * Task name
  77980. */ name: string);
  77981. private _isCompleted;
  77982. private _taskState;
  77983. private _errorObject;
  77984. /**
  77985. * Get if the task is completed
  77986. */
  77987. get isCompleted(): boolean;
  77988. /**
  77989. * Gets the current state of the task
  77990. */
  77991. get taskState(): AssetTaskState;
  77992. /**
  77993. * Gets the current error object (if task is in error)
  77994. */
  77995. get errorObject(): {
  77996. message?: string;
  77997. exception?: any;
  77998. };
  77999. /**
  78000. * Internal only
  78001. * @hidden
  78002. */
  78003. _setErrorObject(message?: string, exception?: any): void;
  78004. /**
  78005. * Execute the current task
  78006. * @param scene defines the scene where you want your assets to be loaded
  78007. * @param onSuccess is a callback called when the task is successfully executed
  78008. * @param onError is a callback called if an error occurs
  78009. */
  78010. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78011. /**
  78012. * Execute the current task
  78013. * @param scene defines the scene where you want your assets to be loaded
  78014. * @param onSuccess is a callback called when the task is successfully executed
  78015. * @param onError is a callback called if an error occurs
  78016. */
  78017. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78018. /**
  78019. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  78020. * This can be used with failed tasks that have the reason for failure fixed.
  78021. */
  78022. reset(): void;
  78023. private onErrorCallback;
  78024. private onDoneCallback;
  78025. }
  78026. /**
  78027. * Define the interface used by progress events raised during assets loading
  78028. */
  78029. export interface IAssetsProgressEvent {
  78030. /**
  78031. * Defines the number of remaining tasks to process
  78032. */
  78033. remainingCount: number;
  78034. /**
  78035. * Defines the total number of tasks
  78036. */
  78037. totalCount: number;
  78038. /**
  78039. * Defines the task that was just processed
  78040. */
  78041. task: AbstractAssetTask;
  78042. }
  78043. /**
  78044. * Class used to share progress information about assets loading
  78045. */
  78046. export class AssetsProgressEvent implements IAssetsProgressEvent {
  78047. /**
  78048. * Defines the number of remaining tasks to process
  78049. */
  78050. remainingCount: number;
  78051. /**
  78052. * Defines the total number of tasks
  78053. */
  78054. totalCount: number;
  78055. /**
  78056. * Defines the task that was just processed
  78057. */
  78058. task: AbstractAssetTask;
  78059. /**
  78060. * Creates a AssetsProgressEvent
  78061. * @param remainingCount defines the number of remaining tasks to process
  78062. * @param totalCount defines the total number of tasks
  78063. * @param task defines the task that was just processed
  78064. */
  78065. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  78066. }
  78067. /**
  78068. * Define a task used by AssetsManager to load assets into a container
  78069. */
  78070. export class ContainerAssetTask extends AbstractAssetTask {
  78071. /**
  78072. * Defines the name of the task
  78073. */
  78074. name: string;
  78075. /**
  78076. * Defines the list of mesh's names you want to load
  78077. */
  78078. meshesNames: any;
  78079. /**
  78080. * Defines the root url to use as a base to load your meshes and associated resources
  78081. */
  78082. rootUrl: string;
  78083. /**
  78084. * Defines the filename or File of the scene to load from
  78085. */
  78086. sceneFilename: string | File;
  78087. /**
  78088. * Get the loaded asset container
  78089. */
  78090. loadedContainer: AssetContainer;
  78091. /**
  78092. * Gets the list of loaded meshes
  78093. */
  78094. loadedMeshes: Array<AbstractMesh>;
  78095. /**
  78096. * Gets the list of loaded particle systems
  78097. */
  78098. loadedParticleSystems: Array<IParticleSystem>;
  78099. /**
  78100. * Gets the list of loaded skeletons
  78101. */
  78102. loadedSkeletons: Array<Skeleton>;
  78103. /**
  78104. * Gets the list of loaded animation groups
  78105. */
  78106. loadedAnimationGroups: Array<AnimationGroup>;
  78107. /**
  78108. * Callback called when the task is successful
  78109. */
  78110. onSuccess: (task: ContainerAssetTask) => void;
  78111. /**
  78112. * Callback called when the task is successful
  78113. */
  78114. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  78115. /**
  78116. * Creates a new ContainerAssetTask
  78117. * @param name defines the name of the task
  78118. * @param meshesNames defines the list of mesh's names you want to load
  78119. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  78120. * @param sceneFilename defines the filename or File of the scene to load from
  78121. */
  78122. constructor(
  78123. /**
  78124. * Defines the name of the task
  78125. */
  78126. name: string,
  78127. /**
  78128. * Defines the list of mesh's names you want to load
  78129. */
  78130. meshesNames: any,
  78131. /**
  78132. * Defines the root url to use as a base to load your meshes and associated resources
  78133. */
  78134. rootUrl: string,
  78135. /**
  78136. * Defines the filename or File of the scene to load from
  78137. */
  78138. sceneFilename: string | File);
  78139. /**
  78140. * Execute the current task
  78141. * @param scene defines the scene where you want your assets to be loaded
  78142. * @param onSuccess is a callback called when the task is successfully executed
  78143. * @param onError is a callback called if an error occurs
  78144. */
  78145. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78146. }
  78147. /**
  78148. * Define a task used by AssetsManager to load meshes
  78149. */
  78150. export class MeshAssetTask extends AbstractAssetTask {
  78151. /**
  78152. * Defines the name of the task
  78153. */
  78154. name: string;
  78155. /**
  78156. * Defines the list of mesh's names you want to load
  78157. */
  78158. meshesNames: any;
  78159. /**
  78160. * Defines the root url to use as a base to load your meshes and associated resources
  78161. */
  78162. rootUrl: string;
  78163. /**
  78164. * Defines the filename or File of the scene to load from
  78165. */
  78166. sceneFilename: string | File;
  78167. /**
  78168. * Gets the list of loaded meshes
  78169. */
  78170. loadedMeshes: Array<AbstractMesh>;
  78171. /**
  78172. * Gets the list of loaded particle systems
  78173. */
  78174. loadedParticleSystems: Array<IParticleSystem>;
  78175. /**
  78176. * Gets the list of loaded skeletons
  78177. */
  78178. loadedSkeletons: Array<Skeleton>;
  78179. /**
  78180. * Gets the list of loaded animation groups
  78181. */
  78182. loadedAnimationGroups: Array<AnimationGroup>;
  78183. /**
  78184. * Callback called when the task is successful
  78185. */
  78186. onSuccess: (task: MeshAssetTask) => void;
  78187. /**
  78188. * Callback called when the task is successful
  78189. */
  78190. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  78191. /**
  78192. * Creates a new MeshAssetTask
  78193. * @param name defines the name of the task
  78194. * @param meshesNames defines the list of mesh's names you want to load
  78195. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  78196. * @param sceneFilename defines the filename or File of the scene to load from
  78197. */
  78198. constructor(
  78199. /**
  78200. * Defines the name of the task
  78201. */
  78202. name: string,
  78203. /**
  78204. * Defines the list of mesh's names you want to load
  78205. */
  78206. meshesNames: any,
  78207. /**
  78208. * Defines the root url to use as a base to load your meshes and associated resources
  78209. */
  78210. rootUrl: string,
  78211. /**
  78212. * Defines the filename or File of the scene to load from
  78213. */
  78214. sceneFilename: string | File);
  78215. /**
  78216. * Execute the current task
  78217. * @param scene defines the scene where you want your assets to be loaded
  78218. * @param onSuccess is a callback called when the task is successfully executed
  78219. * @param onError is a callback called if an error occurs
  78220. */
  78221. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78222. }
  78223. /**
  78224. * Define a task used by AssetsManager to load text content
  78225. */
  78226. export class TextFileAssetTask extends AbstractAssetTask {
  78227. /**
  78228. * Defines the name of the task
  78229. */
  78230. name: string;
  78231. /**
  78232. * Defines the location of the file to load
  78233. */
  78234. url: string;
  78235. /**
  78236. * Gets the loaded text string
  78237. */
  78238. text: string;
  78239. /**
  78240. * Callback called when the task is successful
  78241. */
  78242. onSuccess: (task: TextFileAssetTask) => void;
  78243. /**
  78244. * Callback called when the task is successful
  78245. */
  78246. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  78247. /**
  78248. * Creates a new TextFileAssetTask object
  78249. * @param name defines the name of the task
  78250. * @param url defines the location of the file to load
  78251. */
  78252. constructor(
  78253. /**
  78254. * Defines the name of the task
  78255. */
  78256. name: string,
  78257. /**
  78258. * Defines the location of the file to load
  78259. */
  78260. url: string);
  78261. /**
  78262. * Execute the current task
  78263. * @param scene defines the scene where you want your assets to be loaded
  78264. * @param onSuccess is a callback called when the task is successfully executed
  78265. * @param onError is a callback called if an error occurs
  78266. */
  78267. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78268. }
  78269. /**
  78270. * Define a task used by AssetsManager to load binary data
  78271. */
  78272. export class BinaryFileAssetTask extends AbstractAssetTask {
  78273. /**
  78274. * Defines the name of the task
  78275. */
  78276. name: string;
  78277. /**
  78278. * Defines the location of the file to load
  78279. */
  78280. url: string;
  78281. /**
  78282. * Gets the lodaded data (as an array buffer)
  78283. */
  78284. data: ArrayBuffer;
  78285. /**
  78286. * Callback called when the task is successful
  78287. */
  78288. onSuccess: (task: BinaryFileAssetTask) => void;
  78289. /**
  78290. * Callback called when the task is successful
  78291. */
  78292. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  78293. /**
  78294. * Creates a new BinaryFileAssetTask object
  78295. * @param name defines the name of the new task
  78296. * @param url defines the location of the file to load
  78297. */
  78298. constructor(
  78299. /**
  78300. * Defines the name of the task
  78301. */
  78302. name: string,
  78303. /**
  78304. * Defines the location of the file to load
  78305. */
  78306. url: string);
  78307. /**
  78308. * Execute the current task
  78309. * @param scene defines the scene where you want your assets to be loaded
  78310. * @param onSuccess is a callback called when the task is successfully executed
  78311. * @param onError is a callback called if an error occurs
  78312. */
  78313. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78314. }
  78315. /**
  78316. * Define a task used by AssetsManager to load images
  78317. */
  78318. export class ImageAssetTask extends AbstractAssetTask {
  78319. /**
  78320. * Defines the name of the task
  78321. */
  78322. name: string;
  78323. /**
  78324. * Defines the location of the image to load
  78325. */
  78326. url: string;
  78327. /**
  78328. * Gets the loaded images
  78329. */
  78330. image: HTMLImageElement;
  78331. /**
  78332. * Callback called when the task is successful
  78333. */
  78334. onSuccess: (task: ImageAssetTask) => void;
  78335. /**
  78336. * Callback called when the task is successful
  78337. */
  78338. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  78339. /**
  78340. * Creates a new ImageAssetTask
  78341. * @param name defines the name of the task
  78342. * @param url defines the location of the image to load
  78343. */
  78344. constructor(
  78345. /**
  78346. * Defines the name of the task
  78347. */
  78348. name: string,
  78349. /**
  78350. * Defines the location of the image to load
  78351. */
  78352. url: string);
  78353. /**
  78354. * Execute the current task
  78355. * @param scene defines the scene where you want your assets to be loaded
  78356. * @param onSuccess is a callback called when the task is successfully executed
  78357. * @param onError is a callback called if an error occurs
  78358. */
  78359. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78360. }
  78361. /**
  78362. * Defines the interface used by texture loading tasks
  78363. */
  78364. export interface ITextureAssetTask<TEX extends BaseTexture> {
  78365. /**
  78366. * Gets the loaded texture
  78367. */
  78368. texture: TEX;
  78369. }
  78370. /**
  78371. * Define a task used by AssetsManager to load 2D textures
  78372. */
  78373. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  78374. /**
  78375. * Defines the name of the task
  78376. */
  78377. name: string;
  78378. /**
  78379. * Defines the location of the file to load
  78380. */
  78381. url: string;
  78382. /**
  78383. * Defines if mipmap should not be generated (default is false)
  78384. */
  78385. noMipmap?: boolean | undefined;
  78386. /**
  78387. * Defines if texture must be inverted on Y axis (default is true)
  78388. */
  78389. invertY: boolean;
  78390. /**
  78391. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78392. */
  78393. samplingMode: number;
  78394. /**
  78395. * Gets the loaded texture
  78396. */
  78397. texture: Texture;
  78398. /**
  78399. * Callback called when the task is successful
  78400. */
  78401. onSuccess: (task: TextureAssetTask) => void;
  78402. /**
  78403. * Callback called when the task is successful
  78404. */
  78405. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  78406. /**
  78407. * Creates a new TextureAssetTask object
  78408. * @param name defines the name of the task
  78409. * @param url defines the location of the file to load
  78410. * @param noMipmap defines if mipmap should not be generated (default is false)
  78411. * @param invertY defines if texture must be inverted on Y axis (default is true)
  78412. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78413. */
  78414. constructor(
  78415. /**
  78416. * Defines the name of the task
  78417. */
  78418. name: string,
  78419. /**
  78420. * Defines the location of the file to load
  78421. */
  78422. url: string,
  78423. /**
  78424. * Defines if mipmap should not be generated (default is false)
  78425. */
  78426. noMipmap?: boolean | undefined,
  78427. /**
  78428. * Defines if texture must be inverted on Y axis (default is true)
  78429. */
  78430. invertY?: boolean,
  78431. /**
  78432. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78433. */
  78434. samplingMode?: number);
  78435. /**
  78436. * Execute the current task
  78437. * @param scene defines the scene where you want your assets to be loaded
  78438. * @param onSuccess is a callback called when the task is successfully executed
  78439. * @param onError is a callback called if an error occurs
  78440. */
  78441. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78442. }
  78443. /**
  78444. * Define a task used by AssetsManager to load cube textures
  78445. */
  78446. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  78447. /**
  78448. * Defines the name of the task
  78449. */
  78450. name: string;
  78451. /**
  78452. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78453. */
  78454. url: string;
  78455. /**
  78456. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78457. */
  78458. extensions?: string[] | undefined;
  78459. /**
  78460. * Defines if mipmaps should not be generated (default is false)
  78461. */
  78462. noMipmap?: boolean | undefined;
  78463. /**
  78464. * Defines the explicit list of files (undefined by default)
  78465. */
  78466. files?: string[] | undefined;
  78467. /**
  78468. * Gets the loaded texture
  78469. */
  78470. texture: CubeTexture;
  78471. /**
  78472. * Callback called when the task is successful
  78473. */
  78474. onSuccess: (task: CubeTextureAssetTask) => void;
  78475. /**
  78476. * Callback called when the task is successful
  78477. */
  78478. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  78479. /**
  78480. * Creates a new CubeTextureAssetTask
  78481. * @param name defines the name of the task
  78482. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78483. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78484. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78485. * @param files defines the explicit list of files (undefined by default)
  78486. */
  78487. constructor(
  78488. /**
  78489. * Defines the name of the task
  78490. */
  78491. name: string,
  78492. /**
  78493. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78494. */
  78495. url: string,
  78496. /**
  78497. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78498. */
  78499. extensions?: string[] | undefined,
  78500. /**
  78501. * Defines if mipmaps should not be generated (default is false)
  78502. */
  78503. noMipmap?: boolean | undefined,
  78504. /**
  78505. * Defines the explicit list of files (undefined by default)
  78506. */
  78507. files?: string[] | undefined);
  78508. /**
  78509. * Execute the current task
  78510. * @param scene defines the scene where you want your assets to be loaded
  78511. * @param onSuccess is a callback called when the task is successfully executed
  78512. * @param onError is a callback called if an error occurs
  78513. */
  78514. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78515. }
  78516. /**
  78517. * Define a task used by AssetsManager to load HDR cube textures
  78518. */
  78519. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  78520. /**
  78521. * Defines the name of the task
  78522. */
  78523. name: string;
  78524. /**
  78525. * Defines the location of the file to load
  78526. */
  78527. url: string;
  78528. /**
  78529. * Defines the desired size (the more it increases the longer the generation will be)
  78530. */
  78531. size: number;
  78532. /**
  78533. * Defines if mipmaps should not be generated (default is false)
  78534. */
  78535. noMipmap: boolean;
  78536. /**
  78537. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78538. */
  78539. generateHarmonics: boolean;
  78540. /**
  78541. * 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)
  78542. */
  78543. gammaSpace: boolean;
  78544. /**
  78545. * Internal Use Only
  78546. */
  78547. reserved: boolean;
  78548. /**
  78549. * Gets the loaded texture
  78550. */
  78551. texture: HDRCubeTexture;
  78552. /**
  78553. * Callback called when the task is successful
  78554. */
  78555. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  78556. /**
  78557. * Callback called when the task is successful
  78558. */
  78559. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  78560. /**
  78561. * Creates a new HDRCubeTextureAssetTask object
  78562. * @param name defines the name of the task
  78563. * @param url defines the location of the file to load
  78564. * @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.
  78565. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78566. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78567. * @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)
  78568. * @param reserved Internal use only
  78569. */
  78570. constructor(
  78571. /**
  78572. * Defines the name of the task
  78573. */
  78574. name: string,
  78575. /**
  78576. * Defines the location of the file to load
  78577. */
  78578. url: string,
  78579. /**
  78580. * Defines the desired size (the more it increases the longer the generation will be)
  78581. */
  78582. size: number,
  78583. /**
  78584. * Defines if mipmaps should not be generated (default is false)
  78585. */
  78586. noMipmap?: boolean,
  78587. /**
  78588. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78589. */
  78590. generateHarmonics?: boolean,
  78591. /**
  78592. * 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)
  78593. */
  78594. gammaSpace?: boolean,
  78595. /**
  78596. * Internal Use Only
  78597. */
  78598. reserved?: boolean);
  78599. /**
  78600. * Execute the current task
  78601. * @param scene defines the scene where you want your assets to be loaded
  78602. * @param onSuccess is a callback called when the task is successfully executed
  78603. * @param onError is a callback called if an error occurs
  78604. */
  78605. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78606. }
  78607. /**
  78608. * Define a task used by AssetsManager to load Equirectangular cube textures
  78609. */
  78610. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  78611. /**
  78612. * Defines the name of the task
  78613. */
  78614. name: string;
  78615. /**
  78616. * Defines the location of the file to load
  78617. */
  78618. url: string;
  78619. /**
  78620. * Defines the desired size (the more it increases the longer the generation will be)
  78621. */
  78622. size: number;
  78623. /**
  78624. * Defines if mipmaps should not be generated (default is false)
  78625. */
  78626. noMipmap: boolean;
  78627. /**
  78628. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78629. * but the standard material would require them in Gamma space) (default is true)
  78630. */
  78631. gammaSpace: boolean;
  78632. /**
  78633. * Gets the loaded texture
  78634. */
  78635. texture: EquiRectangularCubeTexture;
  78636. /**
  78637. * Callback called when the task is successful
  78638. */
  78639. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  78640. /**
  78641. * Callback called when the task is successful
  78642. */
  78643. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  78644. /**
  78645. * Creates a new EquiRectangularCubeTextureAssetTask object
  78646. * @param name defines the name of the task
  78647. * @param url defines the location of the file to load
  78648. * @param size defines the desired size (the more it increases the longer the generation will be)
  78649. * If the size is omitted this implies you are using a preprocessed cubemap.
  78650. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78651. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  78652. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  78653. * (default is true)
  78654. */
  78655. constructor(
  78656. /**
  78657. * Defines the name of the task
  78658. */
  78659. name: string,
  78660. /**
  78661. * Defines the location of the file to load
  78662. */
  78663. url: string,
  78664. /**
  78665. * Defines the desired size (the more it increases the longer the generation will be)
  78666. */
  78667. size: number,
  78668. /**
  78669. * Defines if mipmaps should not be generated (default is false)
  78670. */
  78671. noMipmap?: boolean,
  78672. /**
  78673. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78674. * but the standard material would require them in Gamma space) (default is true)
  78675. */
  78676. gammaSpace?: boolean);
  78677. /**
  78678. * Execute the current task
  78679. * @param scene defines the scene where you want your assets to be loaded
  78680. * @param onSuccess is a callback called when the task is successfully executed
  78681. * @param onError is a callback called if an error occurs
  78682. */
  78683. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78684. }
  78685. /**
  78686. * This class can be used to easily import assets into a scene
  78687. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  78688. */
  78689. export class AssetsManager {
  78690. private _scene;
  78691. private _isLoading;
  78692. protected _tasks: AbstractAssetTask[];
  78693. protected _waitingTasksCount: number;
  78694. protected _totalTasksCount: number;
  78695. /**
  78696. * Callback called when all tasks are processed
  78697. */
  78698. onFinish: (tasks: AbstractAssetTask[]) => void;
  78699. /**
  78700. * Callback called when a task is successful
  78701. */
  78702. onTaskSuccess: (task: AbstractAssetTask) => void;
  78703. /**
  78704. * Callback called when a task had an error
  78705. */
  78706. onTaskError: (task: AbstractAssetTask) => void;
  78707. /**
  78708. * Callback called when a task is done (whatever the result is)
  78709. */
  78710. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  78711. /**
  78712. * Observable called when all tasks are processed
  78713. */
  78714. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  78715. /**
  78716. * Observable called when a task had an error
  78717. */
  78718. onTaskErrorObservable: Observable<AbstractAssetTask>;
  78719. /**
  78720. * Observable called when all tasks were executed
  78721. */
  78722. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  78723. /**
  78724. * Observable called when a task is done (whatever the result is)
  78725. */
  78726. onProgressObservable: Observable<IAssetsProgressEvent>;
  78727. /**
  78728. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  78729. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  78730. */
  78731. useDefaultLoadingScreen: boolean;
  78732. /**
  78733. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  78734. * when all assets have been downloaded.
  78735. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  78736. */
  78737. autoHideLoadingUI: boolean;
  78738. /**
  78739. * Creates a new AssetsManager
  78740. * @param scene defines the scene to work on
  78741. */
  78742. constructor(scene: Scene);
  78743. /**
  78744. * Add a ContainerAssetTask 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 ContainerAssetTask object
  78750. */
  78751. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  78752. /**
  78753. * Add a MeshAssetTask to the list of active tasks
  78754. * @param taskName defines the name of the new task
  78755. * @param meshesNames defines the name of meshes to load
  78756. * @param rootUrl defines the root url to use to locate files
  78757. * @param sceneFilename defines the filename of the scene file
  78758. * @returns a new MeshAssetTask object
  78759. */
  78760. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  78761. /**
  78762. * Add a TextFileAssetTask to the list of active tasks
  78763. * @param taskName defines the name of the new task
  78764. * @param url defines the url of the file to load
  78765. * @returns a new TextFileAssetTask object
  78766. */
  78767. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  78768. /**
  78769. * Add a BinaryFileAssetTask to the list of active tasks
  78770. * @param taskName defines the name of the new task
  78771. * @param url defines the url of the file to load
  78772. * @returns a new BinaryFileAssetTask object
  78773. */
  78774. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  78775. /**
  78776. * Add a ImageAssetTask to the list of active tasks
  78777. * @param taskName defines the name of the new task
  78778. * @param url defines the url of the file to load
  78779. * @returns a new ImageAssetTask object
  78780. */
  78781. addImageTask(taskName: string, url: string): ImageAssetTask;
  78782. /**
  78783. * Add a TextureAssetTask to the list of active tasks
  78784. * @param taskName defines the name of the new task
  78785. * @param url defines the url of the file to load
  78786. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78787. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  78788. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  78789. * @returns a new TextureAssetTask object
  78790. */
  78791. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  78792. /**
  78793. * Add a CubeTextureAssetTask to the list of active tasks
  78794. * @param taskName defines the name of the new task
  78795. * @param url defines the url of the file to load
  78796. * @param extensions defines the extension to use to load the cube map (can be null)
  78797. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78798. * @param files defines the list of files to load (can be null)
  78799. * @returns a new CubeTextureAssetTask object
  78800. */
  78801. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  78802. /**
  78803. *
  78804. * Add a HDRCubeTextureAssetTask to the list of active tasks
  78805. * @param taskName defines the name of the new task
  78806. * @param url defines the url of the file to load
  78807. * @param size defines the size you want for the cubemap (can be null)
  78808. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78809. * @param generateHarmonics defines if you want to automatically generate (true by default)
  78810. * @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)
  78811. * @param reserved Internal use only
  78812. * @returns a new HDRCubeTextureAssetTask object
  78813. */
  78814. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  78815. /**
  78816. *
  78817. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  78818. * @param taskName defines the name of the new task
  78819. * @param url defines the url of the file to load
  78820. * @param size defines the size you want for the cubemap (can be null)
  78821. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78822. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  78823. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  78824. * @returns a new EquiRectangularCubeTextureAssetTask object
  78825. */
  78826. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  78827. /**
  78828. * Remove a task from the assets manager.
  78829. * @param task the task to remove
  78830. */
  78831. removeTask(task: AbstractAssetTask): void;
  78832. private _decreaseWaitingTasksCount;
  78833. private _runTask;
  78834. /**
  78835. * Reset the AssetsManager and remove all tasks
  78836. * @return the current instance of the AssetsManager
  78837. */
  78838. reset(): AssetsManager;
  78839. /**
  78840. * Start the loading process
  78841. * @return the current instance of the AssetsManager
  78842. */
  78843. load(): AssetsManager;
  78844. /**
  78845. * Start the loading process as an async operation
  78846. * @return a promise returning the list of failed tasks
  78847. */
  78848. loadAsync(): Promise<void>;
  78849. }
  78850. }
  78851. declare module BABYLON {
  78852. /**
  78853. * Wrapper class for promise with external resolve and reject.
  78854. */
  78855. export class Deferred<T> {
  78856. /**
  78857. * The promise associated with this deferred object.
  78858. */
  78859. readonly promise: Promise<T>;
  78860. private _resolve;
  78861. private _reject;
  78862. /**
  78863. * The resolve method of the promise associated with this deferred object.
  78864. */
  78865. get resolve(): (value: T | PromiseLike<T>) => void;
  78866. /**
  78867. * The reject method of the promise associated with this deferred object.
  78868. */
  78869. get reject(): (reason?: any) => void;
  78870. /**
  78871. * Constructor for this deferred object.
  78872. */
  78873. constructor();
  78874. }
  78875. }
  78876. declare module BABYLON {
  78877. /**
  78878. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  78879. */
  78880. export class MeshExploder {
  78881. private _centerMesh;
  78882. private _meshes;
  78883. private _meshesOrigins;
  78884. private _toCenterVectors;
  78885. private _scaledDirection;
  78886. private _newPosition;
  78887. private _centerPosition;
  78888. /**
  78889. * Explodes meshes from a center mesh.
  78890. * @param meshes The meshes to explode.
  78891. * @param centerMesh The mesh to be center of explosion.
  78892. */
  78893. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  78894. private _setCenterMesh;
  78895. /**
  78896. * Get class name
  78897. * @returns "MeshExploder"
  78898. */
  78899. getClassName(): string;
  78900. /**
  78901. * "Exploded meshes"
  78902. * @returns Array of meshes with the centerMesh at index 0.
  78903. */
  78904. getMeshes(): Array<Mesh>;
  78905. /**
  78906. * Explodes meshes giving a specific direction
  78907. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  78908. */
  78909. explode(direction?: number): void;
  78910. }
  78911. }
  78912. declare module BABYLON {
  78913. /**
  78914. * Class used to help managing file picking and drag'n'drop
  78915. */
  78916. export class FilesInput {
  78917. /**
  78918. * List of files ready to be loaded
  78919. */
  78920. static get FilesToLoad(): {
  78921. [key: string]: File;
  78922. };
  78923. /**
  78924. * Callback called when a file is processed
  78925. */
  78926. onProcessFileCallback: (file: File, name: string, extension: string, setSceneFileToLoad: (sceneFile: File) => void) => boolean;
  78927. /**
  78928. * Function used when loading the scene file
  78929. */
  78930. loadAsync: (sceneFile: File, onProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>) => Promise<Scene>;
  78931. private _engine;
  78932. private _currentScene;
  78933. private _sceneLoadedCallback;
  78934. private _progressCallback;
  78935. private _additionalRenderLoopLogicCallback;
  78936. private _textureLoadingCallback;
  78937. private _startingProcessingFilesCallback;
  78938. private _onReloadCallback;
  78939. private _errorCallback;
  78940. private _elementToMonitor;
  78941. private _sceneFileToLoad;
  78942. private _filesToLoad;
  78943. /**
  78944. * Creates a new FilesInput
  78945. * @param engine defines the rendering engine
  78946. * @param scene defines the hosting scene
  78947. * @param sceneLoadedCallback callback called when scene is loaded
  78948. * @param progressCallback callback called to track progress
  78949. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  78950. * @param textureLoadingCallback callback called when a texture is loading
  78951. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  78952. * @param onReloadCallback callback called when a reload is requested
  78953. * @param errorCallback callback call if an error occurs
  78954. */
  78955. 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>);
  78956. private _dragEnterHandler;
  78957. private _dragOverHandler;
  78958. private _dropHandler;
  78959. /**
  78960. * Calls this function to listen to drag'n'drop events on a specific DOM element
  78961. * @param elementToMonitor defines the DOM element to track
  78962. */
  78963. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  78964. /** Gets the current list of files to load */
  78965. get filesToLoad(): File[];
  78966. /**
  78967. * Release all associated resources
  78968. */
  78969. dispose(): void;
  78970. private renderFunction;
  78971. private drag;
  78972. private drop;
  78973. private _traverseFolder;
  78974. private _processFiles;
  78975. /**
  78976. * Load files from a drop event
  78977. * @param event defines the drop event to use as source
  78978. */
  78979. loadFiles(event: any): void;
  78980. private _processReload;
  78981. /**
  78982. * Reload the current scene from the loaded files
  78983. */
  78984. reload(): void;
  78985. }
  78986. }
  78987. declare module BABYLON {
  78988. /**
  78989. * Defines the root class used to create scene optimization to use with SceneOptimizer
  78990. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78991. */
  78992. export class SceneOptimization {
  78993. /**
  78994. * Defines the priority of this optimization (0 by default which means first in the list)
  78995. */
  78996. priority: number;
  78997. /**
  78998. * Gets a string describing the action executed by the current optimization
  78999. * @returns description string
  79000. */
  79001. getDescription(): string;
  79002. /**
  79003. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79004. * @param scene defines the current scene where to apply this optimization
  79005. * @param optimizer defines the current optimizer
  79006. * @returns true if everything that can be done was applied
  79007. */
  79008. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79009. /**
  79010. * Creates the SceneOptimization object
  79011. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  79012. * @param desc defines the description associated with the optimization
  79013. */
  79014. constructor(
  79015. /**
  79016. * Defines the priority of this optimization (0 by default which means first in the list)
  79017. */
  79018. priority?: number);
  79019. }
  79020. /**
  79021. * Defines an optimization used to reduce the size of render target textures
  79022. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79023. */
  79024. export class TextureOptimization extends SceneOptimization {
  79025. /**
  79026. * Defines the priority of this optimization (0 by default which means first in the list)
  79027. */
  79028. priority: number;
  79029. /**
  79030. * 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
  79031. */
  79032. maximumSize: number;
  79033. /**
  79034. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  79035. */
  79036. step: number;
  79037. /**
  79038. * Gets a string describing the action executed by the current optimization
  79039. * @returns description string
  79040. */
  79041. getDescription(): string;
  79042. /**
  79043. * Creates the TextureOptimization object
  79044. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  79045. * @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
  79046. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  79047. */
  79048. constructor(
  79049. /**
  79050. * Defines the priority of this optimization (0 by default which means first in the list)
  79051. */
  79052. priority?: number,
  79053. /**
  79054. * 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
  79055. */
  79056. maximumSize?: number,
  79057. /**
  79058. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  79059. */
  79060. step?: number);
  79061. /**
  79062. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79063. * @param scene defines the current scene where to apply this optimization
  79064. * @param optimizer defines the current optimizer
  79065. * @returns true if everything that can be done was applied
  79066. */
  79067. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79068. }
  79069. /**
  79070. * Defines an optimization used to increase or decrease the rendering resolution
  79071. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79072. */
  79073. export class HardwareScalingOptimization extends SceneOptimization {
  79074. /**
  79075. * Defines the priority of this optimization (0 by default which means first in the list)
  79076. */
  79077. priority: number;
  79078. /**
  79079. * Defines the maximum scale to use (2 by default)
  79080. */
  79081. maximumScale: number;
  79082. /**
  79083. * Defines the step to use between two passes (0.5 by default)
  79084. */
  79085. step: number;
  79086. private _currentScale;
  79087. private _directionOffset;
  79088. /**
  79089. * Gets a string describing the action executed by the current optimization
  79090. * @return description string
  79091. */
  79092. getDescription(): string;
  79093. /**
  79094. * Creates the HardwareScalingOptimization object
  79095. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  79096. * @param maximumScale defines the maximum scale to use (2 by default)
  79097. * @param step defines the step to use between two passes (0.5 by default)
  79098. */
  79099. constructor(
  79100. /**
  79101. * Defines the priority of this optimization (0 by default which means first in the list)
  79102. */
  79103. priority?: number,
  79104. /**
  79105. * Defines the maximum scale to use (2 by default)
  79106. */
  79107. maximumScale?: number,
  79108. /**
  79109. * Defines the step to use between two passes (0.5 by default)
  79110. */
  79111. step?: number);
  79112. /**
  79113. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79114. * @param scene defines the current scene where to apply this optimization
  79115. * @param optimizer defines the current optimizer
  79116. * @returns true if everything that can be done was applied
  79117. */
  79118. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79119. }
  79120. /**
  79121. * Defines an optimization used to remove shadows
  79122. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79123. */
  79124. export class ShadowsOptimization extends SceneOptimization {
  79125. /**
  79126. * Gets a string describing the action executed by the current optimization
  79127. * @return description string
  79128. */
  79129. getDescription(): string;
  79130. /**
  79131. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79132. * @param scene defines the current scene where to apply this optimization
  79133. * @param optimizer defines the current optimizer
  79134. * @returns true if everything that can be done was applied
  79135. */
  79136. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79137. }
  79138. /**
  79139. * Defines an optimization used to turn post-processes off
  79140. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79141. */
  79142. export class PostProcessesOptimization extends SceneOptimization {
  79143. /**
  79144. * Gets a string describing the action executed by the current optimization
  79145. * @return description string
  79146. */
  79147. getDescription(): string;
  79148. /**
  79149. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79150. * @param scene defines the current scene where to apply this optimization
  79151. * @param optimizer defines the current optimizer
  79152. * @returns true if everything that can be done was applied
  79153. */
  79154. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79155. }
  79156. /**
  79157. * Defines an optimization used to turn lens flares off
  79158. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79159. */
  79160. export class LensFlaresOptimization extends SceneOptimization {
  79161. /**
  79162. * Gets a string describing the action executed by the current optimization
  79163. * @return description string
  79164. */
  79165. getDescription(): string;
  79166. /**
  79167. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79168. * @param scene defines the current scene where to apply this optimization
  79169. * @param optimizer defines the current optimizer
  79170. * @returns true if everything that can be done was applied
  79171. */
  79172. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79173. }
  79174. /**
  79175. * Defines an optimization based on user defined callback.
  79176. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79177. */
  79178. export class CustomOptimization extends SceneOptimization {
  79179. /**
  79180. * Callback called to apply the custom optimization.
  79181. */
  79182. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  79183. /**
  79184. * Callback called to get custom description
  79185. */
  79186. onGetDescription: () => string;
  79187. /**
  79188. * Gets a string describing the action executed by the current optimization
  79189. * @returns description string
  79190. */
  79191. getDescription(): string;
  79192. /**
  79193. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79194. * @param scene defines the current scene where to apply this optimization
  79195. * @param optimizer defines the current optimizer
  79196. * @returns true if everything that can be done was applied
  79197. */
  79198. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79199. }
  79200. /**
  79201. * Defines an optimization used to turn particles off
  79202. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79203. */
  79204. export class ParticlesOptimization extends SceneOptimization {
  79205. /**
  79206. * Gets a string describing the action executed by the current optimization
  79207. * @return description string
  79208. */
  79209. getDescription(): string;
  79210. /**
  79211. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79212. * @param scene defines the current scene where to apply this optimization
  79213. * @param optimizer defines the current optimizer
  79214. * @returns true if everything that can be done was applied
  79215. */
  79216. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79217. }
  79218. /**
  79219. * Defines an optimization used to turn render targets off
  79220. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79221. */
  79222. export class RenderTargetsOptimization extends SceneOptimization {
  79223. /**
  79224. * Gets a string describing the action executed by the current optimization
  79225. * @return description string
  79226. */
  79227. getDescription(): string;
  79228. /**
  79229. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79230. * @param scene defines the current scene where to apply this optimization
  79231. * @param optimizer defines the current optimizer
  79232. * @returns true if everything that can be done was applied
  79233. */
  79234. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79235. }
  79236. /**
  79237. * Defines an optimization used to merge meshes with compatible materials
  79238. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79239. */
  79240. export class MergeMeshesOptimization extends SceneOptimization {
  79241. private static _UpdateSelectionTree;
  79242. /**
  79243. * Gets or sets a boolean which defines if optimization octree has to be updated
  79244. */
  79245. static get UpdateSelectionTree(): boolean;
  79246. /**
  79247. * Gets or sets a boolean which defines if optimization octree has to be updated
  79248. */
  79249. static set UpdateSelectionTree(value: boolean);
  79250. /**
  79251. * Gets a string describing the action executed by the current optimization
  79252. * @return description string
  79253. */
  79254. getDescription(): string;
  79255. private _canBeMerged;
  79256. /**
  79257. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79258. * @param scene defines the current scene where to apply this optimization
  79259. * @param optimizer defines the current optimizer
  79260. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  79261. * @returns true if everything that can be done was applied
  79262. */
  79263. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  79264. }
  79265. /**
  79266. * Defines a list of options used by SceneOptimizer
  79267. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79268. */
  79269. export class SceneOptimizerOptions {
  79270. /**
  79271. * Defines the target frame rate to reach (60 by default)
  79272. */
  79273. targetFrameRate: number;
  79274. /**
  79275. * Defines the interval between two checks (2000ms by default)
  79276. */
  79277. trackerDuration: number;
  79278. /**
  79279. * Gets the list of optimizations to apply
  79280. */
  79281. optimizations: SceneOptimization[];
  79282. /**
  79283. * Creates a new list of options used by SceneOptimizer
  79284. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  79285. * @param trackerDuration defines the interval between two checks (2000ms by default)
  79286. */
  79287. constructor(
  79288. /**
  79289. * Defines the target frame rate to reach (60 by default)
  79290. */
  79291. targetFrameRate?: number,
  79292. /**
  79293. * Defines the interval between two checks (2000ms by default)
  79294. */
  79295. trackerDuration?: number);
  79296. /**
  79297. * Add a new optimization
  79298. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  79299. * @returns the current SceneOptimizerOptions
  79300. */
  79301. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  79302. /**
  79303. * Add a new custom optimization
  79304. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  79305. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  79306. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  79307. * @returns the current SceneOptimizerOptions
  79308. */
  79309. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  79310. /**
  79311. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  79312. * @param targetFrameRate defines the target frame rate (60 by default)
  79313. * @returns a SceneOptimizerOptions object
  79314. */
  79315. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79316. /**
  79317. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  79318. * @param targetFrameRate defines the target frame rate (60 by default)
  79319. * @returns a SceneOptimizerOptions object
  79320. */
  79321. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79322. /**
  79323. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  79324. * @param targetFrameRate defines the target frame rate (60 by default)
  79325. * @returns a SceneOptimizerOptions object
  79326. */
  79327. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79328. }
  79329. /**
  79330. * Class used to run optimizations in order to reach a target frame rate
  79331. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79332. */
  79333. export class SceneOptimizer implements IDisposable {
  79334. private _isRunning;
  79335. private _options;
  79336. private _scene;
  79337. private _currentPriorityLevel;
  79338. private _targetFrameRate;
  79339. private _trackerDuration;
  79340. private _currentFrameRate;
  79341. private _sceneDisposeObserver;
  79342. private _improvementMode;
  79343. /**
  79344. * Defines an observable called when the optimizer reaches the target frame rate
  79345. */
  79346. onSuccessObservable: Observable<SceneOptimizer>;
  79347. /**
  79348. * Defines an observable called when the optimizer enables an optimization
  79349. */
  79350. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  79351. /**
  79352. * Defines an observable called when the optimizer is not able to reach the target frame rate
  79353. */
  79354. onFailureObservable: Observable<SceneOptimizer>;
  79355. /**
  79356. * Gets a boolean indicating if the optimizer is in improvement mode
  79357. */
  79358. get isInImprovementMode(): boolean;
  79359. /**
  79360. * Gets the current priority level (0 at start)
  79361. */
  79362. get currentPriorityLevel(): number;
  79363. /**
  79364. * Gets the current frame rate checked by the SceneOptimizer
  79365. */
  79366. get currentFrameRate(): number;
  79367. /**
  79368. * Gets or sets the current target frame rate (60 by default)
  79369. */
  79370. get targetFrameRate(): number;
  79371. /**
  79372. * Gets or sets the current target frame rate (60 by default)
  79373. */
  79374. set targetFrameRate(value: number);
  79375. /**
  79376. * Gets or sets the current interval between two checks (every 2000ms by default)
  79377. */
  79378. get trackerDuration(): number;
  79379. /**
  79380. * Gets or sets the current interval between two checks (every 2000ms by default)
  79381. */
  79382. set trackerDuration(value: number);
  79383. /**
  79384. * Gets the list of active optimizations
  79385. */
  79386. get optimizations(): SceneOptimization[];
  79387. /**
  79388. * Creates a new SceneOptimizer
  79389. * @param scene defines the scene to work on
  79390. * @param options defines the options to use with the SceneOptimizer
  79391. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  79392. * @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)
  79393. */
  79394. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  79395. /**
  79396. * Stops the current optimizer
  79397. */
  79398. stop(): void;
  79399. /**
  79400. * Reset the optimizer to initial step (current priority level = 0)
  79401. */
  79402. reset(): void;
  79403. /**
  79404. * Start the optimizer. By default it will try to reach a specific framerate
  79405. * but if the optimizer is set with improvementMode === true then it will run all optimization while frame rate is above the target frame rate
  79406. */
  79407. start(): void;
  79408. private _checkCurrentState;
  79409. /**
  79410. * Release all resources
  79411. */
  79412. dispose(): void;
  79413. /**
  79414. * Helper function to create a SceneOptimizer with one single line of code
  79415. * @param scene defines the scene to work on
  79416. * @param options defines the options to use with the SceneOptimizer
  79417. * @param onSuccess defines a callback to call on success
  79418. * @param onFailure defines a callback to call on failure
  79419. * @returns the new SceneOptimizer object
  79420. */
  79421. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  79422. }
  79423. }
  79424. declare module BABYLON {
  79425. /**
  79426. * Class used to serialize a scene into a string
  79427. */
  79428. export class SceneSerializer {
  79429. /**
  79430. * Clear cache used by a previous serialization
  79431. */
  79432. static ClearCache(): void;
  79433. /**
  79434. * Serialize a scene into a JSON compatible object
  79435. * Note that if the current engine does not support synchronous texture reading (like WebGPU), you should use SerializeAsync instead
  79436. * as else you may not retrieve the proper base64 encoded texture data (when using the Texture.ForceSerializeBuffers flag)
  79437. * @param scene defines the scene to serialize
  79438. * @returns a JSON compatible object
  79439. */
  79440. static Serialize(scene: Scene): any;
  79441. private static _Serialize;
  79442. /**
  79443. * Serialize a scene into a JSON compatible object
  79444. * @param scene defines the scene to serialize
  79445. * @returns a JSON promise compatible object
  79446. */
  79447. static SerializeAsync(scene: Scene): Promise<any>;
  79448. private static _CollectPromises;
  79449. /**
  79450. * Serialize a mesh into a JSON compatible object
  79451. * @param toSerialize defines the mesh to serialize
  79452. * @param withParents defines if parents must be serialized as well
  79453. * @param withChildren defines if children must be serialized as well
  79454. * @returns a JSON compatible object
  79455. */
  79456. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  79457. }
  79458. }
  79459. declare module BABYLON {
  79460. /**
  79461. * This represents the different options available for the video capture.
  79462. */
  79463. export interface VideoRecorderOptions {
  79464. /** Defines the mime type of the video. */
  79465. mimeType: string;
  79466. /** Defines the FPS the video should be recorded at. */
  79467. fps: number;
  79468. /** Defines the chunk size for the recording data. */
  79469. recordChunckSize: number;
  79470. /** The audio tracks to attach to the recording. */
  79471. audioTracks?: MediaStreamTrack[];
  79472. }
  79473. /**
  79474. * This can help with recording videos from BabylonJS.
  79475. * This is based on the available WebRTC functionalities of the browser.
  79476. *
  79477. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  79478. */
  79479. export class VideoRecorder {
  79480. private static readonly _defaultOptions;
  79481. /**
  79482. * Returns whether or not the VideoRecorder is available in your browser.
  79483. * @param engine Defines the Babylon Engine.
  79484. * @returns true if supported otherwise false.
  79485. */
  79486. static IsSupported(engine: Engine): boolean;
  79487. private readonly _options;
  79488. private _canvas;
  79489. private _mediaRecorder;
  79490. private _recordedChunks;
  79491. private _fileName;
  79492. private _resolve;
  79493. private _reject;
  79494. /**
  79495. * True when a recording is already in progress.
  79496. */
  79497. get isRecording(): boolean;
  79498. /**
  79499. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  79500. * @param engine Defines the BabylonJS Engine you wish to record.
  79501. * @param options Defines options that can be used to customize the capture.
  79502. */
  79503. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  79504. /**
  79505. * Stops the current recording before the default capture timeout passed in the startRecording function.
  79506. */
  79507. stopRecording(): void;
  79508. /**
  79509. * Starts recording the canvas for a max duration specified in parameters.
  79510. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  79511. * If null no automatic download will start and you can rely on the promise to get the data back.
  79512. * @param maxDuration Defines the maximum recording time in seconds.
  79513. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  79514. * @return A promise callback at the end of the recording with the video data in Blob.
  79515. */
  79516. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  79517. /**
  79518. * Releases internal resources used during the recording.
  79519. */
  79520. dispose(): void;
  79521. private _handleDataAvailable;
  79522. private _handleError;
  79523. private _handleStop;
  79524. }
  79525. }
  79526. declare module BABYLON {
  79527. /**
  79528. * Class containing a set of static utilities functions for screenshots
  79529. */
  79530. export class ScreenshotTools {
  79531. /**
  79532. * Captures a screenshot of the current rendering
  79533. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79534. * @param engine defines the rendering engine
  79535. * @param camera defines the source camera
  79536. * @param size This parameter can be set to a single number or to an object with the
  79537. * following (optional) properties: precision, width, height. If a single number is passed,
  79538. * it will be used for both width and height. If an object is passed, the screenshot size
  79539. * will be derived from the parameters. The precision property is a multiplier allowing
  79540. * rendering at a higher or lower resolution
  79541. * @param successCallback defines the callback receives a single parameter which contains the
  79542. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79543. * src parameter of an <img> to display it
  79544. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79545. * Check your browser for supported MIME types
  79546. * @param forceDownload force the system to download the image even if a successCallback is provided
  79547. */
  79548. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, forceDownload?: boolean): void;
  79549. /**
  79550. * Captures a screenshot of the current rendering
  79551. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79552. * @param engine defines the rendering engine
  79553. * @param camera defines the source camera
  79554. * @param size This parameter can be set to a single number or to an object with the
  79555. * following (optional) properties: precision, width, height. If a single number is passed,
  79556. * it will be used for both width and height. If an object is passed, the screenshot size
  79557. * will be derived from the parameters. The precision property is a multiplier allowing
  79558. * rendering at a higher or lower resolution
  79559. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79560. * Check your browser for supported MIME types
  79561. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79562. * to the src parameter of an <img> to display it
  79563. */
  79564. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  79565. /**
  79566. * 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)
  79567. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79568. * @param engine defines the rendering engine
  79569. * @param camera defines the source camera
  79570. * @param width defines the expected width
  79571. * @param height defines the expected height
  79572. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79573. * Check your browser for supported MIME types
  79574. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79575. * to the src parameter of an <img> to display it
  79576. */
  79577. static CreateScreenshotWithResizeAsync(engine: Engine, camera: Camera, width: number, height: number, mimeType?: string): Promise<void>;
  79578. /**
  79579. * Generates an image screenshot from the specified camera.
  79580. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79581. * @param engine The engine to use for rendering
  79582. * @param camera The camera to use for rendering
  79583. * @param size This parameter can be set to a single number or to an object with the
  79584. * following (optional) properties: precision, width, height. If a single number is passed,
  79585. * it will be used for both width and height. If an object is passed, the screenshot size
  79586. * will be derived from the parameters. The precision property is a multiplier allowing
  79587. * rendering at a higher or lower resolution
  79588. * @param successCallback The callback receives a single parameter which contains the
  79589. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79590. * src parameter of an <img> to display it
  79591. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79592. * Check your browser for supported MIME types
  79593. * @param samples Texture samples (default: 1)
  79594. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79595. * @param fileName A name for for the downloaded file.
  79596. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79597. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  79598. */
  79599. 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;
  79600. /**
  79601. * Generates an image screenshot from the specified camera.
  79602. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79603. * @param engine The engine to use for rendering
  79604. * @param camera The camera to use for rendering
  79605. * @param size This parameter can be set to a single number or to an object with the
  79606. * following (optional) properties: precision, width, height. If a single number is passed,
  79607. * it will be used for both width and height. If an object is passed, the screenshot size
  79608. * will be derived from the parameters. The precision property is a multiplier allowing
  79609. * rendering at a higher or lower resolution
  79610. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79611. * Check your browser for supported MIME types
  79612. * @param samples Texture samples (default: 1)
  79613. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79614. * @param fileName A name for for the downloaded file.
  79615. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79616. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79617. * to the src parameter of an <img> to display it
  79618. */
  79619. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  79620. /**
  79621. * Gets height and width for screenshot size
  79622. * @private
  79623. */
  79624. private static _getScreenshotSize;
  79625. }
  79626. }
  79627. declare module BABYLON {
  79628. /**
  79629. * Interface for a data buffer
  79630. */
  79631. export interface IDataBuffer {
  79632. /**
  79633. * Reads bytes from the data buffer.
  79634. * @param byteOffset The byte offset to read
  79635. * @param byteLength The byte length to read
  79636. * @returns A promise that resolves when the bytes are read
  79637. */
  79638. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  79639. /**
  79640. * The byte length of the buffer.
  79641. */
  79642. readonly byteLength: number;
  79643. }
  79644. /**
  79645. * Utility class for reading from a data buffer
  79646. */
  79647. export class DataReader {
  79648. /**
  79649. * The data buffer associated with this data reader.
  79650. */
  79651. readonly buffer: IDataBuffer;
  79652. /**
  79653. * The current byte offset from the beginning of the data buffer.
  79654. */
  79655. byteOffset: number;
  79656. private _dataView;
  79657. private _dataByteOffset;
  79658. /**
  79659. * Constructor
  79660. * @param buffer The buffer to read
  79661. */
  79662. constructor(buffer: IDataBuffer);
  79663. /**
  79664. * Loads the given byte length.
  79665. * @param byteLength The byte length to load
  79666. * @returns A promise that resolves when the load is complete
  79667. */
  79668. loadAsync(byteLength: number): Promise<void>;
  79669. /**
  79670. * Read a unsigned 32-bit integer from the currently loaded data range.
  79671. * @returns The 32-bit integer read
  79672. */
  79673. readUint32(): number;
  79674. /**
  79675. * Read a byte array from the currently loaded data range.
  79676. * @param byteLength The byte length to read
  79677. * @returns The byte array read
  79678. */
  79679. readUint8Array(byteLength: number): Uint8Array;
  79680. /**
  79681. * Read a string from the currently loaded data range.
  79682. * @param byteLength The byte length to read
  79683. * @returns The string read
  79684. */
  79685. readString(byteLength: number): string;
  79686. /**
  79687. * Skips the given byte length the currently loaded data range.
  79688. * @param byteLength The byte length to skip
  79689. */
  79690. skipBytes(byteLength: number): void;
  79691. }
  79692. }
  79693. declare module BABYLON {
  79694. /**
  79695. * Class for storing data to local storage if available or in-memory storage otherwise
  79696. */
  79697. export class DataStorage {
  79698. private static _Storage;
  79699. private static _GetStorage;
  79700. /**
  79701. * Reads a string from the data storage
  79702. * @param key The key to read
  79703. * @param defaultValue The value if the key doesn't exist
  79704. * @returns The string value
  79705. */
  79706. static ReadString(key: string, defaultValue: string): string;
  79707. /**
  79708. * Writes a string to the data storage
  79709. * @param key The key to write
  79710. * @param value The value to write
  79711. */
  79712. static WriteString(key: string, value: string): void;
  79713. /**
  79714. * Reads a boolean from the data storage
  79715. * @param key The key to read
  79716. * @param defaultValue The value if the key doesn't exist
  79717. * @returns The boolean value
  79718. */
  79719. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  79720. /**
  79721. * Writes a boolean to the data storage
  79722. * @param key The key to write
  79723. * @param value The value to write
  79724. */
  79725. static WriteBoolean(key: string, value: boolean): void;
  79726. /**
  79727. * Reads a number from the data storage
  79728. * @param key The key to read
  79729. * @param defaultValue The value if the key doesn't exist
  79730. * @returns The number value
  79731. */
  79732. static ReadNumber(key: string, defaultValue: number): number;
  79733. /**
  79734. * Writes a number to the data storage
  79735. * @param key The key to write
  79736. * @param value The value to write
  79737. */
  79738. static WriteNumber(key: string, value: number): void;
  79739. }
  79740. }
  79741. declare module BABYLON {
  79742. /**
  79743. * Class used to record delta files between 2 scene states
  79744. */
  79745. export class SceneRecorder {
  79746. private _trackedScene;
  79747. private _savedJSON;
  79748. /**
  79749. * Track a given scene. This means the current scene state will be considered the original state
  79750. * @param scene defines the scene to track
  79751. */
  79752. track(scene: Scene): void;
  79753. /**
  79754. * Get the delta between current state and original state
  79755. * @returns a any containing the delta
  79756. */
  79757. getDelta(): any;
  79758. private _compareArray;
  79759. private _compareObjects;
  79760. private _compareCollections;
  79761. private static GetShadowGeneratorById;
  79762. /**
  79763. * Apply a given delta to a given scene
  79764. * @param deltaJSON defines the JSON containing the delta
  79765. * @param scene defines the scene to apply the delta to
  79766. */
  79767. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  79768. private static _ApplyPropertiesToEntity;
  79769. private static _ApplyDeltaForEntity;
  79770. }
  79771. }
  79772. declare module BABYLON {
  79773. /**
  79774. * A 3D trajectory consisting of an order list of vectors describing a
  79775. * path of motion through 3D space.
  79776. */
  79777. export class Trajectory {
  79778. private _points;
  79779. private readonly _segmentLength;
  79780. /**
  79781. * Serialize to JSON.
  79782. * @returns serialized JSON string
  79783. */
  79784. serialize(): string;
  79785. /**
  79786. * Deserialize from JSON.
  79787. * @param json serialized JSON string
  79788. * @returns deserialized Trajectory
  79789. */
  79790. static Deserialize(json: string): Trajectory;
  79791. /**
  79792. * Create a new empty Trajectory.
  79793. * @param segmentLength radius of discretization for Trajectory points
  79794. */
  79795. constructor(segmentLength?: number);
  79796. /**
  79797. * Get the length of the Trajectory.
  79798. * @returns length of the Trajectory
  79799. */
  79800. getLength(): number;
  79801. /**
  79802. * Append a new point to the Trajectory.
  79803. * NOTE: This implementation has many allocations.
  79804. * @param point point to append to the Trajectory
  79805. */
  79806. add(point: DeepImmutable<Vector3>): void;
  79807. /**
  79808. * Create a new Trajectory with a segment length chosen to make it
  79809. * probable that the new Trajectory will have a specified number of
  79810. * segments. This operation is imprecise.
  79811. * @param targetResolution number of segments desired
  79812. * @returns new Trajectory with approximately the requested number of segments
  79813. */
  79814. resampleAtTargetResolution(targetResolution: number): Trajectory;
  79815. /**
  79816. * Convert Trajectory segments into tokenized representation. This
  79817. * representation is an array of numbers where each nth number is the
  79818. * index of the token which is most similar to the nth segment of the
  79819. * Trajectory.
  79820. * @param tokens list of vectors which serve as discrete tokens
  79821. * @returns list of indices of most similar token per segment
  79822. */
  79823. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  79824. private static _forwardDir;
  79825. private static _inverseFromVec;
  79826. private static _upDir;
  79827. private static _fromToVec;
  79828. private static _lookMatrix;
  79829. /**
  79830. * Transform the rotation (i.e., direction) of a segment to isolate
  79831. * the relative transformation represented by the segment. This operation
  79832. * may or may not succeed due to singularities in the equations that define
  79833. * motion relativity in this context.
  79834. * @param priorVec the origin of the prior segment
  79835. * @param fromVec the origin of the current segment
  79836. * @param toVec the destination of the current segment
  79837. * @param result reference to output variable
  79838. * @returns whether or not transformation was successful
  79839. */
  79840. private static _transformSegmentDirToRef;
  79841. private static _bestMatch;
  79842. private static _score;
  79843. private static _bestScore;
  79844. /**
  79845. * Determine which token vector is most similar to the
  79846. * segment vector.
  79847. * @param segment segment vector
  79848. * @param tokens token vector list
  79849. * @returns index of the most similar token to the segment
  79850. */
  79851. private static _tokenizeSegment;
  79852. }
  79853. /**
  79854. * Class representing a set of known, named trajectories to which Trajectories can be
  79855. * added and using which Trajectories can be recognized.
  79856. */
  79857. export class TrajectoryClassifier {
  79858. private _maximumAllowableMatchCost;
  79859. private _vector3Alphabet;
  79860. private _levenshteinAlphabet;
  79861. private _nameToDescribedTrajectory;
  79862. /**
  79863. * Serialize to JSON.
  79864. * @returns JSON serialization
  79865. */
  79866. serialize(): string;
  79867. /**
  79868. * Deserialize from JSON.
  79869. * @param json JSON serialization
  79870. * @returns deserialized TrajectorySet
  79871. */
  79872. static Deserialize(json: string): TrajectoryClassifier;
  79873. /**
  79874. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  79875. * VERY naive, need to be generating these things from known
  79876. * sets. Better version later, probably eliminating this one.
  79877. * @returns auto-generated TrajectorySet
  79878. */
  79879. static Generate(): TrajectoryClassifier;
  79880. private constructor();
  79881. /**
  79882. * Add a new Trajectory to the set with a given name.
  79883. * @param trajectory new Trajectory to be added
  79884. * @param classification name to which to add the Trajectory
  79885. */
  79886. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  79887. /**
  79888. * Remove a known named trajectory and all Trajectories associated with it.
  79889. * @param classification name to remove
  79890. * @returns whether anything was removed
  79891. */
  79892. deleteClassification(classification: string): boolean;
  79893. /**
  79894. * Attempt to recognize a Trajectory from among all the classifications
  79895. * already known to the classifier.
  79896. * @param trajectory Trajectory to be recognized
  79897. * @returns classification of Trajectory if recognized, null otherwise
  79898. */
  79899. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  79900. }
  79901. }
  79902. declare module BABYLON {
  79903. /**
  79904. * An interface for all Hit test features
  79905. */
  79906. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  79907. /**
  79908. * Triggered when new babylon (transformed) hit test results are available
  79909. */
  79910. onHitTestResultObservable: Observable<T[]>;
  79911. }
  79912. /**
  79913. * Options used for hit testing
  79914. */
  79915. export interface IWebXRLegacyHitTestOptions {
  79916. /**
  79917. * Only test when user interacted with the scene. Default - hit test every frame
  79918. */
  79919. testOnPointerDownOnly?: boolean;
  79920. /**
  79921. * The node to use to transform the local results to world coordinates
  79922. */
  79923. worldParentNode?: TransformNode;
  79924. }
  79925. /**
  79926. * Interface defining the babylon result of raycasting/hit-test
  79927. */
  79928. export interface IWebXRLegacyHitResult {
  79929. /**
  79930. * Transformation matrix that can be applied to a node that will put it in the hit point location
  79931. */
  79932. transformationMatrix: Matrix;
  79933. /**
  79934. * The native hit test result
  79935. */
  79936. xrHitResult: XRHitResult | XRHitTestResult;
  79937. }
  79938. /**
  79939. * The currently-working hit-test module.
  79940. * Hit test (or Ray-casting) is used to interact with the real world.
  79941. * For further information read here - https://github.com/immersive-web/hit-test
  79942. */
  79943. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  79944. /**
  79945. * options to use when constructing this feature
  79946. */
  79947. readonly options: IWebXRLegacyHitTestOptions;
  79948. private _direction;
  79949. private _mat;
  79950. private _onSelectEnabled;
  79951. private _origin;
  79952. /**
  79953. * The module's name
  79954. */
  79955. static readonly Name: string;
  79956. /**
  79957. * The (Babylon) version of this module.
  79958. * This is an integer representing the implementation version.
  79959. * This number does not correspond to the WebXR specs version
  79960. */
  79961. static readonly Version: number;
  79962. /**
  79963. * Populated with the last native XR Hit Results
  79964. */
  79965. lastNativeXRHitResults: XRHitResult[];
  79966. /**
  79967. * Triggered when new babylon (transformed) hit test results are available
  79968. */
  79969. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  79970. /**
  79971. * Creates a new instance of the (legacy version) hit test feature
  79972. * @param _xrSessionManager an instance of WebXRSessionManager
  79973. * @param options options to use when constructing this feature
  79974. */
  79975. constructor(_xrSessionManager: WebXRSessionManager,
  79976. /**
  79977. * options to use when constructing this feature
  79978. */
  79979. options?: IWebXRLegacyHitTestOptions);
  79980. /**
  79981. * execute a hit test with an XR Ray
  79982. *
  79983. * @param xrSession a native xrSession that will execute this hit test
  79984. * @param xrRay the ray (position and direction) to use for ray-casting
  79985. * @param referenceSpace native XR reference space to use for the hit-test
  79986. * @param filter filter function that will filter the results
  79987. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79988. */
  79989. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  79990. /**
  79991. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  79992. * @param event the (select) event to use to select with
  79993. * @param referenceSpace the reference space to use for this hit test
  79994. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79995. */
  79996. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  79997. /**
  79998. * attach this feature
  79999. * Will usually be called by the features manager
  80000. *
  80001. * @returns true if successful.
  80002. */
  80003. attach(): boolean;
  80004. /**
  80005. * detach this feature.
  80006. * Will usually be called by the features manager
  80007. *
  80008. * @returns true if successful.
  80009. */
  80010. detach(): boolean;
  80011. /**
  80012. * Dispose this feature and all of the resources attached
  80013. */
  80014. dispose(): void;
  80015. protected _onXRFrame(frame: XRFrame): void;
  80016. private _onHitTestResults;
  80017. private _onSelect;
  80018. }
  80019. }
  80020. declare module BABYLON {
  80021. /**
  80022. * Options used for hit testing (version 2)
  80023. */
  80024. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  80025. /**
  80026. * Do not create a permanent hit test. Will usually be used when only
  80027. * transient inputs are needed.
  80028. */
  80029. disablePermanentHitTest?: boolean;
  80030. /**
  80031. * Enable transient (for example touch-based) hit test inspections
  80032. */
  80033. enableTransientHitTest?: boolean;
  80034. /**
  80035. * Offset ray for the permanent hit test
  80036. */
  80037. offsetRay?: Vector3;
  80038. /**
  80039. * Offset ray for the transient hit test
  80040. */
  80041. transientOffsetRay?: Vector3;
  80042. /**
  80043. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  80044. */
  80045. useReferenceSpace?: boolean;
  80046. /**
  80047. * Override the default entity type(s) of the hit-test result
  80048. */
  80049. entityTypes?: XRHitTestTrackableType[];
  80050. }
  80051. /**
  80052. * Interface defining the babylon result of hit-test
  80053. */
  80054. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  80055. /**
  80056. * The input source that generated this hit test (if transient)
  80057. */
  80058. inputSource?: XRInputSource;
  80059. /**
  80060. * Is this a transient hit test
  80061. */
  80062. isTransient?: boolean;
  80063. /**
  80064. * Position of the hit test result
  80065. */
  80066. position: Vector3;
  80067. /**
  80068. * Rotation of the hit test result
  80069. */
  80070. rotationQuaternion: Quaternion;
  80071. /**
  80072. * The native hit test result
  80073. */
  80074. xrHitResult: XRHitTestResult;
  80075. }
  80076. /**
  80077. * The currently-working hit-test module.
  80078. * Hit test (or Ray-casting) is used to interact with the real world.
  80079. * For further information read here - https://github.com/immersive-web/hit-test
  80080. *
  80081. * Tested on chrome (mobile) 80.
  80082. */
  80083. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  80084. /**
  80085. * options to use when constructing this feature
  80086. */
  80087. readonly options: IWebXRHitTestOptions;
  80088. private _tmpMat;
  80089. private _tmpPos;
  80090. private _tmpQuat;
  80091. private _transientXrHitTestSource;
  80092. private _xrHitTestSource;
  80093. private initHitTestSource;
  80094. /**
  80095. * The module's name
  80096. */
  80097. static readonly Name: string;
  80098. /**
  80099. * The (Babylon) version of this module.
  80100. * This is an integer representing the implementation version.
  80101. * This number does not correspond to the WebXR specs version
  80102. */
  80103. static readonly Version: number;
  80104. /**
  80105. * When set to true, each hit test will have its own position/rotation objects
  80106. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  80107. * the developers will clone them or copy them as they see fit.
  80108. */
  80109. autoCloneTransformation: boolean;
  80110. /**
  80111. * Triggered when new babylon (transformed) hit test results are available
  80112. * Note - this will be called when results come back from the device. It can be an empty array!!
  80113. */
  80114. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  80115. /**
  80116. * Use this to temporarily pause hit test checks.
  80117. */
  80118. paused: boolean;
  80119. /**
  80120. * Creates a new instance of the hit test feature
  80121. * @param _xrSessionManager an instance of WebXRSessionManager
  80122. * @param options options to use when constructing this feature
  80123. */
  80124. constructor(_xrSessionManager: WebXRSessionManager,
  80125. /**
  80126. * options to use when constructing this feature
  80127. */
  80128. options?: IWebXRHitTestOptions);
  80129. /**
  80130. * attach this feature
  80131. * Will usually be called by the features manager
  80132. *
  80133. * @returns true if successful.
  80134. */
  80135. attach(): boolean;
  80136. /**
  80137. * detach this feature.
  80138. * Will usually be called by the features manager
  80139. *
  80140. * @returns true if successful.
  80141. */
  80142. detach(): boolean;
  80143. /**
  80144. * Dispose this feature and all of the resources attached
  80145. */
  80146. dispose(): void;
  80147. protected _onXRFrame(frame: XRFrame): void;
  80148. private _processWebXRHitTestResult;
  80149. }
  80150. }
  80151. declare module BABYLON {
  80152. /**
  80153. * Configuration options of the anchor system
  80154. */
  80155. export interface IWebXRAnchorSystemOptions {
  80156. /**
  80157. * a node that will be used to convert local to world coordinates
  80158. */
  80159. worldParentNode?: TransformNode;
  80160. /**
  80161. * If set to true a reference of the created anchors will be kept until the next session starts
  80162. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  80163. */
  80164. doNotRemoveAnchorsOnSessionEnded?: boolean;
  80165. }
  80166. /**
  80167. * A babylon container for an XR Anchor
  80168. */
  80169. export interface IWebXRAnchor {
  80170. /**
  80171. * A babylon-assigned ID for this anchor
  80172. */
  80173. id: number;
  80174. /**
  80175. * Transformation matrix to apply to an object attached to this anchor
  80176. */
  80177. transformationMatrix: Matrix;
  80178. /**
  80179. * The native anchor object
  80180. */
  80181. xrAnchor: XRAnchor;
  80182. /**
  80183. * if defined, this object will be constantly updated by the anchor's position and rotation
  80184. */
  80185. attachedNode?: TransformNode;
  80186. /**
  80187. * Remove this anchor from the scene
  80188. */
  80189. remove(): void;
  80190. }
  80191. /**
  80192. * An implementation of the anchor system for WebXR.
  80193. * For further information see https://github.com/immersive-web/anchors/
  80194. */
  80195. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  80196. private _options;
  80197. private _lastFrameDetected;
  80198. private _trackedAnchors;
  80199. private _referenceSpaceForFrameAnchors;
  80200. private _futureAnchors;
  80201. /**
  80202. * The module's name
  80203. */
  80204. static readonly Name: string;
  80205. /**
  80206. * The (Babylon) version of this module.
  80207. * This is an integer representing the implementation version.
  80208. * This number does not correspond to the WebXR specs version
  80209. */
  80210. static readonly Version: number;
  80211. /**
  80212. * Observers registered here will be executed when a new anchor was added to the session
  80213. */
  80214. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  80215. /**
  80216. * Observers registered here will be executed when an anchor was removed from the session
  80217. */
  80218. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  80219. /**
  80220. * Observers registered here will be executed when an existing anchor updates
  80221. * This can execute N times every frame
  80222. */
  80223. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  80224. /**
  80225. * Set the reference space to use for anchor creation, when not using a hit test.
  80226. * Will default to the session's reference space if not defined
  80227. */
  80228. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  80229. /**
  80230. * constructs a new anchor system
  80231. * @param _xrSessionManager an instance of WebXRSessionManager
  80232. * @param _options configuration object for this feature
  80233. */
  80234. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  80235. private _tmpVector;
  80236. private _tmpQuaternion;
  80237. private _populateTmpTransformation;
  80238. /**
  80239. * Create a new anchor point using a hit test result at a specific point in the scene
  80240. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  80241. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  80242. *
  80243. * @param hitTestResult The hit test result to use for this anchor creation
  80244. * @param position an optional position offset for this anchor
  80245. * @param rotationQuaternion an optional rotation offset for this anchor
  80246. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  80247. */
  80248. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  80249. /**
  80250. * Add a new anchor at a specific position and rotation
  80251. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  80252. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  80253. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  80254. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  80255. *
  80256. * @param position the position in which to add an anchor
  80257. * @param rotationQuaternion an optional rotation for the anchor transformation
  80258. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  80259. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  80260. */
  80261. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  80262. /**
  80263. * Get the list of anchors currently being tracked by the system
  80264. */
  80265. get anchors(): IWebXRAnchor[];
  80266. /**
  80267. * detach this feature.
  80268. * Will usually be called by the features manager
  80269. *
  80270. * @returns true if successful.
  80271. */
  80272. detach(): boolean;
  80273. /**
  80274. * Dispose this feature and all of the resources attached
  80275. */
  80276. dispose(): void;
  80277. protected _onXRFrame(frame: XRFrame): void;
  80278. /**
  80279. * avoiding using Array.find for global support.
  80280. * @param xrAnchor the plane to find in the array
  80281. */
  80282. private _findIndexInAnchorArray;
  80283. private _updateAnchorWithXRFrame;
  80284. private _createAnchorAtTransformation;
  80285. }
  80286. }
  80287. declare module BABYLON {
  80288. /**
  80289. * Options used in the plane detector module
  80290. */
  80291. export interface IWebXRPlaneDetectorOptions {
  80292. /**
  80293. * The node to use to transform the local results to world coordinates
  80294. */
  80295. worldParentNode?: TransformNode;
  80296. /**
  80297. * If set to true a reference of the created planes will be kept until the next session starts
  80298. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  80299. */
  80300. doNotRemovePlanesOnSessionEnded?: boolean;
  80301. /**
  80302. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  80303. */
  80304. preferredDetectorOptions?: XRGeometryDetectorOptions;
  80305. }
  80306. /**
  80307. * A babylon interface for a WebXR plane.
  80308. * A Plane is actually a polygon, built from N points in space
  80309. *
  80310. * Supported in chrome 79, not supported in canary 81 ATM
  80311. */
  80312. export interface IWebXRPlane {
  80313. /**
  80314. * a babylon-assigned ID for this polygon
  80315. */
  80316. id: number;
  80317. /**
  80318. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  80319. */
  80320. polygonDefinition: Array<Vector3>;
  80321. /**
  80322. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  80323. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  80324. */
  80325. transformationMatrix: Matrix;
  80326. /**
  80327. * the native xr-plane object
  80328. */
  80329. xrPlane: XRPlane;
  80330. }
  80331. /**
  80332. * The plane detector is used to detect planes in the real world when in AR
  80333. * For more information see https://github.com/immersive-web/real-world-geometry/
  80334. */
  80335. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  80336. private _options;
  80337. private _detectedPlanes;
  80338. private _enabled;
  80339. private _lastFrameDetected;
  80340. /**
  80341. * The module's name
  80342. */
  80343. static readonly Name: string;
  80344. /**
  80345. * The (Babylon) version of this module.
  80346. * This is an integer representing the implementation version.
  80347. * This number does not correspond to the WebXR specs version
  80348. */
  80349. static readonly Version: number;
  80350. /**
  80351. * Observers registered here will be executed when a new plane was added to the session
  80352. */
  80353. onPlaneAddedObservable: Observable<IWebXRPlane>;
  80354. /**
  80355. * Observers registered here will be executed when a plane is no longer detected in the session
  80356. */
  80357. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  80358. /**
  80359. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  80360. * This can execute N times every frame
  80361. */
  80362. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  80363. /**
  80364. * construct a new Plane Detector
  80365. * @param _xrSessionManager an instance of xr Session manager
  80366. * @param _options configuration to use when constructing this feature
  80367. */
  80368. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  80369. /**
  80370. * detach this feature.
  80371. * Will usually be called by the features manager
  80372. *
  80373. * @returns true if successful.
  80374. */
  80375. detach(): boolean;
  80376. /**
  80377. * Dispose this feature and all of the resources attached
  80378. */
  80379. dispose(): void;
  80380. /**
  80381. * Check if the needed objects are defined.
  80382. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80383. */
  80384. isCompatible(): boolean;
  80385. protected _onXRFrame(frame: XRFrame): void;
  80386. private _init;
  80387. private _updatePlaneWithXRPlane;
  80388. /**
  80389. * avoiding using Array.find for global support.
  80390. * @param xrPlane the plane to find in the array
  80391. */
  80392. private _findIndexInPlaneArray;
  80393. }
  80394. }
  80395. declare module BABYLON {
  80396. /**
  80397. * Options interface for the background remover plugin
  80398. */
  80399. export interface IWebXRBackgroundRemoverOptions {
  80400. /**
  80401. * Further background meshes to disable when entering AR
  80402. */
  80403. backgroundMeshes?: AbstractMesh[];
  80404. /**
  80405. * flags to configure the removal of the environment helper.
  80406. * If not set, the entire background will be removed. If set, flags should be set as well.
  80407. */
  80408. environmentHelperRemovalFlags?: {
  80409. /**
  80410. * Should the skybox be removed (default false)
  80411. */
  80412. skyBox?: boolean;
  80413. /**
  80414. * Should the ground be removed (default false)
  80415. */
  80416. ground?: boolean;
  80417. };
  80418. /**
  80419. * don't disable the environment helper
  80420. */
  80421. ignoreEnvironmentHelper?: boolean;
  80422. }
  80423. /**
  80424. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  80425. */
  80426. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  80427. /**
  80428. * read-only options to be used in this module
  80429. */
  80430. readonly options: IWebXRBackgroundRemoverOptions;
  80431. /**
  80432. * The module's name
  80433. */
  80434. static readonly Name: string;
  80435. /**
  80436. * The (Babylon) version of this module.
  80437. * This is an integer representing the implementation version.
  80438. * This number does not correspond to the WebXR specs version
  80439. */
  80440. static readonly Version: number;
  80441. /**
  80442. * registered observers will be triggered when the background state changes
  80443. */
  80444. onBackgroundStateChangedObservable: Observable<boolean>;
  80445. /**
  80446. * constructs a new background remover module
  80447. * @param _xrSessionManager the session manager for this module
  80448. * @param options read-only options to be used in this module
  80449. */
  80450. constructor(_xrSessionManager: WebXRSessionManager,
  80451. /**
  80452. * read-only options to be used in this module
  80453. */
  80454. options?: IWebXRBackgroundRemoverOptions);
  80455. /**
  80456. * attach this feature
  80457. * Will usually be called by the features manager
  80458. *
  80459. * @returns true if successful.
  80460. */
  80461. attach(): boolean;
  80462. /**
  80463. * detach this feature.
  80464. * Will usually be called by the features manager
  80465. *
  80466. * @returns true if successful.
  80467. */
  80468. detach(): boolean;
  80469. /**
  80470. * Dispose this feature and all of the resources attached
  80471. */
  80472. dispose(): void;
  80473. protected _onXRFrame(_xrFrame: XRFrame): void;
  80474. private _setBackgroundState;
  80475. }
  80476. }
  80477. declare module BABYLON {
  80478. /**
  80479. * Options for the controller physics feature
  80480. */
  80481. export class IWebXRControllerPhysicsOptions {
  80482. /**
  80483. * Should the headset get its own impostor
  80484. */
  80485. enableHeadsetImpostor?: boolean;
  80486. /**
  80487. * Optional parameters for the headset impostor
  80488. */
  80489. headsetImpostorParams?: {
  80490. /**
  80491. * The type of impostor to create. Default is sphere
  80492. */
  80493. impostorType: number;
  80494. /**
  80495. * the size of the impostor. Defaults to 10cm
  80496. */
  80497. impostorSize?: number | {
  80498. width: number;
  80499. height: number;
  80500. depth: number;
  80501. };
  80502. /**
  80503. * Friction definitions
  80504. */
  80505. friction?: number;
  80506. /**
  80507. * Restitution
  80508. */
  80509. restitution?: number;
  80510. };
  80511. /**
  80512. * The physics properties of the future impostors
  80513. */
  80514. physicsProperties?: {
  80515. /**
  80516. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  80517. * Note that this requires a physics engine that supports mesh impostors!
  80518. */
  80519. useControllerMesh?: boolean;
  80520. /**
  80521. * The type of impostor to create. Default is sphere
  80522. */
  80523. impostorType?: number;
  80524. /**
  80525. * the size of the impostor. Defaults to 10cm
  80526. */
  80527. impostorSize?: number | {
  80528. width: number;
  80529. height: number;
  80530. depth: number;
  80531. };
  80532. /**
  80533. * Friction definitions
  80534. */
  80535. friction?: number;
  80536. /**
  80537. * Restitution
  80538. */
  80539. restitution?: number;
  80540. };
  80541. /**
  80542. * the xr input to use with this pointer selection
  80543. */
  80544. xrInput: WebXRInput;
  80545. }
  80546. /**
  80547. * Add physics impostor to your webxr controllers,
  80548. * including naive calculation of their linear and angular velocity
  80549. */
  80550. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  80551. private readonly _options;
  80552. private _attachController;
  80553. private _controllers;
  80554. private _debugMode;
  80555. private _delta;
  80556. private _headsetImpostor?;
  80557. private _headsetMesh?;
  80558. private _lastTimestamp;
  80559. private _tmpQuaternion;
  80560. private _tmpVector;
  80561. /**
  80562. * The module's name
  80563. */
  80564. static readonly Name: string;
  80565. /**
  80566. * The (Babylon) version of this module.
  80567. * This is an integer representing the implementation version.
  80568. * This number does not correspond to the webxr specs version
  80569. */
  80570. static readonly Version: number;
  80571. /**
  80572. * Construct a new Controller Physics Feature
  80573. * @param _xrSessionManager the corresponding xr session manager
  80574. * @param _options options to create this feature with
  80575. */
  80576. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  80577. /**
  80578. * @hidden
  80579. * enable debugging - will show console outputs and the impostor mesh
  80580. */
  80581. _enablePhysicsDebug(): void;
  80582. /**
  80583. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  80584. * @param xrController the controller to add
  80585. */
  80586. addController(xrController: WebXRInputSource): void;
  80587. /**
  80588. * attach this feature
  80589. * Will usually be called by the features manager
  80590. *
  80591. * @returns true if successful.
  80592. */
  80593. attach(): boolean;
  80594. /**
  80595. * detach this feature.
  80596. * Will usually be called by the features manager
  80597. *
  80598. * @returns true if successful.
  80599. */
  80600. detach(): boolean;
  80601. /**
  80602. * Get the headset impostor, if enabled
  80603. * @returns the impostor
  80604. */
  80605. getHeadsetImpostor(): PhysicsImpostor | undefined;
  80606. /**
  80607. * Get the physics impostor of a specific controller.
  80608. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  80609. * @param controller the controller or the controller id of which to get the impostor
  80610. * @returns the impostor or null
  80611. */
  80612. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  80613. /**
  80614. * Update the physics properties provided in the constructor
  80615. * @param newProperties the new properties object
  80616. */
  80617. setPhysicsProperties(newProperties: {
  80618. impostorType?: number;
  80619. impostorSize?: number | {
  80620. width: number;
  80621. height: number;
  80622. depth: number;
  80623. };
  80624. friction?: number;
  80625. restitution?: number;
  80626. }): void;
  80627. protected _onXRFrame(_xrFrame: any): void;
  80628. private _detachController;
  80629. }
  80630. }
  80631. declare module BABYLON {
  80632. /**
  80633. * A babylon interface for a "WebXR" feature point.
  80634. * Represents the position and confidence value of a given feature point.
  80635. */
  80636. export interface IWebXRFeaturePoint {
  80637. /**
  80638. * Represents the position of the feature point in world space.
  80639. */
  80640. position: Vector3;
  80641. /**
  80642. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  80643. */
  80644. confidenceValue: number;
  80645. }
  80646. /**
  80647. * The feature point system is used to detect feature points from real world geometry.
  80648. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  80649. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  80650. */
  80651. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  80652. private _enabled;
  80653. private _featurePointCloud;
  80654. /**
  80655. * The module's name
  80656. */
  80657. static readonly Name: string;
  80658. /**
  80659. * The (Babylon) version of this module.
  80660. * This is an integer representing the implementation version.
  80661. * This number does not correspond to the WebXR specs version
  80662. */
  80663. static readonly Version: number;
  80664. /**
  80665. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  80666. * Will notify the observers about which feature points have been added.
  80667. */
  80668. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  80669. /**
  80670. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  80671. * Will notify the observers about which feature points have been updated.
  80672. */
  80673. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  80674. /**
  80675. * The current feature point cloud maintained across frames.
  80676. */
  80677. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  80678. /**
  80679. * construct the feature point system
  80680. * @param _xrSessionManager an instance of xr Session manager
  80681. */
  80682. constructor(_xrSessionManager: WebXRSessionManager);
  80683. /**
  80684. * Detach this feature.
  80685. * Will usually be called by the features manager
  80686. *
  80687. * @returns true if successful.
  80688. */
  80689. detach(): boolean;
  80690. /**
  80691. * Dispose this feature and all of the resources attached
  80692. */
  80693. dispose(): void;
  80694. /**
  80695. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  80696. */
  80697. protected _onXRFrame(frame: XRFrame): void;
  80698. /**
  80699. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  80700. */
  80701. private _init;
  80702. }
  80703. }
  80704. declare module BABYLON {
  80705. /**
  80706. * Configuration interface for the hand tracking feature
  80707. */
  80708. export interface IWebXRHandTrackingOptions {
  80709. /**
  80710. * The xrInput that will be used as source for new hands
  80711. */
  80712. xrInput: WebXRInput;
  80713. /**
  80714. * Configuration object for the joint meshes
  80715. */
  80716. jointMeshes?: {
  80717. /**
  80718. * Should the meshes created be invisible (defaults to false)
  80719. */
  80720. invisible?: boolean;
  80721. /**
  80722. * A source mesh to be used to create instances. Defaults to a sphere.
  80723. * This mesh will be the source for all other (25) meshes.
  80724. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  80725. */
  80726. sourceMesh?: Mesh;
  80727. /**
  80728. * This function will be called after a mesh was created for a specific joint.
  80729. * Using this function you can either manipulate the instance or return a new mesh.
  80730. * When returning a new mesh the instance created before will be disposed
  80731. */
  80732. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  80733. /**
  80734. * Should the source mesh stay visible. Defaults to false
  80735. */
  80736. keepOriginalVisible?: boolean;
  80737. /**
  80738. * Scale factor for all instances (defaults to 2)
  80739. */
  80740. scaleFactor?: number;
  80741. /**
  80742. * Should each instance have its own physics impostor
  80743. */
  80744. enablePhysics?: boolean;
  80745. /**
  80746. * If enabled, override default physics properties
  80747. */
  80748. physicsProps?: {
  80749. friction?: number;
  80750. restitution?: number;
  80751. impostorType?: number;
  80752. };
  80753. /**
  80754. * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).
  80755. */
  80756. disableDefaultHandMesh?: boolean;
  80757. /**
  80758. * a rigged hand-mesh that will be updated according to the XRHand data provided. This will override the default hand mesh
  80759. */
  80760. handMeshes?: {
  80761. right: AbstractMesh;
  80762. left: AbstractMesh;
  80763. };
  80764. /**
  80765. * Are the meshes prepared for a left-handed system. Default hand meshes are right-handed.
  80766. */
  80767. leftHandedSystemMeshes?: boolean;
  80768. /**
  80769. * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh
  80770. */
  80771. rigMapping?: {
  80772. right: string[];
  80773. left: string[];
  80774. };
  80775. /**
  80776. * The utilityLayer scene that contains the 3D UI elements. Passing this in turns on near interactions with the index finger tip
  80777. */
  80778. sceneForNearInteraction?: Scene;
  80779. };
  80780. }
  80781. /**
  80782. * Parts of the hands divided to writs and finger names
  80783. */
  80784. export const enum HandPart {
  80785. /**
  80786. * HandPart - Wrist
  80787. */
  80788. WRIST = "wrist",
  80789. /**
  80790. * HandPart - The thumb
  80791. */
  80792. THUMB = "thumb",
  80793. /**
  80794. * HandPart - Index finger
  80795. */
  80796. INDEX = "index",
  80797. /**
  80798. * HandPart - Middle finger
  80799. */
  80800. MIDDLE = "middle",
  80801. /**
  80802. * HandPart - Ring finger
  80803. */
  80804. RING = "ring",
  80805. /**
  80806. * HandPart - Little finger
  80807. */
  80808. LITTLE = "little"
  80809. }
  80810. /**
  80811. * Representing a single hand (with its corresponding native XRHand object)
  80812. */
  80813. export class WebXRHand implements IDisposable {
  80814. /** the controller to which the hand correlates */
  80815. readonly xrController: WebXRInputSource;
  80816. /** the meshes to be used to track the hand joints */
  80817. readonly trackedMeshes: AbstractMesh[];
  80818. private _handMesh?;
  80819. private _rigMapping?;
  80820. private _nearInteractionMesh?;
  80821. private _leftHandedMeshes?;
  80822. private _scene;
  80823. private _defaultHandMesh;
  80824. private _transformNodeMapping;
  80825. private _boneMapping;
  80826. private _useBones;
  80827. /**
  80828. * Hand-parts definition (key is HandPart)
  80829. */
  80830. handPartsDefinition: {
  80831. [key: string]: number[];
  80832. };
  80833. /**
  80834. * Observers will be triggered when the mesh for this hand was initialized.
  80835. */
  80836. onHandMeshReadyObservable: Observable<WebXRHand>;
  80837. /**
  80838. * Populate the HandPartsDefinition object.
  80839. * This is called as a side effect since certain browsers don't have XRHand defined.
  80840. */
  80841. private generateHandPartsDefinition;
  80842. /**
  80843. * Construct a new hand object
  80844. * @param xrController the controller to which the hand correlates
  80845. * @param trackedMeshes the meshes to be used to track the hand joints
  80846. * @param _handMesh an optional hand mesh. if not provided, ours will be used
  80847. * @param _rigMapping an optional rig mapping for the hand mesh. if not provided, ours will be used
  80848. * @param disableDefaultHandMesh should the default mesh creation be disabled
  80849. * @param _nearInteractionMesh as optional mesh used for near interaction collision checking
  80850. * @param _leftHandedMeshes are the hand meshes left-handed-system meshes
  80851. */
  80852. constructor(
  80853. /** the controller to which the hand correlates */
  80854. xrController: WebXRInputSource,
  80855. /** the meshes to be used to track the hand joints */
  80856. trackedMeshes: AbstractMesh[], _handMesh?: AbstractMesh | undefined, _rigMapping?: string[] | undefined, disableDefaultHandMesh?: boolean, _nearInteractionMesh?: AbstractMesh | null | undefined, _leftHandedMeshes?: boolean | undefined);
  80857. /**
  80858. * Get the hand mesh. It is possible that the hand mesh is not yet ready!
  80859. */
  80860. get handMesh(): AbstractMesh | undefined;
  80861. /**
  80862. * Update this hand from the latest xr frame
  80863. * @param xrFrame xrFrame to update from
  80864. * @param referenceSpace The current viewer reference space
  80865. * @param scaleFactor optional scale factor for the meshes
  80866. */
  80867. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  80868. /**
  80869. * Get meshes of part of the hand
  80870. * @param part the part of hand to get
  80871. * @returns An array of meshes that correlate to the hand part requested
  80872. */
  80873. getHandPartMeshes(part: HandPart): AbstractMesh[];
  80874. /**
  80875. * Dispose this Hand object
  80876. */
  80877. dispose(): void;
  80878. private _generateDefaultHandMesh;
  80879. }
  80880. /**
  80881. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  80882. */
  80883. export class WebXRHandTracking extends WebXRAbstractFeature {
  80884. /**
  80885. * options to use when constructing this feature
  80886. */
  80887. readonly options: IWebXRHandTrackingOptions;
  80888. private static _idCounter;
  80889. /**
  80890. * The module's name
  80891. */
  80892. static readonly Name: string;
  80893. /**
  80894. * The (Babylon) version of this module.
  80895. * This is an integer representing the implementation version.
  80896. * This number does not correspond to the WebXR specs version
  80897. */
  80898. static readonly Version: number;
  80899. /**
  80900. * This observable will notify registered observers when a new hand object was added and initialized
  80901. */
  80902. onHandAddedObservable: Observable<WebXRHand>;
  80903. /**
  80904. * This observable will notify its observers right before the hand object is disposed
  80905. */
  80906. onHandRemovedObservable: Observable<WebXRHand>;
  80907. private _hands;
  80908. /**
  80909. * Creates a new instance of the hit test feature
  80910. * @param _xrSessionManager an instance of WebXRSessionManager
  80911. * @param options options to use when constructing this feature
  80912. */
  80913. constructor(_xrSessionManager: WebXRSessionManager,
  80914. /**
  80915. * options to use when constructing this feature
  80916. */
  80917. options: IWebXRHandTrackingOptions);
  80918. /**
  80919. * Check if the needed objects are defined.
  80920. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80921. */
  80922. isCompatible(): boolean;
  80923. /**
  80924. * attach this feature
  80925. * Will usually be called by the features manager
  80926. *
  80927. * @returns true if successful.
  80928. */
  80929. attach(): boolean;
  80930. /**
  80931. * detach this feature.
  80932. * Will usually be called by the features manager
  80933. *
  80934. * @returns true if successful.
  80935. */
  80936. detach(): boolean;
  80937. /**
  80938. * Dispose this feature and all of the resources attached
  80939. */
  80940. dispose(): void;
  80941. /**
  80942. * Get the hand object according to the controller id
  80943. * @param controllerId the controller id to which we want to get the hand
  80944. * @returns null if not found or the WebXRHand object if found
  80945. */
  80946. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  80947. /**
  80948. * Get a hand object according to the requested handedness
  80949. * @param handedness the handedness to request
  80950. * @returns null if not found or the WebXRHand object if found
  80951. */
  80952. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  80953. protected _onXRFrame(_xrFrame: XRFrame): void;
  80954. private _attachHand;
  80955. private _detachHand;
  80956. }
  80957. }
  80958. declare module BABYLON {
  80959. /**
  80960. * Options used in the mesh detector module
  80961. */
  80962. export interface IWebXRMeshDetectorOptions {
  80963. /**
  80964. * The node to use to transform the local results to world coordinates
  80965. */
  80966. worldParentNode?: TransformNode;
  80967. /**
  80968. * If set to true a reference of the created meshes will be kept until the next session starts
  80969. * If not defined, meshes will be removed from the array when the feature is detached or the session ended.
  80970. */
  80971. doNotRemoveMeshesOnSessionEnded?: boolean;
  80972. /**
  80973. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  80974. */
  80975. preferredDetectorOptions?: XRGeometryDetectorOptions;
  80976. /**
  80977. * If set to true, WebXRMeshDetector will convert coordinate systems for meshes.
  80978. * If not defined, mesh conversions from right handed to left handed coordinate systems won't be conducted.
  80979. * Right handed mesh data will be available through IWebXRVertexData.xrMesh.
  80980. */
  80981. convertCoordinateSystems?: boolean;
  80982. }
  80983. /**
  80984. * A babylon interface for a XR mesh's vertex data.
  80985. *
  80986. * Currently not supported by WebXR, available only with BabylonNative
  80987. */
  80988. export interface IWebXRVertexData {
  80989. /**
  80990. * A babylon-assigned ID for this mesh
  80991. */
  80992. id: number;
  80993. /**
  80994. * Data required for constructing a mesh in Babylon.js.
  80995. */
  80996. xrMesh: XRMesh;
  80997. /**
  80998. * The node to use to transform the local results to world coordinates.
  80999. * WorldParentNode will only exist if it was declared in the IWebXRMeshDetectorOptions.
  81000. */
  81001. worldParentNode?: TransformNode;
  81002. /**
  81003. * An array of vertex positions in babylon space. right/left hand system is taken into account.
  81004. * Positions will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  81005. */
  81006. positions?: Float32Array;
  81007. /**
  81008. * An array of indices in babylon space. Indices have a counterclockwise winding order.
  81009. * Indices will only be populated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  81010. */
  81011. indices?: Uint32Array;
  81012. /**
  81013. * An array of vertex normals in babylon space. right/left hand system is taken into account.
  81014. * Normals will not be calculated if convertCoordinateSystems is undefined in the IWebXRMeshDetectorOptions.
  81015. * Different platforms may or may not support mesh normals when convertCoordinateSystems is set to true.
  81016. */
  81017. normals?: Float32Array;
  81018. /**
  81019. * A transformation matrix to apply on the mesh that will be built using the meshDefinition.
  81020. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module.
  81021. * TransformationMatrix will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  81022. */
  81023. transformationMatrix?: Matrix;
  81024. }
  81025. /**
  81026. * The mesh detector is used to detect meshes in the real world when in AR
  81027. */
  81028. export class WebXRMeshDetector extends WebXRAbstractFeature {
  81029. private _options;
  81030. private _detectedMeshes;
  81031. /**
  81032. * The module's name
  81033. */
  81034. static readonly Name: string;
  81035. /**
  81036. * The (Babylon) version of this module.
  81037. * This is an integer representing the implementation version.
  81038. * This number does not correspond to the WebXR specs version
  81039. */
  81040. static readonly Version: number;
  81041. /**
  81042. * Observers registered here will be executed when a new mesh was added to the session
  81043. */
  81044. onMeshAddedObservable: Observable<IWebXRVertexData>;
  81045. /**
  81046. * Observers registered here will be executed when a mesh is no longer detected in the session
  81047. */
  81048. onMeshRemovedObservable: Observable<IWebXRVertexData>;
  81049. /**
  81050. * Observers registered here will be executed when an existing mesh updates
  81051. */
  81052. onMeshUpdatedObservable: Observable<IWebXRVertexData>;
  81053. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRMeshDetectorOptions);
  81054. detach(): boolean;
  81055. dispose(): void;
  81056. protected _onXRFrame(frame: XRFrame): void;
  81057. private _init;
  81058. private _updateVertexDataWithXRMesh;
  81059. }
  81060. }
  81061. declare module BABYLON {
  81062. /**
  81063. * Options interface for the background remover plugin
  81064. */
  81065. export interface IWebXRImageTrackingOptions {
  81066. /**
  81067. * A required array with images to track
  81068. */
  81069. images: {
  81070. /**
  81071. * The source of the image. can be a URL or an image bitmap
  81072. */
  81073. src: string | ImageBitmap;
  81074. /**
  81075. * The estimated width in the real world (in meters)
  81076. */
  81077. estimatedRealWorldWidth: number;
  81078. }[];
  81079. }
  81080. /**
  81081. * An object representing an image tracked by the system
  81082. */
  81083. export interface IWebXRTrackedImage {
  81084. /**
  81085. * The ID of this image (which is the same as the position in the array that was used to initialize the feature)
  81086. */
  81087. id: number;
  81088. /**
  81089. * Is the transformation provided emulated. If it is, the system "guesses" its real position. Otherwise it can be considered as exact position.
  81090. */
  81091. emulated?: boolean;
  81092. /**
  81093. * Just in case it is needed - the image bitmap that is being tracked
  81094. */
  81095. originalBitmap: ImageBitmap;
  81096. /**
  81097. * The native XR result image tracking result, untouched
  81098. */
  81099. xrTrackingResult?: XRImageTrackingResult;
  81100. /**
  81101. * Width in real world (meters)
  81102. */
  81103. realWorldWidth?: number;
  81104. /**
  81105. * A transformation matrix of this current image in the current reference space.
  81106. */
  81107. transformationMatrix: Matrix;
  81108. /**
  81109. * The width/height ratio of this image. can be used to calculate the size of the detected object/image
  81110. */
  81111. ratio?: number;
  81112. }
  81113. /**
  81114. * Image tracking for immersive AR sessions.
  81115. * Providing a list of images and their estimated widths will enable tracking those images in the real world.
  81116. */
  81117. export class WebXRImageTracking extends WebXRAbstractFeature {
  81118. /**
  81119. * read-only options to be used in this module
  81120. */
  81121. readonly options: IWebXRImageTrackingOptions;
  81122. /**
  81123. * The module's name
  81124. */
  81125. static readonly Name: string;
  81126. /**
  81127. * The (Babylon) version of this module.
  81128. * This is an integer representing the implementation version.
  81129. * This number does not correspond to the WebXR specs version
  81130. */
  81131. static readonly Version: number;
  81132. /**
  81133. * This will be triggered if the underlying system deems an image untrackable.
  81134. * The index is the index of the image from the array used to initialize the feature.
  81135. */
  81136. onUntrackableImageFoundObservable: Observable<number>;
  81137. /**
  81138. * An image was deemed trackable, and the system will start tracking it.
  81139. */
  81140. onTrackableImageFoundObservable: Observable<IWebXRTrackedImage>;
  81141. /**
  81142. * The image was found and its state was updated.
  81143. */
  81144. onTrackedImageUpdatedObservable: Observable<IWebXRTrackedImage>;
  81145. private _trackedImages;
  81146. private _originalTrackingRequest;
  81147. /**
  81148. * constructs the image tracking feature
  81149. * @param _xrSessionManager the session manager for this module
  81150. * @param options read-only options to be used in this module
  81151. */
  81152. constructor(_xrSessionManager: WebXRSessionManager,
  81153. /**
  81154. * read-only options to be used in this module
  81155. */
  81156. options: IWebXRImageTrackingOptions);
  81157. /**
  81158. * attach this feature
  81159. * Will usually be called by the features manager
  81160. *
  81161. * @returns true if successful.
  81162. */
  81163. attach(): boolean;
  81164. /**
  81165. * detach this feature.
  81166. * Will usually be called by the features manager
  81167. *
  81168. * @returns true if successful.
  81169. */
  81170. detach(): boolean;
  81171. /**
  81172. * Check if the needed objects are defined.
  81173. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  81174. */
  81175. isCompatible(): boolean;
  81176. /**
  81177. * Get a tracked image by its ID.
  81178. *
  81179. * @param id the id of the image to load (position in the init array)
  81180. * @returns a trackable image, if exists in this location
  81181. */
  81182. getTrackedImageById(id: number): Nullable<IWebXRTrackedImage>;
  81183. /**
  81184. * Dispose this feature and all of the resources attached
  81185. */
  81186. dispose(): void;
  81187. /**
  81188. * Extends the session init object if needed
  81189. * @returns augmentation object fo the xr session init object.
  81190. */
  81191. getXRSessionInitExtension(): Promise<Partial<XRSessionInit>>;
  81192. protected _onXRFrame(_xrFrame: XRFrame): void;
  81193. private _init;
  81194. }
  81195. }
  81196. declare module BABYLON {
  81197. /**
  81198. * The motion controller class for all microsoft mixed reality controllers
  81199. */
  81200. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  81201. protected readonly _mapping: {
  81202. defaultButton: {
  81203. valueNodeName: string;
  81204. unpressedNodeName: string;
  81205. pressedNodeName: string;
  81206. };
  81207. defaultAxis: {
  81208. valueNodeName: string;
  81209. minNodeName: string;
  81210. maxNodeName: string;
  81211. };
  81212. buttons: {
  81213. "xr-standard-trigger": {
  81214. rootNodeName: string;
  81215. componentProperty: string;
  81216. states: string[];
  81217. };
  81218. "xr-standard-squeeze": {
  81219. rootNodeName: string;
  81220. componentProperty: string;
  81221. states: string[];
  81222. };
  81223. "xr-standard-touchpad": {
  81224. rootNodeName: string;
  81225. labelAnchorNodeName: string;
  81226. touchPointNodeName: string;
  81227. };
  81228. "xr-standard-thumbstick": {
  81229. rootNodeName: string;
  81230. componentProperty: string;
  81231. states: string[];
  81232. };
  81233. };
  81234. axes: {
  81235. "xr-standard-touchpad": {
  81236. "x-axis": {
  81237. rootNodeName: string;
  81238. };
  81239. "y-axis": {
  81240. rootNodeName: string;
  81241. };
  81242. };
  81243. "xr-standard-thumbstick": {
  81244. "x-axis": {
  81245. rootNodeName: string;
  81246. };
  81247. "y-axis": {
  81248. rootNodeName: string;
  81249. };
  81250. };
  81251. };
  81252. };
  81253. /**
  81254. * The base url used to load the left and right controller models
  81255. */
  81256. static MODEL_BASE_URL: string;
  81257. /**
  81258. * The name of the left controller model file
  81259. */
  81260. static MODEL_LEFT_FILENAME: string;
  81261. /**
  81262. * The name of the right controller model file
  81263. */
  81264. static MODEL_RIGHT_FILENAME: string;
  81265. profileId: string;
  81266. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  81267. protected _getFilenameAndPath(): {
  81268. filename: string;
  81269. path: string;
  81270. };
  81271. protected _getModelLoadingConstraints(): boolean;
  81272. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  81273. protected _setRootMesh(meshes: AbstractMesh[]): void;
  81274. protected _updateModel(): void;
  81275. }
  81276. }
  81277. declare module BABYLON {
  81278. /**
  81279. * The motion controller class for oculus touch (quest, rift).
  81280. * This class supports legacy mapping as well the standard xr mapping
  81281. */
  81282. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  81283. private _forceLegacyControllers;
  81284. private _modelRootNode;
  81285. /**
  81286. * The base url used to load the left and right controller models
  81287. */
  81288. static MODEL_BASE_URL: string;
  81289. /**
  81290. * The name of the left controller model file
  81291. */
  81292. static MODEL_LEFT_FILENAME: string;
  81293. /**
  81294. * The name of the right controller model file
  81295. */
  81296. static MODEL_RIGHT_FILENAME: string;
  81297. /**
  81298. * Base Url for the Quest controller model.
  81299. */
  81300. static QUEST_MODEL_BASE_URL: string;
  81301. profileId: string;
  81302. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  81303. protected _getFilenameAndPath(): {
  81304. filename: string;
  81305. path: string;
  81306. };
  81307. protected _getModelLoadingConstraints(): boolean;
  81308. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  81309. protected _setRootMesh(meshes: AbstractMesh[]): void;
  81310. protected _updateModel(): void;
  81311. /**
  81312. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  81313. * between the touch and touch 2.
  81314. */
  81315. private _isQuest;
  81316. }
  81317. }
  81318. declare module BABYLON {
  81319. /**
  81320. * The motion controller class for the standard HTC-Vive controllers
  81321. */
  81322. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  81323. private _modelRootNode;
  81324. /**
  81325. * The base url used to load the left and right controller models
  81326. */
  81327. static MODEL_BASE_URL: string;
  81328. /**
  81329. * File name for the controller model.
  81330. */
  81331. static MODEL_FILENAME: string;
  81332. profileId: string;
  81333. /**
  81334. * Create a new Vive motion controller object
  81335. * @param scene the scene to use to create this controller
  81336. * @param gamepadObject the corresponding gamepad object
  81337. * @param handedness the handedness of the controller
  81338. */
  81339. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  81340. protected _getFilenameAndPath(): {
  81341. filename: string;
  81342. path: string;
  81343. };
  81344. protected _getModelLoadingConstraints(): boolean;
  81345. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  81346. protected _setRootMesh(meshes: AbstractMesh[]): void;
  81347. protected _updateModel(): void;
  81348. }
  81349. }
  81350. declare module BABYLON {
  81351. /** @hidden */
  81352. export class WebGPUCacheRenderPipelineString extends WebGPUCacheRenderPipeline {
  81353. private static _Cache;
  81354. protected _getRenderPipeline(param: {
  81355. token: any;
  81356. pipeline: Nullable<GPURenderPipeline>;
  81357. }): void;
  81358. protected _setRenderPipeline(param: {
  81359. token: any;
  81360. pipeline: Nullable<GPURenderPipeline>;
  81361. }): void;
  81362. }
  81363. }
  81364. declare module BABYLON {
  81365. /** @hidden */
  81366. export var blurPixelShader: {
  81367. name: string;
  81368. shader: string;
  81369. };
  81370. }
  81371. declare module BABYLON {
  81372. /** @hidden */
  81373. export var pointCloudVertexDeclaration: {
  81374. name: string;
  81375. shader: string;
  81376. };
  81377. }
  81378. // Mixins
  81379. interface Window {
  81380. mozIndexedDB: IDBFactory;
  81381. webkitIndexedDB: IDBFactory;
  81382. msIndexedDB: IDBFactory;
  81383. webkitURL: typeof URL;
  81384. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  81385. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  81386. WebGLRenderingContext: WebGLRenderingContext;
  81387. MSGesture: MSGesture;
  81388. CANNON: any;
  81389. AudioContext: AudioContext;
  81390. webkitAudioContext: AudioContext;
  81391. PointerEvent: any;
  81392. Math: Math;
  81393. Uint8Array: Uint8ArrayConstructor;
  81394. Float32Array: Float32ArrayConstructor;
  81395. mozURL: typeof URL;
  81396. msURL: typeof URL;
  81397. VRFrameData: any; // WebVR, from specs 1.1
  81398. DracoDecoderModule: any;
  81399. setImmediate(handler: (...args: any[]) => void): number;
  81400. }
  81401. interface HTMLCanvasElement {
  81402. requestPointerLock(): void;
  81403. msRequestPointerLock?(): void;
  81404. mozRequestPointerLock?(): void;
  81405. webkitRequestPointerLock?(): void;
  81406. /** Track whether a record is in progress */
  81407. isRecording: boolean;
  81408. /** Capture Stream method defined by some browsers */
  81409. captureStream(fps?: number): MediaStream;
  81410. }
  81411. interface CanvasRenderingContext2D {
  81412. msImageSmoothingEnabled: boolean;
  81413. }
  81414. interface MouseEvent {
  81415. mozMovementX: number;
  81416. mozMovementY: number;
  81417. webkitMovementX: number;
  81418. webkitMovementY: number;
  81419. msMovementX: number;
  81420. msMovementY: number;
  81421. }
  81422. interface Navigator {
  81423. mozGetVRDevices: (any: any) => any;
  81424. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  81425. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  81426. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  81427. webkitGetGamepads(): Gamepad[];
  81428. msGetGamepads(): Gamepad[];
  81429. webkitGamepads(): Gamepad[];
  81430. }
  81431. interface HTMLVideoElement {
  81432. mozSrcObject: any;
  81433. }
  81434. interface Math {
  81435. fround(x: number): number;
  81436. imul(a: number, b: number): number;
  81437. log2(x: number): number;
  81438. }
  81439. interface WebGLRenderingContext {
  81440. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  81441. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  81442. vertexAttribDivisor(index: number, divisor: number): void;
  81443. createVertexArray(): any;
  81444. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  81445. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  81446. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  81447. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  81448. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  81449. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  81450. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  81451. // Queries
  81452. createQuery(): WebGLQuery;
  81453. deleteQuery(query: WebGLQuery): void;
  81454. beginQuery(target: number, query: WebGLQuery): void;
  81455. endQuery(target: number): void;
  81456. getQueryParameter(query: WebGLQuery, pname: number): any;
  81457. getQuery(target: number, pname: number): any;
  81458. MAX_SAMPLES: number;
  81459. RGBA8: number;
  81460. READ_FRAMEBUFFER: number;
  81461. DRAW_FRAMEBUFFER: number;
  81462. UNIFORM_BUFFER: number;
  81463. HALF_FLOAT_OES: number;
  81464. RGBA16F: number;
  81465. RGBA32F: number;
  81466. R32F: number;
  81467. RG32F: number;
  81468. RGB32F: number;
  81469. R16F: number;
  81470. RG16F: number;
  81471. RGB16F: number;
  81472. RED: number;
  81473. RG: number;
  81474. R8: number;
  81475. RG8: number;
  81476. UNSIGNED_INT_24_8: number;
  81477. DEPTH24_STENCIL8: number;
  81478. MIN: number;
  81479. MAX: number;
  81480. /* Multiple Render Targets */
  81481. drawBuffers(buffers: number[]): void;
  81482. readBuffer(src: number): void;
  81483. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  81484. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  81485. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  81486. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  81487. // Occlusion Query
  81488. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  81489. ANY_SAMPLES_PASSED: number;
  81490. QUERY_RESULT_AVAILABLE: number;
  81491. QUERY_RESULT: number;
  81492. }
  81493. interface WebGLProgram {
  81494. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  81495. }
  81496. interface EXT_disjoint_timer_query {
  81497. QUERY_COUNTER_BITS_EXT: number;
  81498. TIME_ELAPSED_EXT: number;
  81499. TIMESTAMP_EXT: number;
  81500. GPU_DISJOINT_EXT: number;
  81501. QUERY_RESULT_EXT: number;
  81502. QUERY_RESULT_AVAILABLE_EXT: number;
  81503. queryCounterEXT(query: WebGLQuery, target: number): void;
  81504. createQueryEXT(): WebGLQuery;
  81505. beginQueryEXT(target: number, query: WebGLQuery): void;
  81506. endQueryEXT(target: number): void;
  81507. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  81508. deleteQueryEXT(query: WebGLQuery): void;
  81509. }
  81510. interface WebGLUniformLocation {
  81511. _currentState: any;
  81512. }
  81513. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  81514. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  81515. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  81516. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  81517. interface WebGLRenderingContext {
  81518. readonly RASTERIZER_DISCARD: number;
  81519. readonly DEPTH_COMPONENT24: number;
  81520. readonly TEXTURE_3D: number;
  81521. readonly TEXTURE_2D_ARRAY: number;
  81522. readonly TEXTURE_COMPARE_FUNC: number;
  81523. readonly TEXTURE_COMPARE_MODE: number;
  81524. readonly COMPARE_REF_TO_TEXTURE: number;
  81525. readonly TEXTURE_WRAP_R: number;
  81526. readonly HALF_FLOAT: number;
  81527. readonly RGB8: number;
  81528. readonly RED_INTEGER: number;
  81529. readonly RG_INTEGER: number;
  81530. readonly RGB_INTEGER: number;
  81531. readonly RGBA_INTEGER: number;
  81532. readonly R8_SNORM: number;
  81533. readonly RG8_SNORM: number;
  81534. readonly RGB8_SNORM: number;
  81535. readonly RGBA8_SNORM: number;
  81536. readonly R8I: number;
  81537. readonly RG8I: number;
  81538. readonly RGB8I: number;
  81539. readonly RGBA8I: number;
  81540. readonly R8UI: number;
  81541. readonly RG8UI: number;
  81542. readonly RGB8UI: number;
  81543. readonly RGBA8UI: number;
  81544. readonly R16I: number;
  81545. readonly RG16I: number;
  81546. readonly RGB16I: number;
  81547. readonly RGBA16I: number;
  81548. readonly R16UI: number;
  81549. readonly RG16UI: number;
  81550. readonly RGB16UI: number;
  81551. readonly RGBA16UI: number;
  81552. readonly R32I: number;
  81553. readonly RG32I: number;
  81554. readonly RGB32I: number;
  81555. readonly RGBA32I: number;
  81556. readonly R32UI: number;
  81557. readonly RG32UI: number;
  81558. readonly RGB32UI: number;
  81559. readonly RGBA32UI: number;
  81560. readonly RGB10_A2UI: number;
  81561. readonly R11F_G11F_B10F: number;
  81562. readonly RGB9_E5: number;
  81563. readonly RGB10_A2: number;
  81564. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  81565. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  81566. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  81567. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  81568. readonly DEPTH_COMPONENT32F: number;
  81569. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  81570. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  81571. 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;
  81572. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  81573. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  81574. readonly TRANSFORM_FEEDBACK: number;
  81575. readonly INTERLEAVED_ATTRIBS: number;
  81576. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  81577. createTransformFeedback(): WebGLTransformFeedback;
  81578. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  81579. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  81580. beginTransformFeedback(primitiveMode: number): void;
  81581. endTransformFeedback(): void;
  81582. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  81583. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  81584. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  81585. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  81586. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  81587. }
  81588. interface ImageBitmap {
  81589. readonly width: number;
  81590. readonly height: number;
  81591. close(): void;
  81592. }
  81593. interface WebGLQuery extends WebGLObject {
  81594. }
  81595. declare var WebGLQuery: {
  81596. prototype: WebGLQuery;
  81597. new(): WebGLQuery;
  81598. };
  81599. interface WebGLSampler extends WebGLObject {
  81600. }
  81601. declare var WebGLSampler: {
  81602. prototype: WebGLSampler;
  81603. new(): WebGLSampler;
  81604. };
  81605. interface WebGLSync extends WebGLObject {
  81606. }
  81607. declare var WebGLSync: {
  81608. prototype: WebGLSync;
  81609. new(): WebGLSync;
  81610. };
  81611. interface WebGLTransformFeedback extends WebGLObject {
  81612. }
  81613. declare var WebGLTransformFeedback: {
  81614. prototype: WebGLTransformFeedback;
  81615. new(): WebGLTransformFeedback;
  81616. };
  81617. interface WebGLVertexArrayObject extends WebGLObject {
  81618. }
  81619. declare var WebGLVertexArrayObject: {
  81620. prototype: WebGLVertexArrayObject;
  81621. new(): WebGLVertexArrayObject;
  81622. };
  81623. interface Navigator {
  81624. readonly gpu: GPU | undefined;
  81625. }
  81626. interface GPUColorDict {
  81627. a: number;
  81628. b: number;
  81629. g: number;
  81630. r: number;
  81631. }
  81632. type GPUColor = [number, number, number, number] | GPUColorDict;
  81633. interface GPUOrigin2DDict {
  81634. x?: number;
  81635. y?: number;
  81636. }
  81637. type GPUOrigin2D = [number, number] | GPUOrigin2DDict;
  81638. interface GPUOrigin3DDict {
  81639. x?: number;
  81640. y?: number;
  81641. z?: number;
  81642. }
  81643. type GPUOrigin3D = [number, number, number] | GPUOrigin3DDict;
  81644. interface GPUExtent3DDict {
  81645. width: number;
  81646. height: number;
  81647. depth: number;
  81648. }
  81649. type GPUExtent3D = [number, number, number] | GPUExtent3DDict;
  81650. type GPUBindingResource =
  81651. | GPUSampler
  81652. | GPUTextureView
  81653. | GPUBufferBinding;
  81654. type GPUExtensionName =
  81655. | "texture-compression-bc"
  81656. | "timestamp-query"
  81657. | "pipeline-statistics-query"
  81658. | "depth-clamping"
  81659. | "depth24unorm-stencil8"
  81660. | "depth32float-stencil8";
  81661. type GPUAddressMode = "clamp-to-edge" | "repeat" | "mirror-repeat";
  81662. type GPUBindingType =
  81663. | "uniform-buffer"
  81664. | "storage-buffer"
  81665. | "readonly-storage-buffer"
  81666. | "sampler"
  81667. | "comparison-sampler"
  81668. | "sampled-texture"
  81669. | "readonly-storage-texture"
  81670. | "writeonly-storage-texture";
  81671. type GPUBlendFactor =
  81672. | "zero"
  81673. | "one"
  81674. | "src-color"
  81675. | "one-minus-src-color"
  81676. | "src-alpha"
  81677. | "one-minus-src-alpha"
  81678. | "dst-color"
  81679. | "one-minus-dst-color"
  81680. | "dst-alpha"
  81681. | "one-minus-dst-alpha"
  81682. | "src-alpha-saturated"
  81683. | "blend-color"
  81684. | "one-minus-blend-color";
  81685. type GPUBlendOperation =
  81686. | "add"
  81687. | "subtract"
  81688. | "reverse-subtract"
  81689. | "min"
  81690. | "max";
  81691. type GPUCompareFunction =
  81692. | "never"
  81693. | "less"
  81694. | "equal"
  81695. | "less-equal"
  81696. | "greater"
  81697. | "not-equal"
  81698. | "greater-equal"
  81699. | "always";
  81700. type GPUCullMode = "none" | "front" | "back";
  81701. type GPUFilterMode = "nearest" | "linear";
  81702. type GPUFrontFace = "ccw" | "cw";
  81703. type GPUIndexFormat = "uint16" | "uint32";
  81704. type GPUInputStepMode = "vertex" | "instance";
  81705. type GPULoadOp = "load";
  81706. type GPUPrimitiveTopology =
  81707. | "point-list"
  81708. | "line-list"
  81709. | "line-strip"
  81710. | "triangle-list"
  81711. | "triangle-strip";
  81712. type GPUStencilOperation =
  81713. | "keep"
  81714. | "zero"
  81715. | "replace"
  81716. | "invert"
  81717. | "increment-clamp"
  81718. | "decrement-clamp"
  81719. | "increment-wrap"
  81720. | "decrement-wrap";
  81721. type GPUStoreOp = "store" | "clear";
  81722. type GPUTextureDimension = "1d" | "2d" | "3d";
  81723. type GPUTextureFormat =
  81724. | "r8unorm"
  81725. | "r8snorm"
  81726. | "r8uint"
  81727. | "r8sint"
  81728. | "r16uint"
  81729. | "r16sint"
  81730. | "r16float"
  81731. | "rg8unorm"
  81732. | "rg8snorm"
  81733. | "rg8uint"
  81734. | "rg8sint"
  81735. | "r32uint"
  81736. | "r32sint"
  81737. | "r32float"
  81738. | "rg16uint"
  81739. | "rg16sint"
  81740. | "rg16float"
  81741. | "rgba8unorm"
  81742. | "rgba8unorm-srgb"
  81743. | "rgba8snorm"
  81744. | "rgba8uint"
  81745. | "rgba8sint"
  81746. | "bgra8unorm"
  81747. | "bgra8unorm-srgb"
  81748. | "rgb9e5ufloat"
  81749. | "rgb10a2unorm"
  81750. | "rg11b10ufloat"
  81751. | "rg32uint"
  81752. | "rg32sint"
  81753. | "rg32float"
  81754. | "rgba16uint"
  81755. | "rgba16sint"
  81756. | "rgba16float"
  81757. | "rgba32uint"
  81758. | "rgba32sint"
  81759. | "rgba32float"
  81760. | "stencil8"
  81761. | "depth16unorm"
  81762. | "depth24plus"
  81763. | "depth24plus-stencil8"
  81764. | "depth32float"
  81765. | "bc1-rgba-unorm"
  81766. | "bc1-rgba-unorm-srgb"
  81767. | "bc2-rgba-unorm"
  81768. | "bc2-rgba-unorm-srgb"
  81769. | "bc3-rgba-unorm"
  81770. | "bc3-rgba-unorm-srgb"
  81771. | "bc4-r-unorm"
  81772. | "bc4-r-snorm"
  81773. | "bc5-rg-unorm"
  81774. | "bc5-rg-snorm"
  81775. | "bc6h-rgb-ufloat"
  81776. | "bc6h-rgb-float"
  81777. | "bc7-rgba-unorm"
  81778. | "bc7-rgba-unorm-srgb"
  81779. | "depth24unorm-stencil8"
  81780. | "depth32float-stencil8";
  81781. type GPUTextureComponentType = "float" | "sint" | "uint" | "depth-comparison";
  81782. type GPUTextureViewDimension =
  81783. | "1d"
  81784. | "2d"
  81785. | "2d-array"
  81786. | "cube"
  81787. | "cube-array"
  81788. | "3d";
  81789. type GPUVertexFormat =
  81790. | "uchar2"
  81791. | "uchar4"
  81792. | "char2"
  81793. | "char4"
  81794. | "uchar2norm"
  81795. | "uchar4norm"
  81796. | "char2norm"
  81797. | "char4norm"
  81798. | "ushort2"
  81799. | "ushort4"
  81800. | "short2"
  81801. | "short4"
  81802. | "ushort2norm"
  81803. | "ushort4norm"
  81804. | "short2norm"
  81805. | "short4norm"
  81806. | "half2"
  81807. | "half4"
  81808. | "float"
  81809. | "float2"
  81810. | "float3"
  81811. | "float4"
  81812. | "uint"
  81813. | "uint2"
  81814. | "uint3"
  81815. | "uint4"
  81816. | "int"
  81817. | "int2"
  81818. | "int3"
  81819. | "int4";
  81820. type GPUTextureAspect = "all" | "stencil-only" | "depth-only";
  81821. type GPUBufferUsageFlags = number;
  81822. type GPUColorWriteFlags = number;
  81823. type GPUShaderStageFlags = number;
  81824. type GPUTextureUsageFlags = number;
  81825. type GPUMapModeFlags = number;
  81826. interface GPUBindGroupEntry {
  81827. binding: number;
  81828. resource: GPUBindingResource;
  81829. }
  81830. interface GPUBindGroupDescriptor extends GPUObjectDescriptorBase {
  81831. layout: GPUBindGroupLayout;
  81832. entries: Iterable<GPUBindGroupEntry>;
  81833. }
  81834. interface GPUBindGroupLayoutEntry {
  81835. binding: number;
  81836. visibility: GPUShaderStageFlags;
  81837. type: GPUBindingType;
  81838. hasDynamicOffset?: boolean;
  81839. minBufferBindingSize?: number;
  81840. viewDimension?: GPUTextureViewDimension;
  81841. textureComponentType?: GPUTextureComponentType;
  81842. storageTextureFormat?: GPUTextureFormat;
  81843. }
  81844. interface GPUBindGroupLayoutDescriptor
  81845. extends GPUObjectDescriptorBase {
  81846. entries: Iterable<GPUBindGroupLayoutEntry>;
  81847. }
  81848. interface GPUBlendDescriptor {
  81849. dstFactor?: GPUBlendFactor;
  81850. operation?: GPUBlendOperation;
  81851. srcFactor?: GPUBlendFactor;
  81852. }
  81853. interface GPUColorStateDescriptor {
  81854. format: GPUTextureFormat;
  81855. alphaBlend?: GPUBlendDescriptor;
  81856. colorBlend?: GPUBlendDescriptor;
  81857. writeMask?: GPUColorWriteFlags;
  81858. }
  81859. interface GPUBufferBinding {
  81860. buffer: GPUBuffer;
  81861. offset?: number;
  81862. size?: number;
  81863. }
  81864. interface GPUTextureDataLayout {
  81865. offset?: number;
  81866. bytesPerRow: number;
  81867. rowsPerImage?: number;
  81868. }
  81869. interface GPUBufferCopyView extends GPUTextureDataLayout {
  81870. buffer: GPUBuffer;
  81871. }
  81872. interface GPUTextureCopyView {
  81873. texture: GPUTexture;
  81874. mipLevel?: number;
  81875. origin?: GPUOrigin3D;
  81876. }
  81877. interface GPUImageBitmapCopyView {
  81878. imageBitmap: ImageBitmap;
  81879. origin?: GPUOrigin2D;
  81880. }
  81881. interface GPUBufferDescriptor extends GPUObjectDescriptorBase {
  81882. size: number;
  81883. usage: GPUBufferUsageFlags;
  81884. mappedAtCreation?: boolean;
  81885. }
  81886. interface GPUCommandEncoderDescriptor extends GPUObjectDescriptorBase {
  81887. label?: string;
  81888. measureExecutionTime?: boolean;
  81889. }
  81890. interface GPUComputePipelineDescriptor
  81891. extends GPUPipelineDescriptorBase {
  81892. computeStage: GPUProgrammableStageDescriptor;
  81893. }
  81894. interface GPUDepthStencilStateDescriptor {
  81895. format: GPUTextureFormat;
  81896. depthWriteEnabled?: boolean;
  81897. depthCompare?: GPUCompareFunction;
  81898. stencilFront?: GPUStencilStateFaceDescriptor;
  81899. stencilBack?: GPUStencilStateFaceDescriptor;
  81900. stencilReadMask?: number;
  81901. stencilWriteMask?: number;
  81902. }
  81903. interface GPUDeviceDescriptor extends GPUObjectDescriptorBase {
  81904. extensions?: Iterable<GPUExtensionName>;
  81905. limits?: GPULimits;
  81906. }
  81907. interface GPUFenceDescriptor extends GPUObjectDescriptorBase {
  81908. initialValue?: number;
  81909. label?: string;
  81910. signalQueue?: GPUQueue;
  81911. }
  81912. interface GPUVertexAttributeDescriptor {
  81913. format: GPUVertexFormat;
  81914. offset: number;
  81915. shaderLocation: number;
  81916. }
  81917. interface GPUVertexBufferLayoutDescriptor {
  81918. arrayStride: number;
  81919. stepMode?: GPUInputStepMode;
  81920. attributes: Iterable<GPUVertexAttributeDescriptor>;
  81921. }
  81922. interface GPUVertexStateDescriptor {
  81923. indexFormat?: GPUIndexFormat;
  81924. vertexBuffers?: Iterable<GPUVertexBufferLayoutDescriptor>;
  81925. }
  81926. interface GPULimits {
  81927. maxBindGroups?: number;
  81928. maxDynamicUniformBuffersPerPipelineLayout?: number;
  81929. maxDynamicStorageBuffersPerPipelineLayout?: number;
  81930. maxSampledTexturesPerShaderStage?: number;
  81931. maxSamplersPerShaderStage?: number;
  81932. maxStorageBuffersPerShaderStage?: number;
  81933. maxStorageTexturesPerShaderStage?: number;
  81934. maxUniformBuffersPerShaderStage?: number;
  81935. maxUniformBufferBindingSize?: number;
  81936. }
  81937. interface GPUPipelineDescriptorBase {
  81938. label?: string;
  81939. layout?: GPUPipelineLayout;
  81940. }
  81941. interface GPUPipelineLayoutDescriptor extends GPUObjectDescriptorBase {
  81942. bindGroupLayouts: Iterable<GPUBindGroupLayout>;
  81943. }
  81944. interface GPUProgrammableStageDescriptor {
  81945. module: GPUShaderModule;
  81946. entryPoint: string;
  81947. }
  81948. interface GPURasterizationStateDescriptor {
  81949. frontFace?: GPUFrontFace;
  81950. cullMode?: GPUCullMode;
  81951. clampDepth?: boolean;
  81952. depthBias?: number;
  81953. depthBiasSlopeScale?: number;
  81954. depthBiasClamp?: number;
  81955. }
  81956. interface GPURenderPassColorAttachmentDescriptor {
  81957. attachment: GPUTextureView;
  81958. resolveTarget?: GPUTextureView;
  81959. loadValue: GPULoadOp | GPUColor;
  81960. storeOp?: GPUStoreOp;
  81961. }
  81962. interface GPURenderPassDepthStencilAttachmentDescriptor {
  81963. attachment: GPUTextureView;
  81964. depthLoadValue: GPULoadOp | number;
  81965. depthStoreOp: GPUStoreOp;
  81966. depthReadOnly?: boolean;
  81967. stencilLoadValue: GPULoadOp | number;
  81968. stencilStoreOp: GPUStoreOp;
  81969. stencilReadOnly?: boolean;
  81970. }
  81971. interface GPURenderPassDescriptor extends GPUObjectDescriptorBase {
  81972. colorAttachments: Iterable<GPURenderPassColorAttachmentDescriptor>;
  81973. depthStencilAttachment?: GPURenderPassDepthStencilAttachmentDescriptor;
  81974. }
  81975. interface GPURenderPipelineDescriptor
  81976. extends GPUPipelineDescriptorBase {
  81977. vertexStage: GPUProgrammableStageDescriptor;
  81978. fragmentStage?: GPUProgrammableStageDescriptor;
  81979. primitiveTopology: GPUPrimitiveTopology;
  81980. rasterizationState?: GPURasterizationStateDescriptor;
  81981. colorStates: Iterable<GPUColorStateDescriptor>;
  81982. depthStencilState?: GPUDepthStencilStateDescriptor;
  81983. vertexState?: GPUVertexStateDescriptor;
  81984. sampleCount?: number;
  81985. sampleMask?: number;
  81986. alphaToCoverageEnabled?: boolean;
  81987. }
  81988. interface GPUSamplerDescriptor extends GPUObjectDescriptorBase {
  81989. addressModeU?: GPUAddressMode;
  81990. addressModeV?: GPUAddressMode;
  81991. addressModeW?: GPUAddressMode;
  81992. magFilter?: GPUFilterMode;
  81993. minFilter?: GPUFilterMode;
  81994. mipmapFilter?: GPUFilterMode;
  81995. lodMinClamp?: number;
  81996. lodMaxClamp?: number;
  81997. compare?: GPUCompareFunction;
  81998. maxAnisotropy?: number;
  81999. }
  82000. interface GPUShaderModuleDescriptor extends GPUObjectDescriptorBase {
  82001. code: Uint32Array | string;
  82002. label?: string;
  82003. sourceMap?: object;
  82004. }
  82005. interface GPUStencilStateFaceDescriptor {
  82006. compare?: GPUCompareFunction;
  82007. depthFailOp?: GPUStencilOperation;
  82008. passOp?: GPUStencilOperation;
  82009. failOp?: GPUStencilOperation;
  82010. }
  82011. interface GPUSwapChainDescriptor extends GPUObjectDescriptorBase {
  82012. device: GPUDevice;
  82013. format: GPUTextureFormat;
  82014. usage?: GPUTextureUsageFlags;
  82015. }
  82016. interface GPUTextureDescriptor extends GPUObjectDescriptorBase {
  82017. size: GPUExtent3D;
  82018. mipLevelCount?: number;
  82019. sampleCount?: number;
  82020. dimension?: GPUTextureDimension;
  82021. format: GPUTextureFormat;
  82022. usage: GPUTextureUsageFlags;
  82023. }
  82024. interface GPUTextureViewDescriptor extends GPUObjectDescriptorBase {
  82025. format?: GPUTextureFormat;
  82026. dimension?: GPUTextureViewDimension;
  82027. aspect?: GPUTextureAspect;
  82028. baseArrayLayer?: number;
  82029. baseMipLevel?: number;
  82030. arrayLayerCount?: number;
  82031. mipLevelCount?: number;
  82032. }
  82033. declare class GPUAdapter {
  82034. // https://michalzalecki.com/nominal-typing-in-typescript/#approach-1-class-with-a-private-property
  82035. private __brand: void;
  82036. readonly name: string;
  82037. readonly extensions: GPUExtensionName[];
  82038. readonly limits: Required<GPULimits>;
  82039. requestDevice(descriptor?: GPUDeviceDescriptor): Promise<GPUDevice | null>;
  82040. }
  82041. declare class GPUBindGroup implements GPUObjectBase {
  82042. private __brand: void;
  82043. label: string | undefined;
  82044. }
  82045. declare class GPUBindGroupLayout implements GPUObjectBase {
  82046. private __brand: void;
  82047. label: string | undefined;
  82048. }
  82049. declare class GPUBuffer implements GPUObjectBase {
  82050. private __brand: void;
  82051. label: string | undefined;
  82052. destroy(): void;
  82053. unmap(): void;
  82054. mapAsync(mode: GPUMapModeFlags, offset?: number, size?: number): Promise<void>;
  82055. getMappedRange(offset?: number, size?: number): ArrayBuffer;
  82056. }
  82057. declare class GPUCommandBuffer implements GPUObjectBase {
  82058. private __brand: void;
  82059. label: string | undefined;
  82060. readonly executionTime: Promise<number>;
  82061. }
  82062. interface GPUCommandBufferDescriptor extends GPUObjectDescriptorBase { }
  82063. declare class GPUCommandEncoder implements GPUObjectBase {
  82064. private __brand: void;
  82065. label: string | undefined;
  82066. beginComputePass(
  82067. descriptor?: GPUComputePassDescriptor
  82068. ): GPUComputePassEncoder;
  82069. beginRenderPass(descriptor: GPURenderPassDescriptor): GPURenderPassEncoder;
  82070. copyBufferToBuffer(
  82071. source: GPUBuffer,
  82072. sourceOffset: number,
  82073. destination: GPUBuffer,
  82074. destinationOffset: number,
  82075. size: number
  82076. ): void;
  82077. copyBufferToTexture(
  82078. source: GPUBufferCopyView,
  82079. destination: GPUTextureCopyView,
  82080. copySize: GPUExtent3D
  82081. ): void;
  82082. copyTextureToBuffer(
  82083. source: GPUTextureCopyView,
  82084. destination: GPUBufferCopyView,
  82085. copySize: GPUExtent3D
  82086. ): void;
  82087. copyTextureToTexture(
  82088. source: GPUTextureCopyView,
  82089. destination: GPUTextureCopyView,
  82090. copySize: GPUExtent3D
  82091. ): void;
  82092. finish(descriptor?: GPUCommandBufferDescriptor): GPUCommandBuffer;
  82093. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  82094. popDebugGroup(): void;
  82095. pushDebugGroup(groupLabel: string): void;
  82096. insertDebugMarker(markerLabel: string): void;
  82097. }
  82098. interface GPUComputePassDescriptor extends GPUObjectDescriptorBase { }
  82099. declare class GPUComputePassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder {
  82100. private __brand: void;
  82101. label: string | undefined;
  82102. setBindGroup(
  82103. index: number,
  82104. bindGroup: GPUBindGroup,
  82105. dynamicOffsets?: Iterable<number>
  82106. ): void;
  82107. popDebugGroup(): void;
  82108. pushDebugGroup(groupLabel: string): void;
  82109. insertDebugMarker(markerLabel: string): void;
  82110. setPipeline(pipeline: GPUComputePipeline): void;
  82111. dispatch(x: number, y?: number, z?: number): void;
  82112. dispatchIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  82113. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  82114. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  82115. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  82116. endPass(): void;
  82117. }
  82118. declare class GPUComputePipeline implements GPUPipelineBase {
  82119. private __brand: void;
  82120. label: string | undefined;
  82121. getBindGroupLayout(index: number): GPUBindGroupLayout;
  82122. }
  82123. interface GPUObjectBase {
  82124. label: string | undefined;
  82125. }
  82126. interface GPUObjectDescriptorBase {
  82127. label?: string;
  82128. }
  82129. // SwapChain / CanvasContext
  82130. declare class GPUCanvasContext {
  82131. private __brand: void;
  82132. configureSwapChain(descriptor: GPUSwapChainDescriptor): GPUSwapChain;
  82133. getSwapChainPreferredFormat(device: GPUDevice): Promise<GPUTextureFormat>;
  82134. }
  82135. declare class GPUDevice extends EventTarget implements GPUObjectBase {
  82136. private __brand: void;
  82137. label: string | undefined;
  82138. readonly adapter: GPUAdapter;
  82139. readonly extensions: GPUExtensionName[];
  82140. readonly limits: Required<GPULimits>;
  82141. createBindGroup(descriptor: GPUBindGroupDescriptor): GPUBindGroup;
  82142. createBindGroupLayout(
  82143. descriptor: GPUBindGroupLayoutDescriptor
  82144. ): GPUBindGroupLayout;
  82145. createBuffer(descriptor: GPUBufferDescriptor): GPUBuffer;
  82146. createPipelineLayout(
  82147. descriptor: GPUPipelineLayoutDescriptor
  82148. ): GPUPipelineLayout;
  82149. createSampler(descriptor?: GPUSamplerDescriptor): GPUSampler;
  82150. createShaderModule(descriptor: GPUShaderModuleDescriptor): GPUShaderModule;
  82151. createTexture(descriptor: GPUTextureDescriptor): GPUTexture;
  82152. createComputePipeline(
  82153. descriptor: GPUComputePipelineDescriptor
  82154. ): GPUComputePipeline;
  82155. createRenderPipeline(
  82156. descriptor: GPURenderPipelineDescriptor
  82157. ): GPURenderPipeline;
  82158. createReadyComputePipeline(
  82159. descriptor: GPUComputePipelineDescriptor
  82160. ): Promise<GPUComputePipeline>;
  82161. createReadyRenderPipeline(
  82162. descriptor: GPURenderPipelineDescriptor
  82163. ): Promise<GPURenderPipeline>;
  82164. createCommandEncoder(
  82165. descriptor?: GPUCommandEncoderDescriptor
  82166. ): GPUCommandEncoder;
  82167. createRenderBundleEncoder(
  82168. descriptor: GPURenderBundleEncoderDescriptor
  82169. ): GPURenderBundleEncoder;
  82170. createQuerySet(descriptor: GPUQuerySetDescriptor): GPUQuerySet;
  82171. defaultQueue: GPUQueue;
  82172. pushErrorScope(filter: GPUErrorFilter): void;
  82173. popErrorScope(): Promise<GPUError | null>;
  82174. onuncapturederror: Event | undefined;
  82175. readonly lost: Promise<GPUDeviceLostInfo>;
  82176. }
  82177. declare class GPUFence implements GPUObjectBase {
  82178. private __brand: void;
  82179. label: string | undefined;
  82180. getCompletedValue(): number;
  82181. onCompletion(completionValue: number): Promise<void>;
  82182. }
  82183. interface GPUPipelineBase extends GPUObjectBase {
  82184. getBindGroupLayout(index: number): GPUBindGroupLayout;
  82185. }
  82186. declare class GPUPipelineLayout implements GPUObjectBase {
  82187. private __brand: void;
  82188. label: string | undefined;
  82189. }
  82190. interface GPUProgrammablePassEncoder {
  82191. setBindGroup(
  82192. index: number,
  82193. bindGroup: GPUBindGroup,
  82194. dynamicOffsets?: Iterable<number>
  82195. ): void;
  82196. popDebugGroup(): void;
  82197. pushDebugGroup(groupLabel: string): void;
  82198. insertDebugMarker(markerLabel: string): void;
  82199. }
  82200. declare class GPUQueue implements GPUObjectBase {
  82201. private __brand: void;
  82202. label: string | undefined;
  82203. signal(fence: GPUFence, signalValue: number): void;
  82204. submit(commandBuffers: Iterable<GPUCommandBuffer>): void;
  82205. createFence(descriptor?: GPUFenceDescriptor): GPUFence;
  82206. writeBuffer(buffer: GPUBuffer,
  82207. bufferOffset: number,
  82208. data: BufferSource | ArrayBuffer,
  82209. dataOffset?: number,
  82210. size?: number): void;
  82211. writeTexture(destination: GPUTextureCopyView,
  82212. data: BufferSource | ArrayBuffer,
  82213. dataLayout: GPUTextureDataLayout,
  82214. size: GPUExtent3D): void;
  82215. copyImageBitmapToTexture(
  82216. source: GPUImageBitmapCopyView,
  82217. destination: GPUTextureCopyView,
  82218. copySize: GPUExtent3D
  82219. ): void;
  82220. }
  82221. type GPUQueryType =
  82222. | "occlusion"
  82223. | "timestamp"
  82224. | "pipeline-statistics";
  82225. type GPUPipelineStatisticName =
  82226. | "vertex-shader-invocations"
  82227. | "clipper-invocations"
  82228. | "clipper-primitives-out"
  82229. | "fragment-shader-invocations"
  82230. | "compute-shader-invocations";
  82231. interface GPUQuerySetDescriptor extends GPUObjectDescriptorBase {
  82232. type: GPUQueryType;
  82233. count: number;
  82234. pipelineStatistics?: Iterable<GPUPipelineStatisticName>;
  82235. }
  82236. declare class GPUQuerySet implements GPUObjectBase {
  82237. private __brand: void;
  82238. label: string | undefined;
  82239. destroy(): void;
  82240. }
  82241. interface GPURenderEncoderBase {
  82242. setPipeline(pipeline: GPURenderPipeline): void;
  82243. setIndexBuffer(buffer: GPUBuffer, offset?: number, size?: number): void;
  82244. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  82245. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number, size?: number): void;
  82246. draw(
  82247. vertexCount: number,
  82248. instanceCount?: number,
  82249. firstVertex?: number,
  82250. firstInstance?: number
  82251. ): void;
  82252. drawIndexed(
  82253. indexCount: number,
  82254. instanceCount?: number,
  82255. firstIndex?: number,
  82256. baseVertex?: number,
  82257. firstInstance?: number
  82258. ): void;
  82259. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  82260. drawIndexedIndirect(
  82261. indirectBuffer: GPUBuffer,
  82262. indirectOffset: number
  82263. ): void;
  82264. }
  82265. declare class GPURenderPassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder, GPURenderEncoderBase {
  82266. private __brand: void;
  82267. label: string | undefined;
  82268. setBindGroup(
  82269. index: number,
  82270. bindGroup: GPUBindGroup,
  82271. dynamicOffsets?: Iterable<number>
  82272. ): void;
  82273. popDebugGroup(): void;
  82274. pushDebugGroup(groupLabel: string): void;
  82275. insertDebugMarker(markerLabel: string): void;
  82276. setPipeline(pipeline: GPURenderPipeline): void;
  82277. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  82278. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  82279. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  82280. draw(
  82281. vertexCount: number,
  82282. instanceCount?: number,
  82283. firstVertex?: number,
  82284. firstInstance?: number
  82285. ): void;
  82286. drawIndexed(
  82287. indexCount: number,
  82288. instanceCount?: number,
  82289. firstIndex?: number,
  82290. baseVertex?: number,
  82291. firstInstance?: number
  82292. ): void;
  82293. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  82294. drawIndexedIndirect(
  82295. indirectBuffer: GPUBuffer,
  82296. indirectOffset: number
  82297. ): void;
  82298. setViewport(
  82299. x: number,
  82300. y: number,
  82301. width: number,
  82302. height: number,
  82303. minDepth: number,
  82304. maxDepth: number
  82305. ): void;
  82306. setScissorRect(x: number, y: number, width: number, height: number): void;
  82307. setBlendColor(color: GPUColor): void;
  82308. setStencilReference(reference: number): void;
  82309. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  82310. beginOcclusionQuery(queryIndex: number): void;
  82311. endOcclusionQuery(): void;
  82312. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  82313. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  82314. executeBundles(bundles: Iterable<GPURenderBundle>): void;
  82315. endPass(): void;
  82316. }
  82317. interface GPURenderBundleDescriptor extends GPUObjectDescriptorBase { }
  82318. declare class GPURenderBundle implements GPUObjectBase {
  82319. private __brand: void;
  82320. label: string | undefined;
  82321. }
  82322. declare class GPURenderBundleEncoder implements GPURenderEncoderBase {
  82323. private __brand: void;
  82324. label: string | undefined;
  82325. setBindGroup(
  82326. index: number,
  82327. bindGroup: GPUBindGroup,
  82328. dynamicOffsets?: Iterable<number>
  82329. ): void;
  82330. popDebugGroup(): void;
  82331. pushDebugGroup(groupLabel: string): void;
  82332. insertDebugMarker(markerLabel: string): void;
  82333. setPipeline(pipeline: GPURenderPipeline): void;
  82334. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  82335. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  82336. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  82337. draw(
  82338. vertexCount: number,
  82339. instanceCount?: number,
  82340. firstVertex?: number,
  82341. firstInstance?: number
  82342. ): void;
  82343. drawIndexed(
  82344. indexCount: number,
  82345. instanceCount?: number,
  82346. firstIndex?: number,
  82347. baseVertex?: number,
  82348. firstInstance?: number
  82349. ): void;
  82350. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  82351. drawIndexedIndirect(
  82352. indirectBuffer: GPUBuffer,
  82353. indirectOffset: number
  82354. ): void;
  82355. finish(descriptor?: GPURenderBundleDescriptor): GPURenderBundle;
  82356. }
  82357. interface GPURenderBundleEncoderDescriptor
  82358. extends GPUObjectDescriptorBase {
  82359. colorFormats: Iterable<GPUTextureFormat>;
  82360. depthStencilFormat?: GPUTextureFormat;
  82361. sampleCount?: number;
  82362. }
  82363. declare class GPURenderPipeline implements GPUPipelineBase {
  82364. private __brand: void;
  82365. label: string | undefined;
  82366. getBindGroupLayout(index: number): GPUBindGroupLayout;
  82367. }
  82368. declare class GPUSampler implements GPUObjectBase {
  82369. private __brand: void;
  82370. label: string | undefined;
  82371. }
  82372. type GPUCompilationMessageType =
  82373. | "error"
  82374. | "warning"
  82375. | "info";
  82376. interface GPUCompilationMessage {
  82377. readonly message: string;
  82378. readonly type: GPUCompilationMessageType;
  82379. readonly lineNum: number;
  82380. readonly linePos: number;
  82381. }
  82382. interface GPUCompilationInfo {
  82383. readonly messages: readonly GPUCompilationMessage[];
  82384. }
  82385. declare class GPUShaderModule implements GPUObjectBase {
  82386. private __brand: void;
  82387. label: string | undefined;
  82388. compilationInfo(): Promise<GPUCompilationInfo>;
  82389. }
  82390. declare class GPUSwapChain implements GPUObjectBase {
  82391. private __brand: void;
  82392. label: string | undefined;
  82393. getCurrentTexture(): GPUTexture;
  82394. }
  82395. declare class GPUTexture implements GPUObjectBase {
  82396. private __brand: void;
  82397. label: string | undefined;
  82398. createView(descriptor?: GPUTextureViewDescriptor): GPUTextureView;
  82399. destroy(): void;
  82400. }
  82401. declare class GPUTextureView implements GPUObjectBase {
  82402. private __brand: void;
  82403. label: string | undefined;
  82404. }
  82405. type GPUPowerPreference = "low-power" | "high-performance";
  82406. interface GPURequestAdapterOptions {
  82407. powerPreference?: GPUPowerPreference;
  82408. }
  82409. declare class GPU {
  82410. private __brand: void;
  82411. requestAdapter(options?: GPURequestAdapterOptions): Promise<GPUAdapter | null>;
  82412. }
  82413. // ****************************************************************************
  82414. // ERROR SCOPES
  82415. // ****************************************************************************
  82416. type GPUErrorFilter = "out-of-memory" | "validation";
  82417. declare class GPUOutOfMemoryError {
  82418. private __brand: void;
  82419. constructor();
  82420. }
  82421. declare class GPUValidationError {
  82422. private __brand: void;
  82423. constructor(message: string);
  82424. readonly message: string;
  82425. }
  82426. type GPUError = GPUOutOfMemoryError | GPUValidationError;
  82427. // ****************************************************************************
  82428. // TELEMETRY
  82429. // ****************************************************************************
  82430. declare class GPUUncapturedErrorEvent extends Event {
  82431. private __brand: void;
  82432. constructor(
  82433. type: string,
  82434. gpuUncapturedErrorEventInitDict: GPUUncapturedErrorEventInit
  82435. );
  82436. readonly error: GPUError;
  82437. }
  82438. interface GPUUncapturedErrorEventInit extends EventInit {
  82439. error: GPUError;
  82440. }
  82441. declare class GPUDeviceLostInfo {
  82442. private __brand: void;
  82443. readonly message: string;
  82444. }
  82445. // Type definitions for WebVR API
  82446. // Project: https://w3c.github.io/webvr/
  82447. // Definitions by: six a <https://github.com/lostfictions>
  82448. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  82449. interface VRDisplay extends EventTarget {
  82450. /**
  82451. * Dictionary of capabilities describing the VRDisplay.
  82452. */
  82453. readonly capabilities: VRDisplayCapabilities;
  82454. /**
  82455. * z-depth defining the far plane of the eye view frustum
  82456. * enables mapping of values in the render target depth
  82457. * attachment to scene coordinates. Initially set to 10000.0.
  82458. */
  82459. depthFar: number;
  82460. /**
  82461. * z-depth defining the near plane of the eye view frustum
  82462. * enables mapping of values in the render target depth
  82463. * attachment to scene coordinates. Initially set to 0.01.
  82464. */
  82465. depthNear: number;
  82466. /**
  82467. * An identifier for this distinct VRDisplay. Used as an
  82468. * association point in the Gamepad API.
  82469. */
  82470. readonly displayId: number;
  82471. /**
  82472. * A display name, a user-readable name identifying it.
  82473. */
  82474. readonly displayName: string;
  82475. readonly isConnected: boolean;
  82476. readonly isPresenting: boolean;
  82477. /**
  82478. * If this VRDisplay supports room-scale experiences, the optional
  82479. * stage attribute contains details on the room-scale parameters.
  82480. */
  82481. readonly stageParameters: VRStageParameters | null;
  82482. /**
  82483. * Passing the value returned by `requestAnimationFrame` to
  82484. * `cancelAnimationFrame` will unregister the callback.
  82485. * @param handle Define the hanle of the request to cancel
  82486. */
  82487. cancelAnimationFrame(handle: number): void;
  82488. /**
  82489. * Stops presenting to the VRDisplay.
  82490. * @returns a promise to know when it stopped
  82491. */
  82492. exitPresent(): Promise<void>;
  82493. /**
  82494. * Return the current VREyeParameters for the given eye.
  82495. * @param whichEye Define the eye we want the parameter for
  82496. * @returns the eye parameters
  82497. */
  82498. getEyeParameters(whichEye: string): VREyeParameters;
  82499. /**
  82500. * Populates the passed VRFrameData with the information required to render
  82501. * the current frame.
  82502. * @param frameData Define the data structure to populate
  82503. * @returns true if ok otherwise false
  82504. */
  82505. getFrameData(frameData: VRFrameData): boolean;
  82506. /**
  82507. * Get the layers currently being presented.
  82508. * @returns the list of VR layers
  82509. */
  82510. getLayers(): VRLayer[];
  82511. /**
  82512. * Return a VRPose containing the future predicted pose of the VRDisplay
  82513. * when the current frame will be presented. The value returned will not
  82514. * change until JavaScript has returned control to the browser.
  82515. *
  82516. * The VRPose will contain the position, orientation, velocity,
  82517. * and acceleration of each of these properties.
  82518. * @returns the pose object
  82519. */
  82520. getPose(): VRPose;
  82521. /**
  82522. * Return the current instantaneous pose of the VRDisplay, with no
  82523. * prediction applied.
  82524. * @returns the current instantaneous pose
  82525. */
  82526. getImmediatePose(): VRPose;
  82527. /**
  82528. * The callback passed to `requestAnimationFrame` will be called
  82529. * any time a new frame should be rendered. When the VRDisplay is
  82530. * presenting the callback will be called at the native refresh
  82531. * rate of the HMD. When not presenting this function acts
  82532. * identically to how window.requestAnimationFrame acts. Content should
  82533. * make no assumptions of frame rate or vsync behavior as the HMD runs
  82534. * asynchronously from other displays and at differing refresh rates.
  82535. * @param callback Define the action to run next frame
  82536. * @returns the request handle it
  82537. */
  82538. requestAnimationFrame(callback: FrameRequestCallback): number;
  82539. /**
  82540. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  82541. * Repeat calls while already presenting will update the VRLayers being displayed.
  82542. * @param layers Define the list of layer to present
  82543. * @returns a promise to know when the request has been fulfilled
  82544. */
  82545. requestPresent(layers: VRLayer[]): Promise<void>;
  82546. /**
  82547. * Reset the pose for this display, treating its current position and
  82548. * orientation as the "origin/zero" values. VRPose.position,
  82549. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  82550. * updated when calling resetPose(). This should be called in only
  82551. * sitting-space experiences.
  82552. */
  82553. resetPose(): void;
  82554. /**
  82555. * The VRLayer provided to the VRDisplay will be captured and presented
  82556. * in the HMD. Calling this function has the same effect on the source
  82557. * canvas as any other operation that uses its source image, and canvases
  82558. * created without preserveDrawingBuffer set to true will be cleared.
  82559. * @param pose Define the pose to submit
  82560. */
  82561. submitFrame(pose?: VRPose): void;
  82562. }
  82563. declare var VRDisplay: {
  82564. prototype: VRDisplay;
  82565. new(): VRDisplay;
  82566. };
  82567. interface VRLayer {
  82568. leftBounds?: number[] | Float32Array | null;
  82569. rightBounds?: number[] | Float32Array | null;
  82570. source?: HTMLCanvasElement | null;
  82571. }
  82572. interface VRDisplayCapabilities {
  82573. readonly canPresent: boolean;
  82574. readonly hasExternalDisplay: boolean;
  82575. readonly hasOrientation: boolean;
  82576. readonly hasPosition: boolean;
  82577. readonly maxLayers: number;
  82578. }
  82579. interface VREyeParameters {
  82580. /** @deprecated */
  82581. readonly fieldOfView: VRFieldOfView;
  82582. readonly offset: Float32Array;
  82583. readonly renderHeight: number;
  82584. readonly renderWidth: number;
  82585. }
  82586. interface VRFieldOfView {
  82587. readonly downDegrees: number;
  82588. readonly leftDegrees: number;
  82589. readonly rightDegrees: number;
  82590. readonly upDegrees: number;
  82591. }
  82592. interface VRFrameData {
  82593. readonly leftProjectionMatrix: Float32Array;
  82594. readonly leftViewMatrix: Float32Array;
  82595. readonly pose: VRPose;
  82596. readonly rightProjectionMatrix: Float32Array;
  82597. readonly rightViewMatrix: Float32Array;
  82598. readonly timestamp: number;
  82599. }
  82600. interface VRPose {
  82601. readonly angularAcceleration: Float32Array | null;
  82602. readonly angularVelocity: Float32Array | null;
  82603. readonly linearAcceleration: Float32Array | null;
  82604. readonly linearVelocity: Float32Array | null;
  82605. readonly orientation: Float32Array | null;
  82606. readonly position: Float32Array | null;
  82607. readonly timestamp: number;
  82608. }
  82609. interface VRStageParameters {
  82610. sittingToStandingTransform?: Float32Array;
  82611. sizeX?: number;
  82612. sizeY?: number;
  82613. }
  82614. interface Navigator {
  82615. getVRDisplays(): Promise<VRDisplay[]>;
  82616. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  82617. }
  82618. interface Window {
  82619. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  82620. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  82621. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  82622. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  82623. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  82624. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  82625. }
  82626. interface Gamepad {
  82627. readonly displayId: number;
  82628. }
  82629. /**
  82630. * Available session modes
  82631. */
  82632. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  82633. /**
  82634. * Reference space types
  82635. */
  82636. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  82637. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  82638. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  82639. /**
  82640. * Handedness types
  82641. */
  82642. type XRHandedness = "none" | "left" | "right";
  82643. /**
  82644. * InputSource target ray modes
  82645. */
  82646. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  82647. /**
  82648. * Eye types
  82649. */
  82650. type XREye = "none" | "left" | "right";
  82651. /**
  82652. * Type of XR events available
  82653. */
  82654. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  82655. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  82656. type XRPlaneSet = Set<XRPlane>;
  82657. type XRAnchorSet = Set<XRAnchor>;
  82658. type XREventHandler = (callback: any) => void;
  82659. interface XRLayer extends EventTarget {}
  82660. interface XRSessionInit {
  82661. optionalFeatures?: string[];
  82662. requiredFeatures?: string[];
  82663. trackedImages?: XRTrackedImageInit[];
  82664. }
  82665. interface XRSessionEvent extends Event {
  82666. readonly session: XRSession;
  82667. }
  82668. interface XRSystem {
  82669. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  82670. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  82671. }
  82672. interface XRViewport {
  82673. readonly x: number;
  82674. readonly y: number;
  82675. readonly width: number;
  82676. readonly height: number;
  82677. }
  82678. interface XRWebGLLayerInit {
  82679. antialias?: boolean;
  82680. depth?: boolean;
  82681. stencil?: boolean;
  82682. alpha?: boolean;
  82683. multiview?: boolean;
  82684. framebufferScaleFactor?: number;
  82685. }
  82686. declare class XRWebGLLayer {
  82687. static getNativeFramebufferScaleFactor(session: XRSession): number;
  82688. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  82689. readonly antialias: boolean;
  82690. readonly framebuffer: WebGLFramebuffer;
  82691. readonly framebufferWidth: number;
  82692. readonly framebufferHeight: number;
  82693. readonly ignoreDepthValues: boolean;
  82694. getViewport: (view: XRView) => XRViewport;
  82695. }
  82696. // tslint:disable-next-line no-empty-interface
  82697. interface XRSpace extends EventTarget {}
  82698. interface XRRenderState {
  82699. readonly baseLayer?: XRWebGLLayer;
  82700. readonly depthFar: number;
  82701. readonly depthNear: number;
  82702. readonly inlineVerticalFieldOfView?: number;
  82703. }
  82704. interface XRRenderStateInit extends XRRenderState {
  82705. baseLayer: XRWebGLLayer;
  82706. depthFar: number;
  82707. depthNear: number;
  82708. inlineVerticalFieldOfView?: number;
  82709. layers?: XRLayer[];
  82710. }
  82711. interface XRReferenceSpace extends XRSpace {
  82712. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  82713. onreset: XREventHandler;
  82714. }
  82715. interface XRBoundedReferenceSpace extends XRSpace {
  82716. readonly boundsGeometry: DOMPointReadOnly[];
  82717. }
  82718. interface XRInputSource {
  82719. readonly handedness: XRHandedness;
  82720. readonly targetRayMode: XRTargetRayMode;
  82721. readonly targetRaySpace: XRSpace;
  82722. readonly gripSpace?: XRSpace;
  82723. readonly gamepad?: Gamepad;
  82724. readonly profiles: Array<string>;
  82725. readonly hand?: XRHand;
  82726. }
  82727. interface XRPose {
  82728. readonly transform: XRRigidTransform;
  82729. readonly emulatedPosition: boolean;
  82730. }
  82731. interface XRWorldInformation {
  82732. detectedPlanes?: XRPlaneSet;
  82733. }
  82734. interface XRFrame {
  82735. readonly session: XRSession;
  82736. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  82737. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  82738. // AR
  82739. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  82740. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  82741. // Anchors
  82742. trackedAnchors?: XRAnchorSet;
  82743. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  82744. // World geometries
  82745. worldInformation?: XRWorldInformation;
  82746. // Hand tracking
  82747. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  82748. // Image tracking
  82749. getImageTrackingResults?(): Array<XRImageTrackingResult>;
  82750. }
  82751. interface XRInputSourceEvent extends Event {
  82752. readonly frame: XRFrame;
  82753. readonly inputSource: XRInputSource;
  82754. }
  82755. type XRInputSourceArray = XRInputSource[];
  82756. interface XRSession {
  82757. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  82758. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  82759. /**
  82760. * Returns a list of this session's XRInputSources, each representing an input device
  82761. * used to control the camera and/or scene.
  82762. */
  82763. readonly inputSources: Array<XRInputSource>;
  82764. /**
  82765. * object which contains options affecting how the imagery is rendered.
  82766. * This includes things such as the near and far clipping planes
  82767. */
  82768. readonly renderState: XRRenderState;
  82769. readonly visibilityState: XRVisibilityState;
  82770. /**
  82771. * Removes a callback from the animation frame painting callback from
  82772. * XRSession's set of animation frame rendering callbacks, given the
  82773. * identifying handle returned by a previous call to requestAnimationFrame().
  82774. */
  82775. cancelAnimationFrame: (handle: number) => void;
  82776. /**
  82777. * Ends the WebXR session. Returns a promise which resolves when the
  82778. * session has been shut down.
  82779. */
  82780. end(): Promise<void>;
  82781. /**
  82782. * Schedules the specified method to be called the next time the user agent
  82783. * is working on rendering an animation frame for the WebXR device. Returns an
  82784. * integer value which can be used to identify the request for the purposes of
  82785. * canceling the callback using cancelAnimationFrame(). This method is comparable
  82786. * to the Window.requestAnimationFrame() method.
  82787. */
  82788. requestAnimationFrame: XRFrameRequestCallback;
  82789. /**
  82790. * Requests that a new XRReferenceSpace of the specified type be created.
  82791. * Returns a promise which resolves with the XRReferenceSpace or
  82792. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  82793. * the requested space type isn't supported by the device.
  82794. */
  82795. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  82796. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  82797. onend: XREventHandler;
  82798. oninputsourceschange: XREventHandler;
  82799. onselect: XREventHandler;
  82800. onselectstart: XREventHandler;
  82801. onselectend: XREventHandler;
  82802. onsqueeze: XREventHandler;
  82803. onsqueezestart: XREventHandler;
  82804. onsqueezeend: XREventHandler;
  82805. onvisibilitychange: XREventHandler;
  82806. // hit test
  82807. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  82808. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  82809. // legacy AR hit test
  82810. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  82811. // legacy plane detection
  82812. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  82813. // image tracking
  82814. getTrackedImageScores?(): XRImageTrackingScore[];
  82815. }
  82816. interface XRViewerPose extends XRPose {
  82817. readonly views: Array<XRView>;
  82818. }
  82819. declare class XRRigidTransform {
  82820. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  82821. position: DOMPointReadOnly;
  82822. orientation: DOMPointReadOnly;
  82823. matrix: Float32Array;
  82824. inverse: XRRigidTransform;
  82825. }
  82826. interface XRView {
  82827. readonly eye: XREye;
  82828. readonly projectionMatrix: Float32Array;
  82829. readonly transform: XRRigidTransform;
  82830. readonly recommendedViewportScale?: number;
  82831. requestViewportScale(scale: number): void;
  82832. }
  82833. interface XRInputSourceChangeEvent extends Event {
  82834. session: XRSession;
  82835. removed: Array<XRInputSource>;
  82836. added: Array<XRInputSource>;
  82837. }
  82838. // Experimental/Draft features
  82839. declare class XRRay {
  82840. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  82841. origin: DOMPointReadOnly;
  82842. direction: DOMPointReadOnly;
  82843. matrix: Float32Array;
  82844. }
  82845. declare enum XRHitTestTrackableType {
  82846. "point",
  82847. "plane",
  82848. "mesh",
  82849. }
  82850. interface XRHitResult {
  82851. hitMatrix: Float32Array;
  82852. }
  82853. interface XRTransientInputHitTestResult {
  82854. readonly inputSource: XRInputSource;
  82855. readonly results: Array<XRHitTestResult>;
  82856. }
  82857. interface XRHitTestResult {
  82858. getPose(baseSpace: XRSpace): XRPose | undefined;
  82859. // When anchor system is enabled
  82860. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  82861. }
  82862. interface XRHitTestSource {
  82863. cancel(): void;
  82864. }
  82865. interface XRTransientInputHitTestSource {
  82866. cancel(): void;
  82867. }
  82868. interface XRHitTestOptionsInit {
  82869. space: XRSpace;
  82870. entityTypes?: Array<XRHitTestTrackableType>;
  82871. offsetRay?: XRRay;
  82872. }
  82873. interface XRTransientInputHitTestOptionsInit {
  82874. profile: string;
  82875. entityTypes?: Array<XRHitTestTrackableType>;
  82876. offsetRay?: XRRay;
  82877. }
  82878. interface XRAnchor {
  82879. anchorSpace: XRSpace;
  82880. delete(): void;
  82881. }
  82882. interface XRPlane {
  82883. orientation: "Horizontal" | "Vertical";
  82884. planeSpace: XRSpace;
  82885. polygon: Array<DOMPointReadOnly>;
  82886. lastChangedTime: number;
  82887. }
  82888. interface XRJointSpace extends XRSpace {}
  82889. interface XRJointPose extends XRPose {
  82890. radius: number | undefined;
  82891. }
  82892. interface XRHand extends Iterable<XRJointSpace> {
  82893. readonly length: number;
  82894. [index: number]: XRJointSpace;
  82895. readonly WRIST: number;
  82896. readonly THUMB_METACARPAL: number;
  82897. readonly THUMB_PHALANX_PROXIMAL: number;
  82898. readonly THUMB_PHALANX_DISTAL: number;
  82899. readonly THUMB_PHALANX_TIP: number;
  82900. readonly INDEX_METACARPAL: number;
  82901. readonly INDEX_PHALANX_PROXIMAL: number;
  82902. readonly INDEX_PHALANX_INTERMEDIATE: number;
  82903. readonly INDEX_PHALANX_DISTAL: number;
  82904. readonly INDEX_PHALANX_TIP: number;
  82905. readonly MIDDLE_METACARPAL: number;
  82906. readonly MIDDLE_PHALANX_PROXIMAL: number;
  82907. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  82908. readonly MIDDLE_PHALANX_DISTAL: number;
  82909. readonly MIDDLE_PHALANX_TIP: number;
  82910. readonly RING_METACARPAL: number;
  82911. readonly RING_PHALANX_PROXIMAL: number;
  82912. readonly RING_PHALANX_INTERMEDIATE: number;
  82913. readonly RING_PHALANX_DISTAL: number;
  82914. readonly RING_PHALANX_TIP: number;
  82915. readonly LITTLE_METACARPAL: number;
  82916. readonly LITTLE_PHALANX_PROXIMAL: number;
  82917. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  82918. readonly LITTLE_PHALANX_DISTAL: number;
  82919. readonly LITTLE_PHALANX_TIP: number;
  82920. }
  82921. type XRImageTrackingState = "tracked" | "emulated";
  82922. type XRImageTrackingScore = "untrackable" | "trackable";
  82923. interface XRTrackedImageInit {
  82924. image: ImageBitmap;
  82925. widthInMeters: number;
  82926. }
  82927. interface XRImageTrackingResult {
  82928. readonly imageSpace: XRSpace;
  82929. readonly index: number;
  82930. readonly trackingState: XRImageTrackingState;
  82931. readonly measuredWidthInMeters: number;
  82932. }
  82933. // This file contains native only extensions for WebXR. These APIs are not supported in the browser yet.
  82934. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  82935. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  82936. type XRSceneObjectType = "unknown" | "background" | "wall" | "floor" | "ceiling" | "platform";
  82937. interface XRSceneObject {
  82938. type: XRSceneObjectType;
  82939. }
  82940. interface XRFieldOfView {
  82941. angleLeft: number;
  82942. angleRight: number;
  82943. angleUp: number;
  82944. angleDown: number;
  82945. }
  82946. interface XRFrustum {
  82947. position: DOMPointReadOnly;
  82948. orientation: DOMPointReadOnly;
  82949. fieldOfView: XRFieldOfView;
  82950. farDistance: number;
  82951. }
  82952. interface XRPlane {
  82953. parentSceneObject?: XRSceneObject;
  82954. }
  82955. interface XRMesh {
  82956. meshSpace: XRSpace;
  82957. positions: Float32Array;
  82958. indices: Uint32Array;
  82959. normals?: Float32Array;
  82960. lastChangedTime: number;
  82961. parentSceneObject?: XRSceneObject;
  82962. }
  82963. interface XRFrustumDetectionBoundary {
  82964. type: "frustum";
  82965. frustum: XRFrustum;
  82966. }
  82967. interface XRSphereDetectionBoundary {
  82968. type: "sphere";
  82969. radius: number;
  82970. }
  82971. interface XRBoxDetectionBoundary {
  82972. type: "box";
  82973. extent: DOMPointReadOnly;
  82974. }
  82975. type XRDetectionBoundary = XRFrustumDetectionBoundary | XRSphereDetectionBoundary | XRBoxDetectionBoundary;
  82976. interface XRGeometryDetectorOptions {
  82977. detectionBoundary?: XRDetectionBoundary;
  82978. updateInterval?: number;
  82979. }
  82980. interface XRSession {
  82981. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  82982. trySetPreferredPlaneDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  82983. trySetMeshDetectorEnabled(enabled: boolean): boolean;
  82984. trySetPreferredMeshDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  82985. }
  82986. interface XRFrame {
  82987. featurePointCloud?: Array<number>;
  82988. }
  82989. type XRMeshSet = Set<XRMesh>;
  82990. interface XRWorldInformation {
  82991. detectedMeshes?: XRMeshSet;
  82992. }
  82993. /**
  82994. * @ignore
  82995. */
  82996. declare module BABYLON.GLTF2.Exporter {
  82997. }
  82998. /**
  82999. * @ignore
  83000. */
  83001. declare module BABYLON.GLTF1 {
  83002. }
  83003. declare module BABYLON.GUI {
  83004. /**
  83005. * Interface used to define a control that can receive focus
  83006. */
  83007. export interface IFocusableControl {
  83008. /**
  83009. * Function called when the control receives the focus
  83010. */
  83011. onFocus(): void;
  83012. /**
  83013. * Function called when the control loses the focus
  83014. */
  83015. onBlur(): void;
  83016. /**
  83017. * Function called to let the control handle keyboard events
  83018. * @param evt defines the current keyboard event
  83019. */
  83020. processKeyboard(evt: BABYLON.IKeyboardEvent): void;
  83021. /**
  83022. * Function called to get the list of controls that should not steal the focus from this control
  83023. * @returns an array of controls
  83024. */
  83025. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  83026. /**
  83027. * Function to focus the control programmatically
  83028. */
  83029. focus(): void;
  83030. /**
  83031. * Function to unfocus the control programmatically
  83032. */
  83033. blur(): void;
  83034. }
  83035. }
  83036. declare module BABYLON.GUI {
  83037. /**
  83038. * Class used to specific a value and its associated unit
  83039. */
  83040. export class ValueAndUnit {
  83041. /** defines the unit to store */
  83042. unit: number;
  83043. /** defines a boolean indicating if the value can be negative */
  83044. negativeValueAllowed: boolean;
  83045. private _value;
  83046. private _originalUnit;
  83047. /**
  83048. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  83049. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  83050. */
  83051. ignoreAdaptiveScaling: boolean;
  83052. /**
  83053. * Creates a new ValueAndUnit
  83054. * @param value defines the value to store
  83055. * @param unit defines the unit to store
  83056. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  83057. */
  83058. constructor(value: number,
  83059. /** defines the unit to store */
  83060. unit?: number,
  83061. /** defines a boolean indicating if the value can be negative */
  83062. negativeValueAllowed?: boolean);
  83063. /** Gets a boolean indicating if the value is a percentage */
  83064. get isPercentage(): boolean;
  83065. /** Gets a boolean indicating if the value is store as pixel */
  83066. get isPixel(): boolean;
  83067. /** Gets direct internal value */
  83068. get internalValue(): number;
  83069. /**
  83070. * Gets value as pixel
  83071. * @param host defines the root host
  83072. * @param refValue defines the reference value for percentages
  83073. * @returns the value as pixel
  83074. */
  83075. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  83076. /**
  83077. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  83078. * @param value defines the value to store
  83079. * @param unit defines the unit to store
  83080. * @returns the current ValueAndUnit
  83081. */
  83082. updateInPlace(value: number, unit?: number): ValueAndUnit;
  83083. /**
  83084. * Gets the value accordingly to its unit
  83085. * @param host defines the root host
  83086. * @returns the value
  83087. */
  83088. getValue(host: AdvancedDynamicTexture): number;
  83089. /**
  83090. * Gets a string representation of the value
  83091. * @param host defines the root host
  83092. * @param decimals defines an optional number of decimals to display
  83093. * @returns a string
  83094. */
  83095. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  83096. /**
  83097. * Store a value parsed from a string
  83098. * @param source defines the source string
  83099. * @returns true if the value was successfully parsed
  83100. */
  83101. fromString(source: string | number): boolean;
  83102. private static _Regex;
  83103. private static _UNITMODE_PERCENTAGE;
  83104. private static _UNITMODE_PIXEL;
  83105. /** UNITMODE_PERCENTAGE */
  83106. static get UNITMODE_PERCENTAGE(): number;
  83107. /** UNITMODE_PIXEL */
  83108. static get UNITMODE_PIXEL(): number;
  83109. }
  83110. }
  83111. declare module BABYLON.GUI {
  83112. /**
  83113. * Define a style used by control to automatically setup properties based on a template.
  83114. * Only support font related properties so far
  83115. */
  83116. export class Style implements BABYLON.IDisposable {
  83117. private _fontFamily;
  83118. private _fontStyle;
  83119. private _fontWeight;
  83120. /** @hidden */
  83121. _host: AdvancedDynamicTexture;
  83122. /** @hidden */
  83123. _fontSize: ValueAndUnit;
  83124. /**
  83125. * BABYLON.Observable raised when the style values are changed
  83126. */
  83127. onChangedObservable: BABYLON.Observable<Style>;
  83128. /**
  83129. * Creates a new style object
  83130. * @param host defines the AdvancedDynamicTexture which hosts this style
  83131. */
  83132. constructor(host: AdvancedDynamicTexture);
  83133. /**
  83134. * Gets or sets the font size
  83135. */
  83136. get fontSize(): string | number;
  83137. set fontSize(value: string | number);
  83138. /**
  83139. * Gets or sets the font family
  83140. */
  83141. get fontFamily(): string;
  83142. set fontFamily(value: string);
  83143. /**
  83144. * Gets or sets the font style
  83145. */
  83146. get fontStyle(): string;
  83147. set fontStyle(value: string);
  83148. /** Gets or sets font weight */
  83149. get fontWeight(): string;
  83150. set fontWeight(value: string);
  83151. /** Dispose all associated resources */
  83152. dispose(): void;
  83153. }
  83154. }
  83155. declare module BABYLON.GUI {
  83156. /**
  83157. * Class used to transport BABYLON.Vector2 information for pointer events
  83158. */
  83159. export class Vector2WithInfo extends BABYLON.Vector2 {
  83160. /** defines the current mouse button index */
  83161. buttonIndex: number;
  83162. /**
  83163. * Creates a new Vector2WithInfo
  83164. * @param source defines the vector2 data to transport
  83165. * @param buttonIndex defines the current mouse button index
  83166. */
  83167. constructor(source: BABYLON.Vector2,
  83168. /** defines the current mouse button index */
  83169. buttonIndex?: number);
  83170. }
  83171. /** Class used to provide 2D matrix features */
  83172. export class Matrix2D {
  83173. /** Gets the internal array of 6 floats used to store matrix data */
  83174. m: Float32Array;
  83175. /**
  83176. * Creates a new matrix
  83177. * @param m00 defines value for (0, 0)
  83178. * @param m01 defines value for (0, 1)
  83179. * @param m10 defines value for (1, 0)
  83180. * @param m11 defines value for (1, 1)
  83181. * @param m20 defines value for (2, 0)
  83182. * @param m21 defines value for (2, 1)
  83183. */
  83184. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  83185. /**
  83186. * Fills the matrix from direct values
  83187. * @param m00 defines value for (0, 0)
  83188. * @param m01 defines value for (0, 1)
  83189. * @param m10 defines value for (1, 0)
  83190. * @param m11 defines value for (1, 1)
  83191. * @param m20 defines value for (2, 0)
  83192. * @param m21 defines value for (2, 1)
  83193. * @returns the current modified matrix
  83194. */
  83195. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  83196. /**
  83197. * Gets matrix determinant
  83198. * @returns the determinant
  83199. */
  83200. determinant(): number;
  83201. /**
  83202. * Inverses the matrix and stores it in a target matrix
  83203. * @param result defines the target matrix
  83204. * @returns the current matrix
  83205. */
  83206. invertToRef(result: Matrix2D): Matrix2D;
  83207. /**
  83208. * Multiplies the current matrix with another one
  83209. * @param other defines the second operand
  83210. * @param result defines the target matrix
  83211. * @returns the current matrix
  83212. */
  83213. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  83214. /**
  83215. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  83216. * @param x defines the x coordinate to transform
  83217. * @param y defines the x coordinate to transform
  83218. * @param result defines the target vector2
  83219. * @returns the current matrix
  83220. */
  83221. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  83222. /**
  83223. * Creates an identity matrix
  83224. * @returns a new matrix
  83225. */
  83226. static Identity(): Matrix2D;
  83227. /**
  83228. * Creates a translation matrix and stores it in a target matrix
  83229. * @param x defines the x coordinate of the translation
  83230. * @param y defines the y coordinate of the translation
  83231. * @param result defines the target matrix
  83232. */
  83233. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  83234. /**
  83235. * Creates a scaling matrix and stores it in a target matrix
  83236. * @param x defines the x coordinate of the scaling
  83237. * @param y defines the y coordinate of the scaling
  83238. * @param result defines the target matrix
  83239. */
  83240. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  83241. /**
  83242. * Creates a rotation matrix and stores it in a target matrix
  83243. * @param angle defines the rotation angle
  83244. * @param result defines the target matrix
  83245. */
  83246. static RotationToRef(angle: number, result: Matrix2D): void;
  83247. private static _TempPreTranslationMatrix;
  83248. private static _TempPostTranslationMatrix;
  83249. private static _TempRotationMatrix;
  83250. private static _TempScalingMatrix;
  83251. private static _TempCompose0;
  83252. private static _TempCompose1;
  83253. private static _TempCompose2;
  83254. /**
  83255. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  83256. * @param tx defines the x coordinate of the translation
  83257. * @param ty defines the y coordinate of the translation
  83258. * @param angle defines the rotation angle
  83259. * @param scaleX defines the x coordinate of the scaling
  83260. * @param scaleY defines the y coordinate of the scaling
  83261. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  83262. * @param result defines the target matrix
  83263. */
  83264. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  83265. }
  83266. }
  83267. declare module BABYLON.GUI {
  83268. /**
  83269. * Class used to store 2D control sizes
  83270. */
  83271. export class Measure {
  83272. /** defines left coordinate */
  83273. left: number;
  83274. /** defines top coordinate */
  83275. top: number;
  83276. /** defines width dimension */
  83277. width: number;
  83278. /** defines height dimension */
  83279. height: number;
  83280. /**
  83281. * Creates a new measure
  83282. * @param left defines left coordinate
  83283. * @param top defines top coordinate
  83284. * @param width defines width dimension
  83285. * @param height defines height dimension
  83286. */
  83287. constructor(
  83288. /** defines left coordinate */
  83289. left: number,
  83290. /** defines top coordinate */
  83291. top: number,
  83292. /** defines width dimension */
  83293. width: number,
  83294. /** defines height dimension */
  83295. height: number);
  83296. /**
  83297. * Copy from another measure
  83298. * @param other defines the other measure to copy from
  83299. */
  83300. copyFrom(other: Measure): void;
  83301. /**
  83302. * Copy from a group of 4 floats
  83303. * @param left defines left coordinate
  83304. * @param top defines top coordinate
  83305. * @param width defines width dimension
  83306. * @param height defines height dimension
  83307. */
  83308. copyFromFloats(left: number, top: number, width: number, height: number): void;
  83309. /**
  83310. * Computes the axis aligned bounding box measure for two given measures
  83311. * @param a Input measure
  83312. * @param b Input measure
  83313. * @param result the resulting bounding measure
  83314. */
  83315. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  83316. /**
  83317. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  83318. * @param transform the matrix to transform the measure before computing the AABB
  83319. * @param addX number to add to left
  83320. * @param addY number to add to top
  83321. * @param addWidth number to add to width
  83322. * @param addHeight number to add to height
  83323. * @param result the resulting AABB
  83324. */
  83325. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  83326. /**
  83327. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  83328. * @param transform the matrix to transform the measure before computing the AABB
  83329. * @param result the resulting AABB
  83330. */
  83331. transformToRef(transform: Matrix2D, result: Measure): void;
  83332. /**
  83333. * Check equality between this measure and another one
  83334. * @param other defines the other measures
  83335. * @returns true if both measures are equals
  83336. */
  83337. isEqualsTo(other: Measure): boolean;
  83338. /**
  83339. * Creates an empty measure
  83340. * @returns a new measure
  83341. */
  83342. static Empty(): Measure;
  83343. }
  83344. }
  83345. declare module BABYLON.GUI {
  83346. /**
  83347. * Class used to create texture to support 2D GUI elements
  83348. * @see https://doc.babylonjs.com/how_to/gui
  83349. */
  83350. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  83351. /** Define the Uurl to load snippets */
  83352. static SnippetUrl: string;
  83353. /** Snippet ID if the content was created from the snippet server */
  83354. snippetId: string;
  83355. private _isDirty;
  83356. private _renderObserver;
  83357. private _resizeObserver;
  83358. private _preKeyboardObserver;
  83359. private _pointerMoveObserver;
  83360. private _pointerObserver;
  83361. private _canvasPointerOutObserver;
  83362. private _canvasBlurObserver;
  83363. private _background;
  83364. /** @hidden */
  83365. _rootContainer: Container;
  83366. /** @hidden */
  83367. _lastPickedControl: Control;
  83368. /** @hidden */
  83369. _lastControlOver: {
  83370. [pointerId: number]: Control;
  83371. };
  83372. /** @hidden */
  83373. _lastControlDown: {
  83374. [pointerId: number]: Control;
  83375. };
  83376. /** @hidden */
  83377. _capturingControl: {
  83378. [pointerId: number]: Control;
  83379. };
  83380. /** @hidden */
  83381. _shouldBlockPointer: boolean;
  83382. /** @hidden */
  83383. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  83384. /** @hidden */
  83385. _linkedControls: Control[];
  83386. private _isFullscreen;
  83387. private _fullscreenViewport;
  83388. private _idealWidth;
  83389. private _idealHeight;
  83390. private _useSmallestIdeal;
  83391. private _renderAtIdealSize;
  83392. private _focusedControl;
  83393. private _blockNextFocusCheck;
  83394. private _renderScale;
  83395. private _rootElement;
  83396. private _cursorChanged;
  83397. private _defaultMousePointerId;
  83398. /** @hidden */
  83399. _numLayoutCalls: number;
  83400. /** Gets the number of layout calls made the last time the ADT has been rendered */
  83401. get numLayoutCalls(): number;
  83402. /** @hidden */
  83403. _numRenderCalls: number;
  83404. /** Gets the number of render calls made the last time the ADT has been rendered */
  83405. get numRenderCalls(): number;
  83406. /**
  83407. * Define type to string to ensure compatibility across browsers
  83408. * Safari doesn't support DataTransfer constructor
  83409. */
  83410. private _clipboardData;
  83411. /**
  83412. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  83413. */
  83414. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  83415. /**
  83416. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  83417. */
  83418. onControlPickedObservable: BABYLON.Observable<Control>;
  83419. /**
  83420. * BABYLON.Observable event triggered before layout is evaluated
  83421. */
  83422. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  83423. /**
  83424. * BABYLON.Observable event triggered after the layout was evaluated
  83425. */
  83426. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  83427. /**
  83428. * BABYLON.Observable event triggered before the texture is rendered
  83429. */
  83430. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  83431. /**
  83432. * BABYLON.Observable event triggered after the texture was rendered
  83433. */
  83434. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  83435. /**
  83436. * Gets or sets a boolean defining if alpha is stored as premultiplied
  83437. */
  83438. premulAlpha: boolean;
  83439. /**
  83440. * Gets or sets a boolean indicating that the canvas must be reverted on Y when updating the texture
  83441. */
  83442. applyYInversionOnUpdate: boolean;
  83443. /**
  83444. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  83445. * Useful when you want more antialiasing
  83446. */
  83447. get renderScale(): number;
  83448. set renderScale(value: number);
  83449. /** Gets or sets the background color */
  83450. get background(): string;
  83451. set background(value: string);
  83452. /**
  83453. * Gets or sets the ideal width used to design controls.
  83454. * The GUI will then rescale everything accordingly
  83455. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  83456. */
  83457. get idealWidth(): number;
  83458. set idealWidth(value: number);
  83459. /**
  83460. * Gets or sets the ideal height used to design controls.
  83461. * The GUI will then rescale everything accordingly
  83462. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  83463. */
  83464. get idealHeight(): number;
  83465. set idealHeight(value: number);
  83466. /**
  83467. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  83468. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  83469. */
  83470. get useSmallestIdeal(): boolean;
  83471. set useSmallestIdeal(value: boolean);
  83472. /**
  83473. * Gets or sets a boolean indicating if adaptive scaling must be used
  83474. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  83475. */
  83476. get renderAtIdealSize(): boolean;
  83477. set renderAtIdealSize(value: boolean);
  83478. /**
  83479. * Gets the ratio used when in "ideal mode"
  83480. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  83481. * */
  83482. get idealRatio(): number;
  83483. /**
  83484. * Gets the underlying layer used to render the texture when in fullscreen mode
  83485. */
  83486. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  83487. /**
  83488. * Gets the root container control
  83489. */
  83490. get rootContainer(): Container;
  83491. /**
  83492. * Returns an array containing the root container.
  83493. * This is mostly used to let the Inspector introspects the ADT
  83494. * @returns an array containing the rootContainer
  83495. */
  83496. getChildren(): Array<Container>;
  83497. /**
  83498. * Will return all controls that are inside this texture
  83499. * @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
  83500. * @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
  83501. * @return all child controls
  83502. */
  83503. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  83504. /**
  83505. * Gets or sets the current focused control
  83506. */
  83507. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  83508. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  83509. /**
  83510. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  83511. */
  83512. get isForeground(): boolean;
  83513. set isForeground(value: boolean);
  83514. /**
  83515. * Gets or set information about clipboardData
  83516. */
  83517. get clipboardData(): string;
  83518. set clipboardData(value: string);
  83519. /**
  83520. * Creates a new AdvancedDynamicTexture
  83521. * @param name defines the name of the texture
  83522. * @param width defines the width of the texture
  83523. * @param height defines the height of the texture
  83524. * @param scene defines the hosting scene
  83525. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  83526. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83527. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  83528. */
  83529. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  83530. /**
  83531. * Get the current class name of the texture useful for serialization or dynamic coding.
  83532. * @returns "AdvancedDynamicTexture"
  83533. */
  83534. getClassName(): string;
  83535. /**
  83536. * Function used to execute a function on all controls
  83537. * @param func defines the function to execute
  83538. * @param container defines the container where controls belong. If null the root container will be used
  83539. */
  83540. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  83541. private _useInvalidateRectOptimization;
  83542. /**
  83543. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  83544. */
  83545. get useInvalidateRectOptimization(): boolean;
  83546. set useInvalidateRectOptimization(value: boolean);
  83547. private _invalidatedRectangle;
  83548. /**
  83549. * Invalidates a rectangle area on the gui texture
  83550. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  83551. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  83552. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  83553. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  83554. */
  83555. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  83556. /**
  83557. * Marks the texture as dirty forcing a complete update
  83558. */
  83559. markAsDirty(): void;
  83560. /**
  83561. * Helper function used to create a new style
  83562. * @returns a new style
  83563. * @see https://doc.babylonjs.com/how_to/gui#styles
  83564. */
  83565. createStyle(): Style;
  83566. /**
  83567. * Adds a new control to the root container
  83568. * @param control defines the control to add
  83569. * @returns the current texture
  83570. */
  83571. addControl(control: Control): AdvancedDynamicTexture;
  83572. /**
  83573. * Removes a control from the root container
  83574. * @param control defines the control to remove
  83575. * @returns the current texture
  83576. */
  83577. removeControl(control: Control): AdvancedDynamicTexture;
  83578. /**
  83579. * Release all resources
  83580. */
  83581. dispose(): void;
  83582. private _onResize;
  83583. /** @hidden */
  83584. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  83585. /**
  83586. * Get screen coordinates for a vector3
  83587. * @param position defines the position to project
  83588. * @param worldMatrix defines the world matrix to use
  83589. * @returns the projected position
  83590. */
  83591. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  83592. /**
  83593. * Get screen coordinates for a vector3
  83594. * @param position defines the position to project
  83595. * @param worldMatrix defines the world matrix to use
  83596. * @returns the projected position with Z
  83597. */
  83598. getProjectedPositionWithZ(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector3;
  83599. private _checkUpdate;
  83600. private _clearMeasure;
  83601. private _render;
  83602. /** @hidden */
  83603. _changeCursor(cursor: string): void;
  83604. /** @hidden */
  83605. _registerLastControlDown(control: Control, pointerId: number): void;
  83606. private _doPicking;
  83607. /** @hidden */
  83608. _cleanControlAfterRemovalFromList(list: {
  83609. [pointerId: number]: Control;
  83610. }, control: Control): void;
  83611. /** @hidden */
  83612. _cleanControlAfterRemoval(control: Control): void;
  83613. /** Attach to all scene events required to support pointer events */
  83614. attach(): void;
  83615. /** @hidden */
  83616. private onClipboardCopy;
  83617. /** @hidden */
  83618. private onClipboardCut;
  83619. /** @hidden */
  83620. private onClipboardPaste;
  83621. /**
  83622. * Register the clipboard Events onto the canvas
  83623. */
  83624. registerClipboardEvents(): void;
  83625. /**
  83626. * Unregister the clipboard Events from the canvas
  83627. */
  83628. unRegisterClipboardEvents(): void;
  83629. /**
  83630. * Connect the texture to a hosting mesh to enable interactions
  83631. * @param mesh defines the mesh to attach to
  83632. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  83633. */
  83634. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  83635. /**
  83636. * Move the focus to a specific control
  83637. * @param control defines the control which will receive the focus
  83638. */
  83639. moveFocusToControl(control: IFocusableControl): void;
  83640. private _manageFocus;
  83641. private _attachToOnPointerOut;
  83642. private _attachToOnBlur;
  83643. /**
  83644. * Serializes the entire GUI system
  83645. * @returns an object with the JSON serialized data
  83646. */
  83647. serializeContent(): any;
  83648. /**
  83649. * Recreate the content of the ADT from a JSON object
  83650. * @param serializedObject define the JSON serialized object to restore from
  83651. */
  83652. parseContent(serializedObject: any): void;
  83653. /**
  83654. * Recreate the content of the ADT from a snippet saved by the GUI editor
  83655. * @param snippetId defines the snippet to load
  83656. * @returns a promise that will resolve on success
  83657. */
  83658. parseFromSnippetAsync(snippetId: string): Promise<void>;
  83659. /**
  83660. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  83661. * @param mesh defines the mesh which will receive the texture
  83662. * @param width defines the texture width (1024 by default)
  83663. * @param height defines the texture height (1024 by default)
  83664. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  83665. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  83666. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  83667. * @returns a new AdvancedDynamicTexture
  83668. */
  83669. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  83670. /**
  83671. * 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
  83672. * @param mesh defines the mesh which will receive the texture
  83673. * @param width defines the texture width (1024 by default)
  83674. * @param height defines the texture height (1024 by default)
  83675. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  83676. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  83677. * @returns a new AdvancedDynamicTexture
  83678. */
  83679. static CreateForMeshTexture(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  83680. /**
  83681. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  83682. * In this mode the texture will rely on a layer for its rendering.
  83683. * This allows it to be treated like any other layer.
  83684. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  83685. * LayerMask is set through advancedTexture.layer.layerMask
  83686. * @param name defines name for the texture
  83687. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  83688. * @param scene defines the hsoting scene
  83689. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  83690. * @returns a new AdvancedDynamicTexture
  83691. */
  83692. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  83693. }
  83694. }
  83695. declare module BABYLON.GUI {
  83696. /**
  83697. * Root class used for all 2D controls
  83698. * @see https://doc.babylonjs.com/how_to/gui#controls
  83699. */
  83700. export class Control {
  83701. /** defines the name of the control */
  83702. name?: string | undefined;
  83703. /**
  83704. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  83705. */
  83706. static AllowAlphaInheritance: boolean;
  83707. private _alpha;
  83708. private _alphaSet;
  83709. private _zIndex;
  83710. /** @hidden */
  83711. _host: AdvancedDynamicTexture;
  83712. /** Gets or sets the control parent */
  83713. parent: BABYLON.Nullable<Container>;
  83714. /** @hidden */
  83715. _currentMeasure: Measure;
  83716. private _fontFamily;
  83717. private _fontStyle;
  83718. private _fontWeight;
  83719. private _fontSize;
  83720. private _font;
  83721. /** @hidden */
  83722. _width: ValueAndUnit;
  83723. /** @hidden */
  83724. _height: ValueAndUnit;
  83725. /** @hidden */
  83726. protected _fontOffset: {
  83727. ascent: number;
  83728. height: number;
  83729. descent: number;
  83730. };
  83731. private _color;
  83732. private _style;
  83733. private _styleObserver;
  83734. /** @hidden */
  83735. protected _horizontalAlignment: number;
  83736. /** @hidden */
  83737. protected _verticalAlignment: number;
  83738. /** @hidden */
  83739. protected _isDirty: boolean;
  83740. /** @hidden */
  83741. protected _wasDirty: boolean;
  83742. /** @hidden */
  83743. _tempParentMeasure: Measure;
  83744. /** @hidden */
  83745. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  83746. /** @hidden */
  83747. protected _cachedParentMeasure: Measure;
  83748. private _paddingLeft;
  83749. private _paddingRight;
  83750. private _paddingTop;
  83751. private _paddingBottom;
  83752. /** @hidden */
  83753. _left: ValueAndUnit;
  83754. /** @hidden */
  83755. _top: ValueAndUnit;
  83756. private _scaleX;
  83757. private _scaleY;
  83758. private _rotation;
  83759. private _transformCenterX;
  83760. private _transformCenterY;
  83761. /** @hidden */
  83762. _transformMatrix: Matrix2D;
  83763. /** @hidden */
  83764. protected _invertTransformMatrix: Matrix2D;
  83765. /** @hidden */
  83766. protected _transformedPosition: BABYLON.Vector2;
  83767. private _isMatrixDirty;
  83768. private _cachedOffsetX;
  83769. private _cachedOffsetY;
  83770. private _isVisible;
  83771. private _isHighlighted;
  83772. /** @hidden */
  83773. _linkedMesh: BABYLON.Nullable<BABYLON.TransformNode>;
  83774. private _fontSet;
  83775. private _dummyVector2;
  83776. private _downCount;
  83777. private _enterCount;
  83778. private _doNotRender;
  83779. private _downPointerIds;
  83780. protected _isEnabled: boolean;
  83781. protected _disabledColor: string;
  83782. protected _disabledColorItem: string;
  83783. /** @hidden */
  83784. protected _rebuildLayout: boolean;
  83785. /** @hidden */
  83786. _customData: any;
  83787. /** @hidden */
  83788. _isClipped: boolean;
  83789. /** @hidden */
  83790. _automaticSize: boolean;
  83791. /** @hidden */
  83792. _tag: any;
  83793. /**
  83794. * 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
  83795. */
  83796. uniqueId: number;
  83797. /**
  83798. * Gets or sets an object used to store user defined information for the node
  83799. */
  83800. metadata: any;
  83801. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  83802. isHitTestVisible: boolean;
  83803. /** Gets or sets a boolean indicating if the control can block pointer events */
  83804. isPointerBlocker: boolean;
  83805. /** Gets or sets a boolean indicating if the control can be focusable */
  83806. isFocusInvisible: boolean;
  83807. /**
  83808. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  83809. * 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
  83810. */
  83811. clipChildren: boolean;
  83812. /**
  83813. * Gets or sets a boolean indicating that control content must be clipped
  83814. * 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
  83815. */
  83816. clipContent: boolean;
  83817. /**
  83818. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  83819. */
  83820. useBitmapCache: boolean;
  83821. private _cacheData;
  83822. private _shadowOffsetX;
  83823. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  83824. get shadowOffsetX(): number;
  83825. set shadowOffsetX(value: number);
  83826. private _shadowOffsetY;
  83827. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  83828. get shadowOffsetY(): number;
  83829. set shadowOffsetY(value: number);
  83830. private _shadowBlur;
  83831. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  83832. get shadowBlur(): number;
  83833. set shadowBlur(value: number);
  83834. private _shadowColor;
  83835. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  83836. get shadowColor(): string;
  83837. set shadowColor(value: string);
  83838. /** Gets or sets the cursor to use when the control is hovered */
  83839. hoverCursor: string;
  83840. /** @hidden */
  83841. protected _linkOffsetX: ValueAndUnit;
  83842. /** @hidden */
  83843. protected _linkOffsetY: ValueAndUnit;
  83844. /** Gets the control type name */
  83845. get typeName(): string;
  83846. /**
  83847. * Get the current class name of the control.
  83848. * @returns current class name
  83849. */
  83850. getClassName(): string;
  83851. /**
  83852. * An event triggered when pointer wheel is scrolled
  83853. */
  83854. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  83855. /**
  83856. * An event triggered when the pointer move over the control.
  83857. */
  83858. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  83859. /**
  83860. * An event triggered when the pointer move out of the control.
  83861. */
  83862. onPointerOutObservable: BABYLON.Observable<Control>;
  83863. /**
  83864. * An event triggered when the pointer taps the control
  83865. */
  83866. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  83867. /**
  83868. * An event triggered when pointer up
  83869. */
  83870. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  83871. /**
  83872. * An event triggered when a control is clicked on
  83873. */
  83874. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  83875. /**
  83876. * An event triggered when pointer enters the control
  83877. */
  83878. onPointerEnterObservable: BABYLON.Observable<Control>;
  83879. /**
  83880. * An event triggered when the control is marked as dirty
  83881. */
  83882. onDirtyObservable: BABYLON.Observable<Control>;
  83883. /**
  83884. * An event triggered before drawing the control
  83885. */
  83886. onBeforeDrawObservable: BABYLON.Observable<Control>;
  83887. /**
  83888. * An event triggered after the control was drawn
  83889. */
  83890. onAfterDrawObservable: BABYLON.Observable<Control>;
  83891. /**
  83892. * An event triggered when the control has been disposed
  83893. */
  83894. onDisposeObservable: BABYLON.Observable<Control>;
  83895. /**
  83896. * Get the hosting AdvancedDynamicTexture
  83897. */
  83898. get host(): AdvancedDynamicTexture;
  83899. /** Gets or set information about font offsets (used to render and align text) */
  83900. get fontOffset(): {
  83901. ascent: number;
  83902. height: number;
  83903. descent: number;
  83904. };
  83905. set fontOffset(offset: {
  83906. ascent: number;
  83907. height: number;
  83908. descent: number;
  83909. });
  83910. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  83911. get alpha(): number;
  83912. set alpha(value: number);
  83913. /**
  83914. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  83915. */
  83916. get isHighlighted(): boolean;
  83917. set isHighlighted(value: boolean);
  83918. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  83919. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83920. */
  83921. get scaleX(): number;
  83922. set scaleX(value: number);
  83923. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  83924. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83925. */
  83926. get scaleY(): number;
  83927. set scaleY(value: number);
  83928. /** Gets or sets the rotation angle (0 by default)
  83929. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83930. */
  83931. get rotation(): number;
  83932. set rotation(value: number);
  83933. /** Gets or sets the transformation center on Y axis (0 by default)
  83934. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83935. */
  83936. get transformCenterY(): number;
  83937. set transformCenterY(value: number);
  83938. /** Gets or sets the transformation center on X axis (0 by default)
  83939. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83940. */
  83941. get transformCenterX(): number;
  83942. set transformCenterX(value: number);
  83943. /**
  83944. * Gets or sets the horizontal alignment
  83945. * @see https://doc.babylonjs.com/how_to/gui#alignments
  83946. */
  83947. get horizontalAlignment(): number;
  83948. set horizontalAlignment(value: number);
  83949. /**
  83950. * Gets or sets the vertical alignment
  83951. * @see https://doc.babylonjs.com/how_to/gui#alignments
  83952. */
  83953. get verticalAlignment(): number;
  83954. set verticalAlignment(value: number);
  83955. /**
  83956. * Gets or sets a fixed ratio for this control.
  83957. * When different from 0, the ratio is used to compute the "second" dimension.
  83958. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  83959. * second dimension is computed as first dimension * fixedRatio
  83960. */
  83961. fixedRatio: number;
  83962. private _fixedRatioMasterIsWidth;
  83963. /**
  83964. * Gets or sets control width
  83965. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83966. */
  83967. get width(): string | number;
  83968. set width(value: string | number);
  83969. /**
  83970. * Gets or sets the control width in pixel
  83971. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83972. */
  83973. get widthInPixels(): number;
  83974. set widthInPixels(value: number);
  83975. /**
  83976. * Gets or sets control height
  83977. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83978. */
  83979. get height(): string | number;
  83980. set height(value: string | number);
  83981. /**
  83982. * Gets or sets control height in pixel
  83983. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83984. */
  83985. get heightInPixels(): number;
  83986. set heightInPixels(value: number);
  83987. /** Gets or set font family */
  83988. get fontFamily(): string;
  83989. set fontFamily(value: string);
  83990. /** Gets or sets font style */
  83991. get fontStyle(): string;
  83992. set fontStyle(value: string);
  83993. /** Gets or sets font weight */
  83994. get fontWeight(): string;
  83995. set fontWeight(value: string);
  83996. /**
  83997. * Gets or sets style
  83998. * @see https://doc.babylonjs.com/how_to/gui#styles
  83999. */
  84000. get style(): BABYLON.Nullable<Style>;
  84001. set style(value: BABYLON.Nullable<Style>);
  84002. /** @hidden */
  84003. get _isFontSizeInPercentage(): boolean;
  84004. /** Gets or sets font size in pixels */
  84005. get fontSizeInPixels(): number;
  84006. set fontSizeInPixels(value: number);
  84007. /** Gets or sets font size */
  84008. get fontSize(): string | number;
  84009. set fontSize(value: string | number);
  84010. /** Gets or sets foreground color */
  84011. get color(): string;
  84012. set color(value: string);
  84013. /** Gets or sets z index which is used to reorder controls on the z axis */
  84014. get zIndex(): number;
  84015. set zIndex(value: number);
  84016. /** Gets or sets a boolean indicating if the control can be rendered */
  84017. get notRenderable(): boolean;
  84018. set notRenderable(value: boolean);
  84019. /** Gets or sets a boolean indicating if the control is visible */
  84020. get isVisible(): boolean;
  84021. set isVisible(value: boolean);
  84022. /** Gets a boolean indicating that the control needs to update its rendering */
  84023. get isDirty(): boolean;
  84024. /**
  84025. * Gets the current linked mesh (or null if none)
  84026. */
  84027. get linkedMesh(): BABYLON.Nullable<BABYLON.TransformNode>;
  84028. /**
  84029. * Gets or sets a value indicating the padding to use on the left of the control
  84030. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84031. */
  84032. get paddingLeft(): string | number;
  84033. set paddingLeft(value: string | number);
  84034. /**
  84035. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  84036. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84037. */
  84038. get paddingLeftInPixels(): number;
  84039. set paddingLeftInPixels(value: number);
  84040. /**
  84041. * Gets or sets a value indicating the padding to use on the right of the control
  84042. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84043. */
  84044. get paddingRight(): string | number;
  84045. set paddingRight(value: string | number);
  84046. /**
  84047. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  84048. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84049. */
  84050. get paddingRightInPixels(): number;
  84051. set paddingRightInPixels(value: number);
  84052. /**
  84053. * Gets or sets a value indicating the padding to use on the top of the control
  84054. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84055. */
  84056. get paddingTop(): string | number;
  84057. set paddingTop(value: string | number);
  84058. /**
  84059. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  84060. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84061. */
  84062. get paddingTopInPixels(): number;
  84063. set paddingTopInPixels(value: number);
  84064. /**
  84065. * Gets or sets a value indicating the padding to use on the bottom of the control
  84066. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84067. */
  84068. get paddingBottom(): string | number;
  84069. set paddingBottom(value: string | number);
  84070. /**
  84071. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  84072. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84073. */
  84074. get paddingBottomInPixels(): number;
  84075. set paddingBottomInPixels(value: number);
  84076. /**
  84077. * Gets or sets a value indicating the left coordinate of the control
  84078. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84079. */
  84080. get left(): string | number;
  84081. set left(value: string | number);
  84082. /**
  84083. * Gets or sets a value indicating the left coordinate in pixels of the control
  84084. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84085. */
  84086. get leftInPixels(): number;
  84087. set leftInPixels(value: number);
  84088. /**
  84089. * Gets or sets a value indicating the top coordinate of the control
  84090. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84091. */
  84092. get top(): string | number;
  84093. set top(value: string | number);
  84094. /**
  84095. * Gets or sets a value indicating the top coordinate in pixels of the control
  84096. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84097. */
  84098. get topInPixels(): number;
  84099. set topInPixels(value: number);
  84100. /**
  84101. * Gets or sets a value indicating the offset on X axis to the linked mesh
  84102. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  84103. */
  84104. get linkOffsetX(): string | number;
  84105. set linkOffsetX(value: string | number);
  84106. /**
  84107. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  84108. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  84109. */
  84110. get linkOffsetXInPixels(): number;
  84111. set linkOffsetXInPixels(value: number);
  84112. /**
  84113. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  84114. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  84115. */
  84116. get linkOffsetY(): string | number;
  84117. set linkOffsetY(value: string | number);
  84118. /**
  84119. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  84120. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  84121. */
  84122. get linkOffsetYInPixels(): number;
  84123. set linkOffsetYInPixels(value: number);
  84124. /** Gets the center coordinate on X axis */
  84125. get centerX(): number;
  84126. /** Gets the center coordinate on Y axis */
  84127. get centerY(): number;
  84128. /** Gets or sets if control is Enabled */
  84129. get isEnabled(): boolean;
  84130. set isEnabled(value: boolean);
  84131. /** Gets or sets background color of control if it's disabled */
  84132. get disabledColor(): string;
  84133. set disabledColor(value: string);
  84134. /** Gets or sets front color of control if it's disabled */
  84135. get disabledColorItem(): string;
  84136. set disabledColorItem(value: string);
  84137. /**
  84138. * Creates a new control
  84139. * @param name defines the name of the control
  84140. */
  84141. constructor(
  84142. /** defines the name of the control */
  84143. name?: string | undefined);
  84144. /** @hidden */
  84145. protected _getTypeName(): string;
  84146. /**
  84147. * Gets the first ascendant in the hierarchy of the given type
  84148. * @param className defines the required type
  84149. * @returns the ascendant or null if not found
  84150. */
  84151. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  84152. /** @hidden */
  84153. _resetFontCache(): void;
  84154. /**
  84155. * Determines if a container is an ascendant of the current control
  84156. * @param container defines the container to look for
  84157. * @returns true if the container is one of the ascendant of the control
  84158. */
  84159. isAscendant(container: Control): boolean;
  84160. /**
  84161. * Gets coordinates in local control space
  84162. * @param globalCoordinates defines the coordinates to transform
  84163. * @returns the new coordinates in local space
  84164. */
  84165. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  84166. /**
  84167. * Gets coordinates in local control space
  84168. * @param globalCoordinates defines the coordinates to transform
  84169. * @param result defines the target vector2 where to store the result
  84170. * @returns the current control
  84171. */
  84172. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  84173. /**
  84174. * Gets coordinates in parent local control space
  84175. * @param globalCoordinates defines the coordinates to transform
  84176. * @returns the new coordinates in parent local space
  84177. */
  84178. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  84179. /**
  84180. * Move the current control to a vector3 position projected onto the screen.
  84181. * @param position defines the target position
  84182. * @param scene defines the hosting scene
  84183. */
  84184. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  84185. /**
  84186. * Will store all controls that have this control as ascendant in a given array
  84187. * @param results defines the array where to store the descendants
  84188. * @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
  84189. * @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
  84190. */
  84191. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  84192. /**
  84193. * Will return all controls that have this control as ascendant
  84194. * @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
  84195. * @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
  84196. * @return all child controls
  84197. */
  84198. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  84199. /**
  84200. * Link current control with a target mesh
  84201. * @param mesh defines the mesh to link with
  84202. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  84203. */
  84204. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.TransformNode>): void;
  84205. /**
  84206. * Shorthand funtion to set the top, right, bottom, and left padding values on the control.
  84207. * @param { string | number} paddingTop - The value of the top padding.
  84208. * @param { string | number} paddingRight - The value of the right padding. If omitted, top is used.
  84209. * @param { string | number} paddingBottom - The value of the bottom padding. If omitted, top is used.
  84210. * @param { string | number} paddingLeft - The value of the left padding. If omitted, right is used.
  84211. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84212. */
  84213. setPadding(paddingTop: string | number, paddingRight?: string | number, paddingBottom?: string | number, paddingLeft?: string | number): void;
  84214. /**
  84215. * Shorthand funtion to set the top, right, bottom, and left padding values in pixels on the control.
  84216. * @param { number} paddingTop - The value in pixels of the top padding.
  84217. * @param { number} paddingRight - The value in pixels of the right padding. If omitted, top is used.
  84218. * @param { number} paddingBottom - The value in pixels of the bottom padding. If omitted, top is used.
  84219. * @param { number} paddingLeft - The value in pixels of the left padding. If omitted, right is used.
  84220. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84221. */
  84222. setPaddingInPixels(paddingTop: number, paddingRight?: number, paddingBottom?: number, paddingLeft?: number): void;
  84223. /** @hidden */
  84224. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  84225. /** @hidden */
  84226. _offsetLeft(offset: number): void;
  84227. /** @hidden */
  84228. _offsetTop(offset: number): void;
  84229. /** @hidden */
  84230. _markMatrixAsDirty(): void;
  84231. /** @hidden */
  84232. _flagDescendantsAsMatrixDirty(): void;
  84233. /** @hidden */
  84234. _intersectsRect(rect: Measure): boolean;
  84235. /** @hidden */
  84236. protected invalidateRect(): void;
  84237. /** @hidden */
  84238. _markAsDirty(force?: boolean): void;
  84239. /** @hidden */
  84240. _markAllAsDirty(): void;
  84241. /** @hidden */
  84242. _link(host: AdvancedDynamicTexture): void;
  84243. /** @hidden */
  84244. protected _transform(context?: CanvasRenderingContext2D): void;
  84245. /** @hidden */
  84246. _renderHighlight(context: CanvasRenderingContext2D): void;
  84247. /** @hidden */
  84248. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  84249. /** @hidden */
  84250. protected _applyStates(context: CanvasRenderingContext2D): void;
  84251. /** @hidden */
  84252. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  84253. /** @hidden */
  84254. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84255. protected _evaluateClippingState(parentMeasure: Measure): void;
  84256. /** @hidden */
  84257. _measure(): void;
  84258. /** @hidden */
  84259. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84260. /** @hidden */
  84261. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84262. /** @hidden */
  84263. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84264. /** @hidden */
  84265. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  84266. private static _ClipMeasure;
  84267. private _tmpMeasureA;
  84268. private _clip;
  84269. /** @hidden */
  84270. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  84271. /** @hidden */
  84272. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84273. /**
  84274. * Tests if a given coordinates belong to the current control
  84275. * @param x defines x coordinate to test
  84276. * @param y defines y coordinate to test
  84277. * @returns true if the coordinates are inside the control
  84278. */
  84279. contains(x: number, y: number): boolean;
  84280. /** @hidden */
  84281. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  84282. /** @hidden */
  84283. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  84284. /** @hidden */
  84285. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  84286. /** @hidden */
  84287. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  84288. /** @hidden */
  84289. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84290. /** @hidden */
  84291. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  84292. /** @hidden */
  84293. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  84294. /** @hidden */
  84295. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  84296. /** @hidden */
  84297. _onCanvasBlur(): void;
  84298. /** @hidden */
  84299. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  84300. private _prepareFont;
  84301. /**
  84302. * Serializes the current control
  84303. * @param serializationObject defined the JSON serialized object
  84304. */
  84305. serialize(serializationObject: any): void;
  84306. /** @hidden */
  84307. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  84308. /** Releases associated resources */
  84309. dispose(): void;
  84310. private static _HORIZONTAL_ALIGNMENT_LEFT;
  84311. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  84312. private static _HORIZONTAL_ALIGNMENT_CENTER;
  84313. private static _VERTICAL_ALIGNMENT_TOP;
  84314. private static _VERTICAL_ALIGNMENT_BOTTOM;
  84315. private static _VERTICAL_ALIGNMENT_CENTER;
  84316. /** HORIZONTAL_ALIGNMENT_LEFT */
  84317. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  84318. /** HORIZONTAL_ALIGNMENT_RIGHT */
  84319. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  84320. /** HORIZONTAL_ALIGNMENT_CENTER */
  84321. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  84322. /** VERTICAL_ALIGNMENT_TOP */
  84323. static get VERTICAL_ALIGNMENT_TOP(): number;
  84324. /** VERTICAL_ALIGNMENT_BOTTOM */
  84325. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  84326. /** VERTICAL_ALIGNMENT_CENTER */
  84327. static get VERTICAL_ALIGNMENT_CENTER(): number;
  84328. private static _FontHeightSizes;
  84329. /** @hidden */
  84330. static _GetFontOffset(font: string): {
  84331. ascent: number;
  84332. height: number;
  84333. descent: number;
  84334. };
  84335. /**
  84336. * Creates a Control from parsed data
  84337. * @param serializedObject defines parsed data
  84338. * @param host defines the hosting AdvancedDynamicTexture
  84339. * @returns a new Control
  84340. */
  84341. static Parse(serializedObject: any, host: AdvancedDynamicTexture): Control;
  84342. /**
  84343. * Creates a stack panel that can be used to render headers
  84344. * @param control defines the control to associate with the header
  84345. * @param text defines the text of the header
  84346. * @param size defines the size of the header
  84347. * @param options defines options used to configure the header
  84348. * @returns a new StackPanel
  84349. * @ignore
  84350. * @hidden
  84351. */
  84352. static AddHeader: (control: Control, text: string, size: string | number, options: {
  84353. isHorizontal: boolean;
  84354. controlFirst: boolean;
  84355. }) => any;
  84356. /** @hidden */
  84357. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  84358. }
  84359. }
  84360. declare module BABYLON.GUI {
  84361. /**
  84362. * Root class for 2D containers
  84363. * @see https://doc.babylonjs.com/how_to/gui#containers
  84364. */
  84365. export class Container extends Control {
  84366. name?: string | undefined;
  84367. /** @hidden */
  84368. _children: Control[];
  84369. /** @hidden */
  84370. protected _measureForChildren: Measure;
  84371. /** @hidden */
  84372. protected _background: string;
  84373. /** @hidden */
  84374. protected _adaptWidthToChildren: boolean;
  84375. /** @hidden */
  84376. protected _adaptHeightToChildren: boolean;
  84377. /**
  84378. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  84379. */
  84380. logLayoutCycleErrors: boolean;
  84381. /**
  84382. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  84383. */
  84384. maxLayoutCycle: number;
  84385. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  84386. get adaptHeightToChildren(): boolean;
  84387. set adaptHeightToChildren(value: boolean);
  84388. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  84389. get adaptWidthToChildren(): boolean;
  84390. set adaptWidthToChildren(value: boolean);
  84391. /** Gets or sets background color */
  84392. get background(): string;
  84393. set background(value: string);
  84394. /** Gets the list of children */
  84395. get children(): Control[];
  84396. /**
  84397. * Creates a new Container
  84398. * @param name defines the name of the container
  84399. */
  84400. constructor(name?: string | undefined);
  84401. protected _getTypeName(): string;
  84402. _flagDescendantsAsMatrixDirty(): void;
  84403. /**
  84404. * Gets a child using its name
  84405. * @param name defines the child name to look for
  84406. * @returns the child control if found
  84407. */
  84408. getChildByName(name: string): BABYLON.Nullable<Control>;
  84409. /**
  84410. * Gets a child using its type and its name
  84411. * @param name defines the child name to look for
  84412. * @param type defines the child type to look for
  84413. * @returns the child control if found
  84414. */
  84415. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  84416. /**
  84417. * Search for a specific control in children
  84418. * @param control defines the control to look for
  84419. * @returns true if the control is in child list
  84420. */
  84421. containsControl(control: Control): boolean;
  84422. /**
  84423. * Adds a new control to the current container
  84424. * @param control defines the control to add
  84425. * @returns the current container
  84426. */
  84427. addControl(control: BABYLON.Nullable<Control>): Container;
  84428. /**
  84429. * Removes all controls from the current container
  84430. * @returns the current container
  84431. */
  84432. clearControls(): Container;
  84433. /**
  84434. * Removes a control from the current container
  84435. * @param control defines the control to remove
  84436. * @returns the current container
  84437. */
  84438. removeControl(control: Control): Container;
  84439. /** @hidden */
  84440. _reOrderControl(control: Control): void;
  84441. /** @hidden */
  84442. _offsetLeft(offset: number): void;
  84443. /** @hidden */
  84444. _offsetTop(offset: number): void;
  84445. /** @hidden */
  84446. _markAllAsDirty(): void;
  84447. /** @hidden */
  84448. protected _localDraw(context: CanvasRenderingContext2D): void;
  84449. /** @hidden */
  84450. _link(host: AdvancedDynamicTexture): void;
  84451. /** @hidden */
  84452. protected _beforeLayout(): void;
  84453. /** @hidden */
  84454. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84455. /** @hidden */
  84456. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  84457. protected _postMeasure(): void;
  84458. /** @hidden */
  84459. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  84460. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  84461. /** @hidden */
  84462. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  84463. /** @hidden */
  84464. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84465. /**
  84466. * Serializes the current control
  84467. * @param serializationObject defined the JSON serialized object
  84468. */
  84469. serialize(serializationObject: any): void;
  84470. /** Releases associated resources */
  84471. dispose(): void;
  84472. /** @hidden */
  84473. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  84474. }
  84475. }
  84476. declare module BABYLON.GUI {
  84477. /** Class used to create rectangle container */
  84478. export class Rectangle extends Container {
  84479. name?: string | undefined;
  84480. private _thickness;
  84481. private _cornerRadius;
  84482. /** Gets or sets border thickness */
  84483. get thickness(): number;
  84484. set thickness(value: number);
  84485. /** Gets or sets the corner radius angle */
  84486. get cornerRadius(): number;
  84487. set cornerRadius(value: number);
  84488. /**
  84489. * Creates a new Rectangle
  84490. * @param name defines the control name
  84491. */
  84492. constructor(name?: string | undefined);
  84493. protected _getTypeName(): string;
  84494. protected _localDraw(context: CanvasRenderingContext2D): void;
  84495. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84496. private _drawRoundedRect;
  84497. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  84498. }
  84499. }
  84500. declare module BABYLON.GUI {
  84501. /**
  84502. * Enum that determines the text-wrapping mode to use.
  84503. */
  84504. export enum TextWrapping {
  84505. /**
  84506. * Clip the text when it's larger than Control.width; this is the default mode.
  84507. */
  84508. Clip = 0,
  84509. /**
  84510. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  84511. */
  84512. WordWrap = 1,
  84513. /**
  84514. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  84515. */
  84516. Ellipsis = 2
  84517. }
  84518. /**
  84519. * Class used to create text block control
  84520. */
  84521. export class TextBlock extends Control {
  84522. /**
  84523. * Defines the name of the control
  84524. */
  84525. name?: string | undefined;
  84526. private _text;
  84527. private _textWrapping;
  84528. private _textHorizontalAlignment;
  84529. private _textVerticalAlignment;
  84530. private _lines;
  84531. private _resizeToFit;
  84532. private _lineSpacing;
  84533. private _outlineWidth;
  84534. private _outlineColor;
  84535. private _underline;
  84536. private _lineThrough;
  84537. /**
  84538. * An event triggered after the text is changed
  84539. */
  84540. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  84541. /**
  84542. * An event triggered after the text was broken up into lines
  84543. */
  84544. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  84545. /**
  84546. * Function used to split a string into words. By default, a string is split at each space character found
  84547. */
  84548. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  84549. /**
  84550. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  84551. */
  84552. get lines(): any[];
  84553. /**
  84554. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  84555. */
  84556. get resizeToFit(): boolean;
  84557. /**
  84558. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  84559. */
  84560. set resizeToFit(value: boolean);
  84561. /**
  84562. * Gets or sets a boolean indicating if text must be wrapped
  84563. */
  84564. get textWrapping(): TextWrapping | boolean;
  84565. /**
  84566. * Gets or sets a boolean indicating if text must be wrapped
  84567. */
  84568. set textWrapping(value: TextWrapping | boolean);
  84569. /**
  84570. * Gets or sets text to display
  84571. */
  84572. get text(): string;
  84573. /**
  84574. * Gets or sets text to display
  84575. */
  84576. set text(value: string);
  84577. /**
  84578. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  84579. */
  84580. get textHorizontalAlignment(): number;
  84581. /**
  84582. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  84583. */
  84584. set textHorizontalAlignment(value: number);
  84585. /**
  84586. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  84587. */
  84588. get textVerticalAlignment(): number;
  84589. /**
  84590. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  84591. */
  84592. set textVerticalAlignment(value: number);
  84593. /**
  84594. * Gets or sets line spacing value
  84595. */
  84596. set lineSpacing(value: string | number);
  84597. /**
  84598. * Gets or sets line spacing value
  84599. */
  84600. get lineSpacing(): string | number;
  84601. /**
  84602. * Gets or sets outlineWidth of the text to display
  84603. */
  84604. get outlineWidth(): number;
  84605. /**
  84606. * Gets or sets outlineWidth of the text to display
  84607. */
  84608. set outlineWidth(value: number);
  84609. /**
  84610. * Gets or sets a boolean indicating that text must have underline
  84611. */
  84612. get underline(): boolean;
  84613. /**
  84614. * Gets or sets a boolean indicating that text must have underline
  84615. */
  84616. set underline(value: boolean);
  84617. /**
  84618. * Gets or sets an boolean indicating that text must be crossed out
  84619. */
  84620. get lineThrough(): boolean;
  84621. /**
  84622. * Gets or sets an boolean indicating that text must be crossed out
  84623. */
  84624. set lineThrough(value: boolean);
  84625. /**
  84626. * Gets or sets outlineColor of the text to display
  84627. */
  84628. get outlineColor(): string;
  84629. /**
  84630. * Gets or sets outlineColor of the text to display
  84631. */
  84632. set outlineColor(value: string);
  84633. /**
  84634. * Creates a new TextBlock object
  84635. * @param name defines the name of the control
  84636. * @param text defines the text to display (emptry string by default)
  84637. */
  84638. constructor(
  84639. /**
  84640. * Defines the name of the control
  84641. */
  84642. name?: string | undefined, text?: string);
  84643. protected _getTypeName(): string;
  84644. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84645. private _drawText;
  84646. /** @hidden */
  84647. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84648. protected _applyStates(context: CanvasRenderingContext2D): void;
  84649. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  84650. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  84651. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  84652. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  84653. protected _renderLines(context: CanvasRenderingContext2D): void;
  84654. /**
  84655. * Given a width constraint applied on the text block, find the expected height
  84656. * @returns expected height
  84657. */
  84658. computeExpectedHeight(): number;
  84659. dispose(): void;
  84660. }
  84661. }
  84662. declare module BABYLON.GUI {
  84663. /**
  84664. * Class used to create 2D images
  84665. */
  84666. export class Image extends Control {
  84667. name?: string | undefined;
  84668. private _workingCanvas;
  84669. private _domImage;
  84670. private _imageWidth;
  84671. private _imageHeight;
  84672. private _loaded;
  84673. private _stretch;
  84674. private _source;
  84675. private _autoScale;
  84676. private _sourceLeft;
  84677. private _sourceTop;
  84678. private _sourceWidth;
  84679. private _sourceHeight;
  84680. private _svgAttributesComputationCompleted;
  84681. private _isSVG;
  84682. private _cellWidth;
  84683. private _cellHeight;
  84684. private _cellId;
  84685. private _sliceLeft;
  84686. private _sliceRight;
  84687. private _sliceTop;
  84688. private _sliceBottom;
  84689. private _populateNinePatchSlicesFromImage;
  84690. private _detectPointerOnOpaqueOnly;
  84691. private _imageDataCache;
  84692. /**
  84693. * BABYLON.Observable notified when the content is loaded
  84694. */
  84695. onImageLoadedObservable: BABYLON.Observable<Image>;
  84696. /**
  84697. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  84698. */
  84699. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  84700. /**
  84701. * Gets a boolean indicating that the content is loaded
  84702. */
  84703. get isLoaded(): boolean;
  84704. /**
  84705. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  84706. * Beware using this as this will comsume more memory as the image has to be stored twice
  84707. */
  84708. get detectPointerOnOpaqueOnly(): boolean;
  84709. set detectPointerOnOpaqueOnly(value: boolean);
  84710. /**
  84711. * Gets or sets the left value for slicing (9-patch)
  84712. */
  84713. get sliceLeft(): number;
  84714. set sliceLeft(value: number);
  84715. /**
  84716. * Gets or sets the right value for slicing (9-patch)
  84717. */
  84718. get sliceRight(): number;
  84719. set sliceRight(value: number);
  84720. /**
  84721. * Gets or sets the top value for slicing (9-patch)
  84722. */
  84723. get sliceTop(): number;
  84724. set sliceTop(value: number);
  84725. /**
  84726. * Gets or sets the bottom value for slicing (9-patch)
  84727. */
  84728. get sliceBottom(): number;
  84729. set sliceBottom(value: number);
  84730. /**
  84731. * Gets or sets the left coordinate in the source image
  84732. */
  84733. get sourceLeft(): number;
  84734. set sourceLeft(value: number);
  84735. /**
  84736. * Gets or sets the top coordinate in the source image
  84737. */
  84738. get sourceTop(): number;
  84739. set sourceTop(value: number);
  84740. /**
  84741. * Gets or sets the width to capture in the source image
  84742. */
  84743. get sourceWidth(): number;
  84744. set sourceWidth(value: number);
  84745. /**
  84746. * Gets or sets the height to capture in the source image
  84747. */
  84748. get sourceHeight(): number;
  84749. set sourceHeight(value: number);
  84750. /**
  84751. * Gets the image width
  84752. */
  84753. get imageWidth(): number;
  84754. /**
  84755. * Gets the image height
  84756. */
  84757. get imageHeight(): number;
  84758. /**
  84759. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  84760. */
  84761. get populateNinePatchSlicesFromImage(): boolean;
  84762. set populateNinePatchSlicesFromImage(value: boolean);
  84763. /** Indicates if the format of the image is SVG */
  84764. get isSVG(): boolean;
  84765. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  84766. get svgAttributesComputationCompleted(): boolean;
  84767. /**
  84768. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  84769. * @see https://doc.babylonjs.com/how_to/gui#image
  84770. */
  84771. get autoScale(): boolean;
  84772. set autoScale(value: boolean);
  84773. /** Gets or sets the streching mode used by the image */
  84774. get stretch(): number;
  84775. set stretch(value: number);
  84776. /** @hidden */
  84777. _rotate90(n: number, preserveProperties?: boolean): Image;
  84778. private _handleRotationForSVGImage;
  84779. private _rotate90SourceProperties;
  84780. private _extractNinePatchSliceDataFromImage;
  84781. /**
  84782. * Gets or sets the internal DOM image used to render the control
  84783. */
  84784. set domImage(value: HTMLImageElement);
  84785. get domImage(): HTMLImageElement;
  84786. private _onImageLoaded;
  84787. /**
  84788. * Gets the image source url
  84789. */
  84790. get source(): BABYLON.Nullable<string>;
  84791. /**
  84792. * Gets or sets image source url
  84793. */
  84794. set source(value: BABYLON.Nullable<string>);
  84795. /**
  84796. * Checks for svg document with icon id present
  84797. */
  84798. private _svgCheck;
  84799. /**
  84800. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  84801. * given external svg file and icon id
  84802. */
  84803. private _getSVGAttribs;
  84804. /**
  84805. * Gets or sets the cell width to use when animation sheet is enabled
  84806. * @see https://doc.babylonjs.com/how_to/gui#image
  84807. */
  84808. get cellWidth(): number;
  84809. set cellWidth(value: number);
  84810. /**
  84811. * Gets or sets the cell height to use when animation sheet is enabled
  84812. * @see https://doc.babylonjs.com/how_to/gui#image
  84813. */
  84814. get cellHeight(): number;
  84815. set cellHeight(value: number);
  84816. /**
  84817. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  84818. * @see https://doc.babylonjs.com/how_to/gui#image
  84819. */
  84820. get cellId(): number;
  84821. set cellId(value: number);
  84822. /**
  84823. * Creates a new Image
  84824. * @param name defines the control name
  84825. * @param url defines the image url
  84826. */
  84827. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  84828. /**
  84829. * Tests if a given coordinates belong to the current control
  84830. * @param x defines x coordinate to test
  84831. * @param y defines y coordinate to test
  84832. * @returns true if the coordinates are inside the control
  84833. */
  84834. contains(x: number, y: number): boolean;
  84835. protected _getTypeName(): string;
  84836. /** Force the control to synchronize with its content */
  84837. synchronizeSizeWithContent(): void;
  84838. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84839. private _prepareWorkingCanvasForOpaqueDetection;
  84840. private _drawImage;
  84841. _draw(context: CanvasRenderingContext2D): void;
  84842. private _renderNinePatch;
  84843. dispose(): void;
  84844. /** STRETCH_NONE */
  84845. static readonly STRETCH_NONE: number;
  84846. /** STRETCH_FILL */
  84847. static readonly STRETCH_FILL: number;
  84848. /** STRETCH_UNIFORM */
  84849. static readonly STRETCH_UNIFORM: number;
  84850. /** STRETCH_EXTEND */
  84851. static readonly STRETCH_EXTEND: number;
  84852. /** NINE_PATCH */
  84853. static readonly STRETCH_NINE_PATCH: number;
  84854. }
  84855. }
  84856. declare module BABYLON.GUI {
  84857. /**
  84858. * Class used to create 2D buttons
  84859. */
  84860. export class Button extends Rectangle {
  84861. name?: string | undefined;
  84862. /**
  84863. * Function called to generate a pointer enter animation
  84864. */
  84865. pointerEnterAnimation: () => void;
  84866. /**
  84867. * Function called to generate a pointer out animation
  84868. */
  84869. pointerOutAnimation: () => void;
  84870. /**
  84871. * Function called to generate a pointer down animation
  84872. */
  84873. pointerDownAnimation: () => void;
  84874. /**
  84875. * Function called to generate a pointer up animation
  84876. */
  84877. pointerUpAnimation: () => void;
  84878. /**
  84879. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  84880. */
  84881. delegatePickingToChildren: boolean;
  84882. private _image;
  84883. /**
  84884. * Returns the image part of the button (if any)
  84885. */
  84886. get image(): BABYLON.Nullable<Image>;
  84887. private _textBlock;
  84888. /**
  84889. * Returns the image part of the button (if any)
  84890. */
  84891. get textBlock(): BABYLON.Nullable<TextBlock>;
  84892. /**
  84893. * Creates a new Button
  84894. * @param name defines the name of the button
  84895. */
  84896. constructor(name?: string | undefined);
  84897. protected _getTypeName(): string;
  84898. /** @hidden */
  84899. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  84900. /** @hidden */
  84901. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  84902. /** @hidden */
  84903. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  84904. /** @hidden */
  84905. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84906. /** @hidden */
  84907. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  84908. /**
  84909. * Creates a new button made with an image and a text
  84910. * @param name defines the name of the button
  84911. * @param text defines the text of the button
  84912. * @param imageUrl defines the url of the image
  84913. * @returns a new Button
  84914. */
  84915. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  84916. /**
  84917. * Creates a new button made with an image
  84918. * @param name defines the name of the button
  84919. * @param imageUrl defines the url of the image
  84920. * @returns a new Button
  84921. */
  84922. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  84923. /**
  84924. * Creates a new button made with a text
  84925. * @param name defines the name of the button
  84926. * @param text defines the text of the button
  84927. * @returns a new Button
  84928. */
  84929. static CreateSimpleButton(name: string, text: string): Button;
  84930. /**
  84931. * Creates a new button made with an image and a centered text
  84932. * @param name defines the name of the button
  84933. * @param text defines the text of the button
  84934. * @param imageUrl defines the url of the image
  84935. * @returns a new Button
  84936. */
  84937. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  84938. }
  84939. }
  84940. declare module BABYLON.GUI {
  84941. /**
  84942. * Class used to create a 2D stack panel container
  84943. */
  84944. export class StackPanel extends Container {
  84945. name?: string | undefined;
  84946. private _isVertical;
  84947. private _manualWidth;
  84948. private _manualHeight;
  84949. private _doNotTrackManualChanges;
  84950. /**
  84951. * Gets or sets a boolean indicating that layou warnings should be ignored
  84952. */
  84953. ignoreLayoutWarnings: boolean;
  84954. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  84955. get isVertical(): boolean;
  84956. set isVertical(value: boolean);
  84957. /**
  84958. * Gets or sets panel width.
  84959. * This value should not be set when in horizontal mode as it will be computed automatically
  84960. */
  84961. set width(value: string | number);
  84962. get width(): string | number;
  84963. /**
  84964. * Gets or sets panel height.
  84965. * This value should not be set when in vertical mode as it will be computed automatically
  84966. */
  84967. set height(value: string | number);
  84968. get height(): string | number;
  84969. /**
  84970. * Creates a new StackPanel
  84971. * @param name defines control name
  84972. */
  84973. constructor(name?: string | undefined);
  84974. protected _getTypeName(): string;
  84975. /** @hidden */
  84976. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84977. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84978. protected _postMeasure(): void;
  84979. /**
  84980. * Serializes the current control
  84981. * @param serializationObject defined the JSON serialized object
  84982. */
  84983. serialize(serializationObject: any): void;
  84984. /** @hidden */
  84985. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  84986. }
  84987. }
  84988. declare module BABYLON.GUI {
  84989. /**
  84990. * Class used to represent a 2D checkbox
  84991. */
  84992. export class Checkbox extends Control {
  84993. name?: string | undefined;
  84994. private _isChecked;
  84995. private _background;
  84996. private _checkSizeRatio;
  84997. private _thickness;
  84998. /** Gets or sets border thickness */
  84999. get thickness(): number;
  85000. set thickness(value: number);
  85001. /**
  85002. * BABYLON.Observable raised when isChecked property changes
  85003. */
  85004. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  85005. /** Gets or sets a value indicating the ratio between overall size and check size */
  85006. get checkSizeRatio(): number;
  85007. set checkSizeRatio(value: number);
  85008. /** Gets or sets background color */
  85009. get background(): string;
  85010. set background(value: string);
  85011. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  85012. get isChecked(): boolean;
  85013. set isChecked(value: boolean);
  85014. /**
  85015. * Creates a new CheckBox
  85016. * @param name defines the control name
  85017. */
  85018. constructor(name?: string | undefined);
  85019. protected _getTypeName(): string;
  85020. /** @hidden */
  85021. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85022. /** @hidden */
  85023. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85024. /**
  85025. * Utility function to easily create a checkbox with a header
  85026. * @param title defines the label to use for the header
  85027. * @param onValueChanged defines the callback to call when value changes
  85028. * @returns a StackPanel containing the checkbox and a textBlock
  85029. */
  85030. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  85031. }
  85032. }
  85033. declare module BABYLON.GUI {
  85034. /**
  85035. * Class used to store key control properties
  85036. */
  85037. export class KeyPropertySet {
  85038. /** Width */
  85039. width?: string;
  85040. /** Height */
  85041. height?: string;
  85042. /** Left padding */
  85043. paddingLeft?: string;
  85044. /** Right padding */
  85045. paddingRight?: string;
  85046. /** Top padding */
  85047. paddingTop?: string;
  85048. /** Bottom padding */
  85049. paddingBottom?: string;
  85050. /** Foreground color */
  85051. color?: string;
  85052. /** Background color */
  85053. background?: string;
  85054. }
  85055. /**
  85056. * Class used to create virtual keyboard
  85057. */
  85058. export class VirtualKeyboard extends StackPanel {
  85059. /** BABYLON.Observable raised when a key is pressed */
  85060. onKeyPressObservable: BABYLON.Observable<string>;
  85061. /** Gets or sets default key button width */
  85062. defaultButtonWidth: string;
  85063. /** Gets or sets default key button height */
  85064. defaultButtonHeight: string;
  85065. /** Gets or sets default key button left padding */
  85066. defaultButtonPaddingLeft: string;
  85067. /** Gets or sets default key button right padding */
  85068. defaultButtonPaddingRight: string;
  85069. /** Gets or sets default key button top padding */
  85070. defaultButtonPaddingTop: string;
  85071. /** Gets or sets default key button bottom padding */
  85072. defaultButtonPaddingBottom: string;
  85073. /** Gets or sets default key button foreground color */
  85074. defaultButtonColor: string;
  85075. /** Gets or sets default key button background color */
  85076. defaultButtonBackground: string;
  85077. /** Gets or sets shift button foreground color */
  85078. shiftButtonColor: string;
  85079. /** Gets or sets shift button thickness*/
  85080. selectedShiftThickness: number;
  85081. /** Gets shift key state */
  85082. shiftState: number;
  85083. protected _getTypeName(): string;
  85084. private _createKey;
  85085. /**
  85086. * Adds a new row of keys
  85087. * @param keys defines the list of keys to add
  85088. * @param propertySets defines the associated property sets
  85089. */
  85090. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  85091. /**
  85092. * Set the shift key to a specific state
  85093. * @param shiftState defines the new shift state
  85094. */
  85095. applyShiftState(shiftState: number): void;
  85096. private _currentlyConnectedInputText;
  85097. private _connectedInputTexts;
  85098. private _onKeyPressObserver;
  85099. /** Gets the input text control currently attached to the keyboard */
  85100. get connectedInputText(): BABYLON.Nullable<InputText>;
  85101. /**
  85102. * Connects the keyboard with an input text control
  85103. *
  85104. * @param input defines the target control
  85105. */
  85106. connect(input: InputText): void;
  85107. /**
  85108. * Disconnects the keyboard from connected InputText controls
  85109. *
  85110. * @param input optionally defines a target control, otherwise all are disconnected
  85111. */
  85112. disconnect(input?: InputText): void;
  85113. private _removeConnectedInputObservables;
  85114. /**
  85115. * Release all resources
  85116. */
  85117. dispose(): void;
  85118. /**
  85119. * Creates a new keyboard using a default layout
  85120. *
  85121. * @param name defines control name
  85122. * @returns a new VirtualKeyboard
  85123. */
  85124. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  85125. }
  85126. }
  85127. declare module BABYLON.GUI {
  85128. /** @hidden */
  85129. export class TextWrapper {
  85130. private _text;
  85131. private _characters;
  85132. get text(): string;
  85133. set text(txt: string);
  85134. get length(): number;
  85135. removePart(idxStart: number, idxEnd: number, insertTxt?: string): void;
  85136. charAt(idx: number): string;
  85137. substr(from: number, length?: number): string;
  85138. substring(from: number, to?: number): string;
  85139. isWord(index: number): boolean;
  85140. }
  85141. }
  85142. declare module BABYLON.GUI {
  85143. /**
  85144. * Class used to create input text control
  85145. */
  85146. export class InputText extends Control implements IFocusableControl {
  85147. name?: string | undefined;
  85148. private _textWrapper;
  85149. private _placeholderText;
  85150. private _background;
  85151. private _focusedBackground;
  85152. private _focusedColor;
  85153. private _placeholderColor;
  85154. private _thickness;
  85155. private _margin;
  85156. private _autoStretchWidth;
  85157. private _maxWidth;
  85158. private _isFocused;
  85159. private _blinkTimeout;
  85160. private _blinkIsEven;
  85161. private _cursorOffset;
  85162. private _scrollLeft;
  85163. private _textWidth;
  85164. private _clickedCoordinate;
  85165. private _deadKey;
  85166. private _addKey;
  85167. private _currentKey;
  85168. private _isTextHighlightOn;
  85169. private _textHighlightColor;
  85170. private _highligherOpacity;
  85171. private _highlightedText;
  85172. private _startHighlightIndex;
  85173. private _endHighlightIndex;
  85174. private _cursorIndex;
  85175. private _onFocusSelectAll;
  85176. private _isPointerDown;
  85177. private _onClipboardObserver;
  85178. private _onPointerDblTapObserver;
  85179. /** @hidden */
  85180. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  85181. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  85182. promptMessage: string;
  85183. /** Force disable prompt on mobile device */
  85184. disableMobilePrompt: boolean;
  85185. /** BABYLON.Observable raised when the text changes */
  85186. onTextChangedObservable: BABYLON.Observable<InputText>;
  85187. /** BABYLON.Observable raised just before an entered character is to be added */
  85188. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  85189. /** BABYLON.Observable raised when the control gets the focus */
  85190. onFocusObservable: BABYLON.Observable<InputText>;
  85191. /** BABYLON.Observable raised when the control loses the focus */
  85192. onBlurObservable: BABYLON.Observable<InputText>;
  85193. /**Observable raised when the text is highlighted */
  85194. onTextHighlightObservable: BABYLON.Observable<InputText>;
  85195. /**Observable raised when copy event is triggered */
  85196. onTextCopyObservable: BABYLON.Observable<InputText>;
  85197. /** BABYLON.Observable raised when cut event is triggered */
  85198. onTextCutObservable: BABYLON.Observable<InputText>;
  85199. /** BABYLON.Observable raised when paste event is triggered */
  85200. onTextPasteObservable: BABYLON.Observable<InputText>;
  85201. /** BABYLON.Observable raised when a key event was processed */
  85202. onKeyboardEventProcessedObservable: BABYLON.Observable<BABYLON.IKeyboardEvent>;
  85203. /** Gets or sets the maximum width allowed by the control */
  85204. get maxWidth(): string | number;
  85205. /** Gets the maximum width allowed by the control in pixels */
  85206. get maxWidthInPixels(): number;
  85207. set maxWidth(value: string | number);
  85208. /** Gets or sets the text highlighter transparency; default: 0.4 */
  85209. get highligherOpacity(): number;
  85210. set highligherOpacity(value: number);
  85211. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  85212. get onFocusSelectAll(): boolean;
  85213. set onFocusSelectAll(value: boolean);
  85214. /** Gets or sets the text hightlight color */
  85215. get textHighlightColor(): string;
  85216. set textHighlightColor(value: string);
  85217. /** Gets or sets control margin */
  85218. get margin(): string;
  85219. /** Gets control margin in pixels */
  85220. get marginInPixels(): number;
  85221. set margin(value: string);
  85222. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  85223. get autoStretchWidth(): boolean;
  85224. set autoStretchWidth(value: boolean);
  85225. /** Gets or sets border thickness */
  85226. get thickness(): number;
  85227. set thickness(value: number);
  85228. /** Gets or sets the background color when focused */
  85229. get focusedBackground(): string;
  85230. set focusedBackground(value: string);
  85231. /** Gets or sets the background color when focused */
  85232. get focusedColor(): string;
  85233. set focusedColor(value: string);
  85234. /** Gets or sets the background color */
  85235. get background(): string;
  85236. set background(value: string);
  85237. /** Gets or sets the placeholder color */
  85238. get placeholderColor(): string;
  85239. set placeholderColor(value: string);
  85240. /** Gets or sets the text displayed when the control is empty */
  85241. get placeholderText(): string;
  85242. set placeholderText(value: string);
  85243. /** Gets or sets the dead key flag */
  85244. get deadKey(): boolean;
  85245. set deadKey(flag: boolean);
  85246. /** Gets or sets the highlight text */
  85247. get highlightedText(): string;
  85248. set highlightedText(text: string);
  85249. /** Gets or sets if the current key should be added */
  85250. get addKey(): boolean;
  85251. set addKey(flag: boolean);
  85252. /** Gets or sets the value of the current key being entered */
  85253. get currentKey(): string;
  85254. set currentKey(key: string);
  85255. /** Gets or sets the text displayed in the control */
  85256. get text(): string;
  85257. set text(value: string);
  85258. private _textHasChanged;
  85259. /** Gets or sets control width */
  85260. get width(): string | number;
  85261. set width(value: string | number);
  85262. /**
  85263. * Creates a new InputText
  85264. * @param name defines the control name
  85265. * @param text defines the text of the control
  85266. */
  85267. constructor(name?: string | undefined, text?: string);
  85268. /** @hidden */
  85269. onBlur(): void;
  85270. /** @hidden */
  85271. onFocus(): void;
  85272. /**
  85273. * Function to focus an inputText programmatically
  85274. */
  85275. focus(): void;
  85276. /**
  85277. * Function to unfocus an inputText programmatically
  85278. */
  85279. blur(): void;
  85280. protected _getTypeName(): string;
  85281. /**
  85282. * Function called to get the list of controls that should not steal the focus from this control
  85283. * @returns an array of controls
  85284. */
  85285. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  85286. /** @hidden */
  85287. processKey(keyCode: number, key?: string, evt?: BABYLON.IKeyboardEvent): void;
  85288. /** @hidden */
  85289. private _updateValueFromCursorIndex;
  85290. /** @hidden */
  85291. private _processDblClick;
  85292. /** @hidden */
  85293. private _selectAllText;
  85294. /**
  85295. * Handles the keyboard event
  85296. * @param evt Defines the KeyboardEvent
  85297. */
  85298. processKeyboard(evt: BABYLON.IKeyboardEvent): void;
  85299. /** @hidden */
  85300. private _onCopyText;
  85301. /** @hidden */
  85302. private _onCutText;
  85303. /** @hidden */
  85304. private _onPasteText;
  85305. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85306. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85307. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  85308. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  85309. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  85310. dispose(): void;
  85311. }
  85312. }
  85313. declare module BABYLON.GUI {
  85314. /**
  85315. * Class used to create a 2D grid container
  85316. */
  85317. export class Grid extends Container {
  85318. name?: string | undefined;
  85319. private _rowDefinitions;
  85320. private _columnDefinitions;
  85321. private _cells;
  85322. private _childControls;
  85323. /**
  85324. * Gets the number of columns
  85325. */
  85326. get columnCount(): number;
  85327. /**
  85328. * Gets the number of rows
  85329. */
  85330. get rowCount(): number;
  85331. /** Gets the list of children */
  85332. get children(): Control[];
  85333. /** Gets the list of cells (e.g. the containers) */
  85334. get cells(): {
  85335. [key: string]: Container;
  85336. };
  85337. /**
  85338. * Gets the definition of a specific row
  85339. * @param index defines the index of the row
  85340. * @returns the row definition
  85341. */
  85342. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  85343. /**
  85344. * Gets the definition of a specific column
  85345. * @param index defines the index of the column
  85346. * @returns the column definition
  85347. */
  85348. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  85349. /**
  85350. * Adds a new row to the grid
  85351. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  85352. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  85353. * @returns the current grid
  85354. */
  85355. addRowDefinition(height: number, isPixel?: boolean): Grid;
  85356. /**
  85357. * Adds a new column to the grid
  85358. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  85359. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  85360. * @returns the current grid
  85361. */
  85362. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  85363. /**
  85364. * Update a row definition
  85365. * @param index defines the index of the row to update
  85366. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  85367. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  85368. * @returns the current grid
  85369. */
  85370. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  85371. /**
  85372. * Update a column definition
  85373. * @param index defines the index of the column to update
  85374. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  85375. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  85376. * @returns the current grid
  85377. */
  85378. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  85379. /**
  85380. * Gets the list of children stored in a specific cell
  85381. * @param row defines the row to check
  85382. * @param column defines the column to check
  85383. * @returns the list of controls
  85384. */
  85385. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  85386. /**
  85387. * Gets a string representing the child cell info (row x column)
  85388. * @param child defines the control to get info from
  85389. * @returns a string containing the child cell info (row x column)
  85390. */
  85391. getChildCellInfo(child: Control): string;
  85392. private _removeCell;
  85393. private _offsetCell;
  85394. /**
  85395. * Remove a column definition at specified index
  85396. * @param index defines the index of the column to remove
  85397. * @returns the current grid
  85398. */
  85399. removeColumnDefinition(index: number): Grid;
  85400. /**
  85401. * Remove a row definition at specified index
  85402. * @param index defines the index of the row to remove
  85403. * @returns the current grid
  85404. */
  85405. removeRowDefinition(index: number): Grid;
  85406. /**
  85407. * Adds a new control to the current grid
  85408. * @param control defines the control to add
  85409. * @param row defines the row where to add the control (0 by default)
  85410. * @param column defines the column where to add the control (0 by default)
  85411. * @returns the current grid
  85412. */
  85413. addControl(control: Control, row?: number, column?: number): Grid;
  85414. /**
  85415. * Removes a control from the current container
  85416. * @param control defines the control to remove
  85417. * @returns the current container
  85418. */
  85419. removeControl(control: Control): Container;
  85420. /**
  85421. * Creates a new Grid
  85422. * @param name defines control name
  85423. */
  85424. constructor(name?: string | undefined);
  85425. protected _getTypeName(): string;
  85426. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  85427. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85428. _flagDescendantsAsMatrixDirty(): void;
  85429. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  85430. /** Releases associated resources */
  85431. dispose(): void;
  85432. }
  85433. }
  85434. declare module BABYLON.GUI {
  85435. /** Class used to create color pickers */
  85436. export class ColorPicker extends Control {
  85437. name?: string | undefined;
  85438. private static _Epsilon;
  85439. private _colorWheelCanvas;
  85440. private _value;
  85441. private _tmpColor;
  85442. private _pointerStartedOnSquare;
  85443. private _pointerStartedOnWheel;
  85444. private _squareLeft;
  85445. private _squareTop;
  85446. private _squareSize;
  85447. private _h;
  85448. private _s;
  85449. private _v;
  85450. private _lastPointerDownID;
  85451. /**
  85452. * BABYLON.Observable raised when the value changes
  85453. */
  85454. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  85455. /** Gets or sets the color of the color picker */
  85456. get value(): BABYLON.Color3;
  85457. set value(value: BABYLON.Color3);
  85458. /**
  85459. * Gets or sets control width
  85460. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  85461. */
  85462. get width(): string | number;
  85463. set width(value: string | number);
  85464. /**
  85465. * Gets or sets control height
  85466. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  85467. */
  85468. get height(): string | number;
  85469. /** Gets or sets control height */
  85470. set height(value: string | number);
  85471. /** Gets or sets control size */
  85472. get size(): string | number;
  85473. set size(value: string | number);
  85474. /**
  85475. * Creates a new ColorPicker
  85476. * @param name defines the control name
  85477. */
  85478. constructor(name?: string | undefined);
  85479. protected _getTypeName(): string;
  85480. /** @hidden */
  85481. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85482. private _updateSquareProps;
  85483. private _drawGradientSquare;
  85484. private _drawCircle;
  85485. private _createColorWheelCanvas;
  85486. /** @hidden */
  85487. _draw(context: CanvasRenderingContext2D): void;
  85488. private _pointerIsDown;
  85489. private _updateValueFromPointer;
  85490. private _isPointOnSquare;
  85491. private _isPointOnWheel;
  85492. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85493. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  85494. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  85495. _onCanvasBlur(): void;
  85496. /**
  85497. * This function expands the color picker by creating a color picker dialog with manual
  85498. * color value input and the ability to save colors into an array to be used later in
  85499. * subsequent launches of the dialogue.
  85500. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  85501. * @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.
  85502. * @returns picked color as a hex string and the saved colors array as hex strings.
  85503. */
  85504. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  85505. pickerWidth?: string;
  85506. pickerHeight?: string;
  85507. headerHeight?: string;
  85508. lastColor?: string;
  85509. swatchLimit?: number;
  85510. numSwatchesPerLine?: number;
  85511. savedColors?: Array<string>;
  85512. }): Promise<{
  85513. savedColors?: string[];
  85514. pickedColor: string;
  85515. }>;
  85516. }
  85517. }
  85518. declare module BABYLON.GUI {
  85519. /** Class used to create 2D ellipse containers */
  85520. export class Ellipse extends Container {
  85521. name?: string | undefined;
  85522. private _thickness;
  85523. /** Gets or sets border thickness */
  85524. get thickness(): number;
  85525. set thickness(value: number);
  85526. /**
  85527. * Creates a new Ellipse
  85528. * @param name defines the control name
  85529. */
  85530. constructor(name?: string | undefined);
  85531. protected _getTypeName(): string;
  85532. protected _localDraw(context: CanvasRenderingContext2D): void;
  85533. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85534. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  85535. }
  85536. }
  85537. declare module BABYLON.GUI {
  85538. /**
  85539. * Class used to create a focusable button that can easily handle keyboard events
  85540. */
  85541. export class FocusableButton extends Button implements IFocusableControl {
  85542. name?: string | undefined;
  85543. /** Highlight color when button is focused */
  85544. focusedColor: BABYLON.Nullable<string>;
  85545. private _isFocused;
  85546. private _unfocusedColor;
  85547. /** BABYLON.Observable raised when the control gets the focus */
  85548. onFocusObservable: BABYLON.Observable<Button>;
  85549. /** BABYLON.Observable raised when the control loses the focus */
  85550. onBlurObservable: BABYLON.Observable<Button>;
  85551. /** BABYLON.Observable raised when a key event was processed */
  85552. onKeyboardEventProcessedObservable: BABYLON.Observable<BABYLON.IKeyboardEvent>;
  85553. constructor(name?: string | undefined);
  85554. /** @hidden */
  85555. onBlur(): void;
  85556. /** @hidden */
  85557. onFocus(): void;
  85558. /**
  85559. * Function called to get the list of controls that should not steal the focus from this control
  85560. * @returns an array of controls
  85561. */
  85562. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  85563. /**
  85564. * Function to focus a button programmatically
  85565. */
  85566. focus(): void;
  85567. /**
  85568. * Function to unfocus a button programmatically
  85569. */
  85570. blur(): void;
  85571. /**
  85572. * Handles the keyboard event
  85573. * @param evt Defines the KeyboardEvent
  85574. */
  85575. processKeyboard(evt: BABYLON.IKeyboardEvent): void;
  85576. /** @hidden */
  85577. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85578. /** @hidden */
  85579. displose(): void;
  85580. }
  85581. }
  85582. declare module BABYLON.GUI {
  85583. /**
  85584. * Class used to create a password control
  85585. */
  85586. export class InputPassword extends InputText {
  85587. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  85588. }
  85589. }
  85590. declare module BABYLON.GUI {
  85591. /** Class used to render 2D lines */
  85592. export class Line extends Control {
  85593. name?: string | undefined;
  85594. private _lineWidth;
  85595. private _x1;
  85596. private _y1;
  85597. private _x2;
  85598. private _y2;
  85599. private _dash;
  85600. private _connectedControl;
  85601. private _connectedControlDirtyObserver;
  85602. /** Gets or sets the dash pattern */
  85603. get dash(): Array<number>;
  85604. set dash(value: Array<number>);
  85605. /** Gets or sets the control connected with the line end */
  85606. get connectedControl(): Control;
  85607. set connectedControl(value: Control);
  85608. /** Gets or sets start coordinates on X axis */
  85609. get x1(): string | number;
  85610. set x1(value: string | number);
  85611. /** Gets or sets start coordinates on Y axis */
  85612. get y1(): string | number;
  85613. set y1(value: string | number);
  85614. /** Gets or sets end coordinates on X axis */
  85615. get x2(): string | number;
  85616. set x2(value: string | number);
  85617. /** Gets or sets end coordinates on Y axis */
  85618. get y2(): string | number;
  85619. set y2(value: string | number);
  85620. /** Gets or sets line width */
  85621. get lineWidth(): number;
  85622. set lineWidth(value: number);
  85623. /** Gets or sets horizontal alignment */
  85624. set horizontalAlignment(value: number);
  85625. /** Gets or sets vertical alignment */
  85626. set verticalAlignment(value: number);
  85627. private get _effectiveX2();
  85628. private get _effectiveY2();
  85629. /**
  85630. * Creates a new Line
  85631. * @param name defines the control name
  85632. */
  85633. constructor(name?: string | undefined);
  85634. protected _getTypeName(): string;
  85635. _draw(context: CanvasRenderingContext2D): void;
  85636. _measure(): void;
  85637. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85638. /**
  85639. * Move one end of the line given 3D cartesian coordinates.
  85640. * @param position Targeted world position
  85641. * @param scene BABYLON.Scene
  85642. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  85643. */
  85644. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  85645. /**
  85646. * Move one end of the line to a position in screen absolute space.
  85647. * @param projectedPosition Position in screen absolute space (X, Y)
  85648. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  85649. */
  85650. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  85651. }
  85652. }
  85653. declare module BABYLON.GUI {
  85654. /**
  85655. * Class used to store a point for a MultiLine object.
  85656. * The point can be pure 2D coordinates, a mesh or a control
  85657. */
  85658. export class MultiLinePoint {
  85659. private _multiLine;
  85660. private _x;
  85661. private _y;
  85662. private _control;
  85663. private _mesh;
  85664. private _controlObserver;
  85665. private _meshObserver;
  85666. /** @hidden */
  85667. _point: BABYLON.Vector3;
  85668. /**
  85669. * Creates a new MultiLinePoint
  85670. * @param multiLine defines the source MultiLine object
  85671. */
  85672. constructor(multiLine: MultiLine);
  85673. /** Gets or sets x coordinate */
  85674. get x(): string | number;
  85675. set x(value: string | number);
  85676. /** Gets or sets y coordinate */
  85677. get y(): string | number;
  85678. set y(value: string | number);
  85679. /** Gets or sets the control associated with this point */
  85680. get control(): BABYLON.Nullable<Control>;
  85681. set control(value: BABYLON.Nullable<Control>);
  85682. /** Gets or sets the mesh associated with this point */
  85683. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  85684. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  85685. /** Resets links */
  85686. resetLinks(): void;
  85687. /**
  85688. * Gets a translation vector with Z component
  85689. * @returns the translation vector
  85690. */
  85691. translate(): BABYLON.Vector3;
  85692. private _translatePoint;
  85693. /** Release associated resources */
  85694. dispose(): void;
  85695. }
  85696. }
  85697. declare module BABYLON.GUI {
  85698. /**
  85699. * Class used to create multi line control
  85700. */
  85701. export class MultiLine extends Control {
  85702. name?: string | undefined;
  85703. private _lineWidth;
  85704. private _dash;
  85705. private _points;
  85706. private _minX;
  85707. private _minY;
  85708. private _maxX;
  85709. private _maxY;
  85710. /**
  85711. * Creates a new MultiLine
  85712. * @param name defines the control name
  85713. */
  85714. constructor(name?: string | undefined);
  85715. /** Gets or sets dash pattern */
  85716. get dash(): Array<number>;
  85717. set dash(value: Array<number>);
  85718. /**
  85719. * Gets point stored at specified index
  85720. * @param index defines the index to look for
  85721. * @returns the requested point if found
  85722. */
  85723. getAt(index: number): MultiLinePoint;
  85724. /** Function called when a point is updated */
  85725. onPointUpdate: () => void;
  85726. /**
  85727. * Adds new points to the point collection
  85728. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  85729. * @returns the list of created MultiLinePoint
  85730. */
  85731. add(...items: (AbstractMesh | Control | {
  85732. x: string | number;
  85733. y: string | number;
  85734. })[]): MultiLinePoint[];
  85735. /**
  85736. * Adds a new point to the point collection
  85737. * @param item defines the item (mesh, control or 2d coordiantes) to add
  85738. * @returns the created MultiLinePoint
  85739. */
  85740. push(item?: (AbstractMesh | Control | {
  85741. x: string | number;
  85742. y: string | number;
  85743. })): MultiLinePoint;
  85744. /**
  85745. * Remove a specific value or point from the active point collection
  85746. * @param value defines the value or point to remove
  85747. */
  85748. remove(value: number | MultiLinePoint): void;
  85749. /**
  85750. * Resets this object to initial state (no point)
  85751. */
  85752. reset(): void;
  85753. /**
  85754. * Resets all links
  85755. */
  85756. resetLinks(): void;
  85757. /** Gets or sets line width */
  85758. get lineWidth(): number;
  85759. set lineWidth(value: number);
  85760. set horizontalAlignment(value: number);
  85761. set verticalAlignment(value: number);
  85762. protected _getTypeName(): string;
  85763. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85764. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85765. _measure(): void;
  85766. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85767. dispose(): void;
  85768. }
  85769. }
  85770. declare module BABYLON.GUI {
  85771. /**
  85772. * Class used to create radio button controls
  85773. */
  85774. export class RadioButton extends Control {
  85775. name?: string | undefined;
  85776. private _isChecked;
  85777. private _background;
  85778. private _checkSizeRatio;
  85779. private _thickness;
  85780. /** Gets or sets border thickness */
  85781. get thickness(): number;
  85782. set thickness(value: number);
  85783. /** Gets or sets group name */
  85784. group: string;
  85785. /** BABYLON.Observable raised when isChecked is changed */
  85786. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  85787. /** Gets or sets a value indicating the ratio between overall size and check size */
  85788. get checkSizeRatio(): number;
  85789. set checkSizeRatio(value: number);
  85790. /** Gets or sets background color */
  85791. get background(): string;
  85792. set background(value: string);
  85793. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  85794. get isChecked(): boolean;
  85795. set isChecked(value: boolean);
  85796. /**
  85797. * Creates a new RadioButton
  85798. * @param name defines the control name
  85799. */
  85800. constructor(name?: string | undefined);
  85801. protected _getTypeName(): string;
  85802. _draw(context: CanvasRenderingContext2D): void;
  85803. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85804. /**
  85805. * Utility function to easily create a radio button with a header
  85806. * @param title defines the label to use for the header
  85807. * @param group defines the group to use for the radio button
  85808. * @param isChecked defines the initial state of the radio button
  85809. * @param onValueChanged defines the callback to call when value changes
  85810. * @returns a StackPanel containing the radio button and a textBlock
  85811. */
  85812. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  85813. }
  85814. }
  85815. declare module BABYLON.GUI {
  85816. /**
  85817. * Class used to create slider controls
  85818. */
  85819. export class BaseSlider extends Control {
  85820. name?: string | undefined;
  85821. protected _thumbWidth: ValueAndUnit;
  85822. private _minimum;
  85823. private _maximum;
  85824. private _value;
  85825. private _isVertical;
  85826. protected _barOffset: ValueAndUnit;
  85827. private _isThumbClamped;
  85828. protected _displayThumb: boolean;
  85829. private _step;
  85830. private _lastPointerDownID;
  85831. protected _effectiveBarOffset: number;
  85832. protected _renderLeft: number;
  85833. protected _renderTop: number;
  85834. protected _renderWidth: number;
  85835. protected _renderHeight: number;
  85836. protected _backgroundBoxLength: number;
  85837. protected _backgroundBoxThickness: number;
  85838. protected _effectiveThumbThickness: number;
  85839. /** BABYLON.Observable raised when the sldier value changes */
  85840. onValueChangedObservable: BABYLON.Observable<number>;
  85841. /** Gets or sets a boolean indicating if the thumb must be rendered */
  85842. get displayThumb(): boolean;
  85843. set displayThumb(value: boolean);
  85844. /** Gets or sets a step to apply to values (0 by default) */
  85845. get step(): number;
  85846. set step(value: number);
  85847. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  85848. get barOffset(): string | number;
  85849. /** Gets main bar offset in pixels*/
  85850. get barOffsetInPixels(): number;
  85851. set barOffset(value: string | number);
  85852. /** Gets or sets thumb width */
  85853. get thumbWidth(): string | number;
  85854. /** Gets thumb width in pixels */
  85855. get thumbWidthInPixels(): number;
  85856. set thumbWidth(value: string | number);
  85857. /** Gets or sets minimum value */
  85858. get minimum(): number;
  85859. set minimum(value: number);
  85860. /** Gets or sets maximum value */
  85861. get maximum(): number;
  85862. set maximum(value: number);
  85863. /** Gets or sets current value */
  85864. get value(): number;
  85865. set value(value: number);
  85866. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  85867. get isVertical(): boolean;
  85868. set isVertical(value: boolean);
  85869. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  85870. get isThumbClamped(): boolean;
  85871. set isThumbClamped(value: boolean);
  85872. /**
  85873. * Creates a new BaseSlider
  85874. * @param name defines the control name
  85875. */
  85876. constructor(name?: string | undefined);
  85877. protected _getTypeName(): string;
  85878. protected _getThumbPosition(): number;
  85879. protected _getThumbThickness(type: string): number;
  85880. protected _prepareRenderingData(type: string): void;
  85881. private _pointerIsDown;
  85882. /** @hidden */
  85883. protected _updateValueFromPointer(x: number, y: number): void;
  85884. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85885. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  85886. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  85887. _onCanvasBlur(): void;
  85888. }
  85889. }
  85890. declare module BABYLON.GUI {
  85891. /**
  85892. * Class used to create slider controls
  85893. */
  85894. export class Slider extends BaseSlider {
  85895. name?: string | undefined;
  85896. private _background;
  85897. private _borderColor;
  85898. private _thumbColor;
  85899. private _isThumbCircle;
  85900. protected _displayValueBar: boolean;
  85901. /** Gets or sets a boolean indicating if the value bar must be rendered */
  85902. get displayValueBar(): boolean;
  85903. set displayValueBar(value: boolean);
  85904. /** Gets or sets border color */
  85905. get borderColor(): string;
  85906. set borderColor(value: string);
  85907. /** Gets or sets background color */
  85908. get background(): string;
  85909. set background(value: string);
  85910. /** Gets or sets thumb's color */
  85911. get thumbColor(): string;
  85912. set thumbColor(value: string);
  85913. /** Gets or sets a boolean indicating if the thumb should be round or square */
  85914. get isThumbCircle(): boolean;
  85915. set isThumbCircle(value: boolean);
  85916. /**
  85917. * Creates a new Slider
  85918. * @param name defines the control name
  85919. */
  85920. constructor(name?: string | undefined);
  85921. protected _getTypeName(): string;
  85922. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85923. }
  85924. }
  85925. declare module BABYLON.GUI {
  85926. /** Class used to create a RadioGroup
  85927. * which contains groups of radio buttons
  85928. */
  85929. export class SelectorGroup {
  85930. /** name of SelectorGroup */
  85931. name: string;
  85932. private _groupPanel;
  85933. private _selectors;
  85934. private _groupHeader;
  85935. /**
  85936. * Creates a new SelectorGroup
  85937. * @param name of group, used as a group heading
  85938. */
  85939. constructor(
  85940. /** name of SelectorGroup */
  85941. name: string);
  85942. /** Gets the groupPanel of the SelectorGroup */
  85943. get groupPanel(): StackPanel;
  85944. /** Gets the selectors array */
  85945. get selectors(): StackPanel[];
  85946. /** Gets and sets the group header */
  85947. get header(): string;
  85948. set header(label: string);
  85949. /** @hidden */
  85950. private _addGroupHeader;
  85951. /** @hidden*/
  85952. _getSelector(selectorNb: number): StackPanel | undefined;
  85953. /** Removes the selector at the given position
  85954. * @param selectorNb the position of the selector within the group
  85955. */
  85956. removeSelector(selectorNb: number): void;
  85957. }
  85958. /** Class used to create a CheckboxGroup
  85959. * which contains groups of checkbox buttons
  85960. */
  85961. export class CheckboxGroup extends SelectorGroup {
  85962. /** Adds a checkbox as a control
  85963. * @param text is the label for the selector
  85964. * @param func is the function called when the Selector is checked
  85965. * @param checked is true when Selector is checked
  85966. */
  85967. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  85968. /** @hidden */
  85969. _setSelectorLabel(selectorNb: number, label: string): void;
  85970. /** @hidden */
  85971. _setSelectorLabelColor(selectorNb: number, color: string): void;
  85972. /** @hidden */
  85973. _setSelectorButtonColor(selectorNb: number, color: string): void;
  85974. /** @hidden */
  85975. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  85976. }
  85977. /** Class used to create a RadioGroup
  85978. * which contains groups of radio buttons
  85979. */
  85980. export class RadioGroup extends SelectorGroup {
  85981. private _selectNb;
  85982. /** Adds a radio button as a control
  85983. * @param label is the label for the selector
  85984. * @param func is the function called when the Selector is checked
  85985. * @param checked is true when Selector is checked
  85986. */
  85987. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  85988. /** @hidden */
  85989. _setSelectorLabel(selectorNb: number, label: string): void;
  85990. /** @hidden */
  85991. _setSelectorLabelColor(selectorNb: number, color: string): void;
  85992. /** @hidden */
  85993. _setSelectorButtonColor(selectorNb: number, color: string): void;
  85994. /** @hidden */
  85995. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  85996. }
  85997. /** Class used to create a SliderGroup
  85998. * which contains groups of slider buttons
  85999. */
  86000. export class SliderGroup extends SelectorGroup {
  86001. /**
  86002. * Adds a slider to the SelectorGroup
  86003. * @param label is the label for the SliderBar
  86004. * @param func is the function called when the Slider moves
  86005. * @param unit is a string describing the units used, eg degrees or metres
  86006. * @param min is the minimum value for the Slider
  86007. * @param max is the maximum value for the Slider
  86008. * @param value is the start value for the Slider between min and max
  86009. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  86010. */
  86011. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  86012. /** @hidden */
  86013. _setSelectorLabel(selectorNb: number, label: string): void;
  86014. /** @hidden */
  86015. _setSelectorLabelColor(selectorNb: number, color: string): void;
  86016. /** @hidden */
  86017. _setSelectorButtonColor(selectorNb: number, color: string): void;
  86018. /** @hidden */
  86019. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  86020. }
  86021. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  86022. * @see https://doc.babylonjs.com/how_to/selector
  86023. */
  86024. export class SelectionPanel extends Rectangle {
  86025. /** name of SelectionPanel */
  86026. name: string;
  86027. /** an array of SelectionGroups */
  86028. groups: SelectorGroup[];
  86029. private _panel;
  86030. private _buttonColor;
  86031. private _buttonBackground;
  86032. private _headerColor;
  86033. private _barColor;
  86034. private _barHeight;
  86035. private _spacerHeight;
  86036. private _labelColor;
  86037. private _groups;
  86038. private _bars;
  86039. /**
  86040. * Creates a new SelectionPanel
  86041. * @param name of SelectionPanel
  86042. * @param groups is an array of SelectionGroups
  86043. */
  86044. constructor(
  86045. /** name of SelectionPanel */
  86046. name: string,
  86047. /** an array of SelectionGroups */
  86048. groups?: SelectorGroup[]);
  86049. protected _getTypeName(): string;
  86050. /** Gets the (stack) panel of the SelectionPanel */
  86051. get panel(): StackPanel;
  86052. /** Gets or sets the headerColor */
  86053. get headerColor(): string;
  86054. set headerColor(color: string);
  86055. private _setHeaderColor;
  86056. /** Gets or sets the button color */
  86057. get buttonColor(): string;
  86058. set buttonColor(color: string);
  86059. private _setbuttonColor;
  86060. /** Gets or sets the label color */
  86061. get labelColor(): string;
  86062. set labelColor(color: string);
  86063. private _setLabelColor;
  86064. /** Gets or sets the button background */
  86065. get buttonBackground(): string;
  86066. set buttonBackground(color: string);
  86067. private _setButtonBackground;
  86068. /** Gets or sets the color of separator bar */
  86069. get barColor(): string;
  86070. set barColor(color: string);
  86071. private _setBarColor;
  86072. /** Gets or sets the height of separator bar */
  86073. get barHeight(): string;
  86074. set barHeight(value: string);
  86075. private _setBarHeight;
  86076. /** Gets or sets the height of spacers*/
  86077. get spacerHeight(): string;
  86078. set spacerHeight(value: string);
  86079. private _setSpacerHeight;
  86080. /** Adds a bar between groups */
  86081. private _addSpacer;
  86082. /** Add a group to the selection panel
  86083. * @param group is the selector group to add
  86084. */
  86085. addGroup(group: SelectorGroup): void;
  86086. /** Remove the group from the given position
  86087. * @param groupNb is the position of the group in the list
  86088. */
  86089. removeGroup(groupNb: number): void;
  86090. /** Change a group header label
  86091. * @param label is the new group header label
  86092. * @param groupNb is the number of the group to relabel
  86093. * */
  86094. setHeaderName(label: string, groupNb: number): void;
  86095. /** Change selector label to the one given
  86096. * @param label is the new selector label
  86097. * @param groupNb is the number of the groupcontaining the selector
  86098. * @param selectorNb is the number of the selector within a group to relabel
  86099. * */
  86100. relabel(label: string, groupNb: number, selectorNb: number): void;
  86101. /** For a given group position remove the selector at the given position
  86102. * @param groupNb is the number of the group to remove the selector from
  86103. * @param selectorNb is the number of the selector within the group
  86104. */
  86105. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  86106. /** For a given group position of correct type add a checkbox button
  86107. * @param groupNb is the number of the group to remove the selector from
  86108. * @param label is the label for the selector
  86109. * @param func is the function called when the Selector is checked
  86110. * @param checked is true when Selector is checked
  86111. */
  86112. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  86113. /** For a given group position of correct type add a radio button
  86114. * @param groupNb is the number of the group to remove the selector from
  86115. * @param label is the label for the selector
  86116. * @param func is the function called when the Selector is checked
  86117. * @param checked is true when Selector is checked
  86118. */
  86119. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  86120. /**
  86121. * For a given slider group add a slider
  86122. * @param groupNb is the number of the group to add the slider to
  86123. * @param label is the label for the Slider
  86124. * @param func is the function called when the Slider moves
  86125. * @param unit is a string describing the units used, eg degrees or metres
  86126. * @param min is the minimum value for the Slider
  86127. * @param max is the maximum value for the Slider
  86128. * @param value is the start value for the Slider between min and max
  86129. * @param onVal is the function used to format the value displayed, eg radians to degrees
  86130. */
  86131. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  86132. }
  86133. }
  86134. declare module BABYLON.GUI {
  86135. /**
  86136. * Class used to hold a the container for ScrollViewer
  86137. * @hidden
  86138. */
  86139. export class _ScrollViewerWindow extends Container {
  86140. parentClientWidth: number;
  86141. parentClientHeight: number;
  86142. private _freezeControls;
  86143. private _parentMeasure;
  86144. private _oldLeft;
  86145. private _oldTop;
  86146. get freezeControls(): boolean;
  86147. set freezeControls(value: boolean);
  86148. private _bucketWidth;
  86149. private _bucketHeight;
  86150. private _buckets;
  86151. private _bucketLen;
  86152. get bucketWidth(): number;
  86153. get bucketHeight(): number;
  86154. setBucketSizes(width: number, height: number): void;
  86155. private _useBuckets;
  86156. private _makeBuckets;
  86157. private _dispatchInBuckets;
  86158. private _updateMeasures;
  86159. private _updateChildrenMeasures;
  86160. private _restoreMeasures;
  86161. /**
  86162. * Creates a new ScrollViewerWindow
  86163. * @param name of ScrollViewerWindow
  86164. */
  86165. constructor(name?: string);
  86166. protected _getTypeName(): string;
  86167. /** @hidden */
  86168. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  86169. /** @hidden */
  86170. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  86171. private _scrollChildren;
  86172. private _scrollChildrenWithBuckets;
  86173. /** @hidden */
  86174. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  86175. protected _postMeasure(): void;
  86176. }
  86177. }
  86178. declare module BABYLON.GUI {
  86179. /**
  86180. * Class used to create slider controls
  86181. */
  86182. export class ScrollBar extends BaseSlider {
  86183. name?: string | undefined;
  86184. private _background;
  86185. private _borderColor;
  86186. private _tempMeasure;
  86187. /** Gets or sets border color */
  86188. get borderColor(): string;
  86189. set borderColor(value: string);
  86190. /** Gets or sets background color */
  86191. get background(): string;
  86192. set background(value: string);
  86193. /**
  86194. * Creates a new Slider
  86195. * @param name defines the control name
  86196. */
  86197. constructor(name?: string | undefined);
  86198. protected _getTypeName(): string;
  86199. protected _getThumbThickness(): number;
  86200. _draw(context: CanvasRenderingContext2D): void;
  86201. private _first;
  86202. private _originX;
  86203. private _originY;
  86204. /** @hidden */
  86205. protected _updateValueFromPointer(x: number, y: number): void;
  86206. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  86207. }
  86208. }
  86209. declare module BABYLON.GUI {
  86210. /**
  86211. * Class used to create slider controls
  86212. */
  86213. export class ImageScrollBar extends BaseSlider {
  86214. name?: string | undefined;
  86215. private _backgroundBaseImage;
  86216. private _backgroundImage;
  86217. private _thumbImage;
  86218. private _thumbBaseImage;
  86219. private _thumbLength;
  86220. private _thumbHeight;
  86221. private _barImageHeight;
  86222. private _tempMeasure;
  86223. /** Number of 90° rotation to apply on the images when in vertical mode */
  86224. num90RotationInVerticalMode: number;
  86225. /**
  86226. * Gets or sets the image used to render the background for horizontal bar
  86227. */
  86228. get backgroundImage(): Image;
  86229. set backgroundImage(value: Image);
  86230. /**
  86231. * Gets or sets the image used to render the thumb
  86232. */
  86233. get thumbImage(): Image;
  86234. set thumbImage(value: Image);
  86235. /**
  86236. * Gets or sets the length of the thumb
  86237. */
  86238. get thumbLength(): number;
  86239. set thumbLength(value: number);
  86240. /**
  86241. * Gets or sets the height of the thumb
  86242. */
  86243. get thumbHeight(): number;
  86244. set thumbHeight(value: number);
  86245. /**
  86246. * Gets or sets the height of the bar image
  86247. */
  86248. get barImageHeight(): number;
  86249. set barImageHeight(value: number);
  86250. /**
  86251. * Creates a new ImageScrollBar
  86252. * @param name defines the control name
  86253. */
  86254. constructor(name?: string | undefined);
  86255. protected _getTypeName(): string;
  86256. protected _getThumbThickness(): number;
  86257. _draw(context: CanvasRenderingContext2D): void;
  86258. private _first;
  86259. private _originX;
  86260. private _originY;
  86261. /** @hidden */
  86262. protected _updateValueFromPointer(x: number, y: number): void;
  86263. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  86264. }
  86265. }
  86266. declare module BABYLON.GUI {
  86267. /**
  86268. * Class used to hold a viewer window and sliders in a grid
  86269. */
  86270. export class ScrollViewer extends Rectangle {
  86271. private _grid;
  86272. private _horizontalBarSpace;
  86273. private _verticalBarSpace;
  86274. private _dragSpace;
  86275. private _horizontalBar;
  86276. private _verticalBar;
  86277. private _barColor;
  86278. private _barBackground;
  86279. private _barImage;
  86280. private _horizontalBarImage;
  86281. private _verticalBarImage;
  86282. private _barBackgroundImage;
  86283. private _horizontalBarBackgroundImage;
  86284. private _verticalBarBackgroundImage;
  86285. private _barSize;
  86286. private _window;
  86287. private _pointerIsOver;
  86288. private _wheelPrecision;
  86289. private _onWheelObserver;
  86290. private _clientWidth;
  86291. private _clientHeight;
  86292. private _useImageBar;
  86293. private _thumbLength;
  86294. private _thumbHeight;
  86295. private _barImageHeight;
  86296. private _horizontalBarImageHeight;
  86297. private _verticalBarImageHeight;
  86298. private _oldWindowContentsWidth;
  86299. private _oldWindowContentsHeight;
  86300. /**
  86301. * Gets the horizontal scrollbar
  86302. */
  86303. get horizontalBar(): ScrollBar | ImageScrollBar;
  86304. /**
  86305. * Gets the vertical scrollbar
  86306. */
  86307. get verticalBar(): ScrollBar | ImageScrollBar;
  86308. /**
  86309. * Adds a new control to the current container
  86310. * @param control defines the control to add
  86311. * @returns the current container
  86312. */
  86313. addControl(control: BABYLON.Nullable<Control>): Container;
  86314. /**
  86315. * Removes a control from the current container
  86316. * @param control defines the control to remove
  86317. * @returns the current container
  86318. */
  86319. removeControl(control: Control): Container;
  86320. /** Gets the list of children */
  86321. get children(): Control[];
  86322. _flagDescendantsAsMatrixDirty(): void;
  86323. /**
  86324. * Freezes or unfreezes the controls in the window.
  86325. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  86326. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  86327. */
  86328. get freezeControls(): boolean;
  86329. set freezeControls(value: boolean);
  86330. /** Gets the bucket width */
  86331. get bucketWidth(): number;
  86332. /** Gets the bucket height */
  86333. get bucketHeight(): number;
  86334. /**
  86335. * Sets the bucket sizes.
  86336. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  86337. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  86338. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  86339. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  86340. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  86341. * used), that's why it is not enabled by default.
  86342. * @param width width of the bucket
  86343. * @param height height of the bucket
  86344. */
  86345. setBucketSizes(width: number, height: number): void;
  86346. private _forceHorizontalBar;
  86347. private _forceVerticalBar;
  86348. /**
  86349. * Forces the horizontal scroll bar to be displayed
  86350. */
  86351. get forceHorizontalBar(): boolean;
  86352. set forceHorizontalBar(value: boolean);
  86353. /**
  86354. * Forces the vertical scroll bar to be displayed
  86355. */
  86356. get forceVerticalBar(): boolean;
  86357. set forceVerticalBar(value: boolean);
  86358. /**
  86359. * Creates a new ScrollViewer
  86360. * @param name of ScrollViewer
  86361. */
  86362. constructor(name?: string, isImageBased?: boolean);
  86363. /** Reset the scroll viewer window to initial size */
  86364. resetWindow(): void;
  86365. protected _getTypeName(): string;
  86366. private _buildClientSizes;
  86367. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  86368. protected _postMeasure(): void;
  86369. /**
  86370. * Gets or sets the mouse wheel precision
  86371. * from 0 to 1 with a default value of 0.05
  86372. * */
  86373. get wheelPrecision(): number;
  86374. set wheelPrecision(value: number);
  86375. /** Gets or sets the scroll bar container background color */
  86376. get scrollBackground(): string;
  86377. set scrollBackground(color: string);
  86378. /** Gets or sets the bar color */
  86379. get barColor(): string;
  86380. set barColor(color: string);
  86381. /** Gets or sets the bar image */
  86382. get thumbImage(): Image;
  86383. set thumbImage(value: Image);
  86384. /** Gets or sets the horizontal bar image */
  86385. get horizontalThumbImage(): Image;
  86386. set horizontalThumbImage(value: Image);
  86387. /** Gets or sets the vertical bar image */
  86388. get verticalThumbImage(): Image;
  86389. set verticalThumbImage(value: Image);
  86390. /** Gets or sets the size of the bar */
  86391. get barSize(): number;
  86392. set barSize(value: number);
  86393. /** Gets or sets the length of the thumb */
  86394. get thumbLength(): number;
  86395. set thumbLength(value: number);
  86396. /** Gets or sets the height of the thumb */
  86397. get thumbHeight(): number;
  86398. set thumbHeight(value: number);
  86399. /** Gets or sets the height of the bar image */
  86400. get barImageHeight(): number;
  86401. set barImageHeight(value: number);
  86402. /** Gets or sets the height of the horizontal bar image */
  86403. get horizontalBarImageHeight(): number;
  86404. set horizontalBarImageHeight(value: number);
  86405. /** Gets or sets the height of the vertical bar image */
  86406. get verticalBarImageHeight(): number;
  86407. set verticalBarImageHeight(value: number);
  86408. /** Gets or sets the bar background */
  86409. get barBackground(): string;
  86410. set barBackground(color: string);
  86411. /** Gets or sets the bar background image */
  86412. get barImage(): Image;
  86413. set barImage(value: Image);
  86414. /** Gets or sets the horizontal bar background image */
  86415. get horizontalBarImage(): Image;
  86416. set horizontalBarImage(value: Image);
  86417. /** Gets or sets the vertical bar background image */
  86418. get verticalBarImage(): Image;
  86419. set verticalBarImage(value: Image);
  86420. private _setWindowPosition;
  86421. /** @hidden */
  86422. private _updateScroller;
  86423. _link(host: AdvancedDynamicTexture): void;
  86424. /** @hidden */
  86425. private _addBar;
  86426. /** @hidden */
  86427. private _attachWheel;
  86428. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  86429. /** Releases associated resources */
  86430. dispose(): void;
  86431. }
  86432. }
  86433. declare module BABYLON.GUI {
  86434. /**
  86435. * Class used to create toggle buttons
  86436. */
  86437. export class ToggleButton extends Rectangle {
  86438. name?: string | undefined;
  86439. /**
  86440. * Function called to generate the toActive animation
  86441. */
  86442. toActiveAnimation: () => void;
  86443. /**
  86444. * Function called to generate the toInactive animation
  86445. */
  86446. toInactiveAnimation: () => void;
  86447. /**
  86448. * Function called to generate a pointer enter animation when the toggle button is active.
  86449. */
  86450. pointerEnterActiveAnimation: () => void;
  86451. /**
  86452. * Function called to generate a pointer out animation when the toggle button is active.
  86453. */
  86454. pointerOutActiveAnimation: () => void;
  86455. /**
  86456. * Function called to generate a pointer down animation when the toggle button is active.
  86457. */
  86458. pointerDownActiveAnimation: () => void;
  86459. /**
  86460. * Function called to generate a pointer up animation when the toggle button is active.
  86461. */
  86462. pointerUpActiveAnimation: () => void;
  86463. /**
  86464. * Function called to generate a pointer enter animation when the toggle button is inactive.
  86465. */
  86466. pointerEnterInactiveAnimation: () => void;
  86467. /**
  86468. * Function called to generate a pointer out animation when the toggle button is inactive.
  86469. */
  86470. pointerOutInactiveAnimation: () => void;
  86471. /**
  86472. * Function called to generate a pointer down animation when the toggle button is inactive.
  86473. */
  86474. pointerDownInactiveAnimation: () => void;
  86475. /**
  86476. * Function called to generate a pointer up animation when the toggle button is inactive.
  86477. */
  86478. pointerUpInactiveAnimation: () => void;
  86479. /** BABYLON.Observable raised when isActive is changed */
  86480. onIsActiveChangedObservable: BABYLON.Observable<boolean>;
  86481. /**
  86482. * 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
  86483. */
  86484. delegatePickingToChildren: boolean;
  86485. private _image;
  86486. /**
  86487. * Returns the ToggleButton's image control if it exists
  86488. */
  86489. get image(): BABYLON.Nullable<Image>;
  86490. private _textBlock;
  86491. /**
  86492. * Returns the ToggleButton's child TextBlock control if it exists
  86493. */
  86494. get textBlock(): BABYLON.Nullable<TextBlock>;
  86495. private _group;
  86496. /** Gets or sets group name this toggle button belongs to */
  86497. get group(): string;
  86498. set group(value: string);
  86499. private _isActive;
  86500. /** Gets or sets a boolean indicating if the toogle button is active or not */
  86501. get isActive(): boolean;
  86502. set isActive(value: boolean);
  86503. /**
  86504. * Creates a new ToggleButton
  86505. * @param name defines the control name
  86506. * @param group defines the toggle group this toggle belongs to
  86507. */
  86508. constructor(name?: string | undefined, group?: string);
  86509. protected _getTypeName(): string;
  86510. /** @hidden */
  86511. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  86512. /** @hidden */
  86513. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  86514. /** @hidden */
  86515. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  86516. /** @hidden */
  86517. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  86518. /** @hidden */
  86519. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  86520. }
  86521. }
  86522. declare module BABYLON.GUI {
  86523. /** Class used to render a grid */
  86524. export class DisplayGrid extends Control {
  86525. name?: string | undefined;
  86526. private _cellWidth;
  86527. private _cellHeight;
  86528. private _minorLineTickness;
  86529. private _minorLineColor;
  86530. private _majorLineTickness;
  86531. private _majorLineColor;
  86532. private _majorLineFrequency;
  86533. private _background;
  86534. private _displayMajorLines;
  86535. private _displayMinorLines;
  86536. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  86537. get displayMinorLines(): boolean;
  86538. set displayMinorLines(value: boolean);
  86539. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  86540. get displayMajorLines(): boolean;
  86541. set displayMajorLines(value: boolean);
  86542. /** Gets or sets background color (Black by default) */
  86543. get background(): string;
  86544. set background(value: string);
  86545. /** Gets or sets the width of each cell (20 by default) */
  86546. get cellWidth(): number;
  86547. set cellWidth(value: number);
  86548. /** Gets or sets the height of each cell (20 by default) */
  86549. get cellHeight(): number;
  86550. set cellHeight(value: number);
  86551. /** Gets or sets the tickness of minor lines (1 by default) */
  86552. get minorLineTickness(): number;
  86553. set minorLineTickness(value: number);
  86554. /** Gets or sets the color of minor lines (DarkGray by default) */
  86555. get minorLineColor(): string;
  86556. set minorLineColor(value: string);
  86557. /** Gets or sets the tickness of major lines (2 by default) */
  86558. get majorLineTickness(): number;
  86559. set majorLineTickness(value: number);
  86560. /** Gets or sets the color of major lines (White by default) */
  86561. get majorLineColor(): string;
  86562. set majorLineColor(value: string);
  86563. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  86564. get majorLineFrequency(): number;
  86565. set majorLineFrequency(value: number);
  86566. /**
  86567. * Creates a new GridDisplayRectangle
  86568. * @param name defines the control name
  86569. */
  86570. constructor(name?: string | undefined);
  86571. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  86572. protected _getTypeName(): string;
  86573. }
  86574. }
  86575. declare module BABYLON.GUI {
  86576. /**
  86577. * Class used to create slider controls based on images
  86578. */
  86579. export class ImageBasedSlider extends BaseSlider {
  86580. name?: string | undefined;
  86581. private _backgroundImage;
  86582. private _thumbImage;
  86583. private _valueBarImage;
  86584. private _tempMeasure;
  86585. get displayThumb(): boolean;
  86586. set displayThumb(value: boolean);
  86587. /**
  86588. * Gets or sets the image used to render the background
  86589. */
  86590. get backgroundImage(): Image;
  86591. set backgroundImage(value: Image);
  86592. /**
  86593. * Gets or sets the image used to render the value bar
  86594. */
  86595. get valueBarImage(): Image;
  86596. set valueBarImage(value: Image);
  86597. /**
  86598. * Gets or sets the image used to render the thumb
  86599. */
  86600. get thumbImage(): Image;
  86601. set thumbImage(value: Image);
  86602. /**
  86603. * Creates a new ImageBasedSlider
  86604. * @param name defines the control name
  86605. */
  86606. constructor(name?: string | undefined);
  86607. protected _getTypeName(): string;
  86608. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  86609. }
  86610. }
  86611. declare module BABYLON.GUI {
  86612. /**
  86613. * Forcing an export so that this code will execute
  86614. * @hidden
  86615. */
  86616. const name = "Statics";
  86617. }
  86618. declare module BABYLON.GUI {
  86619. /**
  86620. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  86621. */
  86622. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  86623. /**
  86624. * Define the instrumented AdvancedDynamicTexture.
  86625. */
  86626. texture: AdvancedDynamicTexture;
  86627. private _captureRenderTime;
  86628. private _renderTime;
  86629. private _captureLayoutTime;
  86630. private _layoutTime;
  86631. private _onBeginRenderObserver;
  86632. private _onEndRenderObserver;
  86633. private _onBeginLayoutObserver;
  86634. private _onEndLayoutObserver;
  86635. /**
  86636. * Gets the perf counter used to capture render time
  86637. */
  86638. get renderTimeCounter(): BABYLON.PerfCounter;
  86639. /**
  86640. * Gets the perf counter used to capture layout time
  86641. */
  86642. get layoutTimeCounter(): BABYLON.PerfCounter;
  86643. /**
  86644. * Enable or disable the render time capture
  86645. */
  86646. get captureRenderTime(): boolean;
  86647. set captureRenderTime(value: boolean);
  86648. /**
  86649. * Enable or disable the layout time capture
  86650. */
  86651. get captureLayoutTime(): boolean;
  86652. set captureLayoutTime(value: boolean);
  86653. /**
  86654. * Instantiates a new advanced dynamic texture instrumentation.
  86655. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  86656. * @param texture Defines the AdvancedDynamicTexture to instrument
  86657. */
  86658. constructor(
  86659. /**
  86660. * Define the instrumented AdvancedDynamicTexture.
  86661. */
  86662. texture: AdvancedDynamicTexture);
  86663. /**
  86664. * Dispose and release associated resources.
  86665. */
  86666. dispose(): void;
  86667. }
  86668. }
  86669. declare module BABYLON.GUI {
  86670. /**
  86671. * Class used to load GUI via XML.
  86672. */
  86673. export class XmlLoader {
  86674. private _nodes;
  86675. private _nodeTypes;
  86676. private _isLoaded;
  86677. private _objectAttributes;
  86678. private _parentClass;
  86679. /**
  86680. * Create a new xml loader
  86681. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  86682. */
  86683. constructor(parentClass?: null);
  86684. private _getChainElement;
  86685. private _getClassAttribute;
  86686. private _createGuiElement;
  86687. private _parseGrid;
  86688. private _parseElement;
  86689. private _prepareSourceElement;
  86690. private _parseElementsFromSource;
  86691. private _parseXml;
  86692. /**
  86693. * Gets if the loading has finished.
  86694. * @returns whether the loading has finished or not
  86695. */
  86696. isLoaded(): boolean;
  86697. /**
  86698. * Gets a loaded node / control by id.
  86699. * @param id the Controls id set in the xml
  86700. * @returns element of type Control
  86701. */
  86702. getNodeById(id: string): any;
  86703. /**
  86704. * Gets all loaded nodes / controls
  86705. * @returns Array of controls
  86706. */
  86707. getNodes(): any;
  86708. /**
  86709. * Initiates the xml layout loading
  86710. * @param xmlFile defines the xml layout to load
  86711. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  86712. * @param callback defines the callback called on layout load.
  86713. */
  86714. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  86715. }
  86716. }
  86717. declare module BABYLON.GUI {
  86718. /**
  86719. * Class used to create containers for controls
  86720. */
  86721. export class Container3D extends Control3D {
  86722. private _blockLayout;
  86723. /**
  86724. * Gets the list of child controls
  86725. */
  86726. protected _children: Control3D[];
  86727. /**
  86728. * Gets the list of child controls
  86729. */
  86730. get children(): Array<Control3D>;
  86731. /**
  86732. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  86733. * This is helpful to optimize layout operation when adding multiple children in a row
  86734. */
  86735. get blockLayout(): boolean;
  86736. set blockLayout(value: boolean);
  86737. /**
  86738. * Creates a new container
  86739. * @param name defines the container name
  86740. */
  86741. constructor(name?: string);
  86742. /**
  86743. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  86744. * @returns the current container
  86745. */
  86746. updateLayout(): Container3D;
  86747. /**
  86748. * Gets a boolean indicating if the given control is in the children of this control
  86749. * @param control defines the control to check
  86750. * @returns true if the control is in the child list
  86751. */
  86752. containsControl(control: Control3D): boolean;
  86753. /**
  86754. * Adds a control to the children of this control
  86755. * @param control defines the control to add
  86756. * @returns the current container
  86757. */
  86758. addControl(control: Control3D): Container3D;
  86759. /**
  86760. * This function will be called everytime a new control is added
  86761. */
  86762. protected _arrangeChildren(): void;
  86763. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  86764. /**
  86765. * Removes a control from the children of this control
  86766. * @param control defines the control to remove
  86767. * @returns the current container
  86768. */
  86769. removeControl(control: Control3D): Container3D;
  86770. protected _getTypeName(): string;
  86771. /**
  86772. * Releases all associated resources
  86773. */
  86774. dispose(): void;
  86775. /** Control rotation will remain unchanged */
  86776. static readonly UNSET_ORIENTATION: number;
  86777. /** Control will rotate to make it look at sphere central axis */
  86778. static readonly FACEORIGIN_ORIENTATION: number;
  86779. /** Control will rotate to make it look back at sphere central axis */
  86780. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  86781. /** Control will rotate to look at z axis (0, 0, 1) */
  86782. static readonly FACEFORWARD_ORIENTATION: number;
  86783. /** Control will rotate to look at negative z axis (0, 0, -1) */
  86784. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  86785. }
  86786. }
  86787. declare module BABYLON.GUI {
  86788. /**
  86789. * Class used to create a button in 3D
  86790. */
  86791. export class Button3D extends AbstractButton3D {
  86792. /** @hidden */
  86793. protected _currentMaterial: BABYLON.Material;
  86794. private _facadeTexture;
  86795. private _content;
  86796. private _contentResolution;
  86797. private _contentScaleRatio;
  86798. /**
  86799. * Gets or sets the texture resolution used to render content (512 by default)
  86800. */
  86801. get contentResolution(): BABYLON.int;
  86802. set contentResolution(value: BABYLON.int);
  86803. /**
  86804. * Gets or sets the texture scale ratio used to render content (2 by default)
  86805. */
  86806. get contentScaleRatio(): number;
  86807. set contentScaleRatio(value: number);
  86808. protected _disposeFacadeTexture(): void;
  86809. protected _resetContent(): void;
  86810. /**
  86811. * Creates a new button
  86812. * @param name defines the control name
  86813. */
  86814. constructor(name?: string);
  86815. /**
  86816. * Gets or sets the GUI 2D content used to display the button's facade
  86817. */
  86818. get content(): Control;
  86819. set content(value: Control);
  86820. /**
  86821. * Apply the facade texture (created from the content property).
  86822. * This function can be overloaded by child classes
  86823. * @param facadeTexture defines the AdvancedDynamicTexture to use
  86824. */
  86825. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  86826. protected _getTypeName(): string;
  86827. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86828. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  86829. /**
  86830. * Releases all associated resources
  86831. */
  86832. dispose(): void;
  86833. }
  86834. }
  86835. declare module BABYLON.GUI {
  86836. /**
  86837. * Class used to create a touchable button in 3D
  86838. */
  86839. export class TouchButton3D extends Button3D {
  86840. private _collisionMesh;
  86841. private _collidableFrontDirection;
  86842. private _lastTouchPoint;
  86843. private _tempButtonForwardRay;
  86844. private _lastKnownCollidableScale;
  86845. private _collidableInitialized;
  86846. private _frontOffset;
  86847. private _backOffset;
  86848. private _hoverOffset;
  86849. private _pushThroughBackOffset;
  86850. private _activeInteractions;
  86851. private _previousHeight;
  86852. /**
  86853. * Creates a new touchable button
  86854. * @param name defines the control name
  86855. * @param collisionMesh mesh to track collisions with
  86856. */
  86857. constructor(name?: string, collisionMesh?: BABYLON.Mesh);
  86858. /**
  86859. * Sets the front-facing direction of the button
  86860. * @param frontDir the forward direction of the button
  86861. */
  86862. set collidableFrontDirection(frontWorldDir: BABYLON.Vector3);
  86863. private _getWorldMatrixData;
  86864. /**
  86865. * Sets the mesh used for testing input collision
  86866. * @param collisionMesh the new collision mesh for the button
  86867. */
  86868. set collisionMesh(collisionMesh: BABYLON.Mesh);
  86869. private _getShortestDistancePointToLine;
  86870. private _isPrimedForInteraction;
  86871. private _getPointOnButton;
  86872. private _updateDistanceOffsets;
  86873. private _getHeightFromButtonCenter;
  86874. private _getDistanceOffPlane;
  86875. private _updateButtonState;
  86876. /** @hidden */
  86877. _collisionCheckForStateChange(mesh: BABYLON.AbstractMesh): void;
  86878. protected _getTypeName(): string;
  86879. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86880. /**
  86881. * Releases all associated resources
  86882. */
  86883. dispose(): void;
  86884. }
  86885. }
  86886. declare module BABYLON.GUI {
  86887. /**
  86888. * Class used to manage 3D user interface
  86889. * @see https://doc.babylonjs.com/how_to/gui3d
  86890. */
  86891. export class GUI3DManager implements BABYLON.IDisposable {
  86892. private _scene;
  86893. private _sceneDisposeObserver;
  86894. private _utilityLayer;
  86895. private _rootContainer;
  86896. private _pointerObserver;
  86897. private _pointerOutObserver;
  86898. private _touchableButtons;
  86899. /** @hidden */
  86900. _lastPickedControl: Control3D;
  86901. /** @hidden */
  86902. _lastControlOver: {
  86903. [pointerId: number]: Control3D;
  86904. };
  86905. /** @hidden */
  86906. _lastControlDown: {
  86907. [pointerId: number]: Control3D;
  86908. };
  86909. /**
  86910. * BABYLON.Observable raised when the point picked by the pointer events changed
  86911. */
  86912. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  86913. /** @hidden */
  86914. _sharedMaterials: {
  86915. [key: string]: BABYLON.Material;
  86916. };
  86917. /** @hidden */
  86918. _touchSharedMaterials: {
  86919. [key: string]: BABYLON.Material;
  86920. };
  86921. /** Gets the hosting scene */
  86922. get scene(): BABYLON.Scene;
  86923. /** Gets associated utility layer */
  86924. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  86925. /**
  86926. * Creates a new GUI3DManager
  86927. * @param scene
  86928. */
  86929. constructor(scene?: BABYLON.Scene);
  86930. private _handlePointerOut;
  86931. private _doPicking;
  86932. private _processTouchControls;
  86933. /**
  86934. * Gets the root container
  86935. */
  86936. get rootContainer(): Container3D;
  86937. /**
  86938. * Gets a boolean indicating if the given control is in the root child list
  86939. * @param control defines the control to check
  86940. * @returns true if the control is in the root child list
  86941. */
  86942. containsControl(control: Control3D): boolean;
  86943. /**
  86944. * Adds a control to the root child list
  86945. * @param control defines the control to add
  86946. * @returns the current manager
  86947. */
  86948. addControl(control: Control3D): GUI3DManager;
  86949. /**
  86950. * Removes a control from the root child list
  86951. * @param control defines the control to remove
  86952. * @returns the current container
  86953. */
  86954. removeControl(control: Control3D): GUI3DManager;
  86955. /**
  86956. * Releases all associated resources
  86957. */
  86958. dispose(): void;
  86959. }
  86960. }
  86961. declare module BABYLON.GUI {
  86962. /**
  86963. * Class used to transport BABYLON.Vector3 information for pointer events
  86964. */
  86965. export class Vector3WithInfo extends BABYLON.Vector3 {
  86966. /** defines the current mouse button index */
  86967. buttonIndex: number;
  86968. /**
  86969. * Creates a new Vector3WithInfo
  86970. * @param source defines the vector3 data to transport
  86971. * @param buttonIndex defines the current mouse button index
  86972. */
  86973. constructor(source: BABYLON.Vector3,
  86974. /** defines the current mouse button index */
  86975. buttonIndex?: number);
  86976. }
  86977. }
  86978. declare module BABYLON.GUI {
  86979. /**
  86980. * Class used as base class for controls
  86981. */
  86982. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  86983. /** Defines the control name */
  86984. name?: string | undefined;
  86985. /** @hidden */
  86986. _host: GUI3DManager;
  86987. private _node;
  86988. private _downCount;
  86989. private _enterCount;
  86990. private _downPointerIds;
  86991. private _isVisible;
  86992. /** Gets or sets the control position in world space */
  86993. get position(): BABYLON.Vector3;
  86994. set position(value: BABYLON.Vector3);
  86995. /** Gets or sets the control scaling in world space */
  86996. get scaling(): BABYLON.Vector3;
  86997. set scaling(value: BABYLON.Vector3);
  86998. /** Callback used to start pointer enter animation */
  86999. pointerEnterAnimation: () => void;
  87000. /** Callback used to start pointer out animation */
  87001. pointerOutAnimation: () => void;
  87002. /** Callback used to start pointer down animation */
  87003. pointerDownAnimation: () => void;
  87004. /** Callback used to start pointer up animation */
  87005. pointerUpAnimation: () => void;
  87006. /**
  87007. * An event triggered when the pointer move over the control
  87008. */
  87009. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  87010. /**
  87011. * An event triggered when the pointer move out of the control
  87012. */
  87013. onPointerOutObservable: BABYLON.Observable<Control3D>;
  87014. /**
  87015. * An event triggered when the pointer taps the control
  87016. */
  87017. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  87018. /**
  87019. * An event triggered when pointer is up
  87020. */
  87021. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  87022. /**
  87023. * An event triggered when a control is clicked on (with a mouse)
  87024. */
  87025. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  87026. /**
  87027. * An event triggered when pointer enters the control
  87028. */
  87029. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  87030. /**
  87031. * Gets or sets the parent container
  87032. */
  87033. parent: BABYLON.Nullable<Container3D>;
  87034. private _behaviors;
  87035. /**
  87036. * Gets the list of attached behaviors
  87037. * @see https://doc.babylonjs.com/features/behaviour
  87038. */
  87039. get behaviors(): BABYLON.Behavior<Control3D>[];
  87040. /**
  87041. * Attach a behavior to the control
  87042. * @see https://doc.babylonjs.com/features/behaviour
  87043. * @param behavior defines the behavior to attach
  87044. * @returns the current control
  87045. */
  87046. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  87047. /**
  87048. * Remove an attached behavior
  87049. * @see https://doc.babylonjs.com/features/behaviour
  87050. * @param behavior defines the behavior to attach
  87051. * @returns the current control
  87052. */
  87053. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  87054. /**
  87055. * Gets an attached behavior by name
  87056. * @param name defines the name of the behavior to look for
  87057. * @see https://doc.babylonjs.com/features/behaviour
  87058. * @returns null if behavior was not found else the requested behavior
  87059. */
  87060. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  87061. /** Gets or sets a boolean indicating if the control is visible */
  87062. get isVisible(): boolean;
  87063. set isVisible(value: boolean);
  87064. /**
  87065. * Creates a new control
  87066. * @param name defines the control name
  87067. */
  87068. constructor(
  87069. /** Defines the control name */
  87070. name?: string | undefined);
  87071. /**
  87072. * Gets a string representing the class name
  87073. */
  87074. get typeName(): string;
  87075. /**
  87076. * Get the current class name of the control.
  87077. * @returns current class name
  87078. */
  87079. getClassName(): string;
  87080. protected _getTypeName(): string;
  87081. /**
  87082. * Gets the transform node used by this control
  87083. */
  87084. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  87085. /**
  87086. * Gets the mesh used to render this control
  87087. */
  87088. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  87089. /**
  87090. * Link the control as child of the given node
  87091. * @param node defines the node to link to. Use null to unlink the control
  87092. * @returns the current control
  87093. */
  87094. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  87095. /** @hidden **/
  87096. _prepareNode(scene: BABYLON.Scene): void;
  87097. protected _injectGUI3DMetadata(node: BABYLON.TransformNode): any;
  87098. /**
  87099. * Node creation.
  87100. * Can be overriden by children
  87101. * @param scene defines the scene where the node must be attached
  87102. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  87103. */
  87104. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  87105. /**
  87106. * Affect a material to the given mesh
  87107. * @param mesh defines the mesh which will represent the control
  87108. */
  87109. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  87110. /** @hidden */
  87111. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  87112. /** @hidden */
  87113. _onPointerEnter(target: Control3D): boolean;
  87114. /** @hidden */
  87115. _onPointerOut(target: Control3D): void;
  87116. /** @hidden */
  87117. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  87118. /** @hidden */
  87119. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  87120. /** @hidden */
  87121. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  87122. /** @hidden */
  87123. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  87124. /** @hidden */
  87125. _disposeNode(): void;
  87126. /**
  87127. * Releases all associated resources
  87128. */
  87129. dispose(): void;
  87130. }
  87131. }
  87132. declare module BABYLON.GUI {
  87133. /**
  87134. * Class used as a root to all buttons
  87135. */
  87136. export class AbstractButton3D extends Control3D {
  87137. /**
  87138. * Creates a new button
  87139. * @param name defines the control name
  87140. */
  87141. constructor(name?: string);
  87142. protected _getTypeName(): string;
  87143. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  87144. }
  87145. }
  87146. declare module BABYLON.GUI {
  87147. /**
  87148. * Abstract class used to create a container panel deployed on the surface of a volume
  87149. */
  87150. export abstract class VolumeBasedPanel extends Container3D {
  87151. private _columns;
  87152. private _rows;
  87153. private _rowThenColum;
  87154. private _orientation;
  87155. protected _cellWidth: number;
  87156. protected _cellHeight: number;
  87157. /**
  87158. * Gets or sets the distance between elements
  87159. */
  87160. margin: number;
  87161. /**
  87162. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  87163. * | Value | Type | Description |
  87164. * | ----- | ----------------------------------- | ----------- |
  87165. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  87166. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  87167. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  87168. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  87169. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  87170. */
  87171. get orientation(): number;
  87172. set orientation(value: number);
  87173. /**
  87174. * Gets or sets the number of columns requested (10 by default).
  87175. * The panel will automatically compute the number of rows based on number of child controls.
  87176. */
  87177. get columns(): BABYLON.int;
  87178. set columns(value: BABYLON.int);
  87179. /**
  87180. * Gets or sets a the number of rows requested.
  87181. * The panel will automatically compute the number of columns based on number of child controls.
  87182. */
  87183. get rows(): BABYLON.int;
  87184. set rows(value: BABYLON.int);
  87185. /**
  87186. * Creates new VolumeBasedPanel
  87187. */
  87188. constructor();
  87189. protected _arrangeChildren(): void;
  87190. /** Child classes must implement this function to provide correct control positioning */
  87191. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  87192. /** Child classes can implement this function to provide additional processing */
  87193. protected _finalProcessing(): void;
  87194. }
  87195. }
  87196. declare module BABYLON.GUI {
  87197. /**
  87198. * Class used to create a container panel deployed on the surface of a cylinder
  87199. */
  87200. export class CylinderPanel extends VolumeBasedPanel {
  87201. private _radius;
  87202. /**
  87203. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  87204. */
  87205. get radius(): BABYLON.float;
  87206. set radius(value: BABYLON.float);
  87207. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  87208. private _cylindricalMapping;
  87209. }
  87210. }
  87211. declare module BABYLON.GUI {
  87212. /** @hidden */
  87213. export var fluentVertexShader: {
  87214. name: string;
  87215. shader: string;
  87216. };
  87217. }
  87218. declare module BABYLON.GUI {
  87219. /** @hidden */
  87220. export var fluentPixelShader: {
  87221. name: string;
  87222. shader: string;
  87223. };
  87224. }
  87225. declare module BABYLON.GUI {
  87226. /** @hidden */
  87227. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  87228. INNERGLOW: boolean;
  87229. BORDER: boolean;
  87230. HOVERLIGHT: boolean;
  87231. TEXTURE: boolean;
  87232. constructor();
  87233. }
  87234. /**
  87235. * Class used to render controls with fluent desgin
  87236. */
  87237. export class FluentMaterial extends BABYLON.PushMaterial {
  87238. /**
  87239. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  87240. */
  87241. innerGlowColorIntensity: number;
  87242. /**
  87243. * Gets or sets the inner glow color (white by default)
  87244. */
  87245. innerGlowColor: BABYLON.Color3;
  87246. /**
  87247. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  87248. */
  87249. albedoColor: BABYLON.Color3;
  87250. /**
  87251. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  87252. */
  87253. renderBorders: boolean;
  87254. /**
  87255. * Gets or sets border width (default is 0.5)
  87256. */
  87257. borderWidth: number;
  87258. /**
  87259. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  87260. */
  87261. edgeSmoothingValue: number;
  87262. /**
  87263. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  87264. */
  87265. borderMinValue: number;
  87266. /**
  87267. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  87268. */
  87269. renderHoverLight: boolean;
  87270. /**
  87271. * Gets or sets the radius used to render the hover light (default is 1.0)
  87272. */
  87273. hoverRadius: number;
  87274. /**
  87275. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  87276. */
  87277. hoverColor: BABYLON.Color4;
  87278. /**
  87279. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  87280. */
  87281. hoverPosition: BABYLON.Vector3;
  87282. private _albedoTexture;
  87283. /** Gets or sets the texture to use for albedo color */
  87284. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  87285. /**
  87286. * Creates a new Fluent material
  87287. * @param name defines the name of the material
  87288. * @param scene defines the hosting scene
  87289. */
  87290. constructor(name: string, scene: BABYLON.Scene);
  87291. needAlphaBlending(): boolean;
  87292. needAlphaTesting(): boolean;
  87293. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87294. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87295. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87296. getActiveTextures(): BABYLON.BaseTexture[];
  87297. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87298. dispose(forceDisposeEffect?: boolean): void;
  87299. clone(name: string): FluentMaterial;
  87300. serialize(): any;
  87301. getClassName(): string;
  87302. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  87303. }
  87304. }
  87305. declare module BABYLON.GUI {
  87306. /**
  87307. * Class used to create a holographic button in 3D
  87308. */
  87309. export class HolographicButton extends Button3D {
  87310. private _backPlate;
  87311. private _textPlate;
  87312. private _frontPlate;
  87313. private _text;
  87314. private _imageUrl;
  87315. private _shareMaterials;
  87316. private _frontMaterial;
  87317. private _backMaterial;
  87318. private _plateMaterial;
  87319. private _pickedPointObserver;
  87320. private _tooltipFade;
  87321. private _tooltipTextBlock;
  87322. private _tooltipTexture;
  87323. private _tooltipMesh;
  87324. private _tooltipHoverObserver;
  87325. private _tooltipOutObserver;
  87326. private _disposeTooltip;
  87327. /**
  87328. * Rendering ground id of all the mesh in the button
  87329. */
  87330. set renderingGroupId(id: number);
  87331. get renderingGroupId(): number;
  87332. /**
  87333. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  87334. */
  87335. set tooltipText(text: BABYLON.Nullable<string>);
  87336. get tooltipText(): BABYLON.Nullable<string>;
  87337. /**
  87338. * Gets or sets text for the button
  87339. */
  87340. get text(): string;
  87341. set text(value: string);
  87342. /**
  87343. * Gets or sets the image url for the button
  87344. */
  87345. get imageUrl(): string;
  87346. set imageUrl(value: string);
  87347. /**
  87348. * Gets the back material used by this button
  87349. */
  87350. get backMaterial(): FluentMaterial;
  87351. /**
  87352. * Gets the front material used by this button
  87353. */
  87354. get frontMaterial(): FluentMaterial;
  87355. /**
  87356. * Gets the plate material used by this button
  87357. */
  87358. get plateMaterial(): BABYLON.StandardMaterial;
  87359. /**
  87360. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  87361. */
  87362. get shareMaterials(): boolean;
  87363. /**
  87364. * Creates a new button
  87365. * @param name defines the control name
  87366. */
  87367. constructor(name?: string, shareMaterials?: boolean);
  87368. protected _getTypeName(): string;
  87369. private _rebuildContent;
  87370. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  87371. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  87372. private _createBackMaterial;
  87373. private _createFrontMaterial;
  87374. private _createPlateMaterial;
  87375. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  87376. /**
  87377. * Releases all associated resources
  87378. */
  87379. dispose(): void;
  87380. }
  87381. }
  87382. declare module BABYLON.GUI {
  87383. /**
  87384. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  87385. */
  87386. export class MeshButton3D extends Button3D {
  87387. /** @hidden */
  87388. protected _currentMesh: BABYLON.Mesh;
  87389. /**
  87390. * Creates a new 3D button based on a mesh
  87391. * @param mesh mesh to become a 3D button
  87392. * @param name defines the control name
  87393. */
  87394. constructor(mesh: BABYLON.Mesh, name?: string);
  87395. protected _getTypeName(): string;
  87396. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  87397. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  87398. }
  87399. }
  87400. declare module BABYLON.GUI {
  87401. /**
  87402. * Class used to create a container panel deployed on the surface of a plane
  87403. */
  87404. export class PlanePanel extends VolumeBasedPanel {
  87405. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  87406. }
  87407. }
  87408. declare module BABYLON.GUI {
  87409. /**
  87410. * Class used to create a container panel where items get randomized planar mapping
  87411. */
  87412. export class ScatterPanel extends VolumeBasedPanel {
  87413. private _iteration;
  87414. /**
  87415. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  87416. */
  87417. get iteration(): BABYLON.float;
  87418. set iteration(value: BABYLON.float);
  87419. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  87420. private _scatterMapping;
  87421. protected _finalProcessing(): void;
  87422. }
  87423. }
  87424. declare module BABYLON.GUI {
  87425. /**
  87426. * Class used to create a container panel deployed on the surface of a sphere
  87427. */
  87428. export class SpherePanel extends VolumeBasedPanel {
  87429. private _radius;
  87430. /**
  87431. * Gets or sets the radius of the sphere where to project controls (5 by default)
  87432. */
  87433. get radius(): BABYLON.float;
  87434. set radius(value: BABYLON.float);
  87435. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  87436. private _sphericalMapping;
  87437. }
  87438. }
  87439. declare module BABYLON.GUI {
  87440. /**
  87441. * Class used to create a stack panel in 3D on XY plane
  87442. */
  87443. export class StackPanel3D extends Container3D {
  87444. private _isVertical;
  87445. /**
  87446. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  87447. */
  87448. get isVertical(): boolean;
  87449. set isVertical(value: boolean);
  87450. /**
  87451. * Gets or sets the distance between elements
  87452. */
  87453. margin: number;
  87454. /**
  87455. * Creates new StackPanel
  87456. * @param isVertical
  87457. */
  87458. constructor(isVertical?: boolean);
  87459. protected _arrangeChildren(): void;
  87460. }
  87461. }
  87462. declare module BABYLON.GUI {
  87463. /**
  87464. * Class used to create an interactable object. It's a touchable 3D button using a mesh coming from the current scene
  87465. */
  87466. export class TouchMeshButton3D extends TouchButton3D {
  87467. /** @hidden */
  87468. protected _currentMesh: BABYLON.Mesh;
  87469. /**
  87470. * Creates a new 3D button based on a mesh
  87471. * @param mesh mesh to become a 3D button
  87472. * @param collisionMesh mesh to track collisions with
  87473. * @param name defines the control name
  87474. */
  87475. constructor(mesh: BABYLON.Mesh, options: {
  87476. collisionMesh: BABYLON.Mesh;
  87477. useDynamicMesh?: boolean;
  87478. }, name?: string);
  87479. protected _getTypeName(): string;
  87480. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  87481. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  87482. }
  87483. }
  87484. declare module BABYLON.GUI {
  87485. /**
  87486. * Class used to create a holographic button in 3D
  87487. */
  87488. export class TouchHolographicButton extends TouchButton3D {
  87489. private _backPlate;
  87490. private _textPlate;
  87491. private _frontPlate;
  87492. private _text;
  87493. private _imageUrl;
  87494. private _shareMaterials;
  87495. private _frontMaterial;
  87496. private _backMaterial;
  87497. private _plateMaterial;
  87498. private _pickedPointObserver;
  87499. private _tooltipFade;
  87500. private _tooltipTextBlock;
  87501. private _tooltipTexture;
  87502. private _tooltipMesh;
  87503. private _tooltipHoverObserver;
  87504. private _tooltipOutObserver;
  87505. private _disposeTooltip;
  87506. /**
  87507. * Rendering ground id of all the mesh in the button
  87508. */
  87509. set renderingGroupId(id: number);
  87510. get renderingGroupId(): number;
  87511. /**
  87512. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  87513. */
  87514. set tooltipText(text: BABYLON.Nullable<string>);
  87515. get tooltipText(): BABYLON.Nullable<string>;
  87516. /**
  87517. * Gets or sets text for the button
  87518. */
  87519. get text(): string;
  87520. set text(value: string);
  87521. /**
  87522. * Gets or sets the image url for the button
  87523. */
  87524. get imageUrl(): string;
  87525. set imageUrl(value: string);
  87526. /**
  87527. * Gets the back material used by this button
  87528. */
  87529. get backMaterial(): FluentMaterial;
  87530. /**
  87531. * Gets the front material used by this button
  87532. */
  87533. get frontMaterial(): FluentMaterial;
  87534. /**
  87535. * Gets the plate material used by this button
  87536. */
  87537. get plateMaterial(): BABYLON.StandardMaterial;
  87538. /**
  87539. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  87540. */
  87541. get shareMaterials(): boolean;
  87542. /**
  87543. * Creates a new button
  87544. * @param name defines the control name
  87545. */
  87546. constructor(name?: string, shareMaterials?: boolean);
  87547. protected _getTypeName(): string;
  87548. private _rebuildContent;
  87549. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  87550. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  87551. private _createBackMaterial;
  87552. private _createFrontMaterial;
  87553. private _createPlateMaterial;
  87554. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  87555. /**
  87556. * Releases all associated resources
  87557. */
  87558. dispose(): void;
  87559. }
  87560. }
  87561. declare module BABYLON {
  87562. /**
  87563. * Configuration for glTF validation
  87564. */
  87565. export interface IGLTFValidationConfiguration {
  87566. /**
  87567. * The url of the glTF validator.
  87568. */
  87569. url: string;
  87570. }
  87571. /**
  87572. * glTF validation
  87573. */
  87574. export class GLTFValidation {
  87575. /**
  87576. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  87577. */
  87578. static Configuration: IGLTFValidationConfiguration;
  87579. private static _LoadScriptPromise;
  87580. /**
  87581. * Validate a glTF asset using the glTF-Validator.
  87582. * @param data The JSON of a glTF or the array buffer of a binary glTF
  87583. * @param rootUrl The root url for the glTF
  87584. * @param fileName The file name for the glTF
  87585. * @param getExternalResource The callback to get external resources for the glTF validator
  87586. * @returns A promise that resolves with the glTF validation results once complete
  87587. */
  87588. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  87589. }
  87590. }
  87591. declare module BABYLON {
  87592. /**
  87593. * Mode that determines the coordinate system to use.
  87594. */
  87595. export enum GLTFLoaderCoordinateSystemMode {
  87596. /**
  87597. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  87598. */
  87599. AUTO = 0,
  87600. /**
  87601. * Sets the useRightHandedSystem flag on the scene.
  87602. */
  87603. FORCE_RIGHT_HANDED = 1
  87604. }
  87605. /**
  87606. * Mode that determines what animations will start.
  87607. */
  87608. export enum GLTFLoaderAnimationStartMode {
  87609. /**
  87610. * No animation will start.
  87611. */
  87612. NONE = 0,
  87613. /**
  87614. * The first animation will start.
  87615. */
  87616. FIRST = 1,
  87617. /**
  87618. * All animations will start.
  87619. */
  87620. ALL = 2
  87621. }
  87622. /**
  87623. * Interface that contains the data for the glTF asset.
  87624. */
  87625. export interface IGLTFLoaderData {
  87626. /**
  87627. * The object that represents the glTF JSON.
  87628. */
  87629. json: Object;
  87630. /**
  87631. * The BIN chunk of a binary glTF.
  87632. */
  87633. bin: Nullable<IDataBuffer>;
  87634. }
  87635. /**
  87636. * Interface for extending the loader.
  87637. */
  87638. export interface IGLTFLoaderExtension {
  87639. /**
  87640. * The name of this extension.
  87641. */
  87642. readonly name: string;
  87643. /**
  87644. * Defines whether this extension is enabled.
  87645. */
  87646. enabled: boolean;
  87647. /**
  87648. * Defines the order of this extension.
  87649. * The loader sorts the extensions using these values when loading.
  87650. */
  87651. order?: number;
  87652. }
  87653. /**
  87654. * Loader state.
  87655. */
  87656. export enum GLTFLoaderState {
  87657. /**
  87658. * The asset is loading.
  87659. */
  87660. LOADING = 0,
  87661. /**
  87662. * The asset is ready for rendering.
  87663. */
  87664. READY = 1,
  87665. /**
  87666. * The asset is completely loaded.
  87667. */
  87668. COMPLETE = 2
  87669. }
  87670. /** @hidden */
  87671. export interface IGLTFLoader extends IDisposable {
  87672. readonly state: Nullable<GLTFLoaderState>;
  87673. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<ISceneLoaderAsyncResult>;
  87674. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  87675. }
  87676. /**
  87677. * File loader for loading glTF files into a scene.
  87678. */
  87679. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  87680. /** @hidden */
  87681. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  87682. /** @hidden */
  87683. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  87684. /**
  87685. * Raised when the asset has been parsed
  87686. */
  87687. onParsedObservable: Observable<IGLTFLoaderData>;
  87688. private _onParsedObserver;
  87689. /**
  87690. * Raised when the asset has been parsed
  87691. */
  87692. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  87693. /**
  87694. * 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.
  87695. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  87696. * Defaults to true.
  87697. * @hidden
  87698. */
  87699. static IncrementalLoading: boolean;
  87700. /**
  87701. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  87702. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  87703. * @hidden
  87704. */
  87705. static HomogeneousCoordinates: boolean;
  87706. /**
  87707. * The coordinate system mode. Defaults to AUTO.
  87708. */
  87709. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  87710. /**
  87711. * The animation start mode. Defaults to FIRST.
  87712. */
  87713. animationStartMode: GLTFLoaderAnimationStartMode;
  87714. /**
  87715. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  87716. */
  87717. compileMaterials: boolean;
  87718. /**
  87719. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  87720. */
  87721. useClipPlane: boolean;
  87722. /**
  87723. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  87724. */
  87725. compileShadowGenerators: boolean;
  87726. /**
  87727. * Defines if the Alpha blended materials are only applied as coverage.
  87728. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  87729. * If true, no extra effects are applied to transparent pixels.
  87730. */
  87731. transparencyAsCoverage: boolean;
  87732. /**
  87733. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  87734. * Enabling will disable offline support and glTF validator.
  87735. * Defaults to false.
  87736. */
  87737. useRangeRequests: boolean;
  87738. /**
  87739. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  87740. */
  87741. createInstances: boolean;
  87742. /**
  87743. * 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.
  87744. */
  87745. alwaysComputeBoundingBox: boolean;
  87746. /**
  87747. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  87748. */
  87749. loadAllMaterials: boolean;
  87750. /**
  87751. * Function called before loading a url referenced by the asset.
  87752. */
  87753. preprocessUrlAsync: (url: string) => Promise<string>;
  87754. /**
  87755. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  87756. * 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, ...)
  87757. */
  87758. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  87759. private _onMeshLoadedObserver;
  87760. /**
  87761. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  87762. * 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, ...)
  87763. */
  87764. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  87765. /**
  87766. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  87767. */
  87768. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  87769. private _onTextureLoadedObserver;
  87770. /**
  87771. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  87772. */
  87773. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  87774. /**
  87775. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  87776. */
  87777. readonly onMaterialLoadedObservable: Observable<Material>;
  87778. private _onMaterialLoadedObserver;
  87779. /**
  87780. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  87781. */
  87782. set onMaterialLoaded(callback: (material: Material) => void);
  87783. /**
  87784. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  87785. */
  87786. readonly onCameraLoadedObservable: Observable<Camera>;
  87787. private _onCameraLoadedObserver;
  87788. /**
  87789. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  87790. */
  87791. set onCameraLoaded(callback: (camera: Camera) => void);
  87792. /**
  87793. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  87794. * For assets with LODs, raised when all of the LODs are complete.
  87795. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  87796. */
  87797. readonly onCompleteObservable: Observable<void>;
  87798. private _onCompleteObserver;
  87799. /**
  87800. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  87801. * For assets with LODs, raised when all of the LODs are complete.
  87802. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  87803. */
  87804. set onComplete(callback: () => void);
  87805. /**
  87806. * Observable raised when an error occurs.
  87807. */
  87808. readonly onErrorObservable: Observable<any>;
  87809. private _onErrorObserver;
  87810. /**
  87811. * Callback raised when an error occurs.
  87812. */
  87813. set onError(callback: (reason: any) => void);
  87814. /**
  87815. * Observable raised after the loader is disposed.
  87816. */
  87817. readonly onDisposeObservable: Observable<void>;
  87818. private _onDisposeObserver;
  87819. /**
  87820. * Callback raised after the loader is disposed.
  87821. */
  87822. set onDispose(callback: () => void);
  87823. /**
  87824. * Observable raised after a loader extension is created.
  87825. * Set additional options for a loader extension in this event.
  87826. */
  87827. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  87828. private _onExtensionLoadedObserver;
  87829. /**
  87830. * Callback raised after a loader extension is created.
  87831. */
  87832. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  87833. /**
  87834. * Defines if the loader logging is enabled.
  87835. */
  87836. get loggingEnabled(): boolean;
  87837. set loggingEnabled(value: boolean);
  87838. /**
  87839. * Defines if the loader should capture performance counters.
  87840. */
  87841. get capturePerformanceCounters(): boolean;
  87842. set capturePerformanceCounters(value: boolean);
  87843. /**
  87844. * Defines if the loader should validate the asset.
  87845. */
  87846. validate: boolean;
  87847. /**
  87848. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  87849. */
  87850. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  87851. private _onValidatedObserver;
  87852. /**
  87853. * Callback raised after a loader extension is created.
  87854. */
  87855. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  87856. private _loader;
  87857. private _progressCallback?;
  87858. private _requests;
  87859. private static magicBase64Encoded;
  87860. /**
  87861. * Name of the loader ("gltf")
  87862. */
  87863. name: string;
  87864. /** @hidden */
  87865. extensions: ISceneLoaderPluginExtensions;
  87866. /**
  87867. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  87868. */
  87869. dispose(): void;
  87870. /** @hidden */
  87871. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  87872. /** @hidden */
  87873. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  87874. /** @hidden */
  87875. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  87876. /** @hidden */
  87877. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  87878. /** @hidden */
  87879. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  87880. /** @hidden */
  87881. canDirectLoad(data: string): boolean;
  87882. /** @hidden */
  87883. directLoad(scene: Scene, data: string): Promise<any>;
  87884. /**
  87885. * The callback that allows custom handling of the root url based on the response url.
  87886. * @param rootUrl the original root url
  87887. * @param responseURL the response url if available
  87888. * @returns the new root url
  87889. */
  87890. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  87891. /** @hidden */
  87892. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  87893. /**
  87894. * The loader state or null if the loader is not active.
  87895. */
  87896. get loaderState(): Nullable<GLTFLoaderState>;
  87897. /**
  87898. * Returns a promise that resolves when the asset is completely loaded.
  87899. * @returns a promise that resolves when the asset is completely loaded.
  87900. */
  87901. whenCompleteAsync(): Promise<void>;
  87902. /** @hidden */
  87903. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  87904. /** @hidden */
  87905. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  87906. private _onProgress;
  87907. private _validate;
  87908. private _getLoader;
  87909. private _parseJson;
  87910. private _unpackBinaryAsync;
  87911. private _unpackBinaryV1Async;
  87912. private _unpackBinaryV2Async;
  87913. private static _parseVersion;
  87914. private static _compareVersion;
  87915. private static readonly _logSpaces;
  87916. private _logIndentLevel;
  87917. private _loggingEnabled;
  87918. /** @hidden */
  87919. _log: (message: string) => void;
  87920. /** @hidden */
  87921. _logOpen(message: string): void;
  87922. /** @hidden */
  87923. _logClose(): void;
  87924. private _logEnabled;
  87925. private _logDisabled;
  87926. private _capturePerformanceCounters;
  87927. /** @hidden */
  87928. _startPerformanceCounter: (counterName: string) => void;
  87929. /** @hidden */
  87930. _endPerformanceCounter: (counterName: string) => void;
  87931. private _startPerformanceCounterEnabled;
  87932. private _startPerformanceCounterDisabled;
  87933. private _endPerformanceCounterEnabled;
  87934. private _endPerformanceCounterDisabled;
  87935. }
  87936. }
  87937. declare module BABYLON.GLTF1 {
  87938. /**
  87939. * Enums
  87940. * @hidden
  87941. */
  87942. export enum EComponentType {
  87943. BYTE = 5120,
  87944. UNSIGNED_BYTE = 5121,
  87945. SHORT = 5122,
  87946. UNSIGNED_SHORT = 5123,
  87947. FLOAT = 5126
  87948. }
  87949. /** @hidden */
  87950. export enum EShaderType {
  87951. FRAGMENT = 35632,
  87952. VERTEX = 35633
  87953. }
  87954. /** @hidden */
  87955. export enum EParameterType {
  87956. BYTE = 5120,
  87957. UNSIGNED_BYTE = 5121,
  87958. SHORT = 5122,
  87959. UNSIGNED_SHORT = 5123,
  87960. INT = 5124,
  87961. UNSIGNED_INT = 5125,
  87962. FLOAT = 5126,
  87963. FLOAT_VEC2 = 35664,
  87964. FLOAT_VEC3 = 35665,
  87965. FLOAT_VEC4 = 35666,
  87966. INT_VEC2 = 35667,
  87967. INT_VEC3 = 35668,
  87968. INT_VEC4 = 35669,
  87969. BOOL = 35670,
  87970. BOOL_VEC2 = 35671,
  87971. BOOL_VEC3 = 35672,
  87972. BOOL_VEC4 = 35673,
  87973. FLOAT_MAT2 = 35674,
  87974. FLOAT_MAT3 = 35675,
  87975. FLOAT_MAT4 = 35676,
  87976. SAMPLER_2D = 35678
  87977. }
  87978. /** @hidden */
  87979. export enum ETextureWrapMode {
  87980. CLAMP_TO_EDGE = 33071,
  87981. MIRRORED_REPEAT = 33648,
  87982. REPEAT = 10497
  87983. }
  87984. /** @hidden */
  87985. export enum ETextureFilterType {
  87986. NEAREST = 9728,
  87987. LINEAR = 9728,
  87988. NEAREST_MIPMAP_NEAREST = 9984,
  87989. LINEAR_MIPMAP_NEAREST = 9985,
  87990. NEAREST_MIPMAP_LINEAR = 9986,
  87991. LINEAR_MIPMAP_LINEAR = 9987
  87992. }
  87993. /** @hidden */
  87994. export enum ETextureFormat {
  87995. ALPHA = 6406,
  87996. RGB = 6407,
  87997. RGBA = 6408,
  87998. LUMINANCE = 6409,
  87999. LUMINANCE_ALPHA = 6410
  88000. }
  88001. /** @hidden */
  88002. export enum ECullingType {
  88003. FRONT = 1028,
  88004. BACK = 1029,
  88005. FRONT_AND_BACK = 1032
  88006. }
  88007. /** @hidden */
  88008. export enum EBlendingFunction {
  88009. ZERO = 0,
  88010. ONE = 1,
  88011. SRC_COLOR = 768,
  88012. ONE_MINUS_SRC_COLOR = 769,
  88013. DST_COLOR = 774,
  88014. ONE_MINUS_DST_COLOR = 775,
  88015. SRC_ALPHA = 770,
  88016. ONE_MINUS_SRC_ALPHA = 771,
  88017. DST_ALPHA = 772,
  88018. ONE_MINUS_DST_ALPHA = 773,
  88019. CONSTANT_COLOR = 32769,
  88020. ONE_MINUS_CONSTANT_COLOR = 32770,
  88021. CONSTANT_ALPHA = 32771,
  88022. ONE_MINUS_CONSTANT_ALPHA = 32772,
  88023. SRC_ALPHA_SATURATE = 776
  88024. }
  88025. /** @hidden */
  88026. export interface IGLTFProperty {
  88027. extensions?: {
  88028. [key: string]: any;
  88029. };
  88030. extras?: Object;
  88031. }
  88032. /** @hidden */
  88033. export interface IGLTFChildRootProperty extends IGLTFProperty {
  88034. name?: string;
  88035. }
  88036. /** @hidden */
  88037. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  88038. bufferView: string;
  88039. byteOffset: number;
  88040. byteStride: number;
  88041. count: number;
  88042. type: string;
  88043. componentType: EComponentType;
  88044. max?: number[];
  88045. min?: number[];
  88046. name?: string;
  88047. }
  88048. /** @hidden */
  88049. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  88050. buffer: string;
  88051. byteOffset: number;
  88052. byteLength: number;
  88053. byteStride: number;
  88054. target?: number;
  88055. }
  88056. /** @hidden */
  88057. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  88058. uri: string;
  88059. byteLength?: number;
  88060. type?: string;
  88061. }
  88062. /** @hidden */
  88063. export interface IGLTFShader extends IGLTFChildRootProperty {
  88064. uri: string;
  88065. type: EShaderType;
  88066. }
  88067. /** @hidden */
  88068. export interface IGLTFProgram extends IGLTFChildRootProperty {
  88069. attributes: string[];
  88070. fragmentShader: string;
  88071. vertexShader: string;
  88072. }
  88073. /** @hidden */
  88074. export interface IGLTFTechniqueParameter {
  88075. type: number;
  88076. count?: number;
  88077. semantic?: string;
  88078. node?: string;
  88079. value?: number | boolean | string | Array<any>;
  88080. source?: string;
  88081. babylonValue?: any;
  88082. }
  88083. /** @hidden */
  88084. export interface IGLTFTechniqueCommonProfile {
  88085. lightingModel: string;
  88086. texcoordBindings: Object;
  88087. parameters?: Array<any>;
  88088. }
  88089. /** @hidden */
  88090. export interface IGLTFTechniqueStatesFunctions {
  88091. blendColor?: number[];
  88092. blendEquationSeparate?: number[];
  88093. blendFuncSeparate?: number[];
  88094. colorMask: boolean[];
  88095. cullFace: number[];
  88096. }
  88097. /** @hidden */
  88098. export interface IGLTFTechniqueStates {
  88099. enable: number[];
  88100. functions: IGLTFTechniqueStatesFunctions;
  88101. }
  88102. /** @hidden */
  88103. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  88104. parameters: {
  88105. [key: string]: IGLTFTechniqueParameter;
  88106. };
  88107. program: string;
  88108. attributes: {
  88109. [key: string]: string;
  88110. };
  88111. uniforms: {
  88112. [key: string]: string;
  88113. };
  88114. states: IGLTFTechniqueStates;
  88115. }
  88116. /** @hidden */
  88117. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  88118. technique?: string;
  88119. values: string[];
  88120. }
  88121. /** @hidden */
  88122. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  88123. attributes: {
  88124. [key: string]: string;
  88125. };
  88126. indices: string;
  88127. material: string;
  88128. mode?: number;
  88129. }
  88130. /** @hidden */
  88131. export interface IGLTFMesh extends IGLTFChildRootProperty {
  88132. primitives: IGLTFMeshPrimitive[];
  88133. }
  88134. /** @hidden */
  88135. export interface IGLTFImage extends IGLTFChildRootProperty {
  88136. uri: string;
  88137. }
  88138. /** @hidden */
  88139. export interface IGLTFSampler extends IGLTFChildRootProperty {
  88140. magFilter?: number;
  88141. minFilter?: number;
  88142. wrapS?: number;
  88143. wrapT?: number;
  88144. }
  88145. /** @hidden */
  88146. export interface IGLTFTexture extends IGLTFChildRootProperty {
  88147. sampler: string;
  88148. source: string;
  88149. format?: ETextureFormat;
  88150. internalFormat?: ETextureFormat;
  88151. target?: number;
  88152. type?: number;
  88153. babylonTexture?: Texture;
  88154. }
  88155. /** @hidden */
  88156. export interface IGLTFAmbienLight {
  88157. color?: number[];
  88158. }
  88159. /** @hidden */
  88160. export interface IGLTFDirectionalLight {
  88161. color?: number[];
  88162. }
  88163. /** @hidden */
  88164. export interface IGLTFPointLight {
  88165. color?: number[];
  88166. constantAttenuation?: number;
  88167. linearAttenuation?: number;
  88168. quadraticAttenuation?: number;
  88169. }
  88170. /** @hidden */
  88171. export interface IGLTFSpotLight {
  88172. color?: number[];
  88173. constantAttenuation?: number;
  88174. fallOfAngle?: number;
  88175. fallOffExponent?: number;
  88176. linearAttenuation?: number;
  88177. quadraticAttenuation?: number;
  88178. }
  88179. /** @hidden */
  88180. export interface IGLTFLight extends IGLTFChildRootProperty {
  88181. type: string;
  88182. }
  88183. /** @hidden */
  88184. export interface IGLTFCameraOrthographic {
  88185. xmag: number;
  88186. ymag: number;
  88187. zfar: number;
  88188. znear: number;
  88189. }
  88190. /** @hidden */
  88191. export interface IGLTFCameraPerspective {
  88192. aspectRatio: number;
  88193. yfov: number;
  88194. zfar: number;
  88195. znear: number;
  88196. }
  88197. /** @hidden */
  88198. export interface IGLTFCamera extends IGLTFChildRootProperty {
  88199. type: string;
  88200. }
  88201. /** @hidden */
  88202. export interface IGLTFAnimationChannelTarget {
  88203. id: string;
  88204. path: string;
  88205. }
  88206. /** @hidden */
  88207. export interface IGLTFAnimationChannel {
  88208. sampler: string;
  88209. target: IGLTFAnimationChannelTarget;
  88210. }
  88211. /** @hidden */
  88212. export interface IGLTFAnimationSampler {
  88213. input: string;
  88214. output: string;
  88215. interpolation?: string;
  88216. }
  88217. /** @hidden */
  88218. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  88219. channels?: IGLTFAnimationChannel[];
  88220. parameters?: {
  88221. [key: string]: string;
  88222. };
  88223. samplers?: {
  88224. [key: string]: IGLTFAnimationSampler;
  88225. };
  88226. }
  88227. /** @hidden */
  88228. export interface IGLTFNodeInstanceSkin {
  88229. skeletons: string[];
  88230. skin: string;
  88231. meshes: string[];
  88232. }
  88233. /** @hidden */
  88234. export interface IGLTFSkins extends IGLTFChildRootProperty {
  88235. bindShapeMatrix: number[];
  88236. inverseBindMatrices: string;
  88237. jointNames: string[];
  88238. babylonSkeleton?: Skeleton;
  88239. }
  88240. /** @hidden */
  88241. export interface IGLTFNode extends IGLTFChildRootProperty {
  88242. camera?: string;
  88243. children: string[];
  88244. skin?: string;
  88245. jointName?: string;
  88246. light?: string;
  88247. matrix: number[];
  88248. mesh?: string;
  88249. meshes?: string[];
  88250. rotation?: number[];
  88251. scale?: number[];
  88252. translation?: number[];
  88253. babylonNode?: Node;
  88254. }
  88255. /** @hidden */
  88256. export interface IGLTFScene extends IGLTFChildRootProperty {
  88257. nodes: string[];
  88258. }
  88259. /** @hidden */
  88260. export interface IGLTFRuntime {
  88261. extensions: {
  88262. [key: string]: any;
  88263. };
  88264. accessors: {
  88265. [key: string]: IGLTFAccessor;
  88266. };
  88267. buffers: {
  88268. [key: string]: IGLTFBuffer;
  88269. };
  88270. bufferViews: {
  88271. [key: string]: IGLTFBufferView;
  88272. };
  88273. meshes: {
  88274. [key: string]: IGLTFMesh;
  88275. };
  88276. lights: {
  88277. [key: string]: IGLTFLight;
  88278. };
  88279. cameras: {
  88280. [key: string]: IGLTFCamera;
  88281. };
  88282. nodes: {
  88283. [key: string]: IGLTFNode;
  88284. };
  88285. images: {
  88286. [key: string]: IGLTFImage;
  88287. };
  88288. textures: {
  88289. [key: string]: IGLTFTexture;
  88290. };
  88291. shaders: {
  88292. [key: string]: IGLTFShader;
  88293. };
  88294. programs: {
  88295. [key: string]: IGLTFProgram;
  88296. };
  88297. samplers: {
  88298. [key: string]: IGLTFSampler;
  88299. };
  88300. techniques: {
  88301. [key: string]: IGLTFTechnique;
  88302. };
  88303. materials: {
  88304. [key: string]: IGLTFMaterial;
  88305. };
  88306. animations: {
  88307. [key: string]: IGLTFAnimation;
  88308. };
  88309. skins: {
  88310. [key: string]: IGLTFSkins;
  88311. };
  88312. currentScene?: Object;
  88313. scenes: {
  88314. [key: string]: IGLTFScene;
  88315. };
  88316. extensionsUsed: string[];
  88317. extensionsRequired?: string[];
  88318. buffersCount: number;
  88319. shaderscount: number;
  88320. scene: Scene;
  88321. rootUrl: string;
  88322. loadedBufferCount: number;
  88323. loadedBufferViews: {
  88324. [name: string]: ArrayBufferView;
  88325. };
  88326. loadedShaderCount: number;
  88327. importOnlyMeshes: boolean;
  88328. importMeshesNames?: string[];
  88329. dummyNodes: Node[];
  88330. forAssetContainer: boolean;
  88331. }
  88332. /** @hidden */
  88333. export interface INodeToRoot {
  88334. bone: Bone;
  88335. node: IGLTFNode;
  88336. id: string;
  88337. }
  88338. /** @hidden */
  88339. export interface IJointNode {
  88340. node: IGLTFNode;
  88341. id: string;
  88342. }
  88343. }
  88344. declare module BABYLON.GLTF1 {
  88345. /**
  88346. * Utils functions for GLTF
  88347. * @hidden
  88348. */
  88349. export class GLTFUtils {
  88350. /**
  88351. * Sets the given "parameter" matrix
  88352. * @param scene: the Scene object
  88353. * @param source: the source node where to pick the matrix
  88354. * @param parameter: the GLTF technique parameter
  88355. * @param uniformName: the name of the shader's uniform
  88356. * @param shaderMaterial: the shader material
  88357. */
  88358. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  88359. /**
  88360. * Sets the given "parameter" matrix
  88361. * @param shaderMaterial: the shader material
  88362. * @param uniform: the name of the shader's uniform
  88363. * @param value: the value of the uniform
  88364. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  88365. */
  88366. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  88367. /**
  88368. * Returns the wrap mode of the texture
  88369. * @param mode: the mode value
  88370. */
  88371. static GetWrapMode(mode: number): number;
  88372. /**
  88373. * Returns the byte stride giving an accessor
  88374. * @param accessor: the GLTF accessor objet
  88375. */
  88376. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  88377. /**
  88378. * Returns the texture filter mode giving a mode value
  88379. * @param mode: the filter mode value
  88380. */
  88381. static GetTextureFilterMode(mode: number): ETextureFilterType;
  88382. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  88383. /**
  88384. * Returns a buffer from its accessor
  88385. * @param gltfRuntime: the GLTF runtime
  88386. * @param accessor: the GLTF accessor
  88387. */
  88388. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  88389. /**
  88390. * Decodes a buffer view into a string
  88391. * @param view: the buffer view
  88392. */
  88393. static DecodeBufferToText(view: ArrayBufferView): string;
  88394. /**
  88395. * Returns the default material of gltf. Related to
  88396. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  88397. * @param scene: the Babylon.js scene
  88398. */
  88399. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  88400. private static _DefaultMaterial;
  88401. }
  88402. }
  88403. declare module BABYLON.GLTF1 {
  88404. /**
  88405. * Implementation of the base glTF spec
  88406. * @hidden
  88407. */
  88408. export class GLTFLoaderBase {
  88409. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  88410. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  88411. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  88412. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  88413. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  88414. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  88415. }
  88416. /**
  88417. * glTF V1 Loader
  88418. * @hidden
  88419. */
  88420. export class GLTFLoader implements IGLTFLoader {
  88421. static Extensions: {
  88422. [name: string]: GLTFLoaderExtension;
  88423. };
  88424. static RegisterExtension(extension: GLTFLoaderExtension): void;
  88425. state: Nullable<GLTFLoaderState>;
  88426. dispose(): void;
  88427. private _importMeshAsync;
  88428. /**
  88429. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  88430. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  88431. * @param scene the scene the meshes should be added to
  88432. * @param forAssetContainer defines if the entities must be stored in the scene
  88433. * @param data gltf data containing information of the meshes in a loaded file
  88434. * @param rootUrl root url to load from
  88435. * @param onProgress event that fires when loading progress has occured
  88436. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  88437. */
  88438. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<ISceneLoaderAsyncResult>;
  88439. private _loadAsync;
  88440. /**
  88441. * Imports all objects from a loaded gltf file and adds them to the scene
  88442. * @param scene the scene the objects should be added to
  88443. * @param data gltf data containing information of the meshes in a loaded file
  88444. * @param rootUrl root url to load from
  88445. * @param onProgress event that fires when loading progress has occured
  88446. * @returns a promise which completes when objects have been loaded to the scene
  88447. */
  88448. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  88449. private _loadShadersAsync;
  88450. private _loadBuffersAsync;
  88451. private _createNodes;
  88452. }
  88453. /** @hidden */
  88454. export abstract class GLTFLoaderExtension {
  88455. private _name;
  88456. constructor(name: string);
  88457. get name(): string;
  88458. /**
  88459. * Defines an override for loading the runtime
  88460. * Return true to stop further extensions from loading the runtime
  88461. */
  88462. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  88463. /**
  88464. * Defines an onverride for creating gltf runtime
  88465. * Return true to stop further extensions from creating the runtime
  88466. */
  88467. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  88468. /**
  88469. * Defines an override for loading buffers
  88470. * Return true to stop further extensions from loading this buffer
  88471. */
  88472. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  88473. /**
  88474. * Defines an override for loading texture buffers
  88475. * Return true to stop further extensions from loading this texture data
  88476. */
  88477. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  88478. /**
  88479. * Defines an override for creating textures
  88480. * Return true to stop further extensions from loading this texture
  88481. */
  88482. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  88483. /**
  88484. * Defines an override for loading shader strings
  88485. * Return true to stop further extensions from loading this shader data
  88486. */
  88487. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  88488. /**
  88489. * Defines an override for loading materials
  88490. * Return true to stop further extensions from loading this material
  88491. */
  88492. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  88493. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  88494. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  88495. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  88496. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  88497. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  88498. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  88499. private static LoadTextureBufferAsync;
  88500. private static CreateTextureAsync;
  88501. private static ApplyExtensions;
  88502. }
  88503. }
  88504. declare module BABYLON.GLTF1 {
  88505. /** @hidden */
  88506. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  88507. private _bin;
  88508. constructor();
  88509. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  88510. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  88511. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  88512. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  88513. }
  88514. }
  88515. declare module BABYLON.GLTF1 {
  88516. /** @hidden */
  88517. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  88518. constructor();
  88519. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  88520. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  88521. private _loadTexture;
  88522. }
  88523. }
  88524. declare module BABYLON.GLTF2.Loader {
  88525. /**
  88526. * Loader interface with an index field.
  88527. */
  88528. export interface IArrayItem {
  88529. /**
  88530. * The index of this item in the array.
  88531. */
  88532. index: number;
  88533. }
  88534. /**
  88535. * Loader interface with additional members.
  88536. */
  88537. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  88538. /** @hidden */
  88539. _data?: Promise<ArrayBufferView>;
  88540. /** @hidden */
  88541. _babylonVertexBuffer?: Promise<VertexBuffer>;
  88542. }
  88543. /**
  88544. * Loader interface with additional members.
  88545. */
  88546. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  88547. }
  88548. /** @hidden */
  88549. export interface _IAnimationSamplerData {
  88550. input: Float32Array;
  88551. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  88552. output: Float32Array;
  88553. }
  88554. /**
  88555. * Loader interface with additional members.
  88556. */
  88557. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  88558. /** @hidden */
  88559. _data?: Promise<_IAnimationSamplerData>;
  88560. }
  88561. /**
  88562. * Loader interface with additional members.
  88563. */
  88564. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  88565. channels: IAnimationChannel[];
  88566. samplers: IAnimationSampler[];
  88567. /** @hidden */
  88568. _babylonAnimationGroup?: AnimationGroup;
  88569. }
  88570. /**
  88571. * Loader interface with additional members.
  88572. */
  88573. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  88574. /** @hidden */
  88575. _data?: Promise<ArrayBufferView>;
  88576. }
  88577. /**
  88578. * Loader interface with additional members.
  88579. */
  88580. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  88581. /** @hidden */
  88582. _data?: Promise<ArrayBufferView>;
  88583. /** @hidden */
  88584. _babylonBuffer?: Promise<Buffer>;
  88585. }
  88586. /**
  88587. * Loader interface with additional members.
  88588. */
  88589. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  88590. }
  88591. /**
  88592. * Loader interface with additional members.
  88593. */
  88594. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  88595. /** @hidden */
  88596. _data?: Promise<ArrayBufferView>;
  88597. }
  88598. /**
  88599. * Loader interface with additional members.
  88600. */
  88601. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  88602. }
  88603. /**
  88604. * Loader interface with additional members.
  88605. */
  88606. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  88607. }
  88608. /**
  88609. * Loader interface with additional members.
  88610. */
  88611. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  88612. baseColorTexture?: ITextureInfo;
  88613. metallicRoughnessTexture?: ITextureInfo;
  88614. }
  88615. /**
  88616. * Loader interface with additional members.
  88617. */
  88618. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  88619. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  88620. normalTexture?: IMaterialNormalTextureInfo;
  88621. occlusionTexture?: IMaterialOcclusionTextureInfo;
  88622. emissiveTexture?: ITextureInfo;
  88623. /** @hidden */
  88624. _data?: {
  88625. [babylonDrawMode: number]: {
  88626. babylonMaterial: Material;
  88627. babylonMeshes: AbstractMesh[];
  88628. promise: Promise<void>;
  88629. };
  88630. };
  88631. }
  88632. /**
  88633. * Loader interface with additional members.
  88634. */
  88635. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  88636. primitives: IMeshPrimitive[];
  88637. }
  88638. /**
  88639. * Loader interface with additional members.
  88640. */
  88641. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  88642. /** @hidden */
  88643. _instanceData?: {
  88644. babylonSourceMesh: Mesh;
  88645. promise: Promise<any>;
  88646. };
  88647. }
  88648. /**
  88649. * Loader interface with additional members.
  88650. */
  88651. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  88652. /**
  88653. * The parent glTF node.
  88654. */
  88655. parent?: INode;
  88656. /** @hidden */
  88657. _babylonTransformNode?: TransformNode;
  88658. /** @hidden */
  88659. _primitiveBabylonMeshes?: AbstractMesh[];
  88660. /** @hidden */
  88661. _babylonBones?: Bone[];
  88662. /** @hidden */
  88663. _numMorphTargets?: number;
  88664. }
  88665. /** @hidden */
  88666. export interface _ISamplerData {
  88667. noMipMaps: boolean;
  88668. samplingMode: number;
  88669. wrapU: number;
  88670. wrapV: number;
  88671. }
  88672. /**
  88673. * Loader interface with additional members.
  88674. */
  88675. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  88676. /** @hidden */
  88677. _data?: _ISamplerData;
  88678. }
  88679. /**
  88680. * Loader interface with additional members.
  88681. */
  88682. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  88683. }
  88684. /**
  88685. * Loader interface with additional members.
  88686. */
  88687. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  88688. /** @hidden */
  88689. _data?: {
  88690. babylonSkeleton: Skeleton;
  88691. promise: Promise<void>;
  88692. };
  88693. }
  88694. /**
  88695. * Loader interface with additional members.
  88696. */
  88697. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  88698. /** @hidden */
  88699. _textureInfo: ITextureInfo;
  88700. }
  88701. /**
  88702. * Loader interface with additional members.
  88703. */
  88704. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  88705. /** false or undefined if the texture holds color data (true if data are roughness, normal, ...) */
  88706. nonColorData?: boolean;
  88707. }
  88708. /**
  88709. * Loader interface with additional members.
  88710. */
  88711. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  88712. accessors?: IAccessor[];
  88713. animations?: IAnimation[];
  88714. buffers?: IBuffer[];
  88715. bufferViews?: IBufferView[];
  88716. cameras?: ICamera[];
  88717. images?: IImage[];
  88718. materials?: IMaterial[];
  88719. meshes?: IMesh[];
  88720. nodes?: INode[];
  88721. samplers?: ISampler[];
  88722. scenes?: IScene[];
  88723. skins?: ISkin[];
  88724. textures?: ITexture[];
  88725. }
  88726. }
  88727. declare module BABYLON.GLTF2 {
  88728. /**
  88729. * Interface for a glTF loader extension.
  88730. */
  88731. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  88732. /**
  88733. * Called after the loader state changes to LOADING.
  88734. */
  88735. onLoading?(): void;
  88736. /**
  88737. * Called after the loader state changes to READY.
  88738. */
  88739. onReady?(): void;
  88740. /**
  88741. * Define this method to modify the default behavior when loading scenes.
  88742. * @param context The context when loading the asset
  88743. * @param scene The glTF scene property
  88744. * @returns A promise that resolves when the load is complete or null if not handled
  88745. */
  88746. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  88747. /**
  88748. * Define this method to modify the default behavior when loading nodes.
  88749. * @param context The context when loading the asset
  88750. * @param node The glTF node property
  88751. * @param assign A function called synchronously after parsing the glTF properties
  88752. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  88753. */
  88754. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88755. /**
  88756. * Define this method to modify the default behavior when loading cameras.
  88757. * @param context The context when loading the asset
  88758. * @param camera The glTF camera property
  88759. * @param assign A function called synchronously after parsing the glTF properties
  88760. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  88761. */
  88762. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  88763. /**
  88764. * @hidden
  88765. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  88766. * @param context The context when loading the asset
  88767. * @param primitive The glTF mesh primitive property
  88768. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  88769. */
  88770. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  88771. /**
  88772. * @hidden
  88773. * Define this method to modify the default behavior when loading data for mesh primitives.
  88774. * @param context The context when loading the asset
  88775. * @param name The mesh name when loading the asset
  88776. * @param node The glTF node when loading the asset
  88777. * @param mesh The glTF mesh when loading the asset
  88778. * @param primitive The glTF mesh primitive property
  88779. * @param assign A function called synchronously after parsing the glTF properties
  88780. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  88781. */
  88782. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  88783. /**
  88784. * @hidden
  88785. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  88786. * @param context The context when loading the asset
  88787. * @param material The glTF material property
  88788. * @param assign A function called synchronously after parsing the glTF properties
  88789. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  88790. */
  88791. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  88792. /**
  88793. * Define this method to modify the default behavior when creating materials.
  88794. * @param context The context when loading the asset
  88795. * @param material The glTF material property
  88796. * @param babylonDrawMode The draw mode for the Babylon material
  88797. * @returns The Babylon material or null if not handled
  88798. */
  88799. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  88800. /**
  88801. * Define this method to modify the default behavior when loading material properties.
  88802. * @param context The context when loading the asset
  88803. * @param material The glTF material property
  88804. * @param babylonMaterial The Babylon material
  88805. * @returns A promise that resolves when the load is complete or null if not handled
  88806. */
  88807. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88808. /**
  88809. * Define this method to modify the default behavior when loading texture infos.
  88810. * @param context The context when loading the asset
  88811. * @param textureInfo The glTF texture info 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. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88816. /**
  88817. * @hidden
  88818. * Define this method to modify the default behavior when loading textures.
  88819. * @param context The context when loading the asset
  88820. * @param texture The glTF texture property
  88821. * @param assign A function called synchronously after parsing the glTF properties
  88822. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  88823. */
  88824. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88825. /**
  88826. * Define this method to modify the default behavior when loading animations.
  88827. * @param context The context when loading the asset
  88828. * @param animation The glTF animation property
  88829. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  88830. */
  88831. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  88832. /**
  88833. * @hidden
  88834. * Define this method to modify the default behavior when loading skins.
  88835. * @param context The context when loading the asset
  88836. * @param node The glTF node property
  88837. * @param skin The glTF skin property
  88838. * @returns A promise that resolves when the load is complete or null if not handled
  88839. */
  88840. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  88841. /**
  88842. * @hidden
  88843. * Define this method to modify the default behavior when loading uris.
  88844. * @param context The context when loading the asset
  88845. * @param property The glTF property associated with the uri
  88846. * @param uri The uri to load
  88847. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  88848. */
  88849. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  88850. /**
  88851. * Define this method to modify the default behavior when loading buffer views.
  88852. * @param context The context when loading the asset
  88853. * @param bufferView The glTF buffer view property
  88854. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  88855. */
  88856. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  88857. /**
  88858. * Define this method to modify the default behavior when loading buffers.
  88859. * @param context The context when loading the asset
  88860. * @param buffer The glTF buffer property
  88861. * @param byteOffset The byte offset to load
  88862. * @param byteLength The byte length to load
  88863. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  88864. */
  88865. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  88866. }
  88867. }
  88868. declare module BABYLON.GLTF2 {
  88869. /**
  88870. * Helper class for working with arrays when loading the glTF asset
  88871. */
  88872. export class ArrayItem {
  88873. /**
  88874. * Gets an item from the given array.
  88875. * @param context The context when loading the asset
  88876. * @param array The array to get the item from
  88877. * @param index The index to the array
  88878. * @returns The array item
  88879. */
  88880. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  88881. /**
  88882. * Assign an `index` field to each item of the given array.
  88883. * @param array The array of items
  88884. */
  88885. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  88886. }
  88887. /**
  88888. * The glTF 2.0 loader
  88889. */
  88890. export class GLTFLoader implements IGLTFLoader {
  88891. /** @hidden */
  88892. _completePromises: Promise<any>[];
  88893. /** @hidden */
  88894. _forAssetContainer: boolean;
  88895. /** Storage */
  88896. _babylonLights: Light[];
  88897. /** @hidden */
  88898. _disableInstancedMesh: number;
  88899. private _disposed;
  88900. private _parent;
  88901. private _state;
  88902. private _extensions;
  88903. private _rootUrl;
  88904. private _fileName;
  88905. private _uniqueRootUrl;
  88906. private _gltf;
  88907. private _bin;
  88908. private _babylonScene;
  88909. private _rootBabylonMesh;
  88910. private _defaultBabylonMaterialData;
  88911. private static _RegisteredExtensions;
  88912. /**
  88913. * The default glTF sampler.
  88914. */
  88915. static readonly DefaultSampler: ISampler;
  88916. /**
  88917. * Registers a loader extension.
  88918. * @param name The name of the loader extension.
  88919. * @param factory The factory function that creates the loader extension.
  88920. */
  88921. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  88922. /**
  88923. * Unregisters a loader extension.
  88924. * @param name The name of the loader extension.
  88925. * @returns A boolean indicating whether the extension has been unregistered
  88926. */
  88927. static UnregisterExtension(name: string): boolean;
  88928. /**
  88929. * The loader state.
  88930. */
  88931. get state(): Nullable<GLTFLoaderState>;
  88932. /**
  88933. * The object that represents the glTF JSON.
  88934. */
  88935. get gltf(): IGLTF;
  88936. /**
  88937. * The BIN chunk of a binary glTF.
  88938. */
  88939. get bin(): Nullable<IDataBuffer>;
  88940. /**
  88941. * The parent file loader.
  88942. */
  88943. get parent(): GLTFFileLoader;
  88944. /**
  88945. * The Babylon scene when loading the asset.
  88946. */
  88947. get babylonScene(): Scene;
  88948. /**
  88949. * The root Babylon mesh when loading the asset.
  88950. */
  88951. get rootBabylonMesh(): Mesh;
  88952. /** @hidden */
  88953. constructor(parent: GLTFFileLoader);
  88954. /** @hidden */
  88955. dispose(): void;
  88956. /** @hidden */
  88957. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  88958. /** @hidden */
  88959. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  88960. private _loadAsync;
  88961. private _loadData;
  88962. private _setupData;
  88963. private _loadExtensions;
  88964. private _checkExtensions;
  88965. private _setState;
  88966. private _createRootNode;
  88967. /**
  88968. * Loads a glTF scene.
  88969. * @param context The context when loading the asset
  88970. * @param scene The glTF scene property
  88971. * @returns A promise that resolves when the load is complete
  88972. */
  88973. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  88974. private _forEachPrimitive;
  88975. private _getGeometries;
  88976. private _getMeshes;
  88977. private _getTransformNodes;
  88978. private _getSkeletons;
  88979. private _getAnimationGroups;
  88980. private _startAnimations;
  88981. /**
  88982. * Loads a glTF node.
  88983. * @param context The context when loading the asset
  88984. * @param node The glTF node property
  88985. * @param assign A function called synchronously after parsing the glTF properties
  88986. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  88987. */
  88988. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  88989. private _loadMeshAsync;
  88990. /**
  88991. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  88992. * @param context The context when loading the asset
  88993. * @param name The mesh name when loading the asset
  88994. * @param node The glTF node when loading the asset
  88995. * @param mesh The glTF mesh when loading the asset
  88996. * @param primitive The glTF mesh primitive property
  88997. * @param assign A function called synchronously after parsing the glTF properties
  88998. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  88999. */
  89000. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  89001. private _loadVertexDataAsync;
  89002. private _createMorphTargets;
  89003. private _loadMorphTargetsAsync;
  89004. private _loadMorphTargetVertexDataAsync;
  89005. private static _LoadTransform;
  89006. private _loadSkinAsync;
  89007. private _loadBones;
  89008. private _loadBone;
  89009. private _loadSkinInverseBindMatricesDataAsync;
  89010. private _updateBoneMatrices;
  89011. private _getNodeMatrix;
  89012. /**
  89013. * Loads a glTF camera.
  89014. * @param context The context when loading the asset
  89015. * @param camera The glTF camera property
  89016. * @param assign A function called synchronously after parsing the glTF properties
  89017. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  89018. */
  89019. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  89020. private _loadAnimationsAsync;
  89021. /**
  89022. * Loads a glTF animation.
  89023. * @param context The context when loading the asset
  89024. * @param animation The glTF animation property
  89025. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  89026. */
  89027. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  89028. /**
  89029. * @hidden Loads a glTF animation channel.
  89030. * @param context The context when loading the asset
  89031. * @param animationContext The context of the animation when loading the asset
  89032. * @param animation The glTF animation property
  89033. * @param channel The glTF animation channel property
  89034. * @param babylonAnimationGroup The babylon animation group property
  89035. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  89036. * @returns A void promise when the channel load is complete
  89037. */
  89038. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  89039. private _loadAnimationSamplerAsync;
  89040. /**
  89041. * Loads a glTF buffer.
  89042. * @param context The context when loading the asset
  89043. * @param buffer The glTF buffer property
  89044. * @param byteOffset The byte offset to use
  89045. * @param byteLength The byte length to use
  89046. * @returns A promise that resolves with the loaded data when the load is complete
  89047. */
  89048. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  89049. /**
  89050. * Loads a glTF buffer view.
  89051. * @param context The context when loading the asset
  89052. * @param bufferView The glTF buffer view property
  89053. * @returns A promise that resolves with the loaded data when the load is complete
  89054. */
  89055. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  89056. private _loadAccessorAsync;
  89057. /** @hidden */
  89058. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  89059. private _loadIndicesAccessorAsync;
  89060. private _loadVertexBufferViewAsync;
  89061. private _loadVertexAccessorAsync;
  89062. private _loadMaterialMetallicRoughnessPropertiesAsync;
  89063. /** @hidden */
  89064. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  89065. private _createDefaultMaterial;
  89066. /**
  89067. * Creates a Babylon material from a glTF material.
  89068. * @param context The context when loading the asset
  89069. * @param material The glTF material property
  89070. * @param babylonDrawMode The draw mode for the Babylon material
  89071. * @returns The Babylon material
  89072. */
  89073. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  89074. /**
  89075. * Loads properties from a glTF material into a Babylon material.
  89076. * @param context The context when loading the asset
  89077. * @param material The glTF material property
  89078. * @param babylonMaterial The Babylon material
  89079. * @returns A promise that resolves when the load is complete
  89080. */
  89081. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  89082. /**
  89083. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  89084. * @param context The context when loading the asset
  89085. * @param material The glTF material property
  89086. * @param babylonMaterial The Babylon material
  89087. * @returns A promise that resolves when the load is complete
  89088. */
  89089. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  89090. /**
  89091. * Loads the alpha properties from a glTF material into a Babylon material.
  89092. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  89093. * @param context The context when loading the asset
  89094. * @param material The glTF material property
  89095. * @param babylonMaterial The Babylon material
  89096. */
  89097. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  89098. /**
  89099. * Loads a glTF texture info.
  89100. * @param context The context when loading the asset
  89101. * @param textureInfo The glTF texture info property
  89102. * @param assign A function called synchronously after parsing the glTF properties
  89103. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  89104. */
  89105. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  89106. /** @hidden */
  89107. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  89108. /** @hidden */
  89109. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  89110. private _loadSampler;
  89111. /**
  89112. * Loads a glTF image.
  89113. * @param context The context when loading the asset
  89114. * @param image The glTF image property
  89115. * @returns A promise that resolves with the loaded data when the load is complete
  89116. */
  89117. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  89118. /**
  89119. * Loads a glTF uri.
  89120. * @param context The context when loading the asset
  89121. * @param property The glTF property associated with the uri
  89122. * @param uri The base64 or relative uri
  89123. * @returns A promise that resolves with the loaded data when the load is complete
  89124. */
  89125. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  89126. /**
  89127. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  89128. * @param babylonObject the Babylon object with metadata
  89129. * @param pointer the JSON pointer
  89130. */
  89131. static AddPointerMetadata(babylonObject: {
  89132. metadata: any;
  89133. }, pointer: string): void;
  89134. private static _GetTextureWrapMode;
  89135. private static _GetTextureSamplingMode;
  89136. private static _GetTypedArrayConstructor;
  89137. private static _GetTypedArray;
  89138. private static _GetNumComponents;
  89139. private static _ValidateUri;
  89140. /** @hidden */
  89141. static _GetDrawMode(context: string, mode: number | undefined): number;
  89142. private _compileMaterialsAsync;
  89143. private _compileShadowGeneratorsAsync;
  89144. private _forEachExtensions;
  89145. private _applyExtensions;
  89146. private _extensionsOnLoading;
  89147. private _extensionsOnReady;
  89148. private _extensionsLoadSceneAsync;
  89149. private _extensionsLoadNodeAsync;
  89150. private _extensionsLoadCameraAsync;
  89151. private _extensionsLoadVertexDataAsync;
  89152. private _extensionsLoadMeshPrimitiveAsync;
  89153. private _extensionsLoadMaterialAsync;
  89154. private _extensionsCreateMaterial;
  89155. private _extensionsLoadMaterialPropertiesAsync;
  89156. private _extensionsLoadTextureInfoAsync;
  89157. private _extensionsLoadTextureAsync;
  89158. private _extensionsLoadAnimationAsync;
  89159. private _extensionsLoadSkinAsync;
  89160. private _extensionsLoadUriAsync;
  89161. private _extensionsLoadBufferViewAsync;
  89162. private _extensionsLoadBufferAsync;
  89163. /**
  89164. * Helper method called by a loader extension to load an glTF extension.
  89165. * @param context The context when loading the asset
  89166. * @param property The glTF property to load the extension 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 extension does not exist
  89170. */
  89171. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  89172. /**
  89173. * Helper method called by a loader extension to load a glTF extra.
  89174. * @param context The context when loading the asset
  89175. * @param property The glTF property to load the extra from
  89176. * @param extensionName The name of the extension to load
  89177. * @param actionAsync The action to run
  89178. * @returns The promise returned by actionAsync or null if the extra does not exist
  89179. */
  89180. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  89181. /**
  89182. * Checks for presence of an extension.
  89183. * @param name The name of the extension to check
  89184. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  89185. */
  89186. isExtensionUsed(name: string): boolean;
  89187. /**
  89188. * Increments the indentation level and logs a message.
  89189. * @param message The message to log
  89190. */
  89191. logOpen(message: string): void;
  89192. /**
  89193. * Decrements the indentation level.
  89194. */
  89195. logClose(): void;
  89196. /**
  89197. * Logs a message
  89198. * @param message The message to log
  89199. */
  89200. log(message: string): void;
  89201. /**
  89202. * Starts a performance counter.
  89203. * @param counterName The name of the performance counter
  89204. */
  89205. startPerformanceCounter(counterName: string): void;
  89206. /**
  89207. * Ends a performance counter.
  89208. * @param counterName The name of the performance counter
  89209. */
  89210. endPerformanceCounter(counterName: string): void;
  89211. }
  89212. }
  89213. declare module BABYLON.GLTF2.Loader.Extensions {
  89214. /** @hidden */
  89215. interface IEXTLightsImageBased_LightImageBased {
  89216. _babylonTexture?: BaseTexture;
  89217. _loaded?: Promise<void>;
  89218. }
  89219. /**
  89220. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  89221. */
  89222. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  89223. /**
  89224. * The name of this extension.
  89225. */
  89226. readonly name: string;
  89227. /**
  89228. * Defines whether this extension is enabled.
  89229. */
  89230. enabled: boolean;
  89231. private _loader;
  89232. private _lights?;
  89233. /** @hidden */
  89234. constructor(loader: GLTFLoader);
  89235. /** @hidden */
  89236. dispose(): void;
  89237. /** @hidden */
  89238. onLoading(): void;
  89239. /** @hidden */
  89240. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  89241. private _loadLightAsync;
  89242. }
  89243. }
  89244. declare module BABYLON.GLTF2.Loader.Extensions {
  89245. /**
  89246. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  89247. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  89248. * !!! Experimental Extension Subject to Changes !!!
  89249. */
  89250. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  89251. /**
  89252. * The name of this extension.
  89253. */
  89254. readonly name: string;
  89255. /**
  89256. * Defines whether this extension is enabled.
  89257. */
  89258. enabled: boolean;
  89259. private _loader;
  89260. /** @hidden */
  89261. constructor(loader: GLTFLoader);
  89262. /** @hidden */
  89263. dispose(): void;
  89264. /** @hidden */
  89265. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  89266. }
  89267. }
  89268. declare module BABYLON.GLTF2.Loader.Extensions {
  89269. /**
  89270. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_meshopt_compression)
  89271. *
  89272. * This extension uses a WebAssembly decoder module from https://github.com/zeux/meshoptimizer/tree/master/js
  89273. */
  89274. export class EXT_meshopt_compression implements IGLTFLoaderExtension {
  89275. /**
  89276. * The name of this extension.
  89277. */
  89278. readonly name: string;
  89279. /**
  89280. * Defines whether this extension is enabled.
  89281. */
  89282. enabled: boolean;
  89283. /**
  89284. * Path to decoder module; defaults to https://preview.babylonjs.com/meshopt_decoder.js
  89285. */
  89286. static DecoderPath: string;
  89287. private _loader;
  89288. private _decoderPromise?;
  89289. /** @hidden */
  89290. constructor(loader: GLTFLoader);
  89291. /** @hidden */
  89292. dispose(): void;
  89293. /** @hidden */
  89294. loadBufferViewAsync(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  89295. }
  89296. }
  89297. declare module BABYLON.GLTF2.Loader.Extensions {
  89298. /**
  89299. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  89300. */
  89301. export class EXT_texture_webp implements IGLTFLoaderExtension {
  89302. /** The name of this extension. */
  89303. readonly name: string;
  89304. /** Defines whether this extension is enabled. */
  89305. enabled: boolean;
  89306. private _loader;
  89307. /** @hidden */
  89308. constructor(loader: GLTFLoader);
  89309. /** @hidden */
  89310. dispose(): void;
  89311. /** @hidden */
  89312. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  89313. }
  89314. }
  89315. declare module BABYLON.GLTF2.Loader.Extensions {
  89316. /**
  89317. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  89318. */
  89319. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  89320. /**
  89321. * The name of this extension.
  89322. */
  89323. readonly name: string;
  89324. /**
  89325. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  89326. */
  89327. dracoCompression?: DracoCompression;
  89328. /**
  89329. * Defines whether this extension is enabled.
  89330. */
  89331. enabled: boolean;
  89332. private _loader;
  89333. /** @hidden */
  89334. constructor(loader: GLTFLoader);
  89335. /** @hidden */
  89336. dispose(): void;
  89337. /** @hidden */
  89338. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  89339. }
  89340. }
  89341. declare module BABYLON.GLTF2.Loader.Extensions {
  89342. /**
  89343. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  89344. */
  89345. export class KHR_lights implements IGLTFLoaderExtension {
  89346. /**
  89347. * The name of this extension.
  89348. */
  89349. readonly name: string;
  89350. /**
  89351. * Defines whether this extension is enabled.
  89352. */
  89353. enabled: boolean;
  89354. private _loader;
  89355. private _lights?;
  89356. /** @hidden */
  89357. constructor(loader: GLTFLoader);
  89358. /** @hidden */
  89359. dispose(): void;
  89360. /** @hidden */
  89361. onLoading(): void;
  89362. /** @hidden */
  89363. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  89364. }
  89365. }
  89366. declare module BABYLON.GLTF2.Loader.Extensions {
  89367. /**
  89368. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  89369. */
  89370. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  89371. /**
  89372. * The name of this extension.
  89373. */
  89374. readonly name: string;
  89375. /**
  89376. * Defines whether this extension is enabled.
  89377. */
  89378. enabled: boolean;
  89379. /**
  89380. * Defines a number that determines the order the extensions are applied.
  89381. */
  89382. order: number;
  89383. private _loader;
  89384. /** @hidden */
  89385. constructor(loader: GLTFLoader);
  89386. /** @hidden */
  89387. dispose(): void;
  89388. /** @hidden */
  89389. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89390. private _loadSpecularGlossinessPropertiesAsync;
  89391. }
  89392. }
  89393. declare module BABYLON.GLTF2.Loader.Extensions {
  89394. /**
  89395. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  89396. */
  89397. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  89398. /**
  89399. * The name of this extension.
  89400. */
  89401. readonly name: string;
  89402. /**
  89403. * Defines whether this extension is enabled.
  89404. */
  89405. enabled: boolean;
  89406. /**
  89407. * Defines a number that determines the order the extensions are applied.
  89408. */
  89409. order: number;
  89410. private _loader;
  89411. /** @hidden */
  89412. constructor(loader: GLTFLoader);
  89413. /** @hidden */
  89414. dispose(): void;
  89415. /** @hidden */
  89416. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89417. private _loadUnlitPropertiesAsync;
  89418. }
  89419. }
  89420. declare module BABYLON.GLTF2.Loader.Extensions {
  89421. /**
  89422. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  89423. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  89424. */
  89425. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  89426. /**
  89427. * The name of this extension.
  89428. */
  89429. readonly name: string;
  89430. /**
  89431. * Defines whether this extension is enabled.
  89432. */
  89433. enabled: boolean;
  89434. /**
  89435. * Defines a number that determines the order the extensions are applied.
  89436. */
  89437. order: number;
  89438. private _loader;
  89439. /** @hidden */
  89440. constructor(loader: GLTFLoader);
  89441. /** @hidden */
  89442. dispose(): void;
  89443. /** @hidden */
  89444. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89445. private _loadClearCoatPropertiesAsync;
  89446. }
  89447. }
  89448. declare module BABYLON.GLTF2.Loader.Extensions {
  89449. /**
  89450. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_sheen/README.md)
  89451. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  89452. * !!! Experimental Extension Subject to Changes !!!
  89453. */
  89454. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  89455. /**
  89456. * The name of this extension.
  89457. */
  89458. readonly name: string;
  89459. /**
  89460. * Defines whether this extension is enabled.
  89461. */
  89462. enabled: boolean;
  89463. /**
  89464. * Defines a number that determines the order the extensions are applied.
  89465. */
  89466. order: number;
  89467. private _loader;
  89468. /** @hidden */
  89469. constructor(loader: GLTFLoader);
  89470. /** @hidden */
  89471. dispose(): void;
  89472. /** @hidden */
  89473. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89474. private _loadSheenPropertiesAsync;
  89475. }
  89476. }
  89477. declare module BABYLON.GLTF2.Loader.Extensions {
  89478. /**
  89479. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  89480. * !!! Experimental Extension Subject to Changes !!!
  89481. */
  89482. export class KHR_materials_specular implements IGLTFLoaderExtension {
  89483. /**
  89484. * The name of this extension.
  89485. */
  89486. readonly name: string;
  89487. /**
  89488. * Defines whether this extension is enabled.
  89489. */
  89490. enabled: boolean;
  89491. /**
  89492. * Defines a number that determines the order the extensions are applied.
  89493. */
  89494. order: number;
  89495. private _loader;
  89496. /** @hidden */
  89497. constructor(loader: GLTFLoader);
  89498. /** @hidden */
  89499. dispose(): void;
  89500. /** @hidden */
  89501. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89502. private _loadSpecularPropertiesAsync;
  89503. }
  89504. }
  89505. declare module BABYLON.GLTF2.Loader.Extensions {
  89506. /**
  89507. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  89508. * !!! Experimental Extension Subject to Changes !!!
  89509. */
  89510. export class KHR_materials_ior implements IGLTFLoaderExtension {
  89511. /**
  89512. * Default ior Value from the spec.
  89513. */
  89514. private static readonly _DEFAULT_IOR;
  89515. /**
  89516. * The name of this extension.
  89517. */
  89518. readonly name: string;
  89519. /**
  89520. * Defines whether this extension is enabled.
  89521. */
  89522. enabled: boolean;
  89523. /**
  89524. * Defines a number that determines the order the extensions are applied.
  89525. */
  89526. order: number;
  89527. private _loader;
  89528. /** @hidden */
  89529. constructor(loader: GLTFLoader);
  89530. /** @hidden */
  89531. dispose(): void;
  89532. /** @hidden */
  89533. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89534. private _loadIorPropertiesAsync;
  89535. }
  89536. }
  89537. declare module BABYLON.GLTF2.Loader.Extensions {
  89538. /**
  89539. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_variants/README.md)
  89540. */
  89541. export class KHR_materials_variants implements IGLTFLoaderExtension {
  89542. /**
  89543. * The name of this extension.
  89544. */
  89545. readonly name: string;
  89546. /**
  89547. * Defines whether this extension is enabled.
  89548. */
  89549. enabled: boolean;
  89550. private _loader;
  89551. private _variants?;
  89552. /** @hidden */
  89553. constructor(loader: GLTFLoader);
  89554. /** @hidden */
  89555. dispose(): void;
  89556. /**
  89557. * Gets the list of available variant names for this asset.
  89558. * @param rootMesh The glTF root mesh
  89559. * @returns the list of all the variant names for this model
  89560. */
  89561. static GetAvailableVariants(rootMesh: Mesh): string[];
  89562. /**
  89563. * Gets the list of available variant names for this asset.
  89564. * @param rootMesh The glTF root mesh
  89565. * @returns the list of all the variant names for this model
  89566. */
  89567. getAvailableVariants(rootMesh: Mesh): string[];
  89568. /**
  89569. * Select a variant given a variant name or a list of variant names.
  89570. * @param rootMesh The glTF root mesh
  89571. * @param variantName The variant name(s) to select.
  89572. */
  89573. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  89574. /**
  89575. * Select a variant given a variant name or a list of variant names.
  89576. * @param rootMesh The glTF root mesh
  89577. * @param variantName The variant name(s) to select.
  89578. */
  89579. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  89580. /**
  89581. * Reset back to the original before selecting a variant.
  89582. * @param rootMesh The glTF root mesh
  89583. */
  89584. static Reset(rootMesh: Mesh): void;
  89585. /**
  89586. * Reset back to the original before selecting a variant.
  89587. * @param rootMesh The glTF root mesh
  89588. */
  89589. reset(rootMesh: Mesh): void;
  89590. /**
  89591. * Gets the last selected variant name(s) or null if original.
  89592. * @param rootMesh The glTF root mesh
  89593. * @returns The selected variant name(s).
  89594. */
  89595. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  89596. /**
  89597. * Gets the last selected variant name(s) or null if original.
  89598. * @param rootMesh The glTF root mesh
  89599. * @returns The selected variant name(s).
  89600. */
  89601. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  89602. private static _GetExtensionMetadata;
  89603. /** @hidden */
  89604. onLoading(): void;
  89605. /** @hidden */
  89606. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  89607. }
  89608. }
  89609. declare module BABYLON.GLTF2.Loader.Extensions {
  89610. /**
  89611. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_transmission/README.md)
  89612. */
  89613. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  89614. /**
  89615. * The name of this extension.
  89616. */
  89617. readonly name: string;
  89618. /**
  89619. * Defines whether this extension is enabled.
  89620. */
  89621. enabled: boolean;
  89622. /**
  89623. * Defines a number that determines the order the extensions are applied.
  89624. */
  89625. order: number;
  89626. private _loader;
  89627. /** @hidden */
  89628. constructor(loader: GLTFLoader);
  89629. /** @hidden */
  89630. dispose(): void;
  89631. /** @hidden */
  89632. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89633. private _loadTransparentPropertiesAsync;
  89634. }
  89635. }
  89636. declare module BABYLON.GLTF2.Loader.Extensions {
  89637. /**
  89638. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)
  89639. * !!! Experimental Extension Subject to Changes !!!
  89640. */
  89641. export class KHR_materials_translucency implements IGLTFLoaderExtension {
  89642. /**
  89643. * The name of this extension.
  89644. */
  89645. readonly name: string;
  89646. /**
  89647. * Defines whether this extension is enabled.
  89648. */
  89649. enabled: boolean;
  89650. /**
  89651. * Defines a number that determines the order the extensions are applied.
  89652. */
  89653. order: number;
  89654. private _loader;
  89655. /** @hidden */
  89656. constructor(loader: GLTFLoader);
  89657. /** @hidden */
  89658. dispose(): void;
  89659. /** @hidden */
  89660. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89661. private _loadTranslucentPropertiesAsync;
  89662. }
  89663. }
  89664. declare module BABYLON.GLTF2.Loader.Extensions {
  89665. /**
  89666. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  89667. */
  89668. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  89669. /**
  89670. * The name of this extension.
  89671. */
  89672. readonly name: string;
  89673. /**
  89674. * Defines whether this extension is enabled.
  89675. */
  89676. enabled: boolean;
  89677. /** @hidden */
  89678. constructor(loader: GLTFLoader);
  89679. /** @hidden */
  89680. dispose(): void;
  89681. }
  89682. }
  89683. declare module BABYLON.GLTF2.Loader.Extensions {
  89684. /**
  89685. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  89686. * !!! Experimental Extension Subject to Changes !!!
  89687. */
  89688. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  89689. /** The name of this extension. */
  89690. readonly name: string;
  89691. /** Defines whether this extension is enabled. */
  89692. enabled: boolean;
  89693. private _loader;
  89694. /** @hidden */
  89695. constructor(loader: GLTFLoader);
  89696. /** @hidden */
  89697. dispose(): void;
  89698. /** @hidden */
  89699. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  89700. }
  89701. }
  89702. declare module BABYLON.GLTF2.Loader.Extensions {
  89703. /**
  89704. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  89705. */
  89706. export class KHR_texture_transform implements IGLTFLoaderExtension {
  89707. /**
  89708. * The name of this extension.
  89709. */
  89710. readonly name: string;
  89711. /**
  89712. * Defines whether this extension is enabled.
  89713. */
  89714. enabled: boolean;
  89715. private _loader;
  89716. /** @hidden */
  89717. constructor(loader: GLTFLoader);
  89718. /** @hidden */
  89719. dispose(): void;
  89720. /** @hidden */
  89721. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  89722. }
  89723. }
  89724. declare module BABYLON.GLTF2.Loader.Extensions {
  89725. /**
  89726. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1893)
  89727. * !!! Experimental Extension Subject to Changes !!!
  89728. */
  89729. export class KHR_xmp_json_ld implements IGLTFLoaderExtension {
  89730. /**
  89731. * The name of this extension.
  89732. */
  89733. readonly name: string;
  89734. /**
  89735. * Defines whether this extension is enabled.
  89736. */
  89737. enabled: boolean;
  89738. /**
  89739. * Defines a number that determines the order the extensions are applied.
  89740. */
  89741. order: number;
  89742. private _loader;
  89743. /** @hidden */
  89744. constructor(loader: GLTFLoader);
  89745. /** @hidden */
  89746. dispose(): void;
  89747. /**
  89748. * Called after the loader state changes to LOADING.
  89749. */
  89750. onLoading(): void;
  89751. }
  89752. }
  89753. declare module BABYLON.GLTF2.Loader.Extensions {
  89754. /**
  89755. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  89756. */
  89757. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  89758. /**
  89759. * The name of this extension.
  89760. */
  89761. readonly name: string;
  89762. /**
  89763. * Defines whether this extension is enabled.
  89764. */
  89765. enabled: boolean;
  89766. private _loader;
  89767. private _clips;
  89768. private _emitters;
  89769. /** @hidden */
  89770. constructor(loader: GLTFLoader);
  89771. /** @hidden */
  89772. dispose(): void;
  89773. /** @hidden */
  89774. onLoading(): void;
  89775. /** @hidden */
  89776. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  89777. /** @hidden */
  89778. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  89779. /** @hidden */
  89780. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  89781. private _loadClipAsync;
  89782. private _loadEmitterAsync;
  89783. private _getEventAction;
  89784. private _loadAnimationEventAsync;
  89785. }
  89786. }
  89787. declare module BABYLON.GLTF2.Loader.Extensions {
  89788. /**
  89789. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  89790. */
  89791. export class MSFT_lod implements IGLTFLoaderExtension {
  89792. /**
  89793. * The name of this extension.
  89794. */
  89795. readonly name: string;
  89796. /**
  89797. * Defines whether this extension is enabled.
  89798. */
  89799. enabled: boolean;
  89800. /**
  89801. * Defines a number that determines the order the extensions are applied.
  89802. */
  89803. order: number;
  89804. /**
  89805. * Maximum number of LODs to load, starting from the lowest LOD.
  89806. */
  89807. maxLODsToLoad: number;
  89808. /**
  89809. * Observable raised when all node LODs of one level are loaded.
  89810. * The event data is the index of the loaded LOD starting from zero.
  89811. * Dispose the loader to cancel the loading of the next level of LODs.
  89812. */
  89813. onNodeLODsLoadedObservable: Observable<number>;
  89814. /**
  89815. * Observable raised when all material LODs of one level are loaded.
  89816. * The event data is the index of the loaded LOD starting from zero.
  89817. * Dispose the loader to cancel the loading of the next level of LODs.
  89818. */
  89819. onMaterialLODsLoadedObservable: Observable<number>;
  89820. private _loader;
  89821. private _bufferLODs;
  89822. private _nodeIndexLOD;
  89823. private _nodeSignalLODs;
  89824. private _nodePromiseLODs;
  89825. private _nodeBufferLODs;
  89826. private _materialIndexLOD;
  89827. private _materialSignalLODs;
  89828. private _materialPromiseLODs;
  89829. private _materialBufferLODs;
  89830. /** @hidden */
  89831. constructor(loader: GLTFLoader);
  89832. /** @hidden */
  89833. dispose(): void;
  89834. /** @hidden */
  89835. onReady(): void;
  89836. /** @hidden */
  89837. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  89838. /** @hidden */
  89839. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  89840. /** @hidden */
  89841. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  89842. /** @hidden */
  89843. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  89844. /** @hidden */
  89845. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  89846. private _loadBufferLOD;
  89847. /**
  89848. * Gets an array of LOD properties from lowest to highest.
  89849. */
  89850. private _getLODs;
  89851. private _disposeTransformNode;
  89852. private _disposeMaterials;
  89853. }
  89854. }
  89855. declare module BABYLON.GLTF2.Loader.Extensions {
  89856. /** @hidden */
  89857. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  89858. readonly name: string;
  89859. enabled: boolean;
  89860. private _loader;
  89861. constructor(loader: GLTFLoader);
  89862. dispose(): void;
  89863. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89864. }
  89865. }
  89866. declare module BABYLON.GLTF2.Loader.Extensions {
  89867. /** @hidden */
  89868. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  89869. readonly name: string;
  89870. enabled: boolean;
  89871. private _loader;
  89872. constructor(loader: GLTFLoader);
  89873. dispose(): void;
  89874. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89875. }
  89876. }
  89877. declare module BABYLON.GLTF2.Loader.Extensions {
  89878. /**
  89879. * Store glTF extras (if present) in BJS objects' metadata
  89880. */
  89881. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  89882. /**
  89883. * The name of this extension.
  89884. */
  89885. readonly name: string;
  89886. /**
  89887. * Defines whether this extension is enabled.
  89888. */
  89889. enabled: boolean;
  89890. private _loader;
  89891. private _assignExtras;
  89892. /** @hidden */
  89893. constructor(loader: GLTFLoader);
  89894. /** @hidden */
  89895. dispose(): void;
  89896. /** @hidden */
  89897. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  89898. /** @hidden */
  89899. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  89900. /** @hidden */
  89901. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  89902. }
  89903. }
  89904. declare module BABYLON {
  89905. /**
  89906. * Class reading and parsing the MTL file bundled with the obj file.
  89907. */
  89908. export class MTLFileLoader {
  89909. /**
  89910. * Invert Y-Axis of referenced textures on load
  89911. */
  89912. static INVERT_TEXTURE_Y: boolean;
  89913. /**
  89914. * All material loaded from the mtl will be set here
  89915. */
  89916. materials: StandardMaterial[];
  89917. /**
  89918. * This function will read the mtl file and create each material described inside
  89919. * This function could be improve by adding :
  89920. * -some component missing (Ni, Tf...)
  89921. * -including the specific options available
  89922. *
  89923. * @param scene defines the scene the material will be created in
  89924. * @param data defines the mtl data to parse
  89925. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  89926. * @param forAssetContainer defines if the material should be registered in the scene
  89927. */
  89928. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  89929. /**
  89930. * Gets the texture for the material.
  89931. *
  89932. * If the material is imported from input file,
  89933. * We sanitize the url to ensure it takes the textre from aside the material.
  89934. *
  89935. * @param rootUrl The root url to load from
  89936. * @param value The value stored in the mtl
  89937. * @return The Texture
  89938. */
  89939. private static _getTexture;
  89940. }
  89941. }
  89942. declare module BABYLON {
  89943. /**
  89944. * Options for loading OBJ/MTL files
  89945. */
  89946. type MeshLoadOptions = {
  89947. /**
  89948. * Defines if UVs are optimized by default during load.
  89949. */
  89950. OptimizeWithUV: boolean;
  89951. /**
  89952. * Defines custom scaling of UV coordinates of loaded meshes.
  89953. */
  89954. UVScaling: Vector2;
  89955. /**
  89956. * Invert model on y-axis (does a model scaling inversion)
  89957. */
  89958. InvertY: boolean;
  89959. /**
  89960. * Invert Y-Axis of referenced textures on load
  89961. */
  89962. InvertTextureY: boolean;
  89963. /**
  89964. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  89965. */
  89966. ImportVertexColors: boolean;
  89967. /**
  89968. * Compute the normals for the model, even if normals are present in the file.
  89969. */
  89970. ComputeNormals: boolean;
  89971. /**
  89972. * 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.
  89973. * Using OptimizehNormals = true will help smoothing the lighting by averaging the normals of those vertices.
  89974. */
  89975. OptimizeNormals: boolean;
  89976. /**
  89977. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  89978. */
  89979. SkipMaterials: boolean;
  89980. /**
  89981. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  89982. */
  89983. MaterialLoadingFailsSilently: boolean;
  89984. };
  89985. /**
  89986. * OBJ file type loader.
  89987. * This is a babylon scene loader plugin.
  89988. */
  89989. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  89990. /**
  89991. * Defines if UVs are optimized by default during load.
  89992. */
  89993. static OPTIMIZE_WITH_UV: boolean;
  89994. /**
  89995. * Invert model on y-axis (does a model scaling inversion)
  89996. */
  89997. static INVERT_Y: boolean;
  89998. /**
  89999. * Invert Y-Axis of referenced textures on load
  90000. */
  90001. static get INVERT_TEXTURE_Y(): boolean;
  90002. static set INVERT_TEXTURE_Y(value: boolean);
  90003. /**
  90004. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  90005. */
  90006. static IMPORT_VERTEX_COLORS: boolean;
  90007. /**
  90008. * Compute the normals for the model, even if normals are present in the file.
  90009. */
  90010. static COMPUTE_NORMALS: boolean;
  90011. /**
  90012. * 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.
  90013. * Using OptimizehNormals = true will help smoothing the lighting by averaging the normals of those vertices.
  90014. */
  90015. static OPTIMIZE_NORMALS: boolean;
  90016. /**
  90017. * Defines custom scaling of UV coordinates of loaded meshes.
  90018. */
  90019. static UV_SCALING: Vector2;
  90020. /**
  90021. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  90022. */
  90023. static SKIP_MATERIALS: boolean;
  90024. /**
  90025. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  90026. *
  90027. * Defaults to true for backwards compatibility.
  90028. */
  90029. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  90030. /**
  90031. * Defines the name of the plugin.
  90032. */
  90033. name: string;
  90034. /**
  90035. * Defines the extension the plugin is able to load.
  90036. */
  90037. extensions: string;
  90038. /** @hidden */
  90039. obj: RegExp;
  90040. /** @hidden */
  90041. group: RegExp;
  90042. /** @hidden */
  90043. mtllib: RegExp;
  90044. /** @hidden */
  90045. usemtl: RegExp;
  90046. /** @hidden */
  90047. smooth: RegExp;
  90048. /** @hidden */
  90049. vertexPattern: RegExp;
  90050. /** @hidden */
  90051. normalPattern: RegExp;
  90052. /** @hidden */
  90053. uvPattern: RegExp;
  90054. /** @hidden */
  90055. facePattern1: RegExp;
  90056. /** @hidden */
  90057. facePattern2: RegExp;
  90058. /** @hidden */
  90059. facePattern3: RegExp;
  90060. /** @hidden */
  90061. facePattern4: RegExp;
  90062. /** @hidden */
  90063. facePattern5: RegExp;
  90064. private _forAssetContainer;
  90065. private _meshLoadOptions;
  90066. /**
  90067. * Creates loader for .OBJ files
  90068. *
  90069. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  90070. */
  90071. constructor(meshLoadOptions?: MeshLoadOptions);
  90072. private static get currentMeshLoadOptions();
  90073. /**
  90074. * Calls synchronously the MTL file attached to this obj.
  90075. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  90076. * Without this function materials are not displayed in the first frame (but displayed after).
  90077. * In consequence it is impossible to get material information in your HTML file
  90078. *
  90079. * @param url The URL of the MTL file
  90080. * @param rootUrl
  90081. * @param onSuccess Callback function to be called when the MTL file is loaded
  90082. * @private
  90083. */
  90084. private _loadMTL;
  90085. /**
  90086. * Instantiates a OBJ file loader plugin.
  90087. * @returns the created plugin
  90088. */
  90089. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  90090. /**
  90091. * If the data string can be loaded directly.
  90092. *
  90093. * @param data string containing the file data
  90094. * @returns if the data can be loaded directly
  90095. */
  90096. canDirectLoad(data: string): boolean;
  90097. /**
  90098. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  90099. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  90100. * @param scene the scene the meshes should be added to
  90101. * @param data the OBJ data to load
  90102. * @param rootUrl root url to load from
  90103. * @param onProgress event that fires when loading progress has occured
  90104. * @param fileName Defines the name of the file to load
  90105. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  90106. */
  90107. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  90108. /**
  90109. * Imports all objects from the loaded OBJ data and adds them to the scene
  90110. * @param scene the scene the objects should be added to
  90111. * @param data the OBJ data to load
  90112. * @param rootUrl root url to load from
  90113. * @param onProgress event that fires when loading progress has occured
  90114. * @param fileName Defines the name of the file to load
  90115. * @returns a promise which completes when objects have been loaded to the scene
  90116. */
  90117. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  90118. /**
  90119. * Load into an asset container.
  90120. * @param scene The scene to load into
  90121. * @param data The data to import
  90122. * @param rootUrl The root url for scene and resources
  90123. * @param onProgress The callback when the load progresses
  90124. * @param fileName Defines the name of the file to load
  90125. * @returns The loaded asset container
  90126. */
  90127. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  90128. private _optimizeNormals;
  90129. /**
  90130. * Read the OBJ file and create an Array of meshes.
  90131. * Each mesh contains all information given by the OBJ and the MTL file.
  90132. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  90133. *
  90134. * @param meshesNames
  90135. * @param scene Scene The scene where are displayed the data
  90136. * @param data String The content of the obj file
  90137. * @param rootUrl String The path to the folder
  90138. * @returns Array<AbstractMesh>
  90139. * @private
  90140. */
  90141. private _parseSolid;
  90142. }
  90143. }
  90144. declare module BABYLON {
  90145. /**
  90146. * STL file type loader.
  90147. * This is a babylon scene loader plugin.
  90148. */
  90149. export class STLFileLoader implements ISceneLoaderPlugin {
  90150. /** @hidden */
  90151. solidPattern: RegExp;
  90152. /** @hidden */
  90153. facetsPattern: RegExp;
  90154. /** @hidden */
  90155. normalPattern: RegExp;
  90156. /** @hidden */
  90157. vertexPattern: RegExp;
  90158. /**
  90159. * Defines the name of the plugin.
  90160. */
  90161. name: string;
  90162. /**
  90163. * Defines the extensions the stl loader is able to load.
  90164. * force data to come in as an ArrayBuffer
  90165. * we'll convert to string if it looks like it's an ASCII .stl
  90166. */
  90167. extensions: ISceneLoaderPluginExtensions;
  90168. /**
  90169. * Import meshes into a scene.
  90170. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  90171. * @param scene The scene to import into
  90172. * @param data The data to import
  90173. * @param rootUrl The root url for scene and resources
  90174. * @param meshes The meshes array to import into
  90175. * @param particleSystems The particle systems array to import into
  90176. * @param skeletons The skeletons array to import into
  90177. * @param onError The callback when import fails
  90178. * @returns True if successful or false otherwise
  90179. */
  90180. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  90181. /**
  90182. * Load into a scene.
  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 true if successful or false otherwise
  90188. */
  90189. load(scene: Scene, data: any, rootUrl: string): boolean;
  90190. /**
  90191. * Load into an asset container.
  90192. * @param scene The scene to load into
  90193. * @param data The data to import
  90194. * @param rootUrl The root url for scene and resources
  90195. * @param onError The callback when import fails
  90196. * @returns The loaded asset container
  90197. */
  90198. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  90199. private _isBinary;
  90200. private _parseBinary;
  90201. private _parseASCII;
  90202. }
  90203. }
  90204. declare module BABYLON {
  90205. /**
  90206. * Class for generating OBJ data from a Babylon scene.
  90207. */
  90208. export class OBJExport {
  90209. /**
  90210. * Exports the geometry of a Mesh array in .OBJ file format (text)
  90211. * @param mesh defines the list of meshes to serialize
  90212. * @param materials defines if materials should be exported
  90213. * @param matlibname defines the name of the associated mtl file
  90214. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  90215. * @returns the OBJ content
  90216. */
  90217. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  90218. /**
  90219. * Exports the material(s) of a mesh in .MTL file format (text)
  90220. * @param mesh defines the mesh to extract the material from
  90221. * @returns the mtl content
  90222. */
  90223. static MTL(mesh: Mesh): string;
  90224. }
  90225. }
  90226. declare module BABYLON {
  90227. /** @hidden */
  90228. export var __IGLTFExporterExtension: number;
  90229. /**
  90230. * Interface for extending the exporter
  90231. * @hidden
  90232. */
  90233. export interface IGLTFExporterExtension {
  90234. /**
  90235. * The name of this extension
  90236. */
  90237. readonly name: string;
  90238. /**
  90239. * Defines whether this extension is enabled
  90240. */
  90241. enabled: boolean;
  90242. /**
  90243. * Defines whether this extension is required
  90244. */
  90245. required: boolean;
  90246. }
  90247. }
  90248. declare module BABYLON.GLTF2.Exporter {
  90249. /** @hidden */
  90250. export var __IGLTFExporterExtensionV2: number;
  90251. /**
  90252. * Interface for a glTF exporter extension
  90253. * @hidden
  90254. */
  90255. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  90256. /**
  90257. * Define this method to modify the default behavior before exporting a texture
  90258. * @param context The context when loading the asset
  90259. * @param babylonTexture The Babylon.js texture
  90260. * @param mimeType The mime-type of the generated image
  90261. * @returns A promise that resolves with the exported texture
  90262. */
  90263. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  90264. /**
  90265. * Define this method to get notified when a texture info is created
  90266. * @param context The context when loading the asset
  90267. * @param textureInfo The glTF texture info
  90268. * @param babylonTexture The Babylon.js texture
  90269. */
  90270. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  90271. /**
  90272. * Define this method to modify the default behavior when exporting texture info
  90273. * @param context The context when loading the asset
  90274. * @param meshPrimitive glTF mesh primitive
  90275. * @param babylonSubMesh Babylon submesh
  90276. * @param binaryWriter glTF serializer binary writer instance
  90277. * @returns nullable IMeshPrimitive promise
  90278. */
  90279. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  90280. /**
  90281. * Define this method to modify the default behavior when exporting a node
  90282. * @param context The context when exporting the node
  90283. * @param node glTF node
  90284. * @param babylonNode BabylonJS node
  90285. * @returns nullable INode promise
  90286. */
  90287. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  90288. [key: number]: number;
  90289. }): Promise<Nullable<INode>>;
  90290. /**
  90291. * Define this method to modify the default behavior when exporting a material
  90292. * @param material glTF material
  90293. * @param babylonMaterial BabylonJS material
  90294. * @returns nullable IMaterial promise
  90295. */
  90296. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  90297. /**
  90298. * Define this method to return additional textures to export from a material
  90299. * @param material glTF material
  90300. * @param babylonMaterial BabylonJS material
  90301. * @returns List of textures
  90302. */
  90303. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  90304. /** Gets a boolean indicating that this extension was used */
  90305. wasUsed: boolean;
  90306. /** Gets a boolean indicating that this extension is required for the file to work */
  90307. required: boolean;
  90308. /**
  90309. * Called after the exporter state changes to EXPORTING
  90310. */
  90311. onExporting?(): void;
  90312. }
  90313. }
  90314. declare module BABYLON.GLTF2.Exporter {
  90315. /**
  90316. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  90317. * @hidden
  90318. */
  90319. export class _GLTFMaterialExporter {
  90320. /**
  90321. * Represents the dielectric specular values for R, G and B
  90322. */
  90323. private static readonly _DielectricSpecular;
  90324. /**
  90325. * Allows the maximum specular power to be defined for material calculations
  90326. */
  90327. private static readonly _MaxSpecularPower;
  90328. /**
  90329. * Mapping to store textures
  90330. */
  90331. private _textureMap;
  90332. /**
  90333. * Numeric tolerance value
  90334. */
  90335. private static readonly _Epsilon;
  90336. /**
  90337. * Reference to the glTF Exporter
  90338. */
  90339. private _exporter;
  90340. constructor(exporter: _Exporter);
  90341. /**
  90342. * Specifies if two colors are approximately equal in value
  90343. * @param color1 first color to compare to
  90344. * @param color2 second color to compare to
  90345. * @param epsilon threshold value
  90346. */
  90347. private static FuzzyEquals;
  90348. /**
  90349. * Gets the materials from a Babylon scene and converts them to glTF materials
  90350. * @param scene babylonjs scene
  90351. * @param mimeType texture mime type
  90352. * @param images array of images
  90353. * @param textures array of textures
  90354. * @param materials array of materials
  90355. * @param imageData mapping of texture names to base64 textures
  90356. * @param hasTextureCoords specifies if texture coordinates are present on the material
  90357. */
  90358. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  90359. /**
  90360. * Makes a copy of the glTF material without the texture parameters
  90361. * @param originalMaterial original glTF material
  90362. * @returns glTF material without texture parameters
  90363. */
  90364. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  90365. /**
  90366. * Specifies if the material has any texture parameters present
  90367. * @param material glTF Material
  90368. * @returns boolean specifying if texture parameters are present
  90369. */
  90370. _hasTexturesPresent(material: IMaterial): boolean;
  90371. /**
  90372. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  90373. * @param babylonStandardMaterial
  90374. * @returns glTF Metallic Roughness Material representation
  90375. */
  90376. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  90377. /**
  90378. * Computes the metallic factor
  90379. * @param diffuse diffused value
  90380. * @param specular specular value
  90381. * @param oneMinusSpecularStrength one minus the specular strength
  90382. * @returns metallic value
  90383. */
  90384. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  90385. /**
  90386. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  90387. * @param glTFMaterial glTF material
  90388. * @param babylonMaterial Babylon material
  90389. */
  90390. private static _SetAlphaMode;
  90391. /**
  90392. * Converts a Babylon Standard Material to a glTF Material
  90393. * @param babylonStandardMaterial BJS Standard Material
  90394. * @param mimeType mime type to use for the textures
  90395. * @param images array of glTF image interfaces
  90396. * @param textures array of glTF texture interfaces
  90397. * @param materials array of glTF material interfaces
  90398. * @param imageData map of image file name to data
  90399. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  90400. */
  90401. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  90402. private _finishMaterial;
  90403. /**
  90404. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  90405. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  90406. * @param mimeType mime type to use for the textures
  90407. * @param images array of glTF image interfaces
  90408. * @param textures array of glTF texture interfaces
  90409. * @param materials array of glTF material interfaces
  90410. * @param imageData map of image file name to data
  90411. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  90412. */
  90413. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  90414. /**
  90415. * Converts an image typed array buffer to a base64 image
  90416. * @param buffer typed array buffer
  90417. * @param width width of the image
  90418. * @param height height of the image
  90419. * @param mimeType mimetype of the image
  90420. * @returns base64 image string
  90421. */
  90422. private _createBase64FromCanvasAsync;
  90423. /**
  90424. * Generates a white texture based on the specified width and height
  90425. * @param width width of the texture in pixels
  90426. * @param height height of the texture in pixels
  90427. * @param scene babylonjs scene
  90428. * @returns white texture
  90429. */
  90430. private _createWhiteTexture;
  90431. /**
  90432. * 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
  90433. * @param texture1 first texture to resize
  90434. * @param texture2 second texture to resize
  90435. * @param scene babylonjs scene
  90436. * @returns resized textures or null
  90437. */
  90438. private _resizeTexturesToSameDimensions;
  90439. /**
  90440. * Converts an array of pixels to a Float32Array
  90441. * Throws an error if the pixel format is not supported
  90442. * @param pixels - array buffer containing pixel values
  90443. * @returns Float32 of pixels
  90444. */
  90445. private _convertPixelArrayToFloat32;
  90446. /**
  90447. * Convert Specular Glossiness Textures to Metallic Roughness
  90448. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  90449. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  90450. * @param diffuseTexture texture used to store diffuse information
  90451. * @param specularGlossinessTexture texture used to store specular and glossiness information
  90452. * @param factors specular glossiness material factors
  90453. * @param mimeType the mime type to use for the texture
  90454. * @returns pbr metallic roughness interface or null
  90455. */
  90456. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  90457. /**
  90458. * Converts specular glossiness material properties to metallic roughness
  90459. * @param specularGlossiness interface with specular glossiness material properties
  90460. * @returns interface with metallic roughness material properties
  90461. */
  90462. private _convertSpecularGlossinessToMetallicRoughness;
  90463. /**
  90464. * Calculates the surface reflectance, independent of lighting conditions
  90465. * @param color Color source to calculate brightness from
  90466. * @returns number representing the perceived brightness, or zero if color is undefined
  90467. */
  90468. private _getPerceivedBrightness;
  90469. /**
  90470. * Returns the maximum color component value
  90471. * @param color
  90472. * @returns maximum color component value, or zero if color is null or undefined
  90473. */
  90474. private _getMaxComponent;
  90475. /**
  90476. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  90477. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  90478. * @param mimeType mime type to use for the textures
  90479. * @param images array of glTF image interfaces
  90480. * @param textures array of glTF texture interfaces
  90481. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  90482. * @param imageData map of image file name to data
  90483. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  90484. * @returns glTF PBR Metallic Roughness factors
  90485. */
  90486. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  90487. private _getGLTFTextureSampler;
  90488. private _getGLTFTextureWrapMode;
  90489. private _getGLTFTextureWrapModesSampler;
  90490. /**
  90491. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  90492. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  90493. * @param mimeType mime type to use for the textures
  90494. * @param images array of glTF image interfaces
  90495. * @param textures array of glTF texture interfaces
  90496. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  90497. * @param imageData map of image file name to data
  90498. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  90499. * @returns glTF PBR Metallic Roughness factors
  90500. */
  90501. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  90502. /**
  90503. * Converts a Babylon PBR Base Material to a glTF Material
  90504. * @param babylonPBRMaterial BJS PBR Base Material
  90505. * @param mimeType mime type to use for the textures
  90506. * @param images array of glTF image interfaces
  90507. * @param textures array of glTF texture interfaces
  90508. * @param materials array of glTF material interfaces
  90509. * @param imageData map of image file name to data
  90510. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  90511. */
  90512. _convertPBRMaterialAsync(babylonPBRMaterial: PBRBaseMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  90513. private setMetallicRoughnessPbrMaterial;
  90514. private getPixelsFromTexture;
  90515. /**
  90516. * Extracts a texture from a Babylon texture into file data and glTF data
  90517. * @param babylonTexture Babylon texture to extract
  90518. * @param mimeType Mime Type of the babylonTexture
  90519. * @return glTF texture info, or null if the texture format is not supported
  90520. */
  90521. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  90522. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  90523. /**
  90524. * Builds a texture from base64 string
  90525. * @param base64Texture base64 texture string
  90526. * @param baseTextureName Name to use for the texture
  90527. * @param mimeType image mime type for the texture
  90528. * @param images array of images
  90529. * @param textures array of textures
  90530. * @param imageData map of image data
  90531. * @returns glTF texture info, or null if the texture format is not supported
  90532. */
  90533. private _getTextureInfoFromBase64;
  90534. }
  90535. }
  90536. declare module BABYLON {
  90537. /**
  90538. * Class for holding and downloading glTF file data
  90539. */
  90540. export class GLTFData {
  90541. /**
  90542. * Object which contains the file name as the key and its data as the value
  90543. */
  90544. glTFFiles: {
  90545. [fileName: string]: string | Blob;
  90546. };
  90547. /**
  90548. * Initializes the glTF file object
  90549. */
  90550. constructor();
  90551. /**
  90552. * Downloads the glTF data as files based on their names and data
  90553. */
  90554. downloadFiles(): void;
  90555. }
  90556. }
  90557. declare module BABYLON {
  90558. /**
  90559. * Holds a collection of exporter options and parameters
  90560. */
  90561. export interface IExportOptions {
  90562. /**
  90563. * Function which indicates whether a babylon node should be exported or not
  90564. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  90565. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  90566. */
  90567. shouldExportNode?(node: Node): boolean;
  90568. /**
  90569. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  90570. * @param metadata source metadata to read from
  90571. * @returns the data to store to glTF node extras
  90572. */
  90573. metadataSelector?(metadata: any): any;
  90574. /**
  90575. * The sample rate to bake animation curves
  90576. */
  90577. animationSampleRate?: number;
  90578. /**
  90579. * Begin serialization without waiting for the scene to be ready
  90580. */
  90581. exportWithoutWaitingForScene?: boolean;
  90582. /**
  90583. * Indicates if coordinate system swapping root nodes should be included in export
  90584. */
  90585. includeCoordinateSystemConversionNodes?: boolean;
  90586. }
  90587. /**
  90588. * Class for generating glTF data from a Babylon scene.
  90589. */
  90590. export class GLTF2Export {
  90591. /**
  90592. * Exports the geometry of the scene to .gltf file format asynchronously
  90593. * @param scene Babylon scene with scene hierarchy information
  90594. * @param filePrefix File prefix to use when generating the glTF file
  90595. * @param options Exporter options
  90596. * @returns Returns an object with a .gltf file and associates texture names
  90597. * as keys and their data and paths as values
  90598. */
  90599. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  90600. private static _PreExportAsync;
  90601. private static _PostExportAsync;
  90602. /**
  90603. * Exports the geometry of the scene to .glb file format asychronously
  90604. * @param scene Babylon scene with scene hierarchy information
  90605. * @param filePrefix File prefix to use when generating glb file
  90606. * @param options Exporter options
  90607. * @returns Returns an object with a .glb filename as key and data as value
  90608. */
  90609. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  90610. }
  90611. }
  90612. declare module BABYLON.GLTF2.Exporter {
  90613. /**
  90614. * @hidden
  90615. */
  90616. export class _GLTFUtilities {
  90617. /**
  90618. * Creates a buffer view based on the supplied arguments
  90619. * @param bufferIndex index value of the specified buffer
  90620. * @param byteOffset byte offset value
  90621. * @param byteLength byte length of the bufferView
  90622. * @param byteStride byte distance between conequential elements
  90623. * @param name name of the buffer view
  90624. * @returns bufferView for glTF
  90625. */
  90626. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  90627. /**
  90628. * Creates an accessor based on the supplied arguments
  90629. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  90630. * @param name The name of the accessor
  90631. * @param type The type of the accessor
  90632. * @param componentType The datatype of components in the attribute
  90633. * @param count The number of attributes referenced by this accessor
  90634. * @param byteOffset The offset relative to the start of the bufferView in bytes
  90635. * @param min Minimum value of each component in this attribute
  90636. * @param max Maximum value of each component in this attribute
  90637. * @returns accessor for glTF
  90638. */
  90639. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  90640. /**
  90641. * Calculates the minimum and maximum values of an array of position floats
  90642. * @param positions Positions array of a mesh
  90643. * @param vertexStart Starting vertex offset to calculate min and max values
  90644. * @param vertexCount Number of vertices to check for min and max values
  90645. * @returns min number array and max number array
  90646. */
  90647. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  90648. min: number[];
  90649. max: number[];
  90650. };
  90651. /**
  90652. * Converts a new right-handed Vector3
  90653. * @param vector vector3 array
  90654. * @returns right-handed Vector3
  90655. */
  90656. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  90657. /**
  90658. * Converts a Vector3 to right-handed
  90659. * @param vector Vector3 to convert to right-handed
  90660. */
  90661. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  90662. /**
  90663. * Converts a three element number array to right-handed
  90664. * @param vector number array to convert to right-handed
  90665. */
  90666. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  90667. /**
  90668. * Converts a new right-handed Vector3
  90669. * @param vector vector3 array
  90670. * @returns right-handed Vector3
  90671. */
  90672. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  90673. /**
  90674. * Converts a Vector3 to right-handed
  90675. * @param vector Vector3 to convert to right-handed
  90676. */
  90677. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  90678. /**
  90679. * Converts a three element number array to right-handed
  90680. * @param vector number array to convert to right-handed
  90681. */
  90682. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  90683. /**
  90684. * Converts a Vector4 to right-handed
  90685. * @param vector Vector4 to convert to right-handed
  90686. */
  90687. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  90688. /**
  90689. * Converts a Vector4 to right-handed
  90690. * @param vector Vector4 to convert to right-handed
  90691. */
  90692. static _GetRightHandedArray4FromRef(vector: number[]): void;
  90693. /**
  90694. * Converts a Quaternion to right-handed
  90695. * @param quaternion Source quaternion to convert to right-handed
  90696. */
  90697. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  90698. /**
  90699. * Converts a Quaternion to right-handed
  90700. * @param quaternion Source quaternion to convert to right-handed
  90701. */
  90702. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  90703. static _NormalizeTangentFromRef(tangent: Vector4): void;
  90704. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  90705. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  90706. }
  90707. }
  90708. declare module BABYLON.GLTF2.Exporter {
  90709. /**
  90710. * Converts Babylon Scene into glTF 2.0.
  90711. * @hidden
  90712. */
  90713. export class _Exporter {
  90714. /**
  90715. * Stores the glTF to export
  90716. */
  90717. _glTF: IGLTF;
  90718. /**
  90719. * Stores all generated buffer views, which represents views into the main glTF buffer data
  90720. */
  90721. _bufferViews: IBufferView[];
  90722. /**
  90723. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  90724. */
  90725. _accessors: IAccessor[];
  90726. /**
  90727. * Stores all the generated nodes, which contains transform and/or mesh information per node
  90728. */
  90729. _nodes: INode[];
  90730. /**
  90731. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  90732. */
  90733. private _scenes;
  90734. /**
  90735. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  90736. */
  90737. private _meshes;
  90738. /**
  90739. * Stores all the generated material information, which represents the appearance of each primitive
  90740. */
  90741. _materials: IMaterial[];
  90742. _materialMap: {
  90743. [materialID: number]: number;
  90744. };
  90745. /**
  90746. * Stores all the generated texture information, which is referenced by glTF materials
  90747. */
  90748. _textures: ITexture[];
  90749. /**
  90750. * Stores all the generated image information, which is referenced by glTF textures
  90751. */
  90752. _images: IImage[];
  90753. /**
  90754. * Stores all the texture samplers
  90755. */
  90756. _samplers: ISampler[];
  90757. /**
  90758. * Stores all the generated glTF skins
  90759. */
  90760. _skins: ISkin[];
  90761. /**
  90762. * Stores all the generated animation samplers, which is referenced by glTF animations
  90763. */
  90764. /**
  90765. * Stores the animations for glTF models
  90766. */
  90767. private _animations;
  90768. /**
  90769. * Stores the total amount of bytes stored in the glTF buffer
  90770. */
  90771. private _totalByteLength;
  90772. /**
  90773. * Stores a reference to the Babylon scene containing the source geometry and material information
  90774. */
  90775. _babylonScene: Scene;
  90776. /**
  90777. * Stores a map of the image data, where the key is the file name and the value
  90778. * is the image data
  90779. */
  90780. _imageData: {
  90781. [fileName: string]: {
  90782. data: Uint8Array;
  90783. mimeType: ImageMimeType;
  90784. };
  90785. };
  90786. protected _orderedImageData: Array<{
  90787. data: Uint8Array;
  90788. mimeType: ImageMimeType;
  90789. }>;
  90790. /**
  90791. * Stores a map of the unique id of a node to its index in the node array
  90792. */
  90793. _nodeMap: {
  90794. [key: number]: number;
  90795. };
  90796. /**
  90797. * Specifies if the source Babylon scene was left handed, and needed conversion.
  90798. */
  90799. _convertToRightHandedSystem: boolean;
  90800. /**
  90801. * Specifies if a Babylon node should be converted to right-handed on export
  90802. */
  90803. _convertToRightHandedSystemMap: {
  90804. [nodeId: number]: boolean;
  90805. };
  90806. _includeCoordinateSystemConversionNodes: boolean;
  90807. /**
  90808. * Baked animation sample rate
  90809. */
  90810. private _animationSampleRate;
  90811. private _options;
  90812. private _localEngine;
  90813. _glTFMaterialExporter: _GLTFMaterialExporter;
  90814. private _extensions;
  90815. private static _ExtensionNames;
  90816. private static _ExtensionFactories;
  90817. private _applyExtension;
  90818. private _applyExtensions;
  90819. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  90820. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  90821. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  90822. [key: number]: number;
  90823. }): Promise<Nullable<INode>>;
  90824. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  90825. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  90826. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  90827. private _forEachExtensions;
  90828. private _extensionsOnExporting;
  90829. /**
  90830. * Load glTF serializer extensions
  90831. */
  90832. private _loadExtensions;
  90833. /**
  90834. * Creates a glTF Exporter instance, which can accept optional exporter options
  90835. * @param babylonScene Babylon scene object
  90836. * @param options Options to modify the behavior of the exporter
  90837. */
  90838. constructor(babylonScene: Scene, options?: IExportOptions);
  90839. dispose(): void;
  90840. /**
  90841. * Registers a glTF exporter extension
  90842. * @param name Name of the extension to export
  90843. * @param factory The factory function that creates the exporter extension
  90844. */
  90845. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  90846. /**
  90847. * Un-registers an exporter extension
  90848. * @param name The name fo the exporter extension
  90849. * @returns A boolean indicating whether the extension has been un-registered
  90850. */
  90851. static UnregisterExtension(name: string): boolean;
  90852. private reorderIndicesBasedOnPrimitiveMode;
  90853. /**
  90854. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  90855. * clock-wise during export to glTF
  90856. * @param submesh BabylonJS submesh
  90857. * @param primitiveMode Primitive mode of the mesh
  90858. * @param sideOrientation the winding order of the submesh
  90859. * @param vertexBufferKind The type of vertex attribute
  90860. * @param meshAttributeArray The vertex attribute data
  90861. * @param byteOffset The offset to the binary data
  90862. * @param binaryWriter The binary data for the glTF file
  90863. * @param convertToRightHandedSystem Converts the values to right-handed
  90864. */
  90865. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  90866. /**
  90867. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  90868. * clock-wise during export to glTF
  90869. * @param submesh BabylonJS submesh
  90870. * @param primitiveMode Primitive mode of the mesh
  90871. * @param sideOrientation the winding order of the submesh
  90872. * @param vertexBufferKind The type of vertex attribute
  90873. * @param meshAttributeArray The vertex attribute data
  90874. * @param byteOffset The offset to the binary data
  90875. * @param binaryWriter The binary data for the glTF file
  90876. * @param convertToRightHandedSystem Converts the values to right-handed
  90877. */
  90878. private reorderTriangleFillMode;
  90879. /**
  90880. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  90881. * clock-wise during export to glTF
  90882. * @param submesh BabylonJS submesh
  90883. * @param primitiveMode Primitive mode of the mesh
  90884. * @param sideOrientation the winding order of the submesh
  90885. * @param vertexBufferKind The type of vertex attribute
  90886. * @param meshAttributeArray The vertex attribute data
  90887. * @param byteOffset The offset to the binary data
  90888. * @param binaryWriter The binary data for the glTF file
  90889. * @param convertToRightHandedSystem Converts the values to right-handed
  90890. */
  90891. private reorderTriangleStripDrawMode;
  90892. /**
  90893. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  90894. * clock-wise during export to glTF
  90895. * @param submesh BabylonJS submesh
  90896. * @param primitiveMode Primitive mode of the mesh
  90897. * @param sideOrientation the winding order of the submesh
  90898. * @param vertexBufferKind The type of vertex attribute
  90899. * @param meshAttributeArray The vertex attribute data
  90900. * @param byteOffset The offset to the binary data
  90901. * @param binaryWriter The binary data for the glTF file
  90902. * @param convertToRightHandedSystem Converts the values to right-handed
  90903. */
  90904. private reorderTriangleFanMode;
  90905. /**
  90906. * Writes the vertex attribute data to binary
  90907. * @param vertices The vertices to write to the binary writer
  90908. * @param byteOffset The offset into the binary writer to overwrite binary data
  90909. * @param vertexAttributeKind The vertex attribute type
  90910. * @param meshAttributeArray The vertex attribute data
  90911. * @param binaryWriter The writer containing the binary data
  90912. * @param convertToRightHandedSystem Converts the values to right-handed
  90913. */
  90914. private writeVertexAttributeData;
  90915. /**
  90916. * Writes mesh attribute data to a data buffer
  90917. * Returns the bytelength of the data
  90918. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  90919. * @param meshAttributeArray Array containing the attribute data
  90920. * @param byteStride Specifies the space between data
  90921. * @param binaryWriter The buffer to write the binary data to
  90922. * @param convertToRightHandedSystem Converts the values to right-handed
  90923. */
  90924. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  90925. /**
  90926. * Writes mesh attribute data to a data buffer
  90927. * Returns the bytelength of the data
  90928. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  90929. * @param meshAttributeArray Array containing the attribute data
  90930. * @param byteStride Specifies the space between data
  90931. * @param binaryWriter The buffer to write the binary data to
  90932. * @param convertToRightHandedSystem Converts the values to right-handed
  90933. */
  90934. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  90935. /**
  90936. * Generates glTF json data
  90937. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  90938. * @param glTFPrefix Text to use when prefixing a glTF file
  90939. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  90940. * @returns json data as string
  90941. */
  90942. private generateJSON;
  90943. /**
  90944. * Generates data for .gltf and .bin files based on the glTF prefix string
  90945. * @param glTFPrefix Text to use when prefixing a glTF file
  90946. * @param dispose Dispose the exporter
  90947. * @returns GLTFData with glTF file data
  90948. */
  90949. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  90950. /**
  90951. * Creates a binary buffer for glTF
  90952. * @returns array buffer for binary data
  90953. */
  90954. private _generateBinaryAsync;
  90955. /**
  90956. * Pads the number to a multiple of 4
  90957. * @param num number to pad
  90958. * @returns padded number
  90959. */
  90960. private _getPadding;
  90961. /**
  90962. * @hidden
  90963. */
  90964. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  90965. /**
  90966. * Sets the TRS for each node
  90967. * @param node glTF Node for storing the transformation data
  90968. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  90969. * @param convertToRightHandedSystem Converts the values to right-handed
  90970. */
  90971. private setNodeTransformation;
  90972. private getVertexBufferFromMesh;
  90973. /**
  90974. * Creates a bufferview based on the vertices type for the Babylon mesh
  90975. * @param kind Indicates the type of vertices data
  90976. * @param componentType Indicates the numerical type used to store the data
  90977. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  90978. * @param binaryWriter The buffer to write the bufferview data to
  90979. * @param convertToRightHandedSystem Converts the values to right-handed
  90980. */
  90981. private createBufferViewKind;
  90982. /**
  90983. * Creates a bufferview based on the vertices type for the Babylon mesh
  90984. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  90985. * @param babylonMorphTarget the morph target to be exported
  90986. * @param binaryWriter The buffer to write the bufferview data to
  90987. * @param convertToRightHandedSystem Converts the values to right-handed
  90988. */
  90989. private setMorphTargetAttributes;
  90990. /**
  90991. * The primitive mode of the Babylon mesh
  90992. * @param babylonMesh The BabylonJS mesh
  90993. */
  90994. private getMeshPrimitiveMode;
  90995. /**
  90996. * Sets the primitive mode of the glTF mesh primitive
  90997. * @param meshPrimitive glTF mesh primitive
  90998. * @param primitiveMode The primitive mode
  90999. */
  91000. private setPrimitiveMode;
  91001. /**
  91002. * Sets the vertex attribute accessor based of the glTF mesh primitive
  91003. * @param meshPrimitive glTF mesh primitive
  91004. * @param attributeKind vertex attribute
  91005. * @returns boolean specifying if uv coordinates are present
  91006. */
  91007. private setAttributeKind;
  91008. /**
  91009. * Sets data for the primitive attributes of each submesh
  91010. * @param mesh glTF Mesh object to store the primitive attribute information
  91011. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  91012. * @param binaryWriter Buffer to write the attribute data to
  91013. * @param convertToRightHandedSystem Converts the values to right-handed
  91014. */
  91015. private setPrimitiveAttributesAsync;
  91016. /**
  91017. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  91018. * @param node The node to check
  91019. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  91020. */
  91021. private isBabylonCoordinateSystemConvertingNode;
  91022. /**
  91023. * Creates a glTF scene based on the array of meshes
  91024. * Returns the the total byte offset
  91025. * @param babylonScene Babylon scene to get the mesh data from
  91026. * @param binaryWriter Buffer to write binary data to
  91027. */
  91028. private createSceneAsync;
  91029. /**
  91030. * Creates a mapping of Node unique id to node index and handles animations
  91031. * @param babylonScene Babylon Scene
  91032. * @param nodes Babylon transform nodes
  91033. * @param binaryWriter Buffer to write binary data to
  91034. * @returns Node mapping of unique id to index
  91035. */
  91036. private createNodeMapAndAnimationsAsync;
  91037. /**
  91038. * Creates a glTF node from a Babylon mesh
  91039. * @param babylonMesh Source Babylon mesh
  91040. * @param binaryWriter Buffer for storing geometry data
  91041. * @param convertToRightHandedSystem Converts the values to right-handed
  91042. * @param nodeMap Node mapping of unique id to glTF node index
  91043. * @returns glTF node
  91044. */
  91045. private createNodeAsync;
  91046. /**
  91047. * Creates a glTF skin from a Babylon skeleton
  91048. * @param babylonScene Babylon Scene
  91049. * @param nodes Babylon transform nodes
  91050. * @param binaryWriter Buffer to write binary data to
  91051. * @returns Node mapping of unique id to index
  91052. */
  91053. private createSkinsAsync;
  91054. }
  91055. /**
  91056. * @hidden
  91057. *
  91058. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  91059. */
  91060. export class _BinaryWriter {
  91061. /**
  91062. * Array buffer which stores all binary data
  91063. */
  91064. private _arrayBuffer;
  91065. /**
  91066. * View of the array buffer
  91067. */
  91068. private _dataView;
  91069. /**
  91070. * byte offset of data in array buffer
  91071. */
  91072. private _byteOffset;
  91073. /**
  91074. * Initialize binary writer with an initial byte length
  91075. * @param byteLength Initial byte length of the array buffer
  91076. */
  91077. constructor(byteLength: number);
  91078. /**
  91079. * Resize the array buffer to the specified byte length
  91080. * @param byteLength
  91081. */
  91082. private resizeBuffer;
  91083. /**
  91084. * Get an array buffer with the length of the byte offset
  91085. * @returns ArrayBuffer resized to the byte offset
  91086. */
  91087. getArrayBuffer(): ArrayBuffer;
  91088. /**
  91089. * Get the byte offset of the array buffer
  91090. * @returns byte offset
  91091. */
  91092. getByteOffset(): number;
  91093. /**
  91094. * Stores an UInt8 in the array buffer
  91095. * @param entry
  91096. * @param byteOffset If defined, specifies where to set the value as an offset.
  91097. */
  91098. setUInt8(entry: number, byteOffset?: number): void;
  91099. /**
  91100. * Stores an UInt16 in the array buffer
  91101. * @param entry
  91102. * @param byteOffset If defined, specifies where to set the value as an offset.
  91103. */
  91104. setUInt16(entry: number, byteOffset?: number): void;
  91105. /**
  91106. * Gets an UInt32 in the array buffer
  91107. * @param entry
  91108. * @param byteOffset If defined, specifies where to set the value as an offset.
  91109. */
  91110. getUInt32(byteOffset: number): number;
  91111. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  91112. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  91113. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  91114. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  91115. /**
  91116. * Stores a Float32 in the array buffer
  91117. * @param entry
  91118. */
  91119. setFloat32(entry: number, byteOffset?: number): void;
  91120. /**
  91121. * Stores an UInt32 in the array buffer
  91122. * @param entry
  91123. * @param byteOffset If defined, specifies where to set the value as an offset.
  91124. */
  91125. setUInt32(entry: number, byteOffset?: number): void;
  91126. }
  91127. }
  91128. declare module BABYLON.GLTF2.Exporter {
  91129. /**
  91130. * @hidden
  91131. * Interface to store animation data.
  91132. */
  91133. export interface _IAnimationData {
  91134. /**
  91135. * Keyframe data.
  91136. */
  91137. inputs: number[];
  91138. /**
  91139. * Value data.
  91140. */
  91141. outputs: number[][];
  91142. /**
  91143. * Animation interpolation data.
  91144. */
  91145. samplerInterpolation: AnimationSamplerInterpolation;
  91146. /**
  91147. * Minimum keyframe value.
  91148. */
  91149. inputsMin: number;
  91150. /**
  91151. * Maximum keyframe value.
  91152. */
  91153. inputsMax: number;
  91154. }
  91155. /**
  91156. * @hidden
  91157. */
  91158. export interface _IAnimationInfo {
  91159. /**
  91160. * The target channel for the animation
  91161. */
  91162. animationChannelTargetPath: AnimationChannelTargetPath;
  91163. /**
  91164. * The glTF accessor type for the data.
  91165. */
  91166. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  91167. /**
  91168. * Specifies if quaternions should be used.
  91169. */
  91170. useQuaternion: boolean;
  91171. }
  91172. /**
  91173. * @hidden
  91174. * Utility class for generating glTF animation data from BabylonJS.
  91175. */
  91176. export class _GLTFAnimation {
  91177. /**
  91178. * @ignore
  91179. *
  91180. * Creates glTF channel animation from BabylonJS animation.
  91181. * @param babylonTransformNode - BabylonJS mesh.
  91182. * @param animation - animation.
  91183. * @param animationChannelTargetPath - The target animation channel.
  91184. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  91185. * @param useQuaternion - Specifies if quaternions are used.
  91186. * @returns nullable IAnimationData
  91187. */
  91188. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  91189. private static _DeduceAnimationInfo;
  91190. /**
  91191. * @ignore
  91192. * Create node animations from the transform node animations
  91193. * @param babylonNode
  91194. * @param runtimeGLTFAnimation
  91195. * @param idleGLTFAnimations
  91196. * @param nodeMap
  91197. * @param nodes
  91198. * @param binaryWriter
  91199. * @param bufferViews
  91200. * @param accessors
  91201. * @param convertToRightHandedSystem
  91202. * @param animationSampleRate
  91203. */
  91204. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  91205. [key: number]: number;
  91206. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  91207. /**
  91208. * @ignore
  91209. * Create individual morph animations from the mesh's morph target animation tracks
  91210. * @param babylonNode
  91211. * @param runtimeGLTFAnimation
  91212. * @param idleGLTFAnimations
  91213. * @param nodeMap
  91214. * @param nodes
  91215. * @param binaryWriter
  91216. * @param bufferViews
  91217. * @param accessors
  91218. * @param convertToRightHandedSystem
  91219. * @param animationSampleRate
  91220. */
  91221. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  91222. [key: number]: number;
  91223. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  91224. /**
  91225. * @ignore
  91226. * Create node and morph animations from the animation groups
  91227. * @param babylonScene
  91228. * @param glTFAnimations
  91229. * @param nodeMap
  91230. * @param nodes
  91231. * @param binaryWriter
  91232. * @param bufferViews
  91233. * @param accessors
  91234. * @param convertToRightHandedSystemMap
  91235. * @param animationSampleRate
  91236. */
  91237. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  91238. [key: number]: number;
  91239. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  91240. [nodeId: number]: boolean;
  91241. }, animationSampleRate: number): void;
  91242. private static AddAnimation;
  91243. /**
  91244. * Create a baked animation
  91245. * @param babylonTransformNode BabylonJS mesh
  91246. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  91247. * @param animationChannelTargetPath animation target channel
  91248. * @param minFrame minimum animation frame
  91249. * @param maxFrame maximum animation frame
  91250. * @param fps frames per second of the animation
  91251. * @param inputs input key frames of the animation
  91252. * @param outputs output key frame data of the animation
  91253. * @param convertToRightHandedSystem converts the values to right-handed
  91254. * @param useQuaternion specifies if quaternions should be used
  91255. */
  91256. private static _CreateBakedAnimation;
  91257. private static _ConvertFactorToVector3OrQuaternion;
  91258. private static _SetInterpolatedValue;
  91259. /**
  91260. * Creates linear animation from the animation key frames
  91261. * @param babylonTransformNode BabylonJS mesh
  91262. * @param animation BabylonJS animation
  91263. * @param animationChannelTargetPath The target animation channel
  91264. * @param frameDelta The difference between the last and first frame of the animation
  91265. * @param inputs Array to store the key frame times
  91266. * @param outputs Array to store the key frame data
  91267. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  91268. * @param useQuaternion Specifies if quaternions are used in the animation
  91269. */
  91270. private static _CreateLinearOrStepAnimation;
  91271. /**
  91272. * Creates cubic spline animation from the animation key frames
  91273. * @param babylonTransformNode BabylonJS mesh
  91274. * @param animation BabylonJS animation
  91275. * @param animationChannelTargetPath The target animation channel
  91276. * @param frameDelta The difference between the last and first frame of the animation
  91277. * @param inputs Array to store the key frame times
  91278. * @param outputs Array to store the key frame data
  91279. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  91280. * @param useQuaternion Specifies if quaternions are used in the animation
  91281. */
  91282. private static _CreateCubicSplineAnimation;
  91283. private static _GetBasePositionRotationOrScale;
  91284. /**
  91285. * Adds a key frame value
  91286. * @param keyFrame
  91287. * @param animation
  91288. * @param outputs
  91289. * @param animationChannelTargetPath
  91290. * @param basePositionRotationOrScale
  91291. * @param convertToRightHandedSystem
  91292. * @param useQuaternion
  91293. */
  91294. private static _AddKeyframeValue;
  91295. /**
  91296. * Determine the interpolation based on the key frames
  91297. * @param keyFrames
  91298. * @param animationChannelTargetPath
  91299. * @param useQuaternion
  91300. */
  91301. private static _DeduceInterpolation;
  91302. /**
  91303. * Adds an input tangent or output tangent to the output data
  91304. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  91305. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  91306. * @param outputs The animation data by keyframe
  91307. * @param animationChannelTargetPath The target animation channel
  91308. * @param interpolation The interpolation type
  91309. * @param keyFrame The key frame with the animation data
  91310. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  91311. * @param useQuaternion Specifies if quaternions are used
  91312. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  91313. */
  91314. private static AddSplineTangent;
  91315. /**
  91316. * Get the minimum and maximum key frames' frame values
  91317. * @param keyFrames animation key frames
  91318. * @returns the minimum and maximum key frame value
  91319. */
  91320. private static calculateMinMaxKeyFrames;
  91321. }
  91322. }
  91323. declare module BABYLON.GLTF2.Exporter {
  91324. /** @hidden */
  91325. export var textureTransformPixelShader: {
  91326. name: string;
  91327. shader: string;
  91328. };
  91329. }
  91330. declare module BABYLON.GLTF2.Exporter.Extensions {
  91331. /**
  91332. * @hidden
  91333. */
  91334. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  91335. private _recordedTextures;
  91336. /** Name of this extension */
  91337. readonly name: string;
  91338. /** Defines whether this extension is enabled */
  91339. enabled: boolean;
  91340. /** Defines whether this extension is required */
  91341. required: boolean;
  91342. /** Reference to the glTF exporter */
  91343. private _wasUsed;
  91344. constructor(exporter: _Exporter);
  91345. dispose(): void;
  91346. /** @hidden */
  91347. get wasUsed(): boolean;
  91348. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  91349. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  91350. /**
  91351. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  91352. * @param babylonTexture
  91353. * @param offset
  91354. * @param rotation
  91355. * @param scale
  91356. * @param scene
  91357. */
  91358. private _textureTransformTextureAsync;
  91359. }
  91360. }
  91361. declare module BABYLON.GLTF2.Exporter.Extensions {
  91362. /**
  91363. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  91364. */
  91365. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  91366. /** The name of this extension. */
  91367. readonly name: string;
  91368. /** Defines whether this extension is enabled. */
  91369. enabled: boolean;
  91370. /** Defines whether this extension is required */
  91371. required: boolean;
  91372. /** Reference to the glTF exporter */
  91373. private _exporter;
  91374. private _lights;
  91375. /** @hidden */
  91376. constructor(exporter: _Exporter);
  91377. /** @hidden */
  91378. dispose(): void;
  91379. /** @hidden */
  91380. get wasUsed(): boolean;
  91381. /** @hidden */
  91382. onExporting(): void;
  91383. /**
  91384. * Define this method to modify the default behavior when exporting a node
  91385. * @param context The context when exporting the node
  91386. * @param node glTF node
  91387. * @param babylonNode BabylonJS node
  91388. * @param nodeMap Node mapping of unique id to glTF node index
  91389. * @returns nullable INode promise
  91390. */
  91391. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  91392. [key: number]: number;
  91393. }): Promise<Nullable<INode>>;
  91394. }
  91395. }
  91396. declare module BABYLON.GLTF2.Exporter.Extensions {
  91397. /**
  91398. * @hidden
  91399. */
  91400. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  91401. /** Name of this extension */
  91402. readonly name: string;
  91403. /** Defines whether this extension is enabled */
  91404. enabled: boolean;
  91405. /** Defines whether this extension is required */
  91406. required: boolean;
  91407. /** Reference to the glTF exporter */
  91408. private _textureInfos;
  91409. private _exportedTextures;
  91410. private _wasUsed;
  91411. constructor(exporter: _Exporter);
  91412. dispose(): void;
  91413. /** @hidden */
  91414. get wasUsed(): boolean;
  91415. private _getTextureIndex;
  91416. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  91417. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  91418. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  91419. }
  91420. }
  91421. declare module BABYLON.GLTF2.Exporter.Extensions {
  91422. /**
  91423. * @hidden
  91424. */
  91425. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  91426. /** Name of this extension */
  91427. readonly name: string;
  91428. /** Defines whether this extension is enabled */
  91429. enabled: boolean;
  91430. /** Defines whether this extension is required */
  91431. required: boolean;
  91432. private _wasUsed;
  91433. constructor(exporter: _Exporter);
  91434. /** @hidden */
  91435. get wasUsed(): boolean;
  91436. dispose(): void;
  91437. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  91438. }
  91439. }
  91440. declare module BABYLON {
  91441. /**
  91442. * Class for generating STL data from a Babylon scene.
  91443. */
  91444. export class STLExport {
  91445. /**
  91446. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  91447. * @param meshes list defines the mesh to serialize
  91448. * @param download triggers the automatic download of the file.
  91449. * @param fileName changes the downloads fileName.
  91450. * @param binary changes the STL to a binary type.
  91451. * @param isLittleEndian toggle for binary type exporter.
  91452. * @param doNotBakeTransform toggle if meshes transforms should be baked or not.
  91453. * @returns the STL as UTF8 string
  91454. */
  91455. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean, doNotBakeTransform?: boolean): any;
  91456. }
  91457. }
  91458. declare module "babylonjs-gltf2interface" {
  91459. export = BABYLON.GLTF2;
  91460. }
  91461. /**
  91462. * Module for glTF 2.0 Interface
  91463. */
  91464. declare module BABYLON.GLTF2 {
  91465. /**
  91466. * The datatype of the components in the attribute
  91467. */
  91468. const enum AccessorComponentType {
  91469. /**
  91470. * Byte
  91471. */
  91472. BYTE = 5120,
  91473. /**
  91474. * Unsigned Byte
  91475. */
  91476. UNSIGNED_BYTE = 5121,
  91477. /**
  91478. * Short
  91479. */
  91480. SHORT = 5122,
  91481. /**
  91482. * Unsigned Short
  91483. */
  91484. UNSIGNED_SHORT = 5123,
  91485. /**
  91486. * Unsigned Int
  91487. */
  91488. UNSIGNED_INT = 5125,
  91489. /**
  91490. * Float
  91491. */
  91492. FLOAT = 5126,
  91493. }
  91494. /**
  91495. * Specifies if the attirbute is a scalar, vector, or matrix
  91496. */
  91497. const enum AccessorType {
  91498. /**
  91499. * Scalar
  91500. */
  91501. SCALAR = "SCALAR",
  91502. /**
  91503. * Vector2
  91504. */
  91505. VEC2 = "VEC2",
  91506. /**
  91507. * Vector3
  91508. */
  91509. VEC3 = "VEC3",
  91510. /**
  91511. * Vector4
  91512. */
  91513. VEC4 = "VEC4",
  91514. /**
  91515. * Matrix2x2
  91516. */
  91517. MAT2 = "MAT2",
  91518. /**
  91519. * Matrix3x3
  91520. */
  91521. MAT3 = "MAT3",
  91522. /**
  91523. * Matrix4x4
  91524. */
  91525. MAT4 = "MAT4",
  91526. }
  91527. /**
  91528. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  91529. */
  91530. const enum AnimationChannelTargetPath {
  91531. /**
  91532. * Translation
  91533. */
  91534. TRANSLATION = "translation",
  91535. /**
  91536. * Rotation
  91537. */
  91538. ROTATION = "rotation",
  91539. /**
  91540. * Scale
  91541. */
  91542. SCALE = "scale",
  91543. /**
  91544. * Weights
  91545. */
  91546. WEIGHTS = "weights",
  91547. }
  91548. /**
  91549. * Interpolation algorithm
  91550. */
  91551. const enum AnimationSamplerInterpolation {
  91552. /**
  91553. * The animated values are linearly interpolated between keyframes
  91554. */
  91555. LINEAR = "LINEAR",
  91556. /**
  91557. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  91558. */
  91559. STEP = "STEP",
  91560. /**
  91561. * The animation's interpolation is computed using a cubic spline with specified tangents
  91562. */
  91563. CUBICSPLINE = "CUBICSPLINE",
  91564. }
  91565. /**
  91566. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  91567. */
  91568. const enum CameraType {
  91569. /**
  91570. * A perspective camera containing properties to create a perspective projection matrix
  91571. */
  91572. PERSPECTIVE = "perspective",
  91573. /**
  91574. * An orthographic camera containing properties to create an orthographic projection matrix
  91575. */
  91576. ORTHOGRAPHIC = "orthographic",
  91577. }
  91578. /**
  91579. * The mime-type of the image
  91580. */
  91581. const enum ImageMimeType {
  91582. /**
  91583. * JPEG Mime-type
  91584. */
  91585. JPEG = "image/jpeg",
  91586. /**
  91587. * PNG Mime-type
  91588. */
  91589. PNG = "image/png",
  91590. }
  91591. /**
  91592. * The alpha rendering mode of the material
  91593. */
  91594. const enum MaterialAlphaMode {
  91595. /**
  91596. * The alpha value is ignored and the rendered output is fully opaque
  91597. */
  91598. OPAQUE = "OPAQUE",
  91599. /**
  91600. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  91601. */
  91602. MASK = "MASK",
  91603. /**
  91604. * 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)
  91605. */
  91606. BLEND = "BLEND",
  91607. }
  91608. /**
  91609. * The type of the primitives to render
  91610. */
  91611. const enum MeshPrimitiveMode {
  91612. /**
  91613. * Points
  91614. */
  91615. POINTS = 0,
  91616. /**
  91617. * Lines
  91618. */
  91619. LINES = 1,
  91620. /**
  91621. * Line Loop
  91622. */
  91623. LINE_LOOP = 2,
  91624. /**
  91625. * Line Strip
  91626. */
  91627. LINE_STRIP = 3,
  91628. /**
  91629. * Triangles
  91630. */
  91631. TRIANGLES = 4,
  91632. /**
  91633. * Triangle Strip
  91634. */
  91635. TRIANGLE_STRIP = 5,
  91636. /**
  91637. * Triangle Fan
  91638. */
  91639. TRIANGLE_FAN = 6,
  91640. }
  91641. /**
  91642. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  91643. */
  91644. const enum TextureMagFilter {
  91645. /**
  91646. * Nearest
  91647. */
  91648. NEAREST = 9728,
  91649. /**
  91650. * Linear
  91651. */
  91652. LINEAR = 9729,
  91653. }
  91654. /**
  91655. * Minification filter. All valid values correspond to WebGL enums
  91656. */
  91657. const enum TextureMinFilter {
  91658. /**
  91659. * Nearest
  91660. */
  91661. NEAREST = 9728,
  91662. /**
  91663. * Linear
  91664. */
  91665. LINEAR = 9729,
  91666. /**
  91667. * Nearest Mip-Map Nearest
  91668. */
  91669. NEAREST_MIPMAP_NEAREST = 9984,
  91670. /**
  91671. * Linear Mipmap Nearest
  91672. */
  91673. LINEAR_MIPMAP_NEAREST = 9985,
  91674. /**
  91675. * Nearest Mipmap Linear
  91676. */
  91677. NEAREST_MIPMAP_LINEAR = 9986,
  91678. /**
  91679. * Linear Mipmap Linear
  91680. */
  91681. LINEAR_MIPMAP_LINEAR = 9987,
  91682. }
  91683. /**
  91684. * S (U) wrapping mode. All valid values correspond to WebGL enums
  91685. */
  91686. const enum TextureWrapMode {
  91687. /**
  91688. * Clamp to Edge
  91689. */
  91690. CLAMP_TO_EDGE = 33071,
  91691. /**
  91692. * Mirrored Repeat
  91693. */
  91694. MIRRORED_REPEAT = 33648,
  91695. /**
  91696. * Repeat
  91697. */
  91698. REPEAT = 10497,
  91699. }
  91700. /**
  91701. * glTF Property
  91702. */
  91703. interface IProperty {
  91704. /**
  91705. * Dictionary object with extension-specific objects
  91706. */
  91707. extensions?: {
  91708. [key: string]: any;
  91709. };
  91710. /**
  91711. * Application-Specific data
  91712. */
  91713. extras?: any;
  91714. }
  91715. /**
  91716. * glTF Child of Root Property
  91717. */
  91718. interface IChildRootProperty extends IProperty {
  91719. /**
  91720. * The user-defined name of this object
  91721. */
  91722. name?: string;
  91723. }
  91724. /**
  91725. * Indices of those attributes that deviate from their initialization value
  91726. */
  91727. interface IAccessorSparseIndices extends IProperty {
  91728. /**
  91729. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  91730. */
  91731. bufferView: number;
  91732. /**
  91733. * The offset relative to the start of the bufferView in bytes. Must be aligned
  91734. */
  91735. byteOffset?: number;
  91736. /**
  91737. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  91738. */
  91739. componentType: AccessorComponentType;
  91740. }
  91741. /**
  91742. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  91743. */
  91744. interface IAccessorSparseValues extends IProperty {
  91745. /**
  91746. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  91747. */
  91748. bufferView: number;
  91749. /**
  91750. * The offset relative to the start of the bufferView in bytes. Must be aligned
  91751. */
  91752. byteOffset?: number;
  91753. }
  91754. /**
  91755. * Sparse storage of attributes that deviate from their initialization value
  91756. */
  91757. interface IAccessorSparse extends IProperty {
  91758. /**
  91759. * The number of attributes encoded in this sparse accessor
  91760. */
  91761. count: number;
  91762. /**
  91763. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  91764. */
  91765. indices: IAccessorSparseIndices;
  91766. /**
  91767. * 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
  91768. */
  91769. values: IAccessorSparseValues;
  91770. }
  91771. /**
  91772. * 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
  91773. */
  91774. interface IAccessor extends IChildRootProperty {
  91775. /**
  91776. * The index of the bufferview
  91777. */
  91778. bufferView?: number;
  91779. /**
  91780. * The offset relative to the start of the bufferView in bytes
  91781. */
  91782. byteOffset?: number;
  91783. /**
  91784. * The datatype of components in the attribute
  91785. */
  91786. componentType: AccessorComponentType;
  91787. /**
  91788. * Specifies whether integer data values should be normalized
  91789. */
  91790. normalized?: boolean;
  91791. /**
  91792. * The number of attributes referenced by this accessor
  91793. */
  91794. count: number;
  91795. /**
  91796. * Specifies if the attribute is a scalar, vector, or matrix
  91797. */
  91798. type: AccessorType;
  91799. /**
  91800. * Maximum value of each component in this attribute
  91801. */
  91802. max?: number[];
  91803. /**
  91804. * Minimum value of each component in this attribute
  91805. */
  91806. min?: number[];
  91807. /**
  91808. * Sparse storage of attributes that deviate from their initialization value
  91809. */
  91810. sparse?: IAccessorSparse;
  91811. }
  91812. /**
  91813. * Targets an animation's sampler at a node's property
  91814. */
  91815. interface IAnimationChannel extends IProperty {
  91816. /**
  91817. * The index of a sampler in this animation used to compute the value for the target
  91818. */
  91819. sampler: number;
  91820. /**
  91821. * The index of the node and TRS property to target
  91822. */
  91823. target: IAnimationChannelTarget;
  91824. }
  91825. /**
  91826. * The index of the node and TRS property that an animation channel targets
  91827. */
  91828. interface IAnimationChannelTarget extends IProperty {
  91829. /**
  91830. * The index of the node to target
  91831. */
  91832. node: number;
  91833. /**
  91834. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  91835. */
  91836. path: AnimationChannelTargetPath;
  91837. }
  91838. /**
  91839. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  91840. */
  91841. interface IAnimationSampler extends IProperty {
  91842. /**
  91843. * The index of an accessor containing keyframe input values, e.g., time
  91844. */
  91845. input: number;
  91846. /**
  91847. * Interpolation algorithm
  91848. */
  91849. interpolation?: AnimationSamplerInterpolation;
  91850. /**
  91851. * The index of an accessor, containing keyframe output values
  91852. */
  91853. output: number;
  91854. }
  91855. /**
  91856. * A keyframe animation
  91857. */
  91858. interface IAnimation extends IChildRootProperty {
  91859. /**
  91860. * An array of channels, each of which targets an animation's sampler at a node's property
  91861. */
  91862. channels: IAnimationChannel[];
  91863. /**
  91864. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  91865. */
  91866. samplers: IAnimationSampler[];
  91867. }
  91868. /**
  91869. * Metadata about the glTF asset
  91870. */
  91871. interface IAsset extends IChildRootProperty {
  91872. /**
  91873. * A copyright message suitable for display to credit the content creator
  91874. */
  91875. copyright?: string;
  91876. /**
  91877. * Tool that generated this glTF model. Useful for debugging
  91878. */
  91879. generator?: string;
  91880. /**
  91881. * The glTF version that this asset targets
  91882. */
  91883. version: string;
  91884. /**
  91885. * The minimum glTF version that this asset targets
  91886. */
  91887. minVersion?: string;
  91888. }
  91889. /**
  91890. * A buffer points to binary geometry, animation, or skins
  91891. */
  91892. interface IBuffer extends IChildRootProperty {
  91893. /**
  91894. * 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
  91895. */
  91896. uri?: string;
  91897. /**
  91898. * The length of the buffer in bytes
  91899. */
  91900. byteLength: number;
  91901. }
  91902. /**
  91903. * A view into a buffer generally representing a subset of the buffer
  91904. */
  91905. interface IBufferView extends IChildRootProperty {
  91906. /**
  91907. * The index of the buffer
  91908. */
  91909. buffer: number;
  91910. /**
  91911. * The offset into the buffer in bytes
  91912. */
  91913. byteOffset?: number;
  91914. /**
  91915. * The lenth of the bufferView in bytes
  91916. */
  91917. byteLength: number;
  91918. /**
  91919. * The stride, in bytes
  91920. */
  91921. byteStride?: number;
  91922. }
  91923. /**
  91924. * An orthographic camera containing properties to create an orthographic projection matrix
  91925. */
  91926. interface ICameraOrthographic extends IProperty {
  91927. /**
  91928. * The floating-point horizontal magnification of the view. Must not be zero
  91929. */
  91930. xmag: number;
  91931. /**
  91932. * The floating-point vertical magnification of the view. Must not be zero
  91933. */
  91934. ymag: number;
  91935. /**
  91936. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  91937. */
  91938. zfar: number;
  91939. /**
  91940. * The floating-point distance to the near clipping plane
  91941. */
  91942. znear: number;
  91943. }
  91944. /**
  91945. * A perspective camera containing properties to create a perspective projection matrix
  91946. */
  91947. interface ICameraPerspective extends IProperty {
  91948. /**
  91949. * The floating-point aspect ratio of the field of view
  91950. */
  91951. aspectRatio?: number;
  91952. /**
  91953. * The floating-point vertical field of view in radians
  91954. */
  91955. yfov: number;
  91956. /**
  91957. * The floating-point distance to the far clipping plane
  91958. */
  91959. zfar?: number;
  91960. /**
  91961. * The floating-point distance to the near clipping plane
  91962. */
  91963. znear: number;
  91964. }
  91965. /**
  91966. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  91967. */
  91968. interface ICamera extends IChildRootProperty {
  91969. /**
  91970. * An orthographic camera containing properties to create an orthographic projection matrix
  91971. */
  91972. orthographic?: ICameraOrthographic;
  91973. /**
  91974. * A perspective camera containing properties to create a perspective projection matrix
  91975. */
  91976. perspective?: ICameraPerspective;
  91977. /**
  91978. * Specifies if the camera uses a perspective or orthographic projection
  91979. */
  91980. type: CameraType;
  91981. }
  91982. /**
  91983. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  91984. */
  91985. interface IImage extends IChildRootProperty {
  91986. /**
  91987. * 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
  91988. */
  91989. uri?: string;
  91990. /**
  91991. * The image's MIME type
  91992. */
  91993. mimeType?: ImageMimeType;
  91994. /**
  91995. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  91996. */
  91997. bufferView?: number;
  91998. }
  91999. /**
  92000. * Material Normal Texture Info
  92001. */
  92002. interface IMaterialNormalTextureInfo extends ITextureInfo {
  92003. /**
  92004. * The scalar multiplier applied to each normal vector of the normal texture
  92005. */
  92006. scale?: number;
  92007. }
  92008. /**
  92009. * Material Occlusion Texture Info
  92010. */
  92011. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  92012. /**
  92013. * A scalar multiplier controlling the amount of occlusion applied
  92014. */
  92015. strength?: number;
  92016. }
  92017. /**
  92018. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  92019. */
  92020. interface IMaterialPbrMetallicRoughness {
  92021. /**
  92022. * The material's base color factor
  92023. */
  92024. baseColorFactor?: number[];
  92025. /**
  92026. * The base color texture
  92027. */
  92028. baseColorTexture?: ITextureInfo;
  92029. /**
  92030. * The metalness of the material
  92031. */
  92032. metallicFactor?: number;
  92033. /**
  92034. * The roughness of the material
  92035. */
  92036. roughnessFactor?: number;
  92037. /**
  92038. * The metallic-roughness texture
  92039. */
  92040. metallicRoughnessTexture?: ITextureInfo;
  92041. }
  92042. /**
  92043. * The material appearance of a primitive
  92044. */
  92045. interface IMaterial extends IChildRootProperty {
  92046. /**
  92047. * 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
  92048. */
  92049. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  92050. /**
  92051. * The normal map texture
  92052. */
  92053. normalTexture?: IMaterialNormalTextureInfo;
  92054. /**
  92055. * The occlusion map texture
  92056. */
  92057. occlusionTexture?: IMaterialOcclusionTextureInfo;
  92058. /**
  92059. * The emissive map texture
  92060. */
  92061. emissiveTexture?: ITextureInfo;
  92062. /**
  92063. * 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
  92064. */
  92065. emissiveFactor?: number[];
  92066. /**
  92067. * The alpha rendering mode of the material
  92068. */
  92069. alphaMode?: MaterialAlphaMode;
  92070. /**
  92071. * The alpha cutoff value of the material
  92072. */
  92073. alphaCutoff?: number;
  92074. /**
  92075. * Specifies whether the material is double sided
  92076. */
  92077. doubleSided?: boolean;
  92078. }
  92079. /**
  92080. * Geometry to be rendered with the given material
  92081. */
  92082. interface IMeshPrimitive extends IProperty {
  92083. /**
  92084. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  92085. */
  92086. attributes: {
  92087. [name: string]: number;
  92088. };
  92089. /**
  92090. * The index of the accessor that contains the indices
  92091. */
  92092. indices?: number;
  92093. /**
  92094. * The index of the material to apply to this primitive when rendering
  92095. */
  92096. material?: number;
  92097. /**
  92098. * The type of primitives to render. All valid values correspond to WebGL enums
  92099. */
  92100. mode?: MeshPrimitiveMode;
  92101. /**
  92102. * 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
  92103. */
  92104. targets?: {
  92105. [name: string]: number;
  92106. }[];
  92107. }
  92108. /**
  92109. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  92110. */
  92111. interface IMesh extends IChildRootProperty {
  92112. /**
  92113. * An array of primitives, each defining geometry to be rendered with a material
  92114. */
  92115. primitives: IMeshPrimitive[];
  92116. /**
  92117. * Array of weights to be applied to the Morph Targets
  92118. */
  92119. weights?: number[];
  92120. }
  92121. /**
  92122. * A node in the node hierarchy
  92123. */
  92124. interface INode extends IChildRootProperty {
  92125. /**
  92126. * The index of the camera referenced by this node
  92127. */
  92128. camera?: number;
  92129. /**
  92130. * The indices of this node's children
  92131. */
  92132. children?: number[];
  92133. /**
  92134. * The index of the skin referenced by this node
  92135. */
  92136. skin?: number;
  92137. /**
  92138. * A floating-point 4x4 transformation matrix stored in column-major order
  92139. */
  92140. matrix?: number[];
  92141. /**
  92142. * The index of the mesh in this node
  92143. */
  92144. mesh?: number;
  92145. /**
  92146. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  92147. */
  92148. rotation?: number[];
  92149. /**
  92150. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  92151. */
  92152. scale?: number[];
  92153. /**
  92154. * The node's translation along the x, y, and z axes
  92155. */
  92156. translation?: number[];
  92157. /**
  92158. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  92159. */
  92160. weights?: number[];
  92161. }
  92162. /**
  92163. * Texture sampler properties for filtering and wrapping modes
  92164. */
  92165. interface ISampler extends IChildRootProperty {
  92166. /**
  92167. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  92168. */
  92169. magFilter?: TextureMagFilter;
  92170. /**
  92171. * Minification filter. All valid values correspond to WebGL enums
  92172. */
  92173. minFilter?: TextureMinFilter;
  92174. /**
  92175. * S (U) wrapping mode. All valid values correspond to WebGL enums
  92176. */
  92177. wrapS?: TextureWrapMode;
  92178. /**
  92179. * T (V) wrapping mode. All valid values correspond to WebGL enums
  92180. */
  92181. wrapT?: TextureWrapMode;
  92182. }
  92183. /**
  92184. * The root nodes of a scene
  92185. */
  92186. interface IScene extends IChildRootProperty {
  92187. /**
  92188. * The indices of each root node
  92189. */
  92190. nodes: number[];
  92191. }
  92192. /**
  92193. * Joints and matrices defining a skin
  92194. */
  92195. interface ISkin extends IChildRootProperty {
  92196. /**
  92197. * 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
  92198. */
  92199. inverseBindMatrices?: number;
  92200. /**
  92201. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  92202. */
  92203. skeleton?: number;
  92204. /**
  92205. * 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)
  92206. */
  92207. joints: number[];
  92208. }
  92209. /**
  92210. * A texture and its sampler
  92211. */
  92212. interface ITexture extends IChildRootProperty {
  92213. /**
  92214. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  92215. */
  92216. sampler?: number;
  92217. /**
  92218. * The index of the image used by this texture
  92219. */
  92220. source: number;
  92221. }
  92222. /**
  92223. * Reference to a texture
  92224. */
  92225. interface ITextureInfo extends IProperty {
  92226. /**
  92227. * The index of the texture
  92228. */
  92229. index: number;
  92230. /**
  92231. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  92232. */
  92233. texCoord?: number;
  92234. }
  92235. /**
  92236. * The root object for a glTF asset
  92237. */
  92238. interface IGLTF extends IProperty {
  92239. /**
  92240. * An array of accessors. An accessor is a typed view into a bufferView
  92241. */
  92242. accessors?: IAccessor[];
  92243. /**
  92244. * An array of keyframe animations
  92245. */
  92246. animations?: IAnimation[];
  92247. /**
  92248. * Metadata about the glTF asset
  92249. */
  92250. asset: IAsset;
  92251. /**
  92252. * An array of buffers. A buffer points to binary geometry, animation, or skins
  92253. */
  92254. buffers?: IBuffer[];
  92255. /**
  92256. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  92257. */
  92258. bufferViews?: IBufferView[];
  92259. /**
  92260. * An array of cameras
  92261. */
  92262. cameras?: ICamera[];
  92263. /**
  92264. * Names of glTF extensions used somewhere in this asset
  92265. */
  92266. extensionsUsed?: string[];
  92267. /**
  92268. * Names of glTF extensions required to properly load this asset
  92269. */
  92270. extensionsRequired?: string[];
  92271. /**
  92272. * An array of images. An image defines data used to create a texture
  92273. */
  92274. images?: IImage[];
  92275. /**
  92276. * An array of materials. A material defines the appearance of a primitive
  92277. */
  92278. materials?: IMaterial[];
  92279. /**
  92280. * An array of meshes. A mesh is a set of primitives to be rendered
  92281. */
  92282. meshes?: IMesh[];
  92283. /**
  92284. * An array of nodes
  92285. */
  92286. nodes?: INode[];
  92287. /**
  92288. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  92289. */
  92290. samplers?: ISampler[];
  92291. /**
  92292. * The index of the default scene
  92293. */
  92294. scene?: number;
  92295. /**
  92296. * An array of scenes
  92297. */
  92298. scenes?: IScene[];
  92299. /**
  92300. * An array of skins. A skin is defined by joints and matrices
  92301. */
  92302. skins?: ISkin[];
  92303. /**
  92304. * An array of textures
  92305. */
  92306. textures?: ITexture[];
  92307. }
  92308. /**
  92309. * The glTF validation results
  92310. * @ignore
  92311. */
  92312. interface IGLTFValidationResults {
  92313. info: {
  92314. generator: string;
  92315. hasAnimations: boolean;
  92316. hasDefaultScene: boolean;
  92317. hasMaterials: boolean;
  92318. hasMorphTargets: boolean;
  92319. hasSkins: boolean;
  92320. hasTextures: boolean;
  92321. maxAttributesUsed: number;
  92322. primitivesCount: number
  92323. };
  92324. issues: {
  92325. messages: Array<string>;
  92326. numErrors: number;
  92327. numHints: number;
  92328. numInfos: number;
  92329. numWarnings: number;
  92330. truncated: boolean
  92331. };
  92332. mimeType: string;
  92333. uri: string;
  92334. validatedAt: string;
  92335. validatorVersion: string;
  92336. }
  92337. /**
  92338. * The glTF validation options
  92339. */
  92340. interface IGLTFValidationOptions {
  92341. /** Uri to use */
  92342. uri?: string;
  92343. /** Function used to load external resources */
  92344. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  92345. /** Boolean indicating that we need to validate accessor data */
  92346. validateAccessorData?: boolean;
  92347. /** max number of issues allowed */
  92348. maxIssues?: number;
  92349. /** Ignored issues */
  92350. ignoredIssues?: Array<string>;
  92351. /** Value to override severy settings */
  92352. severityOverrides?: Object;
  92353. }
  92354. /**
  92355. * The glTF validator object
  92356. * @ignore
  92357. */
  92358. interface IGLTFValidator {
  92359. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  92360. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  92361. }
  92362. /**
  92363. * Interfaces from the EXT_lights_image_based extension
  92364. */
  92365. /** @hidden */
  92366. interface IEXTLightsImageBased_LightReferenceImageBased {
  92367. light: number;
  92368. }
  92369. /** @hidden */
  92370. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  92371. intensity: number;
  92372. rotation: number[];
  92373. specularImageSize: number;
  92374. specularImages: number[][];
  92375. irradianceCoefficients: number[][];
  92376. }
  92377. /** @hidden */
  92378. interface IEXTLightsImageBased {
  92379. lights: IEXTLightsImageBased_LightImageBased[];
  92380. }
  92381. /**
  92382. * Interfaces from the EXT_mesh_gpu_instancing extension
  92383. * !!! Experimental Extension Subject to Changes !!!
  92384. */
  92385. /** @hidden */
  92386. interface IEXTMeshGpuInstancing {
  92387. mesh?: number;
  92388. attributes: { [name: string]: number };
  92389. }
  92390. /**
  92391. * Interfaces from the KHR_draco_mesh_compression extension
  92392. */
  92393. /** @hidden */
  92394. interface IKHRDracoMeshCompression {
  92395. bufferView: number;
  92396. attributes: { [name: string]: number };
  92397. }
  92398. /**
  92399. * Interfaces from the KHR_lights_punctual extension
  92400. */
  92401. /** @hidden */
  92402. const enum IKHRLightsPunctual_LightType {
  92403. DIRECTIONAL = "directional",
  92404. POINT = "point",
  92405. SPOT = "spot"
  92406. }
  92407. /** @hidden */
  92408. interface IKHRLightsPunctual_LightReference {
  92409. light: number;
  92410. }
  92411. /** @hidden */
  92412. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  92413. type: IKHRLightsPunctual_LightType;
  92414. color?: number[];
  92415. intensity?: number;
  92416. range?: number;
  92417. spot?: {
  92418. innerConeAngle?: number;
  92419. outerConeAngle?: number;
  92420. };
  92421. }
  92422. /** @hidden */
  92423. interface IKHRLightsPunctual {
  92424. lights: IKHRLightsPunctual_Light[];
  92425. }
  92426. /**
  92427. * Interfaces from the KHR_materials_clearcoat extension
  92428. * !!! Experimental Extension Subject to Changes !!!
  92429. */
  92430. /** @hidden */
  92431. interface IKHRMaterialsClearcoat {
  92432. clearcoatFactor: number;
  92433. clearcoatTexture: ITextureInfo;
  92434. clearcoatRoughnessFactor: number;
  92435. clearcoatRoughnessTexture: ITextureInfo;
  92436. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  92437. }
  92438. /**
  92439. * Interfaces from the KHR_materials_ior extension
  92440. * !!! Experimental Extension Subject to Changes !!!
  92441. */
  92442. /** @hidden */
  92443. interface IKHRMaterialsIor {
  92444. ior: number;
  92445. }
  92446. /**
  92447. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  92448. */
  92449. /** @hidden */
  92450. interface IKHRMaterialsPbrSpecularGlossiness {
  92451. diffuseFactor: number[];
  92452. diffuseTexture: ITextureInfo;
  92453. specularFactor: number[];
  92454. glossinessFactor: number;
  92455. specularGlossinessTexture: ITextureInfo;
  92456. }
  92457. /**
  92458. * Interfaces from the KHR_materials_sheen extension
  92459. * !!! Experimental Extension Subject to Changes !!!
  92460. */
  92461. /** @hidden */
  92462. interface IKHRMaterialsSheen {
  92463. sheenColorFactor?: number[];
  92464. sheenColorTexture?: ITextureInfo;
  92465. sheenRoughnessFactor?: number;
  92466. sheenRoughnessTexture?: ITextureInfo;
  92467. }
  92468. /**
  92469. * Interfaces from the KHR_materials_specular extension
  92470. * !!! Experimental Extension Subject to Changes !!!
  92471. */
  92472. /** @hidden */
  92473. interface IKHRMaterialsSpecular {
  92474. specularFactor: number;
  92475. specularColorFactor: number[];
  92476. specularTexture: ITextureInfo;
  92477. }
  92478. /**
  92479. * Interfaces from the KHR_materials_transmission extension
  92480. * !!! Experimental Extension Subject to Changes !!!
  92481. */
  92482. /** @hidden */
  92483. interface IKHRMaterialsTransmission {
  92484. transmissionFactor?: number;
  92485. transmissionTexture?: ITextureInfo;
  92486. }
  92487. /**
  92488. * Interfaces from the KHR_materials_translucency extension
  92489. * !!! Experimental Extension Subject to Changes !!!
  92490. */
  92491. /** @hidden */
  92492. interface IKHRMaterialsTranslucency {
  92493. translucencyFactor?: number;
  92494. translucencyTexture?: ITextureInfo;
  92495. }
  92496. /**
  92497. * Interfaces from the KHR_materials_variants extension
  92498. * !!! Experimental Extension Subject to Changes !!!
  92499. */
  92500. /** @hidden */
  92501. interface IKHRMaterialVariants_Mapping extends IProperty {
  92502. mappings: Array<{
  92503. variants: number[];
  92504. material: number;
  92505. }>;
  92506. }
  92507. /** @hidden */
  92508. interface IKHRMaterialVariants_Variant extends IProperty {
  92509. name: string;
  92510. }
  92511. /** @hidden */
  92512. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  92513. variants: Array<IKHRMaterialVariants_Variant>;
  92514. }
  92515. /**
  92516. * Interfaces from the KHR_texture_basisu extension
  92517. * !!! Experimental Extension Subject to Changes !!!
  92518. */
  92519. /** @hidden */
  92520. interface IKHRTextureBasisU {
  92521. source: number;
  92522. }
  92523. /**
  92524. * Interfaces from the EXT_texture_webp extension
  92525. */
  92526. /** @hidden */
  92527. interface IEXTTextureWebP {
  92528. source: number;
  92529. }
  92530. /**
  92531. * Interfaces from the KHR_texture_transform extension
  92532. */
  92533. /** @hidden */
  92534. interface IKHRTextureTransform {
  92535. offset?: number[];
  92536. rotation?: number;
  92537. scale?: number[];
  92538. texCoord?: number;
  92539. }
  92540. /**
  92541. * Interfaces from the KHR_xmp_json_ld extension
  92542. * !!! Experimental Extension Subject to Changes !!!
  92543. */
  92544. /** @hidden */
  92545. interface IKHRXmpJsonLd_Gltf {
  92546. packets: Array<{
  92547. [key: string]: unknown;
  92548. }>;
  92549. }
  92550. /** @hidden */
  92551. interface IKHRXmpJsonLd_Node {
  92552. packet: number;
  92553. }
  92554. /**
  92555. * Interfaces from the MSFT_audio_emitter extension
  92556. */
  92557. /** @hidden */
  92558. interface IMSFTAudioEmitter_ClipReference {
  92559. clip: number;
  92560. weight?: number;
  92561. }
  92562. /** @hidden */
  92563. interface IMSFTAudioEmitter_EmittersReference {
  92564. emitters: number[];
  92565. }
  92566. /** @hidden */
  92567. const enum IMSFTAudioEmitter_DistanceModel {
  92568. linear = "linear",
  92569. inverse = "inverse",
  92570. exponential = "exponential",
  92571. }
  92572. /** @hidden */
  92573. interface IMSFTAudioEmitter_Emitter {
  92574. name?: string;
  92575. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  92576. refDistance?: number;
  92577. maxDistance?: number;
  92578. rolloffFactor?: number;
  92579. innerAngle?: number;
  92580. outerAngle?: number;
  92581. loop?: boolean;
  92582. volume?: number;
  92583. clips: IMSFTAudioEmitter_ClipReference[];
  92584. }
  92585. /** @hidden */
  92586. const enum IMSFTAudioEmitter_AudioMimeType {
  92587. WAV = "audio/wav",
  92588. }
  92589. /** @hidden */
  92590. interface IMSFTAudioEmitter_Clip extends IProperty {
  92591. uri?: string;
  92592. bufferView?: number;
  92593. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  92594. }
  92595. /** @hidden */
  92596. const enum IMSFTAudioEmitter_AnimationEventAction {
  92597. play = "play",
  92598. pause = "pause",
  92599. stop = "stop",
  92600. }
  92601. /** @hidden */
  92602. interface IMSFTAudioEmitter_AnimationEvent {
  92603. action: IMSFTAudioEmitter_AnimationEventAction;
  92604. emitter: number;
  92605. time: number;
  92606. startOffset?: number;
  92607. }
  92608. /**
  92609. * Interfaces from the MSFT_lod extension
  92610. */
  92611. /** @hidden */
  92612. interface IMSFTLOD {
  92613. ids: number[];
  92614. }
  92615. /**
  92616. * Interfaces from the EXT_meshopt_compression extension
  92617. */
  92618. /** @hidden */
  92619. interface IEXTMeshoptCompression {
  92620. buffer: number;
  92621. byteOffset?: number;
  92622. byteLength: number;
  92623. byteStride: number;
  92624. count: number;
  92625. mode: "ATTRIBUTES" | "TRIANGLES" | "INDICES";
  92626. filter?: "NONE" | "OCTAHEDRAL" | "QUATERNION" | "EXPONENTIAL";
  92627. }
  92628. }
  92629. declare module BABYLON {
  92630. /** @hidden */
  92631. export var cellPixelShader: {
  92632. name: string;
  92633. shader: string;
  92634. };
  92635. }
  92636. declare module BABYLON {
  92637. /** @hidden */
  92638. export var cellVertexShader: {
  92639. name: string;
  92640. shader: string;
  92641. };
  92642. }
  92643. declare module BABYLON {
  92644. export class CellMaterial extends BABYLON.PushMaterial {
  92645. private _diffuseTexture;
  92646. diffuseTexture: BABYLON.BaseTexture;
  92647. diffuseColor: BABYLON.Color3;
  92648. _computeHighLevel: boolean;
  92649. computeHighLevel: boolean;
  92650. private _disableLighting;
  92651. disableLighting: boolean;
  92652. private _maxSimultaneousLights;
  92653. maxSimultaneousLights: number;
  92654. constructor(name: string, scene: BABYLON.Scene);
  92655. needAlphaBlending(): boolean;
  92656. needAlphaTesting(): boolean;
  92657. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92658. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92659. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92660. getAnimatables(): BABYLON.IAnimatable[];
  92661. getActiveTextures(): BABYLON.BaseTexture[];
  92662. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92663. dispose(forceDisposeEffect?: boolean): void;
  92664. getClassName(): string;
  92665. clone(name: string): CellMaterial;
  92666. serialize(): any;
  92667. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  92668. }
  92669. }
  92670. declare module BABYLON {
  92671. export class CustomShaderStructure {
  92672. FragmentStore: string;
  92673. VertexStore: string;
  92674. constructor();
  92675. }
  92676. export class ShaderSpecialParts {
  92677. constructor();
  92678. Fragment_Begin: string;
  92679. Fragment_Definitions: string;
  92680. Fragment_MainBegin: string;
  92681. Fragment_Custom_Diffuse: string;
  92682. Fragment_Before_Lights: string;
  92683. Fragment_Before_Fog: string;
  92684. Fragment_Custom_Alpha: string;
  92685. Fragment_Before_FragColor: string;
  92686. Vertex_Begin: string;
  92687. Vertex_Definitions: string;
  92688. Vertex_MainBegin: string;
  92689. Vertex_Before_PositionUpdated: string;
  92690. Vertex_Before_NormalUpdated: string;
  92691. Vertex_After_WorldPosComputed: string;
  92692. Vertex_MainEnd: string;
  92693. }
  92694. export class CustomMaterial extends BABYLON.StandardMaterial {
  92695. static ShaderIndexer: number;
  92696. CustomParts: ShaderSpecialParts;
  92697. _isCreatedShader: boolean;
  92698. _createdShaderName: string;
  92699. _customUniform: string[];
  92700. _newUniforms: string[];
  92701. _newUniformInstances: {
  92702. [name: string]: any;
  92703. };
  92704. _newSamplerInstances: {
  92705. [name: string]: BABYLON.Texture;
  92706. };
  92707. _customAttributes: string[];
  92708. FragmentShader: string;
  92709. VertexShader: string;
  92710. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  92711. ReviewUniform(name: string, arr: string[]): string[];
  92712. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  92713. constructor(name: string, scene: BABYLON.Scene);
  92714. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  92715. AddAttribute(name: string): CustomMaterial;
  92716. Fragment_Begin(shaderPart: string): CustomMaterial;
  92717. Fragment_Definitions(shaderPart: string): CustomMaterial;
  92718. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  92719. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  92720. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  92721. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  92722. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  92723. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  92724. Vertex_Begin(shaderPart: string): CustomMaterial;
  92725. Vertex_Definitions(shaderPart: string): CustomMaterial;
  92726. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  92727. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  92728. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  92729. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  92730. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  92731. }
  92732. }
  92733. declare module BABYLON {
  92734. export class ShaderAlebdoParts {
  92735. constructor();
  92736. Fragment_Begin: string;
  92737. Fragment_Definitions: string;
  92738. Fragment_MainBegin: string;
  92739. Fragment_Custom_Albedo: string;
  92740. Fragment_Before_Lights: string;
  92741. Fragment_Custom_MetallicRoughness: string;
  92742. Fragment_Custom_MicroSurface: string;
  92743. Fragment_Before_Fog: string;
  92744. Fragment_Custom_Alpha: string;
  92745. Fragment_Before_FragColor: string;
  92746. Vertex_Begin: string;
  92747. Vertex_Definitions: string;
  92748. Vertex_MainBegin: string;
  92749. Vertex_Before_PositionUpdated: string;
  92750. Vertex_Before_NormalUpdated: string;
  92751. Vertex_After_WorldPosComputed: string;
  92752. Vertex_MainEnd: string;
  92753. }
  92754. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  92755. static ShaderIndexer: number;
  92756. CustomParts: ShaderAlebdoParts;
  92757. _isCreatedShader: boolean;
  92758. _createdShaderName: string;
  92759. _customUniform: string[];
  92760. _newUniforms: string[];
  92761. _newUniformInstances: {
  92762. [name: string]: any;
  92763. };
  92764. _newSamplerInstances: {
  92765. [name: string]: BABYLON.Texture;
  92766. };
  92767. _customAttributes: string[];
  92768. FragmentShader: string;
  92769. VertexShader: string;
  92770. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  92771. ReviewUniform(name: string, arr: string[]): string[];
  92772. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[], options?: BABYLON.ICustomShaderNameResolveOptions): string;
  92773. constructor(name: string, scene: BABYLON.Scene);
  92774. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  92775. AddAttribute(name: string): PBRCustomMaterial;
  92776. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  92777. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  92778. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  92779. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  92780. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  92781. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  92782. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  92783. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  92784. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  92785. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  92786. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  92787. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  92788. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  92789. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  92790. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  92791. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  92792. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  92793. }
  92794. }
  92795. declare module BABYLON {
  92796. /** @hidden */
  92797. export var firePixelShader: {
  92798. name: string;
  92799. shader: string;
  92800. };
  92801. }
  92802. declare module BABYLON {
  92803. /** @hidden */
  92804. export var fireVertexShader: {
  92805. name: string;
  92806. shader: string;
  92807. };
  92808. }
  92809. declare module BABYLON {
  92810. export class FireMaterial extends BABYLON.PushMaterial {
  92811. private _diffuseTexture;
  92812. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  92813. private _distortionTexture;
  92814. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  92815. private _opacityTexture;
  92816. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  92817. diffuseColor: BABYLON.Color3;
  92818. speed: number;
  92819. private _scaledDiffuse;
  92820. private _lastTime;
  92821. constructor(name: string, scene: BABYLON.Scene);
  92822. needAlphaBlending(): boolean;
  92823. needAlphaTesting(): boolean;
  92824. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92825. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92826. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92827. getAnimatables(): BABYLON.IAnimatable[];
  92828. getActiveTextures(): BABYLON.BaseTexture[];
  92829. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92830. getClassName(): string;
  92831. dispose(forceDisposeEffect?: boolean): void;
  92832. clone(name: string): FireMaterial;
  92833. serialize(): any;
  92834. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  92835. }
  92836. }
  92837. declare module BABYLON {
  92838. /** @hidden */
  92839. export var furPixelShader: {
  92840. name: string;
  92841. shader: string;
  92842. };
  92843. }
  92844. declare module BABYLON {
  92845. /** @hidden */
  92846. export var furVertexShader: {
  92847. name: string;
  92848. shader: string;
  92849. };
  92850. }
  92851. declare module BABYLON {
  92852. export class FurMaterial extends BABYLON.PushMaterial {
  92853. private _diffuseTexture;
  92854. diffuseTexture: BABYLON.BaseTexture;
  92855. private _heightTexture;
  92856. heightTexture: BABYLON.BaseTexture;
  92857. diffuseColor: BABYLON.Color3;
  92858. furLength: number;
  92859. furAngle: number;
  92860. furColor: BABYLON.Color3;
  92861. furOffset: number;
  92862. furSpacing: number;
  92863. furGravity: BABYLON.Vector3;
  92864. furSpeed: number;
  92865. furDensity: number;
  92866. furOcclusion: number;
  92867. furTexture: BABYLON.DynamicTexture;
  92868. private _disableLighting;
  92869. disableLighting: boolean;
  92870. private _maxSimultaneousLights;
  92871. maxSimultaneousLights: number;
  92872. highLevelFur: boolean;
  92873. _meshes: BABYLON.AbstractMesh[];
  92874. private _furTime;
  92875. constructor(name: string, scene: BABYLON.Scene);
  92876. get furTime(): number;
  92877. set furTime(furTime: number);
  92878. needAlphaBlending(): boolean;
  92879. needAlphaTesting(): boolean;
  92880. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92881. updateFur(): void;
  92882. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92883. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92884. getAnimatables(): BABYLON.IAnimatable[];
  92885. getActiveTextures(): BABYLON.BaseTexture[];
  92886. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92887. dispose(forceDisposeEffect?: boolean): void;
  92888. clone(name: string): FurMaterial;
  92889. serialize(): any;
  92890. getClassName(): string;
  92891. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  92892. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  92893. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  92894. }
  92895. }
  92896. declare module BABYLON {
  92897. /** @hidden */
  92898. export var gradientPixelShader: {
  92899. name: string;
  92900. shader: string;
  92901. };
  92902. }
  92903. declare module BABYLON {
  92904. /** @hidden */
  92905. export var gradientVertexShader: {
  92906. name: string;
  92907. shader: string;
  92908. };
  92909. }
  92910. declare module BABYLON {
  92911. export class GradientMaterial extends BABYLON.PushMaterial {
  92912. private _maxSimultaneousLights;
  92913. maxSimultaneousLights: number;
  92914. topColor: BABYLON.Color3;
  92915. topColorAlpha: number;
  92916. bottomColor: BABYLON.Color3;
  92917. bottomColorAlpha: number;
  92918. offset: number;
  92919. scale: number;
  92920. smoothness: number;
  92921. private _disableLighting;
  92922. disableLighting: boolean;
  92923. constructor(name: string, scene: BABYLON.Scene);
  92924. needAlphaBlending(): boolean;
  92925. needAlphaTesting(): boolean;
  92926. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92927. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92928. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92929. getAnimatables(): BABYLON.IAnimatable[];
  92930. dispose(forceDisposeEffect?: boolean): void;
  92931. clone(name: string): GradientMaterial;
  92932. serialize(): any;
  92933. getClassName(): string;
  92934. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  92935. }
  92936. }
  92937. declare module BABYLON {
  92938. /** @hidden */
  92939. export var gridPixelShader: {
  92940. name: string;
  92941. shader: string;
  92942. };
  92943. }
  92944. declare module BABYLON {
  92945. /** @hidden */
  92946. export var gridVertexShader: {
  92947. name: string;
  92948. shader: string;
  92949. };
  92950. }
  92951. declare module BABYLON {
  92952. /**
  92953. * The grid materials allows you to wrap any shape with a grid.
  92954. * Colors are customizable.
  92955. */
  92956. export class GridMaterial extends BABYLON.PushMaterial {
  92957. /**
  92958. * Main color of the grid (e.g. between lines)
  92959. */
  92960. mainColor: BABYLON.Color3;
  92961. /**
  92962. * Color of the grid lines.
  92963. */
  92964. lineColor: BABYLON.Color3;
  92965. /**
  92966. * The scale of the grid compared to unit.
  92967. */
  92968. gridRatio: number;
  92969. /**
  92970. * Allows setting an offset for the grid lines.
  92971. */
  92972. gridOffset: BABYLON.Vector3;
  92973. /**
  92974. * The frequency of thicker lines.
  92975. */
  92976. majorUnitFrequency: number;
  92977. /**
  92978. * The visibility of minor units in the grid.
  92979. */
  92980. minorUnitVisibility: number;
  92981. /**
  92982. * The grid opacity outside of the lines.
  92983. */
  92984. opacity: number;
  92985. /**
  92986. * Determine RBG output is premultiplied by alpha value.
  92987. */
  92988. preMultiplyAlpha: boolean;
  92989. private _opacityTexture;
  92990. opacityTexture: BABYLON.BaseTexture;
  92991. private _gridControl;
  92992. /**
  92993. * constructor
  92994. * @param name The name given to the material in order to identify it afterwards.
  92995. * @param scene The scene the material is used in.
  92996. */
  92997. constructor(name: string, scene: BABYLON.Scene);
  92998. /**
  92999. * Returns wehter or not the grid requires alpha blending.
  93000. */
  93001. needAlphaBlending(): boolean;
  93002. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  93003. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  93004. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  93005. /**
  93006. * Dispose the material and its associated resources.
  93007. * @param forceDisposeEffect will also dispose the used effect when true
  93008. */
  93009. dispose(forceDisposeEffect?: boolean): void;
  93010. clone(name: string): GridMaterial;
  93011. serialize(): any;
  93012. getClassName(): string;
  93013. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  93014. }
  93015. }
  93016. declare module BABYLON {
  93017. /** @hidden */
  93018. export var lavaPixelShader: {
  93019. name: string;
  93020. shader: string;
  93021. };
  93022. }
  93023. declare module BABYLON {
  93024. /** @hidden */
  93025. export var lavaVertexShader: {
  93026. name: string;
  93027. shader: string;
  93028. };
  93029. }
  93030. declare module BABYLON {
  93031. export class LavaMaterial extends BABYLON.PushMaterial {
  93032. private _diffuseTexture;
  93033. diffuseTexture: BABYLON.BaseTexture;
  93034. noiseTexture: BABYLON.BaseTexture;
  93035. fogColor: BABYLON.Color3;
  93036. speed: number;
  93037. movingSpeed: number;
  93038. lowFrequencySpeed: number;
  93039. fogDensity: number;
  93040. private _lastTime;
  93041. diffuseColor: BABYLON.Color3;
  93042. private _disableLighting;
  93043. disableLighting: boolean;
  93044. private _unlit;
  93045. unlit: boolean;
  93046. private _maxSimultaneousLights;
  93047. maxSimultaneousLights: number;
  93048. private _scaledDiffuse;
  93049. constructor(name: string, scene: BABYLON.Scene);
  93050. needAlphaBlending(): boolean;
  93051. needAlphaTesting(): boolean;
  93052. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  93053. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  93054. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  93055. getAnimatables(): BABYLON.IAnimatable[];
  93056. getActiveTextures(): BABYLON.BaseTexture[];
  93057. hasTexture(texture: BABYLON.BaseTexture): boolean;
  93058. dispose(forceDisposeEffect?: boolean): void;
  93059. clone(name: string): LavaMaterial;
  93060. serialize(): any;
  93061. getClassName(): string;
  93062. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  93063. }
  93064. }
  93065. declare module BABYLON {
  93066. /** @hidden */
  93067. export var mixPixelShader: {
  93068. name: string;
  93069. shader: string;
  93070. };
  93071. }
  93072. declare module BABYLON {
  93073. /** @hidden */
  93074. export var mixVertexShader: {
  93075. name: string;
  93076. shader: string;
  93077. };
  93078. }
  93079. declare module BABYLON {
  93080. export class MixMaterial extends BABYLON.PushMaterial {
  93081. /**
  93082. * Mix textures
  93083. */
  93084. private _mixTexture1;
  93085. mixTexture1: BABYLON.BaseTexture;
  93086. private _mixTexture2;
  93087. mixTexture2: BABYLON.BaseTexture;
  93088. /**
  93089. * Diffuse textures
  93090. */
  93091. private _diffuseTexture1;
  93092. diffuseTexture1: BABYLON.Texture;
  93093. private _diffuseTexture2;
  93094. diffuseTexture2: BABYLON.Texture;
  93095. private _diffuseTexture3;
  93096. diffuseTexture3: BABYLON.Texture;
  93097. private _diffuseTexture4;
  93098. diffuseTexture4: BABYLON.Texture;
  93099. private _diffuseTexture5;
  93100. diffuseTexture5: BABYLON.Texture;
  93101. private _diffuseTexture6;
  93102. diffuseTexture6: BABYLON.Texture;
  93103. private _diffuseTexture7;
  93104. diffuseTexture7: BABYLON.Texture;
  93105. private _diffuseTexture8;
  93106. diffuseTexture8: BABYLON.Texture;
  93107. /**
  93108. * Uniforms
  93109. */
  93110. diffuseColor: BABYLON.Color3;
  93111. specularColor: BABYLON.Color3;
  93112. specularPower: number;
  93113. private _disableLighting;
  93114. disableLighting: boolean;
  93115. private _maxSimultaneousLights;
  93116. maxSimultaneousLights: number;
  93117. constructor(name: string, scene: BABYLON.Scene);
  93118. needAlphaBlending(): boolean;
  93119. needAlphaTesting(): boolean;
  93120. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  93121. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  93122. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  93123. getAnimatables(): BABYLON.IAnimatable[];
  93124. getActiveTextures(): BABYLON.BaseTexture[];
  93125. hasTexture(texture: BABYLON.BaseTexture): boolean;
  93126. dispose(forceDisposeEffect?: boolean): void;
  93127. clone(name: string): MixMaterial;
  93128. serialize(): any;
  93129. getClassName(): string;
  93130. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  93131. }
  93132. }
  93133. declare module BABYLON {
  93134. /** @hidden */
  93135. export var normalPixelShader: {
  93136. name: string;
  93137. shader: string;
  93138. };
  93139. }
  93140. declare module BABYLON {
  93141. /** @hidden */
  93142. export var normalVertexShader: {
  93143. name: string;
  93144. shader: string;
  93145. };
  93146. }
  93147. declare module BABYLON {
  93148. export class NormalMaterial extends BABYLON.PushMaterial {
  93149. private _diffuseTexture;
  93150. diffuseTexture: BABYLON.BaseTexture;
  93151. diffuseColor: BABYLON.Color3;
  93152. private _disableLighting;
  93153. disableLighting: boolean;
  93154. private _maxSimultaneousLights;
  93155. maxSimultaneousLights: number;
  93156. constructor(name: string, scene: BABYLON.Scene);
  93157. needAlphaBlending(): boolean;
  93158. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  93159. needAlphaTesting(): boolean;
  93160. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  93161. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  93162. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  93163. getAnimatables(): BABYLON.IAnimatable[];
  93164. getActiveTextures(): BABYLON.BaseTexture[];
  93165. hasTexture(texture: BABYLON.BaseTexture): boolean;
  93166. dispose(forceDisposeEffect?: boolean): void;
  93167. clone(name: string): NormalMaterial;
  93168. serialize(): any;
  93169. getClassName(): string;
  93170. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  93171. }
  93172. }
  93173. declare module BABYLON {
  93174. /** @hidden */
  93175. export var shadowOnlyPixelShader: {
  93176. name: string;
  93177. shader: string;
  93178. };
  93179. }
  93180. declare module BABYLON {
  93181. /** @hidden */
  93182. export var shadowOnlyVertexShader: {
  93183. name: string;
  93184. shader: string;
  93185. };
  93186. }
  93187. declare module BABYLON {
  93188. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  93189. private _activeLight;
  93190. private _needAlphaBlending;
  93191. constructor(name: string, scene: BABYLON.Scene);
  93192. shadowColor: BABYLON.Color3;
  93193. needAlphaBlending(): boolean;
  93194. needAlphaTesting(): boolean;
  93195. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  93196. get activeLight(): BABYLON.IShadowLight;
  93197. set activeLight(light: BABYLON.IShadowLight);
  93198. private _getFirstShadowLightForMesh;
  93199. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  93200. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  93201. clone(name: string): ShadowOnlyMaterial;
  93202. serialize(): any;
  93203. getClassName(): string;
  93204. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  93205. }
  93206. }
  93207. declare module BABYLON {
  93208. /** @hidden */
  93209. export var simplePixelShader: {
  93210. name: string;
  93211. shader: string;
  93212. };
  93213. }
  93214. declare module BABYLON {
  93215. /** @hidden */
  93216. export var simpleVertexShader: {
  93217. name: string;
  93218. shader: string;
  93219. };
  93220. }
  93221. declare module BABYLON {
  93222. export class SimpleMaterial extends BABYLON.PushMaterial {
  93223. private _diffuseTexture;
  93224. diffuseTexture: BABYLON.BaseTexture;
  93225. diffuseColor: BABYLON.Color3;
  93226. private _disableLighting;
  93227. disableLighting: boolean;
  93228. private _maxSimultaneousLights;
  93229. maxSimultaneousLights: number;
  93230. constructor(name: string, scene: BABYLON.Scene);
  93231. needAlphaBlending(): boolean;
  93232. needAlphaTesting(): boolean;
  93233. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  93234. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  93235. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  93236. getAnimatables(): BABYLON.IAnimatable[];
  93237. getActiveTextures(): BABYLON.BaseTexture[];
  93238. hasTexture(texture: BABYLON.BaseTexture): boolean;
  93239. dispose(forceDisposeEffect?: boolean): void;
  93240. clone(name: string): SimpleMaterial;
  93241. serialize(): any;
  93242. getClassName(): string;
  93243. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  93244. }
  93245. }
  93246. declare module BABYLON {
  93247. /** @hidden */
  93248. export var skyPixelShader: {
  93249. name: string;
  93250. shader: string;
  93251. };
  93252. }
  93253. declare module BABYLON {
  93254. /** @hidden */
  93255. export var skyVertexShader: {
  93256. name: string;
  93257. shader: string;
  93258. };
  93259. }
  93260. declare module BABYLON {
  93261. /**
  93262. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  93263. * @see https://doc.babylonjs.com/extensions/sky
  93264. */
  93265. export class SkyMaterial extends BABYLON.PushMaterial {
  93266. /**
  93267. * Defines the overall luminance of sky in interval ]0, 1[.
  93268. */
  93269. luminance: number;
  93270. /**
  93271. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  93272. */
  93273. turbidity: number;
  93274. /**
  93275. * Defines the sky appearance (light intensity).
  93276. */
  93277. rayleigh: number;
  93278. /**
  93279. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  93280. */
  93281. mieCoefficient: number;
  93282. /**
  93283. * Defines the amount of haze particles following the Mie scattering theory.
  93284. */
  93285. mieDirectionalG: number;
  93286. /**
  93287. * Defines the distance of the sun according to the active scene camera.
  93288. */
  93289. distance: number;
  93290. /**
  93291. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  93292. * "inclined".
  93293. */
  93294. inclination: number;
  93295. /**
  93296. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  93297. * an object direction and a reference direction.
  93298. */
  93299. azimuth: number;
  93300. /**
  93301. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  93302. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  93303. */
  93304. sunPosition: BABYLON.Vector3;
  93305. /**
  93306. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  93307. * .sunPosition property.
  93308. */
  93309. useSunPosition: boolean;
  93310. /**
  93311. * Defines an offset vector used to get a horizon offset.
  93312. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  93313. */
  93314. cameraOffset: BABYLON.Vector3;
  93315. /**
  93316. * Defines the vector the skyMaterial should consider as up. (default is BABYLON.Vector3(0, 1, 0) as returned by BABYLON.Vector3.Up())
  93317. */
  93318. up: BABYLON.Vector3;
  93319. private _cameraPosition;
  93320. private _skyOrientation;
  93321. /**
  93322. * Instantiates a new sky material.
  93323. * This material allows to create dynamic and texture free
  93324. * effects for skyboxes by taking care of the atmosphere state.
  93325. * @see https://doc.babylonjs.com/extensions/sky
  93326. * @param name Define the name of the material in the scene
  93327. * @param scene Define the scene the material belong to
  93328. */
  93329. constructor(name: string, scene: BABYLON.Scene);
  93330. /**
  93331. * Specifies if the material will require alpha blending
  93332. * @returns a boolean specifying if alpha blending is needed
  93333. */
  93334. needAlphaBlending(): boolean;
  93335. /**
  93336. * Specifies if this material should be rendered in alpha test mode
  93337. * @returns false as the sky material doesn't need alpha testing.
  93338. */
  93339. needAlphaTesting(): boolean;
  93340. /**
  93341. * Get the texture used for alpha test purpose.
  93342. * @returns null as the sky material has no texture.
  93343. */
  93344. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  93345. /**
  93346. * Get if the submesh is ready to be used and all its information available.
  93347. * Child classes can use it to update shaders
  93348. * @param mesh defines the mesh to check
  93349. * @param subMesh defines which submesh to check
  93350. * @param useInstances specifies that instances should be used
  93351. * @returns a boolean indicating that the submesh is ready or not
  93352. */
  93353. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  93354. /**
  93355. * Binds the submesh to this material by preparing the effect and shader to draw
  93356. * @param world defines the world transformation matrix
  93357. * @param mesh defines the mesh containing the submesh
  93358. * @param subMesh defines the submesh to bind the material to
  93359. */
  93360. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  93361. /**
  93362. * Get the list of animatables in the material.
  93363. * @returns the list of animatables object used in the material
  93364. */
  93365. getAnimatables(): BABYLON.IAnimatable[];
  93366. /**
  93367. * Disposes the material
  93368. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  93369. */
  93370. dispose(forceDisposeEffect?: boolean): void;
  93371. /**
  93372. * Makes a duplicate of the material, and gives it a new name
  93373. * @param name defines the new name for the duplicated material
  93374. * @returns the cloned material
  93375. */
  93376. clone(name: string): SkyMaterial;
  93377. /**
  93378. * Serializes this material in a JSON representation
  93379. * @returns the serialized material object
  93380. */
  93381. serialize(): any;
  93382. /**
  93383. * Gets the current class name of the material e.g. "SkyMaterial"
  93384. * Mainly use in serialization.
  93385. * @returns the class name
  93386. */
  93387. getClassName(): string;
  93388. /**
  93389. * Creates a sky material from parsed material data
  93390. * @param source defines the JSON representation of the material
  93391. * @param scene defines the hosting scene
  93392. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  93393. * @returns a new sky material
  93394. */
  93395. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  93396. }
  93397. }
  93398. declare module BABYLON {
  93399. /** @hidden */
  93400. export var terrainPixelShader: {
  93401. name: string;
  93402. shader: string;
  93403. };
  93404. }
  93405. declare module BABYLON {
  93406. /** @hidden */
  93407. export var terrainVertexShader: {
  93408. name: string;
  93409. shader: string;
  93410. };
  93411. }
  93412. declare module BABYLON {
  93413. export class TerrainMaterial extends BABYLON.PushMaterial {
  93414. private _mixTexture;
  93415. mixTexture: BABYLON.BaseTexture;
  93416. private _diffuseTexture1;
  93417. diffuseTexture1: BABYLON.Texture;
  93418. private _diffuseTexture2;
  93419. diffuseTexture2: BABYLON.Texture;
  93420. private _diffuseTexture3;
  93421. diffuseTexture3: BABYLON.Texture;
  93422. private _bumpTexture1;
  93423. bumpTexture1: BABYLON.Texture;
  93424. private _bumpTexture2;
  93425. bumpTexture2: BABYLON.Texture;
  93426. private _bumpTexture3;
  93427. bumpTexture3: BABYLON.Texture;
  93428. diffuseColor: BABYLON.Color3;
  93429. specularColor: BABYLON.Color3;
  93430. specularPower: number;
  93431. private _disableLighting;
  93432. disableLighting: boolean;
  93433. private _maxSimultaneousLights;
  93434. maxSimultaneousLights: number;
  93435. constructor(name: string, scene: BABYLON.Scene);
  93436. needAlphaBlending(): boolean;
  93437. needAlphaTesting(): boolean;
  93438. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  93439. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  93440. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  93441. getAnimatables(): BABYLON.IAnimatable[];
  93442. getActiveTextures(): BABYLON.BaseTexture[];
  93443. hasTexture(texture: BABYLON.BaseTexture): boolean;
  93444. dispose(forceDisposeEffect?: boolean): void;
  93445. clone(name: string): TerrainMaterial;
  93446. serialize(): any;
  93447. getClassName(): string;
  93448. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  93449. }
  93450. }
  93451. declare module BABYLON {
  93452. /** @hidden */
  93453. export var triplanarPixelShader: {
  93454. name: string;
  93455. shader: string;
  93456. };
  93457. }
  93458. declare module BABYLON {
  93459. /** @hidden */
  93460. export var triplanarVertexShader: {
  93461. name: string;
  93462. shader: string;
  93463. };
  93464. }
  93465. declare module BABYLON {
  93466. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  93467. mixTexture: BABYLON.BaseTexture;
  93468. private _diffuseTextureX;
  93469. diffuseTextureX: BABYLON.BaseTexture;
  93470. private _diffuseTextureY;
  93471. diffuseTextureY: BABYLON.BaseTexture;
  93472. private _diffuseTextureZ;
  93473. diffuseTextureZ: BABYLON.BaseTexture;
  93474. private _normalTextureX;
  93475. normalTextureX: BABYLON.BaseTexture;
  93476. private _normalTextureY;
  93477. normalTextureY: BABYLON.BaseTexture;
  93478. private _normalTextureZ;
  93479. normalTextureZ: BABYLON.BaseTexture;
  93480. tileSize: number;
  93481. diffuseColor: BABYLON.Color3;
  93482. specularColor: BABYLON.Color3;
  93483. specularPower: number;
  93484. private _disableLighting;
  93485. disableLighting: boolean;
  93486. private _maxSimultaneousLights;
  93487. maxSimultaneousLights: number;
  93488. constructor(name: string, scene: BABYLON.Scene);
  93489. needAlphaBlending(): boolean;
  93490. needAlphaTesting(): boolean;
  93491. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  93492. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  93493. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  93494. getAnimatables(): BABYLON.IAnimatable[];
  93495. getActiveTextures(): BABYLON.BaseTexture[];
  93496. hasTexture(texture: BABYLON.BaseTexture): boolean;
  93497. dispose(forceDisposeEffect?: boolean): void;
  93498. clone(name: string): TriPlanarMaterial;
  93499. serialize(): any;
  93500. getClassName(): string;
  93501. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  93502. }
  93503. }
  93504. declare module BABYLON {
  93505. /** @hidden */
  93506. export var waterPixelShader: {
  93507. name: string;
  93508. shader: string;
  93509. };
  93510. }
  93511. declare module BABYLON {
  93512. /** @hidden */
  93513. export var waterVertexShader: {
  93514. name: string;
  93515. shader: string;
  93516. };
  93517. }
  93518. declare module BABYLON {
  93519. export class WaterMaterial extends BABYLON.PushMaterial {
  93520. renderTargetSize: BABYLON.Vector2;
  93521. private _bumpTexture;
  93522. bumpTexture: BABYLON.BaseTexture;
  93523. diffuseColor: BABYLON.Color3;
  93524. specularColor: BABYLON.Color3;
  93525. specularPower: number;
  93526. private _disableLighting;
  93527. disableLighting: boolean;
  93528. private _maxSimultaneousLights;
  93529. maxSimultaneousLights: number;
  93530. /**
  93531. * Defines the wind force.
  93532. */
  93533. windForce: number;
  93534. /**
  93535. * Defines the direction of the wind in the plane (X, Z).
  93536. */
  93537. windDirection: BABYLON.Vector2;
  93538. /**
  93539. * Defines the height of the waves.
  93540. */
  93541. waveHeight: number;
  93542. /**
  93543. * Defines the bump height related to the bump map.
  93544. */
  93545. bumpHeight: number;
  93546. /**
  93547. * Defines wether or not: to add a smaller moving bump to less steady waves.
  93548. */
  93549. private _bumpSuperimpose;
  93550. bumpSuperimpose: boolean;
  93551. /**
  93552. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  93553. */
  93554. private _fresnelSeparate;
  93555. fresnelSeparate: boolean;
  93556. /**
  93557. * Defines wether or not bump Wwves modify the reflection.
  93558. */
  93559. private _bumpAffectsReflection;
  93560. bumpAffectsReflection: boolean;
  93561. /**
  93562. * Defines the water color blended with the refraction (near).
  93563. */
  93564. waterColor: BABYLON.Color3;
  93565. /**
  93566. * Defines the blend factor related to the water color.
  93567. */
  93568. colorBlendFactor: number;
  93569. /**
  93570. * Defines the water color blended with the reflection (far).
  93571. */
  93572. waterColor2: BABYLON.Color3;
  93573. /**
  93574. * Defines the blend factor related to the water color (reflection, far).
  93575. */
  93576. colorBlendFactor2: number;
  93577. /**
  93578. * Defines the maximum length of a wave.
  93579. */
  93580. waveLength: number;
  93581. /**
  93582. * Defines the waves speed.
  93583. */
  93584. waveSpeed: number;
  93585. /**
  93586. * 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.
  93587. */
  93588. waveCount: number;
  93589. /**
  93590. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  93591. * will avoid calculating useless pixels in the pixel shader of the water material.
  93592. */
  93593. disableClipPlane: boolean;
  93594. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  93595. private _mesh;
  93596. private _refractionRTT;
  93597. private _reflectionRTT;
  93598. private _reflectionTransform;
  93599. private _lastTime;
  93600. private _lastDeltaTime;
  93601. private _useLogarithmicDepth;
  93602. private _waitingRenderList;
  93603. private _imageProcessingConfiguration;
  93604. private _imageProcessingObserver;
  93605. /**
  93606. * Gets a boolean indicating that current material needs to register RTT
  93607. */
  93608. get hasRenderTargetTextures(): boolean;
  93609. /**
  93610. * Constructor
  93611. */
  93612. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  93613. get useLogarithmicDepth(): boolean;
  93614. set useLogarithmicDepth(value: boolean);
  93615. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  93616. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  93617. addToRenderList(node: any): void;
  93618. enableRenderTargets(enable: boolean): void;
  93619. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  93620. get renderTargetsEnabled(): boolean;
  93621. needAlphaBlending(): boolean;
  93622. needAlphaTesting(): boolean;
  93623. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  93624. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  93625. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  93626. private _createRenderTargets;
  93627. getAnimatables(): BABYLON.IAnimatable[];
  93628. getActiveTextures(): BABYLON.BaseTexture[];
  93629. hasTexture(texture: BABYLON.BaseTexture): boolean;
  93630. dispose(forceDisposeEffect?: boolean): void;
  93631. clone(name: string): WaterMaterial;
  93632. serialize(): any;
  93633. getClassName(): string;
  93634. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  93635. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  93636. }
  93637. }
  93638. declare module BABYLON {
  93639. /** @hidden */
  93640. export var asciiartPixelShader: {
  93641. name: string;
  93642. shader: string;
  93643. };
  93644. }
  93645. declare module BABYLON {
  93646. /**
  93647. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  93648. *
  93649. * It basically takes care rendering the font front the given font size to a texture.
  93650. * This is used later on in the postprocess.
  93651. */
  93652. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  93653. private _font;
  93654. private _text;
  93655. private _charSize;
  93656. /**
  93657. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  93658. */
  93659. get charSize(): number;
  93660. /**
  93661. * Create a new instance of the Ascii Art FontTexture class
  93662. * @param name the name of the texture
  93663. * @param font the font to use, use the W3C CSS notation
  93664. * @param text the caracter set to use in the rendering.
  93665. * @param scene the scene that owns the texture
  93666. */
  93667. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  93668. /**
  93669. * Gets the max char width of a font.
  93670. * @param font the font to use, use the W3C CSS notation
  93671. * @return the max char width
  93672. */
  93673. private getFontWidth;
  93674. /**
  93675. * Gets the max char height of a font.
  93676. * @param font the font to use, use the W3C CSS notation
  93677. * @return the max char height
  93678. */
  93679. private getFontHeight;
  93680. /**
  93681. * Clones the current AsciiArtTexture.
  93682. * @return the clone of the texture.
  93683. */
  93684. clone(): AsciiArtFontTexture;
  93685. /**
  93686. * Parses a json object representing the texture and returns an instance of it.
  93687. * @param source the source JSON representation
  93688. * @param scene the scene to create the texture for
  93689. * @return the parsed texture
  93690. */
  93691. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  93692. }
  93693. /**
  93694. * Option available in the Ascii Art Post Process.
  93695. */
  93696. export interface IAsciiArtPostProcessOptions {
  93697. /**
  93698. * The font to use following the w3c font definition.
  93699. */
  93700. font?: string;
  93701. /**
  93702. * The character set to use in the postprocess.
  93703. */
  93704. characterSet?: string;
  93705. /**
  93706. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  93707. * This number is defined between 0 and 1;
  93708. */
  93709. mixToTile?: number;
  93710. /**
  93711. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  93712. * This number is defined between 0 and 1;
  93713. */
  93714. mixToNormal?: number;
  93715. }
  93716. /**
  93717. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  93718. *
  93719. * Simmply add it to your scene and let the nerd that lives in you have fun.
  93720. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  93721. */
  93722. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  93723. /**
  93724. * The font texture used to render the char in the post process.
  93725. */
  93726. private _asciiArtFontTexture;
  93727. /**
  93728. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  93729. * This number is defined between 0 and 1;
  93730. */
  93731. mixToTile: number;
  93732. /**
  93733. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  93734. * This number is defined between 0 and 1;
  93735. */
  93736. mixToNormal: number;
  93737. /**
  93738. * Instantiates a new Ascii Art Post Process.
  93739. * @param name the name to give to the postprocess
  93740. * @camera the camera to apply the post process to.
  93741. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  93742. */
  93743. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  93744. }
  93745. }
  93746. declare module BABYLON {
  93747. /** @hidden */
  93748. export var digitalrainPixelShader: {
  93749. name: string;
  93750. shader: string;
  93751. };
  93752. }
  93753. declare module BABYLON {
  93754. /**
  93755. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  93756. *
  93757. * It basically takes care rendering the font front the given font size to a texture.
  93758. * This is used later on in the postprocess.
  93759. */
  93760. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  93761. private _font;
  93762. private _text;
  93763. private _charSize;
  93764. /**
  93765. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  93766. */
  93767. get charSize(): number;
  93768. /**
  93769. * Create a new instance of the Digital Rain FontTexture class
  93770. * @param name the name of the texture
  93771. * @param font the font to use, use the W3C CSS notation
  93772. * @param text the caracter set to use in the rendering.
  93773. * @param scene the scene that owns the texture
  93774. */
  93775. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  93776. /**
  93777. * Gets the max char width of a font.
  93778. * @param font the font to use, use the W3C CSS notation
  93779. * @return the max char width
  93780. */
  93781. private getFontWidth;
  93782. /**
  93783. * Gets the max char height of a font.
  93784. * @param font the font to use, use the W3C CSS notation
  93785. * @return the max char height
  93786. */
  93787. private getFontHeight;
  93788. /**
  93789. * Clones the current DigitalRainFontTexture.
  93790. * @return the clone of the texture.
  93791. */
  93792. clone(): DigitalRainFontTexture;
  93793. /**
  93794. * Parses a json object representing the texture and returns an instance of it.
  93795. * @param source the source JSON representation
  93796. * @param scene the scene to create the texture for
  93797. * @return the parsed texture
  93798. */
  93799. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  93800. }
  93801. /**
  93802. * Option available in the Digital Rain Post Process.
  93803. */
  93804. export interface IDigitalRainPostProcessOptions {
  93805. /**
  93806. * The font to use following the w3c font definition.
  93807. */
  93808. font?: string;
  93809. /**
  93810. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  93811. * This number is defined between 0 and 1;
  93812. */
  93813. mixToTile?: number;
  93814. /**
  93815. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  93816. * This number is defined between 0 and 1;
  93817. */
  93818. mixToNormal?: number;
  93819. }
  93820. /**
  93821. * DigitalRainPostProcess helps rendering everithing in digital rain.
  93822. *
  93823. * Simmply add it to your scene and let the nerd that lives in you have fun.
  93824. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  93825. */
  93826. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  93827. /**
  93828. * The font texture used to render the char in the post process.
  93829. */
  93830. private _digitalRainFontTexture;
  93831. /**
  93832. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  93833. * This number is defined between 0 and 1;
  93834. */
  93835. mixToTile: number;
  93836. /**
  93837. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  93838. * This number is defined between 0 and 1;
  93839. */
  93840. mixToNormal: number;
  93841. /**
  93842. * Instantiates a new Digital Rain Post Process.
  93843. * @param name the name to give to the postprocess
  93844. * @camera the camera to apply the post process to.
  93845. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  93846. */
  93847. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  93848. }
  93849. }
  93850. declare module BABYLON {
  93851. /** @hidden */
  93852. export var brickProceduralTexturePixelShader: {
  93853. name: string;
  93854. shader: string;
  93855. };
  93856. }
  93857. declare module BABYLON {
  93858. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  93859. private _numberOfBricksHeight;
  93860. private _numberOfBricksWidth;
  93861. private _jointColor;
  93862. private _brickColor;
  93863. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93864. updateShaderUniforms(): void;
  93865. get numberOfBricksHeight(): number;
  93866. set numberOfBricksHeight(value: number);
  93867. get numberOfBricksWidth(): number;
  93868. set numberOfBricksWidth(value: number);
  93869. get jointColor(): BABYLON.Color3;
  93870. set jointColor(value: BABYLON.Color3);
  93871. get brickColor(): BABYLON.Color3;
  93872. set brickColor(value: BABYLON.Color3);
  93873. /**
  93874. * Serializes this brick procedural texture
  93875. * @returns a serialized brick procedural texture object
  93876. */
  93877. serialize(): any;
  93878. /**
  93879. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  93880. * @param parsedTexture defines parsed texture data
  93881. * @param scene defines the current scene
  93882. * @param rootUrl defines the root URL containing brick procedural texture information
  93883. * @returns a parsed Brick Procedural BABYLON.Texture
  93884. */
  93885. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  93886. }
  93887. }
  93888. declare module BABYLON {
  93889. /** @hidden */
  93890. export var cloudProceduralTexturePixelShader: {
  93891. name: string;
  93892. shader: string;
  93893. };
  93894. }
  93895. declare module BABYLON {
  93896. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  93897. private _skyColor;
  93898. private _cloudColor;
  93899. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93900. updateShaderUniforms(): void;
  93901. get skyColor(): BABYLON.Color4;
  93902. set skyColor(value: BABYLON.Color4);
  93903. get cloudColor(): BABYLON.Color4;
  93904. set cloudColor(value: BABYLON.Color4);
  93905. /**
  93906. * Serializes this cloud procedural texture
  93907. * @returns a serialized cloud procedural texture object
  93908. */
  93909. serialize(): any;
  93910. /**
  93911. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  93912. * @param parsedTexture defines parsed texture data
  93913. * @param scene defines the current scene
  93914. * @param rootUrl defines the root URL containing cloud procedural texture information
  93915. * @returns a parsed Cloud Procedural BABYLON.Texture
  93916. */
  93917. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  93918. }
  93919. }
  93920. declare module BABYLON {
  93921. /** @hidden */
  93922. export var fireProceduralTexturePixelShader: {
  93923. name: string;
  93924. shader: string;
  93925. };
  93926. }
  93927. declare module BABYLON {
  93928. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  93929. private _time;
  93930. private _speed;
  93931. private _autoGenerateTime;
  93932. private _fireColors;
  93933. private _alphaThreshold;
  93934. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93935. updateShaderUniforms(): void;
  93936. render(useCameraPostProcess?: boolean): void;
  93937. static get PurpleFireColors(): BABYLON.Color3[];
  93938. static get GreenFireColors(): BABYLON.Color3[];
  93939. static get RedFireColors(): BABYLON.Color3[];
  93940. static get BlueFireColors(): BABYLON.Color3[];
  93941. get autoGenerateTime(): boolean;
  93942. set autoGenerateTime(value: boolean);
  93943. get fireColors(): BABYLON.Color3[];
  93944. set fireColors(value: BABYLON.Color3[]);
  93945. get time(): number;
  93946. set time(value: number);
  93947. get speed(): BABYLON.Vector2;
  93948. set speed(value: BABYLON.Vector2);
  93949. get alphaThreshold(): number;
  93950. set alphaThreshold(value: number);
  93951. /**
  93952. * Serializes this fire procedural texture
  93953. * @returns a serialized fire procedural texture object
  93954. */
  93955. serialize(): any;
  93956. /**
  93957. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  93958. * @param parsedTexture defines parsed texture data
  93959. * @param scene defines the current scene
  93960. * @param rootUrl defines the root URL containing fire procedural texture information
  93961. * @returns a parsed Fire Procedural BABYLON.Texture
  93962. */
  93963. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  93964. }
  93965. }
  93966. declare module BABYLON {
  93967. /** @hidden */
  93968. export var grassProceduralTexturePixelShader: {
  93969. name: string;
  93970. shader: string;
  93971. };
  93972. }
  93973. declare module BABYLON {
  93974. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  93975. private _grassColors;
  93976. private _groundColor;
  93977. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93978. updateShaderUniforms(): void;
  93979. get grassColors(): BABYLON.Color3[];
  93980. set grassColors(value: BABYLON.Color3[]);
  93981. get groundColor(): BABYLON.Color3;
  93982. set groundColor(value: BABYLON.Color3);
  93983. /**
  93984. * Serializes this grass procedural texture
  93985. * @returns a serialized grass procedural texture object
  93986. */
  93987. serialize(): any;
  93988. /**
  93989. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  93990. * @param parsedTexture defines parsed texture data
  93991. * @param scene defines the current scene
  93992. * @param rootUrl defines the root URL containing grass procedural texture information
  93993. * @returns a parsed Grass Procedural BABYLON.Texture
  93994. */
  93995. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  93996. }
  93997. }
  93998. declare module BABYLON {
  93999. /** @hidden */
  94000. export var marbleProceduralTexturePixelShader: {
  94001. name: string;
  94002. shader: string;
  94003. };
  94004. }
  94005. declare module BABYLON {
  94006. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  94007. private _numberOfTilesHeight;
  94008. private _numberOfTilesWidth;
  94009. private _amplitude;
  94010. private _jointColor;
  94011. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  94012. updateShaderUniforms(): void;
  94013. get numberOfTilesHeight(): number;
  94014. set numberOfTilesHeight(value: number);
  94015. get amplitude(): number;
  94016. set amplitude(value: number);
  94017. get numberOfTilesWidth(): number;
  94018. set numberOfTilesWidth(value: number);
  94019. get jointColor(): BABYLON.Color3;
  94020. set jointColor(value: BABYLON.Color3);
  94021. /**
  94022. * Serializes this marble procedural texture
  94023. * @returns a serialized marble procedural texture object
  94024. */
  94025. serialize(): any;
  94026. /**
  94027. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  94028. * @param parsedTexture defines parsed texture data
  94029. * @param scene defines the current scene
  94030. * @param rootUrl defines the root URL containing marble procedural texture information
  94031. * @returns a parsed Marble Procedural BABYLON.Texture
  94032. */
  94033. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  94034. }
  94035. }
  94036. declare module BABYLON {
  94037. /** @hidden */
  94038. export var normalMapProceduralTexturePixelShader: {
  94039. name: string;
  94040. shader: string;
  94041. };
  94042. }
  94043. declare module BABYLON {
  94044. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  94045. private _baseTexture;
  94046. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  94047. updateShaderUniforms(): void;
  94048. render(useCameraPostProcess?: boolean): void;
  94049. resize(size: any, generateMipMaps: any): void;
  94050. isReady(): boolean;
  94051. get baseTexture(): BABYLON.Texture;
  94052. set baseTexture(texture: BABYLON.Texture);
  94053. /**
  94054. * Serializes this normal map procedural texture
  94055. * @returns a serialized normal map procedural texture object
  94056. */
  94057. serialize(): any;
  94058. /**
  94059. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  94060. * @param parsedTexture defines parsed texture data
  94061. * @param scene defines the current scene
  94062. * @param rootUrl defines the root URL containing normal map procedural texture information
  94063. * @returns a parsed Normal Map Procedural BABYLON.Texture
  94064. */
  94065. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  94066. }
  94067. }
  94068. declare module BABYLON {
  94069. /** @hidden */
  94070. export var perlinNoiseProceduralTexturePixelShader: {
  94071. name: string;
  94072. shader: string;
  94073. };
  94074. }
  94075. declare module BABYLON {
  94076. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  94077. time: number;
  94078. timeScale: number;
  94079. translationSpeed: number;
  94080. private _currentTranslation;
  94081. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  94082. updateShaderUniforms(): void;
  94083. render(useCameraPostProcess?: boolean): void;
  94084. resize(size: any, generateMipMaps: any): void;
  94085. /**
  94086. * Serializes this perlin noise procedural texture
  94087. * @returns a serialized perlin noise procedural texture object
  94088. */
  94089. serialize(): any;
  94090. /**
  94091. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  94092. * @param parsedTexture defines parsed texture data
  94093. * @param scene defines the current scene
  94094. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  94095. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  94096. */
  94097. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  94098. }
  94099. }
  94100. declare module BABYLON {
  94101. /** @hidden */
  94102. export var roadProceduralTexturePixelShader: {
  94103. name: string;
  94104. shader: string;
  94105. };
  94106. }
  94107. declare module BABYLON {
  94108. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  94109. private _roadColor;
  94110. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  94111. updateShaderUniforms(): void;
  94112. get roadColor(): BABYLON.Color3;
  94113. set roadColor(value: BABYLON.Color3);
  94114. /**
  94115. * Serializes this road procedural texture
  94116. * @returns a serialized road procedural texture object
  94117. */
  94118. serialize(): any;
  94119. /**
  94120. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  94121. * @param parsedTexture defines parsed texture data
  94122. * @param scene defines the current scene
  94123. * @param rootUrl defines the root URL containing road procedural texture information
  94124. * @returns a parsed Road Procedural BABYLON.Texture
  94125. */
  94126. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  94127. }
  94128. }
  94129. declare module BABYLON {
  94130. /** @hidden */
  94131. export var starfieldProceduralTexturePixelShader: {
  94132. name: string;
  94133. shader: string;
  94134. };
  94135. }
  94136. declare module BABYLON {
  94137. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  94138. private _time;
  94139. private _alpha;
  94140. private _beta;
  94141. private _zoom;
  94142. private _formuparam;
  94143. private _stepsize;
  94144. private _tile;
  94145. private _brightness;
  94146. private _darkmatter;
  94147. private _distfading;
  94148. private _saturation;
  94149. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  94150. updateShaderUniforms(): void;
  94151. get time(): number;
  94152. set time(value: number);
  94153. get alpha(): number;
  94154. set alpha(value: number);
  94155. get beta(): number;
  94156. set beta(value: number);
  94157. get formuparam(): number;
  94158. set formuparam(value: number);
  94159. get stepsize(): number;
  94160. set stepsize(value: number);
  94161. get zoom(): number;
  94162. set zoom(value: number);
  94163. get tile(): number;
  94164. set tile(value: number);
  94165. get brightness(): number;
  94166. set brightness(value: number);
  94167. get darkmatter(): number;
  94168. set darkmatter(value: number);
  94169. get distfading(): number;
  94170. set distfading(value: number);
  94171. get saturation(): number;
  94172. set saturation(value: number);
  94173. /**
  94174. * Serializes this starfield procedural texture
  94175. * @returns a serialized starfield procedural texture object
  94176. */
  94177. serialize(): any;
  94178. /**
  94179. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  94180. * @param parsedTexture defines parsed texture data
  94181. * @param scene defines the current scene
  94182. * @param rootUrl defines the root URL containing startfield procedural texture information
  94183. * @returns a parsed Starfield Procedural BABYLON.Texture
  94184. */
  94185. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  94186. }
  94187. }
  94188. declare module BABYLON {
  94189. /** @hidden */
  94190. export var woodProceduralTexturePixelShader: {
  94191. name: string;
  94192. shader: string;
  94193. };
  94194. }
  94195. declare module BABYLON {
  94196. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  94197. private _ampScale;
  94198. private _woodColor;
  94199. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  94200. updateShaderUniforms(): void;
  94201. get ampScale(): number;
  94202. set ampScale(value: number);
  94203. get woodColor(): BABYLON.Color3;
  94204. set woodColor(value: BABYLON.Color3);
  94205. /**
  94206. * Serializes this wood procedural texture
  94207. * @returns a serialized wood procedural texture object
  94208. */
  94209. serialize(): any;
  94210. /**
  94211. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  94212. * @param parsedTexture defines parsed texture data
  94213. * @param scene defines the current scene
  94214. * @param rootUrl defines the root URL containing wood procedural texture information
  94215. * @returns a parsed Wood Procedural BABYLON.Texture
  94216. */
  94217. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  94218. }
  94219. }